diff --git a/retail/arm9/include/gm9i/f_xy.h b/retail/arm9/include/gm9i/f_xy.h deleted file mode 100644 index 383868e46..000000000 --- a/retail/arm9/include/gm9i/f_xy.h +++ /dev/null @@ -1,36 +0,0 @@ -/* f_xy.h - * - * This file was imported from godmode9i, but it is liely not the - * original source. twltool uses the same file. - * - * If you happen to know whom to credit I'd love to add the name - * - * Refactored to reduce the pointer casts and remove the dependency - * from tonccpy. - */ - -#ifndef _H_F_XY -#define _H_F_XY - -#ifdef __cplusplus -extern "C" { -#endif - -/************************ Constants / Defines *********************************/ - -extern const uint8_t DSi_KEY_MAGIC[16] ; -extern const uint8_t DSi_NAND_KEY_Y[16] ; -extern const uint8_t DSi_ES_KEY_Y[16] ; -extern const uint8_t DSi_BOOT2_KEY[16] ; - -/************************ Function Protoypes **********************************/ - -void F_XY(uint8_t *key, const uint8_t *key_x, const uint8_t *key_y); -void F_XY_reverse(const uint8_t *key, uint8_t *key_xy); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/retail/arm9/source/conf_sd.cpp b/retail/arm9/source/conf_sd.cpp index 73771b73b..ab34f0fc2 100644 --- a/retail/arm9/source/conf_sd.cpp +++ b/retail/arm9/source/conf_sd.cpp @@ -33,7 +33,6 @@ #include "version.h" #include "nandio.h" -#include "f_xy.h" #include "dsi.h" #include "u128_math.h" @@ -49,6 +48,15 @@ struct IgmText *igmText = (struct IgmText *)INGAME_MENU_LOCATION; +const uint8_t DSi_KEY_MAGIC[16] = { 0x79, 0x3e, 0x4f, 0x1a, 0x5f, 0x0f, 0x68, 0x2a, + 0x58, 0x02, 0x59, 0x29, 0x4e, 0xfb, 0xfe, 0xff }; +const uint8_t DSi_NAND_KEY_Y[16] = { 0x76, 0xdc, 0xb9, 0x0a, 0xd3, 0xc4, 0x4d, 0xbd, + 0x1d, 0xdd, 0x2d, 0x20, 0x05, 0x00, 0xa0, 0xe1 }; +const uint8_t DSi_ES_KEY_Y[16] = { 0xe5, 0xcc, 0x5a, 0x8b, 0x56, 0xd0, 0xc9,0x72, + 0x9c, 0x17, 0xe8, 0xdc, 0x39, 0x12, 0x36, 0xa9 }; +const uint8_t DSi_BOOT2_KEY[16] = { 0x98, 0xee, 0x80, 0x80, 0x00, 0x6c, 0xb4, 0xf6, + 0x3a, 0xc2, 0x6e, 0x62, 0xf9, 0xec, 0x34, 0xad }; + void decrypt_modcrypt_area(dsi_context* ctx, u8 *buffer, unsigned int size) { uint32_t len = size / 0x10; diff --git a/retail/arm9/source/gm9i/f_xy.c b/retail/arm9/source/gm9i/f_xy.c deleted file mode 100644 index e07c796a3..000000000 --- a/retail/arm9/source/gm9i/f_xy.c +++ /dev/null @@ -1,50 +0,0 @@ -/* f_xy.c - * - * This file was imported from godmode9i, but it is liely not the - * original source. twltool uses the same file. - * - * If you happen to know whom to credit I'd love to add the name - * - * Refactored to reduce the pointer casts and remove the dependency - * from tonccpy. - */ - -#include -#include -#include "u128_math.h" - - -/************************ Constants / Defines *********************************/ - -const uint8_t DSi_KEY_MAGIC[16] = { 0x79, 0x3e, 0x4f, 0x1a, 0x5f, 0x0f, 0x68, 0x2a, - 0x58, 0x02, 0x59, 0x29, 0x4e, 0xfb, 0xfe, 0xff }; -const uint8_t DSi_NAND_KEY_Y[16] = { 0x76, 0xdc, 0xb9, 0x0a, 0xd3, 0xc4, 0x4d, 0xbd, - 0x1d, 0xdd, 0x2d, 0x20, 0x05, 0x00, 0xa0, 0xe1 }; -const uint8_t DSi_ES_KEY_Y[16] = { 0xe5, 0xcc, 0x5a, 0x8b, 0x56, 0xd0, 0xc9,0x72, - 0x9c, 0x17, 0xe8, 0xdc, 0x39, 0x12, 0x36, 0xa9 }; -const uint8_t DSi_BOOT2_KEY[16] = { 0x98, 0xee, 0x80, 0x80, 0x00, 0x6c, 0xb4, 0xf6, - 0x3a, 0xc2, 0x6e, 0x62, 0xf9, 0xec, 0x34, 0xad }; - -/************************ Functions *******************************************/ - -void F_XY(uint8_t *key, const uint8_t *key_x, const uint8_t *key_y) -{ - uint8_t key_xy[16]; - - for(int i=0; i<16; i++) - key_xy[i] = key_x[i] ^ key_y[i]; - - memcpy(key, DSi_KEY_MAGIC, sizeof(DSi_KEY_MAGIC)); - - u128_add(key, key_xy); - u128_lrot(key, 42); -} - -//F_XY_reverse does the reverse of F(X^Y): takes (normal)key, and does F in reverse to generate the original X^Y key_xy. -void F_XY_reverse(const uint8_t *key, uint8_t *key_xy) -{ - memcpy(key_xy, key, 16); - u128_rrot(key_xy, 42); - u128_sub(key_xy, DSi_KEY_MAGIC); -} -