diff options
Diffstat (limited to 'games-util/wbfs_file/files')
-rw-r--r-- | games-util/wbfs_file/files/64bit_fix.patch | 38 | ||||
-rw-r--r-- | games-util/wbfs_file/files/no-openssl.patch | 169 |
2 files changed, 207 insertions, 0 deletions
diff --git a/games-util/wbfs_file/files/64bit_fix.patch b/games-util/wbfs_file/files/64bit_fix.patch new file mode 100644 index 0000000..97d6db2 --- /dev/null +++ b/games-util/wbfs_file/files/64bit_fix.patch @@ -0,0 +1,38 @@ +diff -r -u source/libwbfs/rijndael.c wbfs_file_2.9/source/libwbfs/rijndael.c +--- source/libwbfs/rijndael.c 2009-03-26 18:37:14.000000000 +0100 ++++ source/libwbfs/rijndael.c 2012-03-06 22:44:07.000000000 +0100 +@@ -11,10 +11,11 @@ + + #include <stdio.h> + #include <string.h> ++#include <stdint.h> + + #define u8 unsigned char /* 8 bits */ +-#define u32 unsigned long /* 32 bits */ +-#define u64 unsigned long long ++#define u32 uint32_t /* 32 bits */ ++#define u64 uint64_t + + /* rotates x one bit to the left */ + +diff -r -u source/tools.h wbfs_file_2.9_64bit//source/tools.h +--- source/tools.h 2009-03-18 17:17:38.000000000 +0100 ++++ source/tools.h 2012-03-06 22:43:26.000000000 +0100 +@@ -5,11 +5,13 @@ + #ifndef _TOOLS_H + #define _TOOLS_H + ++#include <stdint.h> ++ + // basic data types + typedef unsigned char u8; +-typedef unsigned short u16; +-typedef unsigned int u32; +-typedef unsigned long long u64; ++typedef uint16_t u16; ++typedef uint32_t u32; ++typedef uint64_t u64; + + u16 be16(const u8 *p); + u32 be32(const u8 *p); +Only in wbfs_file_2.9_64bit//source: wbfs_file diff --git a/games-util/wbfs_file/files/no-openssl.patch b/games-util/wbfs_file/files/no-openssl.patch new file mode 100644 index 0000000..cecbb97 --- /dev/null +++ b/games-util/wbfs_file/files/no-openssl.patch @@ -0,0 +1,169 @@ +diff -r -u source/tools.c wbfs_file_2.9_no_openssl//source/tools.c +--- source/tools.c 2010-01-12 13:52:20.000000000 +0100 ++++ wbfs_file_2.9_no_openssl//source/tools.c 2012-03-06 23:14:55.000000000 +0100 +@@ -5,9 +5,6 @@ + #include "tools.h" + + #include <stddef.h> // to accommodate certain broken versions of openssl +-#include <openssl/md5.h> +-#include <openssl/aes.h> +-#include <openssl/sha.h> + #include <stdarg.h> + #include <stdlib.h> + #include <string.h> +@@ -61,16 +58,6 @@ + // crypto + // + +-void md5(u8 *data, u32 len, u8 *hash) +-{ +- MD5(data, len, hash); +-} +- +-void sha(u8 *data, u32 len, u8 *hash) +-{ +- SHA1(data, len, hash); +-} +- + void get_key(const char *name, u8 *key, u32 len) + { + char path[256]; +@@ -90,35 +77,6 @@ + fclose(fp); + } + +-void aes_cbc_dec(u8 *key, u8 *iv, u8 *in, u32 len, u8 *out) +-{ +- AES_KEY aes_key; +- +- AES_set_decrypt_key(key, 128, &aes_key); +- AES_cbc_encrypt(in, out, len, &aes_key, iv, AES_DECRYPT); +-} +- +-void aes_cbc_enc(u8 *key, u8 *iv, u8 *in, u32 len, u8 *out) +-{ +- AES_KEY aes_key; +- +- AES_set_encrypt_key(key, 128, &aes_key); +- AES_cbc_encrypt(in, out, len, &aes_key, iv, AES_ENCRYPT); +-} +- +-void decrypt_title_key(u8 *tik, u8 *title_key) +-{ +- u8 common_key[16]; +- u8 iv[16]; +- +- get_key("common-key", common_key, 16); +- +- memset(iv, 0, sizeof iv); +- memcpy(iv, tik + 0x01dc, 8); +- aes_cbc_dec(common_key, iv, tik + 0x01bf, 16, title_key); +- printf("title key: %02x %02x %02x\n",title_key[0],title_key[1],title_key[2]); +-} +- + static u8 root_key[0x204]; + static u8 *get_root_key(void) + { +@@ -166,26 +124,6 @@ + return 0; + } + +-int check_ec(u8 *ng, u8 *ap, u8 *sig, u8 *sig_hash) +-{ +- u8 ap_hash[20]; +- u8 *ng_Q, *ap_R, *ap_S; +- u8 *ap_Q, *sig_R, *sig_S; +- +- ng_Q = ng + 0x0108; +- ap_R = ap + 0x04; +- ap_S = ap + 0x22; +- +- SHA1(ap + 0x80, 0x100, ap_hash); +- +- ap_Q = ap + 0x0108; +- sig_R = sig; +- sig_S = sig + 30; +- +- return check_ecdsa(ng_Q, ap_R, ap_S, ap_hash) +- && check_ecdsa(ap_Q, sig_R, sig_S, sig_hash); +-} +- + static int check_rsa(u8 *h, u8 *sig, u8 *key, u32 n) + { + u8 correct[0x200]; +@@ -268,57 +206,6 @@ + return 0; + } + +-int check_cert_chain(u8 *data, u32 data_len, u8 *cert, u32 cert_len) +-{ +- u8 *sig; +- u8 *sub; +- u32 sig_len; +- u32 sub_len; +- u8 h[20]; +- u8 *key_cert; +- u8 *key; +- int ret; +- sig = data; +- sig_len = get_sig_len(sig); +- if (sig_len == 0) +- return -1; +- sub = data + sig_len; +- sub_len = data_len - sig_len; +- if (sub_len == 0) +- return -2; +- +- for (;;) { +- printf(">>>>>> checking sig by %s...\n", sub); +- if (strcmp((char*)sub, "Root") == 0) { +- key = get_root_key(); +- sha(sub, sub_len, h); +- if (be32(sig) != 0x10000) +- return -8; +- return check_rsa(h, sig + 4, key, 0x200); +- } +- +- key_cert = find_cert_in_chain(sub, cert, cert_len); +- if (key_cert == 0) +- return -3; +- +- key = key_cert + get_sig_len(key_cert); +- +- sha(sub, sub_len, h); +- ret = check_hash(h, sig, key); +- if (ret) +- return ret; +- +- sig = key_cert; +- sig_len = get_sig_len(sig); +- if (sig_len == 0) +- return -4; +- sub = sig + sig_len; +- sub_len = get_sub_len(sub); +- if (sub_len == 0) +- return -5; +- } +-} +- + // + // compression + // +diff -r -u source/tools.h wbfs_file_2.9_no_openssl//source/tools.h +--- source/tools.h 2009-03-18 17:17:38.000000000 +0100 ++++ wbfs_file_2.9_no_openssl//source/tools.h 2012-03-06 23:15:03.000000000 +0100 +@@ -32,14 +32,7 @@ + void bn_exp(u8 *d, u8 *a, u8 *N, u32 n, u8 *e, u32 en); + + // crypto +-void md5(u8 *data, u32 len, u8 *hash); +-void sha(u8 *data, u32 len, u8 *hash); + void get_key(const char *name, u8 *key, u32 len); +-void aes_cbc_dec(u8 *key, u8 *iv, u8 *in, u32 len, u8 *out); +-void aes_cbc_enc(u8 *key, u8 *iv, u8 *in, u32 len, u8 *out); +-void decrypt_title_key(u8 *tik, u8 *title_key); +-int check_cert_chain(u8 *data, u32 data_len, u8 *cert, u32 cert_len); +-int check_ec(u8 *ng, u8 *ap, u8 *sig, u8 *sig_hash); + void generate_ecdsa(u8 *R, u8 *S, u8 *k, u8 *hash); + int check_ecdsa(u8 *Q, u8 *R, u8 *S, u8 *hash); + void ec_priv_to_pub(u8 *k, u8 *Q); |