Skip to content

[secrman] add arcade SECRMAN #532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions common/include/libsecr-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__ */
3 changes: 3 additions & 0 deletions iop/kernel/include/secrman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions iop/security/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

SUBDIRS = \
secrman \
secrman_arcade \
secrsif

include $(PS2SDKSRC)/Defs.make
Expand Down
5 changes: 5 additions & 0 deletions iop/security/secrman/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
175 changes: 175 additions & 0 deletions iop/security/secrman/src/DongleAuth.c
Original file line number Diff line number Diff line change
@@ -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;
}

1 change: 1 addition & 0 deletions iop/security/secrman/src/DongleAuth.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int SecrAuthDongle(int port,int slot,int cnum);
4 changes: 2 additions & 2 deletions iop/security/secrman/src/MechaAuth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 3 additions & 0 deletions iop/security/secrman/src/MechaAuth.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions iop/security/secrman/src/exports.tab
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 14 additions & 4 deletions iop/security/secrman/src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions iop/security/secrman/src/secrman.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 9 additions & 0 deletions iop/security/secrman_arcade/Makefile
Original file line number Diff line number Diff line change
@@ -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