let's maintain the '315-5881- keys in 'machine/315-5881_helper.c' until the key format is finalized

as things stand the entire set of keys is of arbitrary bit order / poliarity / number of bits and just based on how our implementation works, storing them in files just means a lot of files have to be regenerated each time our understanding changes.

I've left placeholder ROM_LOADs (with invalid crc/sha1s, compiled out) for placing the keys back once the format IS final.

The list in 315-5881_helper.c needs updating / syncing with current knowledge, would appreciate somebody doing this.

I'm going to see if I can see where / how the chip hooks up on Model 2 and Model 3, and if we can pass those checks with our current code.
This commit is contained in:
mamehaze 2015-01-21 15:12:09 +00:00
parent b2ee45ad85
commit f1f71c77f8
11 changed files with 321 additions and 288 deletions

View File

@ -381,6 +381,8 @@ Notes:
#include "emu.h"
#include "cpu/sh4/sh4.h"
#include "machine/naomicrypt.h"
#include "machine/315-5881_helper.h"
#define CPU_CLOCK (200000000)
/* MD2 MD1 MD0 MD6 MD4 MD3 MD5 MD7 MD8 */
@ -571,8 +573,7 @@ ROM_START( airtrix )
/* ic66 unpopulated */
// 315-5881 security IC key
ROM_REGION( 4, "rom_key", 0 )
ROM_LOAD( "airtrix-key.bin", 0, 4, CRC(bebdc179) SHA1(327ea299934ef78f3c88329fc624dc3771877453) )
_315_5881_KEYFILE("airtrix-key.bin", CRC(11111111) SHA1(1111111111111111111111111111111111111111))
ROM_END
@ -610,8 +611,7 @@ ROM_START( pharrier )
ROM_LOAD32_WORD( "mpr-23564.ic66", 0xe000002, 0x1000000, CRC(255724b6) SHA1(1b382fad165831de3f2e39352c031146759dfc69) )
// 315-5881 security IC key
ROM_REGION( 4, "rom_key", 0 )
ROM_LOAD( "pharrier-key.bin", 0, 4, CRC(1697d591) SHA1(8ad4c93f63e2e379795e820d3edbdd990f8ca7e1) )
_315_5881_KEYFILE("pharrier-key.bin", CRC(11111111) SHA1(1111111111111111111111111111111111111111))
ROM_END
ROM_START( podrace )
@ -709,7 +709,7 @@ ROM_START( braveff )
ROM_LOAD32_WORD( "mpr-22023.ic60s", 0xb000002, 0x800000, CRC(07f00869) SHA1(92282d09d72d3e65a91128e06bb0d4426bb90be5) )
// 315-5881 not populated
ROM_REGION( 4, "rom_key", ROMREGION_ERASE00 )
_315_5881_UNUSED
ROM_END
ROM_START( sgnascar )
@ -741,8 +741,7 @@ ROM_START( sgnascar )
// 317-0283-COM Actel A54SX32
// ID 0x4252
ROM_REGION( 4, "rom_key", 0 )
ROM_LOAD( "sgnascar-key.bin", 0x000000, 0x000004, CRC(f1452f9e) SHA1(86fb0f278a2eb0aba66a24032fb683f7a516b32b) )
_NAOMI_M1_KEYFILE( "sgnascar-key.bin", CRC(f1452f9e) SHA1(86fb0f278a2eb0aba66a24032fb683f7a516b32b) )
ROM_END
GAME( 2000, hikaru, 0, hikaru, hikaru, driver_device, 0, ROT0, "Sega", "Hikaru Bios", GAME_NO_SOUND|GAME_NOT_WORKING|GAME_IS_BIOS_ROOT )

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,8 @@
#ifndef __SEGA315_5881_CRYPT__
#define __SEGA315_5881_CRYPT__
#include "315-5881_helper.h"
typedef device_delegate<UINT16 (UINT32)> sega_m2_read_delegate;
extern const device_type SEGA315_5881_CRYPT;

View File

