Mercurial > dropbear
comparison libtomcrypt/notes/rsa-testvectors/oaep-int.txt @ 1471:6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 09 Feb 2018 21:44:05 +0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1470:8bba51a55704 | 1471:6dba84798cd5 |
---|---|
1 # ================================= | |
2 # WORKED-OUT EXAMPLE FOR RSAES-OAEP | |
3 # ================================= | |
4 # | |
5 # This file gives an example of the process of | |
6 # encrypting and decrypting a message with | |
7 # RSAES-OAEP as specified in PKCS #1 v2.1. | |
8 # | |
9 # The message is a bit string of length 128, | |
10 # while the size of the modulus in the public | |
11 # key is 1024 bits. The second representation | |
12 # of the private key is used, which means that | |
13 # CRT is applied in the decryption process. | |
14 # | |
15 # The underlying hash function is SHA-1; the | |
16 # mask generation function is MGF1 with SHA-1 | |
17 # as specified in PKCS #1 v2.1. | |
18 # | |
19 # This file also contains a demonstration of | |
20 # the RSADP decryption primitive with CRT. | |
21 # Finally, DER encodings of the RSA keys are | |
22 # given at the end of the file. | |
23 # | |
24 # | |
25 # Integers are represented by strings of octets | |
26 # with the leftmost octet being the most | |
27 # significant octet. For example, | |
28 # | |
29 # 9,202,000 = (0x)8c 69 50. | |
30 # | |
31 # ============================================= | |
32 | |
33 # ------------------------------ | |
34 # Components of the RSA Key Pair | |
35 # ------------------------------ | |
36 | |
37 # RSA modulus n: | |
38 bb f8 2f 09 06 82 ce 9c 23 38 ac 2b 9d a8 71 f7 | |
39 36 8d 07 ee d4 10 43 a4 40 d6 b6 f0 74 54 f5 1f | |
40 b8 df ba af 03 5c 02 ab 61 ea 48 ce eb 6f cd 48 | |
41 76 ed 52 0d 60 e1 ec 46 19 71 9d 8a 5b 8b 80 7f | |
42 af b8 e0 a3 df c7 37 72 3e e6 b4 b7 d9 3a 25 84 | |
43 ee 6a 64 9d 06 09 53 74 88 34 b2 45 45 98 39 4e | |
44 e0 aa b1 2d 7b 61 a5 1f 52 7a 9a 41 f6 c1 68 7f | |
45 e2 53 72 98 ca 2a 8f 59 46 f8 e5 fd 09 1d bd cb | |
46 | |
47 # RSA public exponent e: | |
48 (0x)11 | |
49 | |
50 # Prime p: | |
51 ee cf ae 81 b1 b9 b3 c9 08 81 0b 10 a1 b5 60 01 | |
52 99 eb 9f 44 ae f4 fd a4 93 b8 1a 9e 3d 84 f6 32 | |
53 12 4e f0 23 6e 5d 1e 3b 7e 28 fa e7 aa 04 0a 2d | |
54 5b 25 21 76 45 9d 1f 39 75 41 ba 2a 58 fb 65 99 | |
55 | |
56 # Prime q: | |
57 c9 7f b1 f0 27 f4 53 f6 34 12 33 ea aa d1 d9 35 | |
58 3f 6c 42 d0 88 66 b1 d0 5a 0f 20 35 02 8b 9d 86 | |
59 98 40 b4 16 66 b4 2e 92 ea 0d a3 b4 32 04 b5 cf | |
60 ce 33 52 52 4d 04 16 a5 a4 41 e7 00 af 46 15 03 | |
61 | |
62 # p's CRT exponent dP: | |
63 54 49 4c a6 3e ba 03 37 e4 e2 40 23 fc d6 9a 5a | |
64 eb 07 dd dc 01 83 a4 d0 ac 9b 54 b0 51 f2 b1 3e | |
65 d9 49 09 75 ea b7 74 14 ff 59 c1 f7 69 2e 9a 2e | |
66 20 2b 38 fc 91 0a 47 41 74 ad c9 3c 1f 67 c9 81 | |
67 | |
68 # q's CRT exponent dQ: | |
69 47 1e 02 90 ff 0a f0 75 03 51 b7 f8 78 86 4c a9 | |
70 61 ad bd 3a 8a 7e 99 1c 5c 05 56 a9 4c 31 46 a7 | |
71 f9 80 3f 8f 6f 8a e3 42 e9 31 fd 8a e4 7a 22 0d | |
72 1b 99 a4 95 84 98 07 fe 39 f9 24 5a 98 36 da 3d | |
73 | |
74 # CRT coefficient qInv: | |
75 b0 6c 4f da bb 63 01 19 8d 26 5b db ae 94 23 b3 | |
76 80 f2 71 f7 34 53 88 50 93 07 7f cd 39 e2 11 9f | |
77 c9 86 32 15 4f 58 83 b1 67 a9 67 bf 40 2b 4e 9e | |
78 2e 0f 96 56 e6 98 ea 36 66 ed fb 25 79 80 39 f7 | |
79 | |
80 # ---------------------------------- | |
81 # Step-by-step RSAES-OAEP Encryption | |
82 # ---------------------------------- | |
83 | |
84 # Message M to be encrypted: | |
85 d4 36 e9 95 69 fd 32 a7 c8 a0 5b bc 90 d3 2c 49 | |
86 | |
87 # Label L: | |
88 (the empty string) | |
89 | |
90 # lHash = Hash(L) | |
91 # DB = lHash || Padding || M | |
92 # seed = random string of octets | |
93 # dbMask = MGF(seed, length(DB)) | |
94 # maskedDB = DB xor dbMask | |
95 # seedMask = MGF(maskedDB, length(seed)) | |
96 # maskedSeed = seed xor seedMask | |
97 # EM = 0x00 || maskedSeed || maskedDB | |
98 | |
99 # lHash: | |
100 da 39 a3 ee 5e 6b 4b 0d 32 55 bf ef 95 60 18 90 | |
101 af d8 07 09 | |
102 | |
103 # DB: | |
104 da 39 a3 ee 5e 6b 4b 0d 32 55 bf ef 95 60 18 90 | |
105 af d8 07 09 00 00 00 00 00 00 00 00 00 00 00 00 | |
106 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | |
107 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | |
108 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | |
109 00 00 00 00 00 00 00 00 00 00 01 d4 36 e9 95 69 | |
110 fd 32 a7 c8 a0 5b bc 90 d3 2c 49 | |
111 | |
112 # seed: | |
113 aa fd 12 f6 59 ca e6 34 89 b4 79 e5 07 6d de c2 | |
114 f0 6c b5 8f | |
115 | |
116 # dbMask: | |
117 06 e1 de b2 36 9a a5 a5 c7 07 d8 2c 8e 4e 93 24 | |
118 8a c7 83 de e0 b2 c0 46 26 f5 af f9 3e dc fb 25 | |
119 c9 c2 b3 ff 8a e1 0e 83 9a 2d db 4c dc fe 4f f4 | |
120 77 28 b4 a1 b7 c1 36 2b aa d2 9a b4 8d 28 69 d5 | |
121 02 41 21 43 58 11 59 1b e3 92 f9 82 fb 3e 87 d0 | |
122 95 ae b4 04 48 db 97 2f 3a c1 4e af f4 9c 8c 3b | |
123 7c fc 95 1a 51 ec d1 dd e6 12 64 | |
124 | |
125 # maskedDB: | |
126 dc d8 7d 5c 68 f1 ee a8 f5 52 67 c3 1b 2e 8b b4 | |
127 25 1f 84 d7 e0 b2 c0 46 26 f5 af f9 3e dc fb 25 | |
128 c9 c2 b3 ff 8a e1 0e 83 9a 2d db 4c dc fe 4f f4 | |
129 77 28 b4 a1 b7 c1 36 2b aa d2 9a b4 8d 28 69 d5 | |
130 02 41 21 43 58 11 59 1b e3 92 f9 82 fb 3e 87 d0 | |
131 95 ae b4 04 48 db 97 2f 3a c1 4f 7b c2 75 19 52 | |
132 81 ce 32 d2 f1 b7 6d 4d 35 3e 2d | |
133 | |
134 # seedMask: | |
135 41 87 0b 5a b0 29 e6 57 d9 57 50 b5 4c 28 3c 08 | |
136 72 5d be a9 | |
137 | |
138 # maskedSeed: | |
139 eb 7a 19 ac e9 e3 00 63 50 e3 29 50 4b 45 e2 ca | |
140 82 31 0b 26 | |
141 | |
142 # EM = 00 || maskedSeed || maskedDB: | |
143 00 eb 7a 19 ac e9 e3 00 63 50 e3 29 50 4b 45 e2 | |
144 ca 82 31 0b 26 dc d8 7d 5c 68 f1 ee a8 f5 52 67 | |
145 c3 1b 2e 8b b4 25 1f 84 d7 e0 b2 c0 46 26 f5 af | |
146 f9 3e dc fb 25 c9 c2 b3 ff 8a e1 0e 83 9a 2d db | |
147 4c dc fe 4f f4 77 28 b4 a1 b7 c1 36 2b aa d2 9a | |
148 b4 8d 28 69 d5 02 41 21 43 58 11 59 1b e3 92 f9 | |
149 82 fb 3e 87 d0 95 ae b4 04 48 db 97 2f 3a c1 4f | |
150 7b c2 75 19 52 81 ce 32 d2 f1 b7 6d 4d 35 3e 2d | |
151 | |
152 # Ciphertext, the RSA encryption of EM: | |
153 12 53 e0 4d c0 a5 39 7b b4 4a 7a b8 7e 9b f2 a0 | |
154 39 a3 3d 1e 99 6f c8 2a 94 cc d3 00 74 c9 5d f7 | |
155 63 72 20 17 06 9e 52 68 da 5d 1c 0b 4f 87 2c f6 | |
156 53 c1 1d f8 23 14 a6 79 68 df ea e2 8d ef 04 bb | |
157 6d 84 b1 c3 1d 65 4a 19 70 e5 78 3b d6 eb 96 a0 | |
158 24 c2 ca 2f 4a 90 fe 9f 2e f5 c9 c1 40 e5 bb 48 | |
159 da 95 36 ad 87 00 c8 4f c9 13 0a de a7 4e 55 8d | |
160 51 a7 4d df 85 d8 b5 0d e9 68 38 d6 06 3e 09 55 | |
161 | |
162 # -------------------------------------------- | |
163 # Step-by-step RSAES-OAEP Decryption Using CRT | |
164 # -------------------------------------------- | |
165 | |
166 # c = the integer value of C above | |
167 # m1 = c^dP mod p = (c mod p)^dP mod p | |
168 # m2 = c^dQ mod q = (c mod q)^dQ mod q | |
169 # h = (m1-m2)*qInv mod p | |
170 # m = m2 + q*h = the integer value of EM above | |
171 | |
172 # c mod p: | |
173 de 63 d4 72 35 66 fa a7 59 bf e4 08 82 1d d5 25 | |
174 72 ec 92 85 4d df 87 a2 b6 64 d4 4d aa 37 ca 34 | |
175 6a 05 20 3d 82 ff 2d e8 e3 6c ec 1d 34 f9 8e b6 | |
176 05 e2 a7 d2 6d e7 af 36 9c e4 ec ae 14 e3 56 33 | |
177 | |
178 # c mod q: | |
179 a2 d9 24 de d9 c3 6d 62 3e d9 a6 5b 5d 86 2c fb | |
180 ec 8b 19 9c 64 27 9c 54 14 e6 41 19 6e f1 c9 3c | |
181 50 7a 9b 52 13 88 1a ad 05 b4 cc fa 02 8a c1 ec | |
182 61 42 09 74 bf 16 25 83 6b 0b 7d 05 fb b7 53 36 | |
183 | |
184 # m1: | |
185 89 6c a2 6c d7 e4 87 1c 7f c9 68 a8 ed ea 11 e2 | |
186 71 82 4f 0e 03 65 52 17 94 f1 e9 e9 43 b4 a4 4b | |
187 57 c9 e3 95 a1 46 74 78 f5 26 49 6b 4b b9 1f 1c | |
188 ba ea 90 0f fc 60 2c f0 c6 63 6e ba 84 fc 9f f7 | |
189 | |
190 # m2: | |
191 4e bb 22 75 85 f0 c1 31 2d ca 19 e0 b5 41 db 14 | |
192 99 fb f1 4e 27 0e 69 8e 23 9a 8c 27 a9 6c da 9a | |
193 74 09 74 de 93 7b 5c 9c 93 ea d9 46 2c 65 75 02 | |
194 1a 23 d4 64 99 dc 9f 6b 35 89 75 59 60 8f 19 be | |
195 | |
196 # h: | |
197 01 2b 2b 24 15 0e 76 e1 59 bd 8d db 42 76 e0 7b | |
198 fa c1 88 e0 8d 60 47 cf 0e fb 8a e2 ae bd f2 51 | |
199 c4 0e bc 23 dc fd 4a 34 42 43 94 ad a9 2c fc be | |
200 1b 2e ff bb 60 fd fb 03 35 9a 95 36 8d 98 09 25 | |
201 | |
202 # m: | |
203 00 eb 7a 19 ac e9 e3 00 63 50 e3 29 50 4b 45 e2 | |
204 ca 82 31 0b 26 dc d8 7d 5c 68 f1 ee a8 f5 52 67 | |
205 c3 1b 2e 8b b4 25 1f 84 d7 e0 b2 c0 46 26 f5 af | |
206 f9 3e dc fb 25 c9 c2 b3 ff 8a e1 0e 83 9a 2d db | |
207 4c dc fe 4f f4 77 28 b4 a1 b7 c1 36 2b aa d2 9a | |
208 b4 8d 28 69 d5 02 41 21 43 58 11 59 1b e3 92 f9 | |
209 82 fb 3e 87 d0 95 ae b4 04 48 db 97 2f 3a c1 4f | |
210 7b c2 75 19 52 81 ce 32 d2 f1 b7 6d 4d 35 3e 2d | |
211 | |
212 # The intermediate values in the remaining | |
213 # decryption process are the same as during | |
214 # RSAES-OAEP encryption of M. | |
215 | |
216 # ============================================= | |
217 | |
218 # ======================== | |
219 # DER Encoding of RSA Keys | |
220 # ======================== | |
221 | |
222 # ------------ | |
223 # RSAPublicKey | |
224 # ------------ | |
225 30 81 87 | |
226 # modulus | |
227 02 81 81 | |
228 00 bb f8 2f 09 06 82 ce | |
229 9c 23 38 ac 2b 9d a8 71 | |
230 f7 36 8d 07 ee d4 10 43 | |
231 a4 40 d6 b6 f0 74 54 f5 | |
232 1f b8 df ba af 03 5c 02 | |
233 ab 61 ea 48 ce eb 6f cd | |
234 48 76 ed 52 0d 60 e1 ec | |
235 46 19 71 9d 8a 5b 8b 80 | |
236 7f af b8 e0 a3 df c7 37 | |
237 72 3e e6 b4 b7 d9 3a 25 | |
238 84 ee 6a 64 9d 06 09 53 | |
239 74 88 34 b2 45 45 98 39 | |
240 4e e0 aa b1 2d 7b 61 a5 | |
241 1f 52 7a 9a 41 f6 c1 68 | |
242 7f e2 53 72 98 ca 2a 8f | |
243 59 46 f8 e5 fd 09 1d bd | |
244 cb | |
245 # publicExponent | |
246 02 01 | |
247 11 | |
248 | |
249 # ------------- | |
250 # RSAPrivateKey | |
251 # ------------- | |
252 30 82 02 5b | |
253 # version | |
254 02 01 | |
255 00 | |
256 # modulus | |
257 02 81 81 | |
258 00 bb f8 2f 09 06 82 ce | |
259 9c 23 38 ac 2b 9d a8 71 | |
260 f7 36 8d 07 ee d4 10 43 | |
261 a4 40 d6 b6 f0 74 54 f5 | |
262 1f b8 df ba af 03 5c 02 | |
263 ab 61 ea 48 ce eb 6f cd | |
264 48 76 ed 52 0d 60 e1 ec | |
265 46 19 71 9d 8a 5b 8b 80 | |
266 7f af b8 e0 a3 df c7 37 | |
267 72 3e e6 b4 b7 d9 3a 25 | |
268 84 ee 6a 64 9d 06 09 53 | |
269 74 88 34 b2 45 45 98 39 | |
270 4e e0 aa b1 2d 7b 61 a5 | |
271 1f 52 7a 9a 41 f6 c1 68 | |
272 7f e2 53 72 98 ca 2a 8f | |
273 59 46 f8 e5 fd 09 1d bd | |
274 cb | |
275 # publicExponent | |
276 02 01 | |
277 11 | |
278 # privateExponent | |
279 02 81 81 | |
280 00 a5 da fc 53 41 fa f2 | |
281 89 c4 b9 88 db 30 c1 cd | |
282 f8 3f 31 25 1e 06 68 b4 | |
283 27 84 81 38 01 57 96 41 | |
284 b2 94 10 b3 c7 99 8d 6b | |
285 c4 65 74 5e 5c 39 26 69 | |
286 d6 87 0d a2 c0 82 a9 39 | |
287 e3 7f dc b8 2e c9 3e da | |
288 c9 7f f3 ad 59 50 ac cf | |
289 bc 11 1c 76 f1 a9 52 94 | |
290 44 e5 6a af 68 c5 6c 09 | |
291 2c d3 8d c3 be f5 d2 0a | |
292 93 99 26 ed 4f 74 a1 3e | |
293 dd fb e1 a1 ce cc 48 94 | |
294 af 94 28 c2 b7 b8 88 3f | |
295 e4 46 3a 4b c8 5b 1c b3 | |
296 c1 | |
297 # prime1 | |
298 02 41 | |
299 00 ee cf ae 81 b1 b9 b3 | |
300 c9 08 81 0b 10 a1 b5 60 | |
301 01 99 eb 9f 44 ae f4 fd | |
302 a4 93 b8 1a 9e 3d 84 f6 | |
303 32 12 4e f0 23 6e 5d 1e | |
304 3b 7e 28 fa e7 aa 04 0a | |
305 2d 5b 25 21 76 45 9d 1f | |
306 39 75 41 ba 2a 58 fb 65 | |
307 99 | |
308 # prime2 | |
309 02 41 | |
310 00 c9 7f b1 f0 27 f4 53 | |
311 f6 34 12 33 ea aa d1 d9 | |
312 35 3f 6c 42 d0 88 66 b1 | |
313 d0 5a 0f 20 35 02 8b 9d | |
314 86 98 40 b4 16 66 b4 2e | |
315 92 ea 0d a3 b4 32 04 b5 | |
316 cf ce 33 52 52 4d 04 16 | |
317 a5 a4 41 e7 00 af 46 15 | |
318 03 | |
319 # exponent1 | |
320 02 40 | |
321 54 49 4c a6 3e ba 03 37 | |
322 e4 e2 40 23 fc d6 9a 5a | |
323 eb 07 dd dc 01 83 a4 d0 | |
324 ac 9b 54 b0 51 f2 b1 3e | |
325 d9 49 09 75 ea b7 74 14 | |
326 ff 59 c1 f7 69 2e 9a 2e | |
327 20 2b 38 fc 91 0a 47 41 | |
328 74 ad c9 3c 1f 67 c9 81 | |
329 # exponent2 | |
330 02 40 | |
331 47 1e 02 90 ff 0a f0 75 | |
332 03 51 b7 f8 78 86 4c a9 | |
333 61 ad bd 3a 8a 7e 99 1c | |
334 5c 05 56 a9 4c 31 46 a7 | |
335 f9 80 3f 8f 6f 8a e3 42 | |
336 e9 31 fd 8a e4 7a 22 0d | |
337 1b 99 a4 95 84 98 07 fe | |
338 39 f9 24 5a 98 36 da 3d | |
339 # coefficient | |
340 02 41 | |
341 00 b0 6c 4f da bb 63 01 | |
342 19 8d 26 5b db ae 94 23 | |
343 b3 80 f2 71 f7 34 53 88 | |
344 50 93 07 7f cd 39 e2 11 | |
345 9f c9 86 32 15 4f 58 83 | |
346 b1 67 a9 67 bf 40 2b 4e | |
347 9e 2e 0f 96 56 e6 98 ea | |
348 36 66 ed fb 25 79 80 39 | |
349 f7 | |
350 | |
351 # ------------------------ | |
352 # PrivateKeyInfo (PKCS #8) | |
353 # ------------------------ | |
354 30 82 02 75 | |
355 # version | |
356 02 01 | |
357 00 | |
358 # privateKeyAlgorithmIdentifier | |
359 30 0d | |
360 06 09 | |
361 2a 86 48 86 f7 0d 01 01 01 | |
362 # parameters | |
363 05 00 | |
364 # privateKey = RSAPrivateKey encoding | |
365 04 82 02 5f | |
366 # DER encoding of RSAPrivateKey structure | |
367 30 82 02 5b ... 79 80 39 f7 | |
368 | |
369 # ============================================= |