aboutsummaryrefslogtreecommitdiffstats
path: root/games-util/wbfs_file/files/no-openssl.patch
blob: cecbb975e2e793ac289c4e61b2fcc7ea14afa6e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
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);