@ -0,0 +1,135 @@
/* Sega 315-5881 support file
This encryption chip was used on various games running on
ST-V
Naomi
Naomi 2
Hikaru
Model 2
Model 3
(more?)
As the encryption isn't fully understood yet this file holds the current keys, these are subject to change.
*/
#include "emu.h"
#include "315-5881_helper.h"
struct game_keys
{
const char *name; /* game driver name */
const INT64 key; // INT64 so we can use -1 for unknown keys
};
// chip numbers based on Guru's list at
// http://members.iinet.net.au/~lantra9jp1/gurudumps/sega-security/sega_security.html
// (todo , complete it )
static const struct game_keys keys_table[] =
{
// name key gameid # year chip label platform
// { "twcup98", 0x05200913 }, // 25209801 1998 317-5039-COM ST-V (this is correct key, but not yet working with our code)
{ "twcup98", -1 }, // 25209801 1998 317-5039-COM ST-V
{ "astrass", 0x052e2901 }, // 25349801 1998 317-5040-COM ST-V (yes, the 317-5040-COM chip was reused for 3 different games and on both Naomi and ST-V!)
{ "wldkicks", 0x052e2901 }, // 25209801 2000 317-5040-COM Naomi
{ "toukon4", 0x052e2901 }, // 25349801 2000 317-5040-COM Naomi
{ "rsgun", -1 }, // 1998 317-5041-COM ST-V
{ "sss", -1 }, // 1998 317-5042-COM ST-V
{ "elandore", -1 }, // 1998 317-5043-COM ST-V
{ "ffreveng", -1 }, // 1998 317-5049-COM ST-V
{ "ninjaslt", 0x000ca510 }, // 25469801 2000
{ "ninjaslt4", 0x000ca510 }, // 25469801 2000
{ "gunsur2e", 0x000680d0 }, // 25709801 2001
{ "mazan", 0x000fea94 }, // 25869812 2002
{ "f355twin", 0x0006efd4 }, // 834-13950 1999
{ "alpiltdx", 0x00070e41 }, // 834-????? 1999
{ "f355twn2", 0x001666c6 }, // 834-????? 2001
{ "crzytaxi", 0x000d2f45 }, // 840-0002 1999
{ "zombrvn", 0x00012b41 }, // 840-0003 1999
{ "ringout", 0x000b1e40 }, // 840-0004 1999
{ "alpilota", 0x00070e41 }, // 840-0005 1999
{ "ggram2", 0x00074a61 }, // 840-0007 1999
{ "vs2_2k", 0x00088b08 }, // 840-0010 1999
{ "toyfight", 0x0002ca85 }, // 840-0011 1999
{ "smlg99", 0x00048a01 }, // 840-0012 1999
{ "jambo", 0x000fab95 }, // 840-0013 1999
{ "vtennis", 0x0003eb15 }, // 840-0015 1999
{ "derbyoc", 0x000fee35 }, // 840-0016 1999
{ "otrigger", 0x000fea94 }, // 840-0017 1999
{ "sgtetris", 0x0008ae51 }, // 840-0018 1999
{ "dybb99", 0x00048a01 }, // 840-0019 1999
{ "samba", 0x000a8b5d }, // 840-0020 1999
{ "sambap", 0x000a8b5d }, // 840-0020 1999
{ "virnbao", 0x00068b58 }, // 840-0021 2000
{ "18wheelr", 0x0007cf54 }, // 840-0023 2000
{ "marstv", 0x000b8ef5 }, // 840-0025 1999
{ "vonot", 0x00010715 }, // 840-0028 2000
{ "sstrkfgt", 0x00132303 }, // 840-0035 2000
{ "18wheels", 0x0007cf54 }, // 840-0036 2000
{ "wwfroyal", 0x001627c3 }, // 840-0040 2000
{ "slasho", 0x001a66ca }, // 840-0041 2000
{ "crackndj", 0x001c2347 }, // 840-0043 2000
{ "csmash", 0x00103347 }, // 840-0044 2000
{ "csmasho", 0x00103347 }, // 840-0044 2000
{ "samba2k", 0x001702cf }, // 840-0047 2000
{ "alienfnt", 0x00174343 }, // 840-0048 2001
{ "alienfnta", 0x00174343 }, // 840-0048 2001
{ "crackdj2", 0x00428247 }, // 840-0068 2001
{ "vf4cart", 0x06ef2f92 }, // 840-0080 2002
{ "pstone", 0x000e69c1 }, // 841-0001 1999
{ "suchie3", 0x000368e1 }, // 841-0002 1999
{ "doa2", 0x0008ad01 }, // 841-0003 1999
{ "doa2m", 0x0008ad01 }, // 841-0003 1999
{ "spawn", 0x00078d01 }, // 841-0005 1999
{ "puyoda", 0x000acd40 }, // 841-0006 1999
{ "pstone2", 0x000b8dc0 }, // 841-0008 2000
{ "capsnk", 0x00000000 }, // 841-0011 2000
{ "capsnka", 0x00000000 }, // 841-0011 2000
{ "capsnkb", 0x00000000 }, // 841-0011 2000
{ "cspike", 0x000e2010 }, // 841-0012 2000
{ "ggx", 0x00076110 }, // 841-0013 2000
{ "gwing2", 0x000b25d0 }, // 841-0014 2000
{ "pjustic", 0x000725d0 }, // 841-0015 2000
{ "deathcox", 0x000b64d0 }, // 841-0016 2000
{ "gundmct", 0x000e8010 }, // 841-0017 2001
{ "zerogu2", 0x0007c010 }, // 841-0020 2001
{ "hmgeo", 0x00038510 }, // HMG016007 2001
{ "airtrix", -1 }, // ???? 317-0294-COM Hikaru
{ "pharrier", -1 }, // ???? 317-0297-COM Hikaru
{ "podrace", -1 }, // ???? 317-0277-COM Hikaru
{ "vs298", 0x09234e96 }, // ???? 317-????-COM Model 3
{ "vs299", 0x09222ac8 }, // ???? 317-0245-COM Model 3
{ "swt", 0x11272a01 }, // ???? 317-0241-COM Model 3
{ "dynamcop", 0x0c2a4a93 }, // ???? 317-0236-COM Model 2
{ NULL, 0 } // end of table
};
INT64 get_315_5881_key(running_machine &machine)
{
const char *gamename = machine.system().name;
const struct game_keys *k = &keys_table[0];
while (k->name)
{
if (strcmp(k->name, gamename) == 0)
{
// we have a proper key so return it
return k->key;
}
++k;
}
printf("get_naomi_key : KEY NOT FOUND\n");
return 0;
}

