diff --git a/common/include/libsecr-common.h b/common/include/libsecr-common.h index 81b84cd32df..08dc74702b5 100644 --- a/common/include/libsecr-common.h +++ b/common/include/libsecr-common.h @@ -78,4 +78,6 @@ extern int SecrDownloadGetKbit(int port, int slot, void *kbit); extern int SecrDownloadGetKc(int port, int slot, void *kbit); extern int SecrDownloadGetICVPS2(void *icvps2); +/* FOLLOWING EXPORTS ARE ONLY AVAILABLE IN ARCADE SECRMAN */ +extern int SecrAuthDongle(int port,int slot,int cnum); #endif /* __LIBSECR_COMMON_H__ */ diff --git a/iop/kernel/include/secrman.h b/iop/kernel/include/secrman.h index de3ec4a9baf..6a9792c04d3 100644 --- a/iop/kernel/include/secrman.h +++ b/iop/kernel/include/secrman.h @@ -57,6 +57,9 @@ extern void SecrResetAuthCard(int port, int slot, int cnum); #define I_SecrDownloadGetKc DECLARE_IMPORT(18, SecrDownloadGetKc) #define I_SecrDownloadGetICVPS2 DECLARE_IMPORT(19, SecrDownloadGetICVPS2) +/* FOLLOWING EXPORTS ARE ONLY AVAILABLE IN ARCADE SECRMAN */ +#define I_SecrAuthDongle DECLARE_IMPORT(20, SecrAuthDongle) + #ifdef __cplusplus } #endif diff --git a/iop/security/Makefile b/iop/security/Makefile index c6689c6226e..36dad1eee07 100644 --- a/iop/security/Makefile +++ b/iop/security/Makefile @@ -8,6 +8,7 @@ SUBDIRS = \ secrman \ + secrman_arcade \ secrsif include $(PS2SDKSRC)/Defs.make diff --git a/iop/security/secrman/Makefile b/iop/security/secrman/Makefile index fd5a02a068e..d1da457e1c7 100644 --- a/iop/security/secrman/Makefile +++ b/iop/security/secrman/Makefile @@ -12,10 +12,15 @@ IOP_OBJS = secrman.o MechaAuth.o CardAuth.o keyman.o imports.o exports.o # Define to 1, to enable runtime support for both CEX and DEX units. DEX_SUPPORT ?= 1 +COH_SUPPORT ?= 0 ifneq (x$(DEX_SUPPORT),x9) IOP_CFLAGS += -DDEX_SUPPORT=1 endif +ifeq ($(COH_SUPPORT),1) +IOP_CFLAGS += -DBUILDING_SYSTEM2x6_SECRMAN=1 +IOP_OBJS += DongleAuth.o +endif include $(PS2SDKSRC)/Defs.make include $(PS2SDKSRC)/iop/Rules.bin.make diff --git a/iop/security/secrman/src/DongleAuth.c b/iop/security/secrman/src/DongleAuth.c new file mode 100644 index 00000000000..94bb1e90101 --- /dev/null +++ b/iop/security/secrman/src/DongleAuth.c @@ -0,0 +1,175 @@ +#include <stdio.h> +#include <sysclib.h> +#include "secrman.h" +#include "main.h" +#include "CardAuth.h" +#include "MechaAuth.h" +#include "DongleAuth.h" + + +int SecrAuthDongle(int port,int slot,int cnum) +{ + int x; + u8 CardIV[8]; + u8 CardMaterial[8]; + u8 CardNonce[8]; + u8 MechaChallenge3[7]; + u8 MechaChallenge2[5]; + u8 auStack_44[4]; + u8 MechaChallenge1[8]; + u8 CardResponse1[8]; + u8 CardResponse2[8]; + u8 CardResponse3[8]; + + if (GetMcCommandHandler() == NULL) { + _arcade_printf("mcCommand isn\'t assigned\n"); + } + else { + memset(MechaChallenge2, 0, sizeof(MechaChallenge2)); + _arcade_printf("SecrAuthDongle start\n"); + x = card_auth_60(port,slot); + if (x != 0) { + _arcade_printf("dongle auth 0x60\n"); + x = mechacon_auth_80(cnum); + if (x != 0) { + _arcade_printf("mechacon auth 0x80\n"); + x = card_auth(port,slot,0xf0,0); + if (x == 0) { + card_auth_60(port,slot); + } + else { + _arcade_printf("dongle auth 0x00\n"); + x = mechacon_auth_81(cnum | 0x40); + if (x == 0) { + card_auth_60(port,slot); + } + else { + _arcade_printf("mechacon auth 0x81\n"); + x = card_auth_read(port,slot,CardIV,0xf0,1); + if (x != 0) { + _arcade_printf("dongle auth 0x01\n"); + x = card_auth_read(port,slot,CardMaterial,0xf0,2); + if (x != 0) { + _arcade_printf("dongle auth 0x02\n"); + x = mechacon_auth_82(CardIV,CardMaterial); + if (x != 0) { + _arcade_printf("mechacon auth 0x82\n"); + x = card_auth(port,slot,0xf0,3); + if (x != 0) { + _arcade_printf("dongle auth 0x03\n"); + x = card_auth_read(port,slot,CardNonce,0xf0,4); + if (x != 0) { + _arcade_printf("dongle auth 0x04\n"); + x = mechacon_auth_83(CardNonce); + if (x != 0) { + _arcade_printf("mechacon auth 0x83\n"); + x = card_auth(port,slot,0xf0,5); + if (x != 0) { + _arcade_printf("dongle auth 0x05\n"); + x = pol_cal_cmplt(); + if (x != 0) { + _arcade_printf("mechacon auth 0x8f\n"); + x = mechacon_auth_84(MechaChallenge1,MechaChallenge2 + 1); + if (x != 0) { + _arcade_printf("mechacon auth 0x84\n"); + x = mechacon_auth_85(auStack_44,MechaChallenge3); + if (x != 0) { + _arcade_printf("mechacon auth 0x85\n"); + x = card_auth_write(port,slot,MechaChallenge3,0xf0,6); + if (x != 0) { + _arcade_printf("dongle auth 0x06\n"); + x = card_auth_write(port,slot,MechaChallenge2 + 1,0xf0,7); + if (x != 0) { + _arcade_printf("dongle auth 0x07\n"); + x = card_auth(port,slot,0xf0,8); + if (x != 0) { + _arcade_printf("dongle auth 0x08\n"); + x = card_auth2(port,slot,0xf0,9); + if (x != 0) { + _arcade_printf("dongle auth 0x09\n"); + x = card_auth(port,slot,0xf0,10); + if (x != 0) { + _arcade_printf("dongle auth 0x10\n"); + x = card_auth_write(port,slot,MechaChallenge1,0xf0,0xb); + if (x != 0) { + _arcade_printf("dongle auth 0x0b\n"); + x = card_auth(port,slot,0xf0,0xc); + if (x != 0) { + _arcade_printf("dongle auth 0x0c\n"); + x = card_auth2(port,slot,0xf0,0xd); + if (x != 0) { + _arcade_printf("dongle auth 0x0d\n"); + x = card_auth(port,slot,0xf0,0xe); + if (x != 0) { + _arcade_printf("dongle auth 0x0e\n"); + x = card_auth_read(port,slot,CardResponse1,0xf0, + 0xf); + if (x != 0) { + _arcade_printf("dongle auth 0x0f\n"); + x = card_auth(port,slot,0xf0,0x10); + if (x != 0) { + _arcade_printf("dongle auth 0x10\n"); + x = card_auth_read(port,slot,CardResponse2,0xf0,0x11); + if (x != 0) { + _arcade_printf("dongle auth 0x11\n"); + x = mechacon_auth_86(CardResponse1,CardResponse2); + if (x != 0) { + _arcade_printf("mechacon auth 0x86\n"); + x = card_auth(port,slot,0xf0,0x12); + if (x != 0) { + _arcade_printf("dongle auth 0x12\n"); + x = card_auth_read(port,slot,CardResponse3,0xf0,0x13); + if (x != 0) { + _arcade_printf("dongle auth 0x13\n"); + x = mechacon_auth_87(CardResponse3); + if (x != 0) { + _arcade_printf("mechacon auth 0x87\n"); + x = pol_cal_cmplt(); + if (x != 0) { + _arcade_printf("mechacon auth 0x8f\n"); + x = card_auth(port,slot,0xf0,0x14); + if (x != 0) { + _arcade_printf("dongle auth 0x14\n"); + x = mechacon_auth_88(); + if (x != 0) { + _arcade_printf("mechacon auth 0x88\n"); + return 1; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + card_auth_60(port,slot); + mechacon_auth_80(cnum); + } + } + } + } + } + return 0; +} + diff --git a/iop/security/secrman/src/DongleAuth.h b/iop/security/secrman/src/DongleAuth.h new file mode 100644 index 00000000000..65f32fcca02 --- /dev/null +++ b/iop/security/secrman/src/DongleAuth.h @@ -0,0 +1 @@ +int SecrAuthDongle(int port,int slot,int cnum); \ No newline at end of file diff --git a/iop/security/secrman/src/MechaAuth.c b/iop/security/secrman/src/MechaAuth.c index d958624f9b0..a135a34e6d0 100644 --- a/iop/security/secrman/src/MechaAuth.c +++ b/iop/security/secrman/src/MechaAuth.c @@ -25,9 +25,9 @@ int SendMechaCommand(int command, const void *input, unsigned short int length, _printf3("mecha command:%02x param:", (unsigned char)command); for (i = 0; i < length; i++) { - _printf3(" %02x", ((unsigned char *)input)[i]); + _printf_no_modname(" %02x", ((unsigned char *)input)[i]); } - _printf3("\n"); + _printf_no_modname("\n"); return sceCdApplySCmd((unsigned char)command, (void *)input, length, output); } diff --git a/iop/security/secrman/src/MechaAuth.h b/iop/security/secrman/src/MechaAuth.h index 8ec4caca68f..812e2880426 100644 --- a/iop/security/secrman/src/MechaAuth.h +++ b/iop/security/secrman/src/MechaAuth.h @@ -9,6 +9,9 @@ int mechacon_auth_85(void *buffer, void *buffer2); int mechacon_auth_86(void *buffer, void *buffer2); int mechacon_auth_87(void *buffer); int mechacon_auth_88(void); +#ifdef BUILDING_SYSTEM2x6_SECRMAN +int mechacon_auth_8F(void); +#endif int write_HD_start(unsigned char mode, int cnum, int arg2, unsigned short int HeaderLength); int write_data(const void *buffer, unsigned short int length); diff --git a/iop/security/secrman/src/exports.tab b/iop/security/secrman/src/exports.tab index dc47203b8e9..cc2eee1f8e5 100644 --- a/iop/security/secrman/src/exports.tab +++ b/iop/security/secrman/src/exports.tab @@ -21,4 +21,7 @@ DECLARE_EXPORT_TABLE(secrman, 0x01, 0x03) DECLARE_EXPORT(SecrDownloadGetKbit) /* 017 */ DECLARE_EXPORT(SecrDownloadGetKc) /* 018 */ DECLARE_EXPORT(SecrDownloadGetICVPS2) /* 019 */ +#ifdef BUILDING_SYSTEM2x6_SECRMAN + DECLARE_EXPORT(SecrAuthDongle) /* 020 */ +#endif END_EXPORT_TABLE diff --git a/iop/security/secrman/src/main.h b/iop/security/secrman/src/main.h index 35181229d2d..46f1707f189 100644 --- a/iop/security/secrman/src/main.h +++ b/iop/security/secrman/src/main.h @@ -6,13 +6,23 @@ */ #ifdef DEBUG -#define _printf(args...) printf("SECRMAN: "args) -#define _printf2(args...) printf("SECRMAN: "args) -#define _printf3(args...) printf("SECRMAN: "args) -#define _printf4(args...) printf("SECRMAN: "args) +#ifdef BUILDING_SYSTEM2x6_SECRMAN +#define LOGMODNAME "ARCADE_SECRMAN: " +#else +#define LOGMODNAME "SECRMAN: " +#endif + +#define _printf(args...) printf(LOGMODNAME args) +#define _printf2(args...) printf(LOGMODNAME args) +#define _printf3(args...) printf(LOGMODNAME args) +#define _printf4(args...) printf(LOGMODNAME args) +#define _arcade_printf(args...) printf(LOGMODNAME args) +#define _printf_no_modname(args...) printf(args) #else #define _printf(args...) #define _printf2(args...) #define _printf3(args...) #define _printf4(args...) +#define _arcade_printf(args...) +#define _printf_no_modname(args...) #endif diff --git a/iop/security/secrman/src/secrman.c b/iop/security/secrman/src/secrman.c index 9089120adda..190ccbc1aaf 100644 --- a/iop/security/secrman/src/secrman.c +++ b/iop/security/secrman/src/secrman.c @@ -582,7 +582,11 @@ int SecrAuthCard(int port, int slot, int cnum) #ifdef DEX_SUPPORT IsDEX || #endif +#ifdef BUILDING_SYSTEM2x6_SECRMAN + card_auth_key_change(port, slot, 3)) == 0) { +#else card_auth_key_change(port, slot, 1)) == 0) { +#endif card_auth_60(port, slot); return 0; } diff --git a/iop/security/secrman_arcade/Makefile b/iop/security/secrman_arcade/Makefile new file mode 100644 index 00000000000..5a81a3d3012 --- /dev/null +++ b/iop/security/secrman_arcade/Makefile @@ -0,0 +1,9 @@ +IOP_PARENT_DIR = $(PS2SDKSRC)/iop/security/secrman +IOP_SRC_DIR = $(IOP_PARENT_DIR)/src/ +IOP_INC_DIR = $(IOP_PARENT_DIR)/include/ + +IOP_BIN ?= secrman_arcade_namco.irx + +COH_SUPPORT ?= 1 + +include $(IOP_PARENT_DIR)/Makefile \ No newline at end of file