View File

@ -0,0 +1,33 @@
// use the internal key list, or external files?
#define USE_315_5881_HELPER 1
INT64 get_315_5881_key(running_machine &machine);
#if USE_315_5881_HELPER
#define _315_5881_KEYFILE(name,hash) \
/* nothing */
#define _315_5881_UNUSED_OR_UNKNOWN \
/* nothing */
#define _315_5881_UNUSED \
/* nothing */
#else
#define _315_5881_KEYFILE(name,hash) \
ROM_REGION( 4, "315_5881key", 0 ) \
ROM_LOAD( name, 0, 4, hash )
#define _315_5881_UNUSED_OR_UNKNOWN \
ROM_REGION( 4, "315_5881key", ROMREGION_ERASE00 )
#define _315_5881_UNUSED \
ROM_REGION( 4, "315_5881key", ROMREGION_ERASE00 )
#endif

View File

@ -1,15 +1,15 @@
/* Naomi cartridge encryption
/* Sega 'M1' type encryption ( using an Actel A54SX32 )
see naomim1.c, naomim2.c and naomim4.c for implementation details
see naomim1.c for Naomi hokup details
The keys here are totally arbitrary and have nothing to do with the real keys.
Atomiswave is significantly different and not listed here.
Naomi GD-ROMs use DES encryption, and the keys are stored as part of the PIC dumps instead.
used by
Naomi
Hikaru
the Naomi schemes are clearly related to CPS2
the ST-V scheme could also be related to this.
*/
@ -27,66 +27,6 @@ struct game_keys
static const struct game_keys keys_table[] =
{
// name key gameid # year
// M2
{ "wldkicks", 0x052e2901 }, // 25209801 2000
{ "toukon4", 0x052e2901 }, // 25349801 2000
{ "ninjaslt", 0x000ca510 }, // 25469801 2000
{ "ninjaslt4", 0x000ca510 }, // 25469801 2000
{ "gunsur2e", 0x000680d0 }, // 25709801 2001
{ "mazan", 0x000fea94 }, // 25869812 2002
{ "f355twin", 0x0006efd4 }, // 834-13950 1999
{ "alpiltdx", 0x00070e41 }, // 834-????? 1999
{ "f355twn2", 0x001666c6 }, // 834-????? 2001
{ "crzytaxi", 0x000d2f45 }, // 840-0002 1999
{ "zombrvn", 0x00012b41 }, // 840-0003 1999
{ "ringout", 0x000b1e40 }, // 840-0004 1999
{ "alpilota", 0x00070e41 }, // 840-0005 1999
{ "ggram2", 0x00074a61 }, // 840-0007 1999
{ "vs2_2k", 0x00088b08 }, // 840-0010 1999
{ "toyfight", 0x0002ca85 }, // 840-0011 1999
{ "smlg99", 0x00048a01 }, // 840-0012 1999
{ "jambo", 0x000fab95 }, // 840-0013 1999
{ "vtennis", 0x0003eb15 }, // 840-0015 1999
{ "derbyoc", 0x000fee35 }, // 840-0016 1999
{ "otrigger", 0x000fea94 }, // 840-0017 1999
{ "sgtetris", 0x0008ae51 }, // 840-0018 1999
{ "dybb99", 0x00048a01 }, // 840-0019 1999
{ "samba", 0x000a8b5d }, // 840-0020 1999
{ "sambap", 0x000a8b5d }, // 840-0020 1999
{ "virnbao", 0x00068b58 }, // 840-0021 2000
{ "18wheelr", 0x0007cf54 }, // 840-0023 2000
{ "marstv", 0x000b8ef5 }, // 840-0025 1999
{ "vonot", 0x00010715 }, // 840-0028 2000
{ "sstrkfgt", 0x00132303 }, // 840-0035 2000
{ "18wheels", 0x0007cf54 }, // 840-0036 2000
{ "wwfroyal", 0x001627c3 }, // 840-0040 2000
{ "slasho", 0x001a66ca }, // 840-0041 2000
{ "crackndj", 0x001c2347 }, // 840-0043 2000
{ "csmash", 0x00103347 }, // 840-0044 2000
{ "csmasho", 0x00103347 }, // 840-0044 2000
{ "samba2k", 0x001702cf }, // 840-0047 2000
{ "alienfnt", 0x00174343 }, // 840-0048 2001
{ "alienfnta", 0x00174343 }, // 840-0048 2001
{ "crackdj2", 0x00428247 }, // 840-0068 2001
{ "vf4cart", 0x06ef2f92 }, // 840-0080 2002
{ "pstone", 0x000e69c1 }, // 841-0001 1999
{ "suchie3", 0x000368e1 }, // 841-0002 1999
{ "doa2", 0x0008ad01 }, // 841-0003 1999
{ "doa2m", 0x0008ad01 }, // 841-0003 1999
{ "spawn", 0x00078d01 }, // 841-0005 1999
{ "puyoda", 0x000acd40 }, // 841-0006 1999
{ "pstone2", 0x000b8dc0 }, // 841-0008 2000
{ "capsnk", 0x00000000 }, // 841-0011 2000
{ "capsnka", 0x00000000 }, // 841-0011 2000
{ "capsnkb", 0x00000000 }, // 841-0011 2000
{ "cspike", 0x000e2010 }, // 841-0012 2000
{ "ggx", 0x00076110 }, // 841-0013 2000
{ "gwing2", 0x000b25d0 }, // 841-0014 2000
{ "pjustic", 0x000725d0 }, // 841-0015 2000
{ "deathcox", 0x000b64d0 }, // 841-0016 2000
{ "gundmct", 0x000e8010 }, // 841-0017 2001
{ "zerogu2", 0x0007c010 }, // 841-0020 2001
{ "hmgeo", 0x00038510 }, // HMG016007 2001
// M1
{ "tduno2", 0x2f6f0f8d }, // 840-0022 2000
{ "qmegamis", 0x96489bcd }, // 840-0030 2000
@ -99,6 +39,7 @@ static const struct game_keys keys_table[] =
{ "kick4csh", 0xc9570882 }, // 840-0140 2004
{ "mtkob2", 0x3892fb3a }, // 840-0150 2003
{ "mvsc2", 0x7c6e8bc1 }, // 841-0007-02 2000
// sgnascar (Hikaru)
{ NULL, 0 } // end of table
};

View File

@ -1,4 +1,15 @@
/* naomicrypt.h */
// use internal M1 key tables, or external files (0 = external files)
#define USE_NAOMICRYPT 0
UINT32 get_naomi_key(running_machine &machine);
#define _NAOMI_M1_KEYFILE(name,hash) \
ROM_REGION( 4, "rom_key", 0 ) \
ROM_LOAD( name, 0, 4, hash )
#define _NAOMI_M1_KEYFILE_UNUSED \
ROM_REGION( 4, "rom_key", ROMREGION_ERASE00 ) \

View File

@ -135,8 +135,8 @@ void naomi_m2_board::device_reset()
rom_cur_address = 0;
#if USE_NAOMICRYPT
m_cryptdevice->set_key(get_naomi_key(machine()));
#if USE_315_5881_HELPER
m_cryptdevice->set_key(get_315_5881_key(machine()));
#else
const UINT8 *key_data = memregion(key_tag)->base();
m_cryptdevice->set_key((key_data[0] << 24) | (key_data[1] << 16) | (key_data[2] << 8) | key_data[3]);

View File

@ -4,6 +4,7 @@
#include "naomibd.h"
#include "315-5881_crypt.h"
#define MCFG_NAOMI_M2_BOARD_ADD(_tag, _key_tag, _eeprom_tag, _actel_tag, _irq_cb) \
MCFG_NAOMI_BOARD_ADD(_tag, NAOMI_M2_BOARD, _eeprom_tag, _actel_tag, _irq_cb) \
naomi_m2_board::static_set_tags(*device, _key_tag);

View File

@ -674,7 +674,15 @@ void stv_state::install_common_protection()
{
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x4fffff0, 0x4ffffff, read32_delegate(FUNC(stv_state::common_prot_r), this), write32_delegate(FUNC(stv_state::common_prot_w), this));
INT64 key = get_315_5881_key(machine());
if (key != -1)
{
m_cryptdevice->set_key(key); // use real decryption
m_using_crypt_device = 1;
}
else
m_using_crypt_device = 0; // use protection sim
}
void stv_state::install_sss_protection()
@ -686,9 +694,6 @@ void stv_state::install_sss_protection()
void stv_state::install_astrass_protection()
{
install_common_protection();
// m_prot_readback = astrass_prot_read_callback;
m_cryptdevice->set_key(0x052e2901); // same key as wldkicks / toukon4
m_using_crypt_device = 1;
}
void stv_state::install_ffreveng_protection()
@ -713,16 +718,11 @@ void stv_state::install_twcup98_protection()
{
install_common_protection();
m_prot_readback = twcup98_prot_read_callback;
m_cryptdevice->set_key(0x05200913 );
m_using_crypt_device = 0; // doesn't currently work
}
void stv_state::stv_register_protection_savestates()
{
save_item(NAME(m_a_bus));
save_item(NAME(m_ctrl_index));
save_item(NAME(m_internal_counter));

View File

@ -1723,6 +1723,7 @@ $(MAMEOBJ)/sega.a: \
$(MACHINE)/naomig1.o $(MACHINE)/naomibd.o $(MACHINE)/naomirom.o $(MACHINE)/naomigd.o \
$(MACHINE)/naomicrypt.o $(MACHINE)/naomim1.o $(MACHINE)/naomim2.o $(MACHINE)/naomim4.o \
$(MACHINE)/315-5881_crypt.o \
$(MACHINE)/315-5881_helper.o \
$(MACHINE)/awboard.o \
$(MACHINE)/mie.o $(MACHINE)/maple-dc.o $(MACHINE)/mapledev.o $(MACHINE)/dc-ctrl.o $(MACHINE)/jvs13551.o \
$(DRIVERS)/triforce.o \