d3409d5e |
1 | # Test vectors for Montgomery reduction |
2 | # |
890e34fd |
3 | # $Id: mpmont,v 1.2 1999/11/19 13:18:39 mdw Exp $ |
d3409d5e |
4 | |
5 | create { |
6 | 340809809850981098423498794792349 # m |
7 | 266454859 # -m^{-1} mod b |
8 | 130655606683780235388773757767708 # R mod m |
9 | 237786678640282040194246459306177; # R^2 mod m |
10 | } |
11 | |
12 | mul { |
13 | 43289823545 |
14 | 234324324 |
15 | 6456542564 |
16 | 10807149256; |
17 | } |
18 | |
19 | exp { |
20 | 4325987397987458979875737589783 |
21 | 435365332435654643667 |
22 | 8745435676786567758678547 |
23 | 2439674515119108242643169132064; |
24 | |
890e34fd |
25 | # --- Bizarre bug --- |
26 | # |
27 | # This was caused by omission of the test-and-subtract step in the |
28 | # Montgomery reduction. |
29 | |
30 | 8939489893434234331 1804289383 454353454354565 6139425926295484741; |
31 | 8939489893434234331 1804289383 8939489893434234330 1; |
32 | |
d3409d5e |
33 | # --- Quick RSA test --- |
34 | |
35 | 905609324890967090294090970600361 # This is p |
36 | 3 |
37 | 905609324890967090294090970600360 # This is (p - 1) |
38 | 1; # Fermat test: p is prime |
39 | |
40 | 734589569806680985408670989082927 # This is q |
41 | 5 |
42 | 734589569806680985408670989082926 # And this is (q - 1) |
43 | 1; # Fermat again: q is prime |
44 | |
45 | # --- Encrypt a message --- |
46 | # |
47 | # The public and private exponents are from the GCD test. The message |
48 | # is just obvious. The modulus is the product of the two primes above. |
49 | |
50 | 665251164384574309450646977867045404520085938543622535546005136647 |
51 | 123456789012345678901234567890123456789012345678901234567890 |
52 | 5945908509680983480596809586040589085680968709809890671 |
53 | 25906467774034212974484417859588980567136610347807401817990462701; |
54 | |
55 | # --- And decrypt it again --- |
56 | |
57 | 665251164384574309450646977867045404520085938543622535546005136647 |
58 | 25906467774034212974484417859588980567136610347807401817990462701 |
59 | 514778499400157641662814932021958856708417966520837469125919104431 |
60 | 123456789012345678901234567890123456789012345678901234567890; |
61 | } |
890e34fd |
62 | |
63 | # --- Simultaneous exponentiation --- |
64 | |
65 | mexp-1 { |
66 | 4325987397987458979875737589783 |
67 | 435365332435654643667 |
68 | 8745435676786567758678547 |
69 | 2439674515119108242643169132064; |
70 | } |
71 | |
72 | mexp-2 { |
73 | 16_8df2a494492276aa3d25759bb06869cbeac0d83afb8d0cf7cbb8324f0d7882e5d0762fc5b7210eafc2e9adac32ab7aac49693dfbf83724c2ec0736ee31c80291 |
74 | 16_626d027839ea0a13413163a55b4cb500299d5522956cefcb3bff10f399ce2c2e71cb9de5fa24babf58e5b79521925c9cc42e9f6f464b088cc572af53e6d78802 |
75 | 16_bf655bd046f0b35ec791b004804afcbb8ef7d69d |
76 | 16_19131871d75b1612a819f29d78d1b0d7346f7aa77bb62a859bfd6c5675da9d212d3a36ef1672ef660b8c7c255cc0ec74858fba33f44c06699630a76b030ee333 |
77 | 16_821a926312e97adeabcc8d082b5278978a2df4b0 |
78 | 16_2fc6cb9ac3be0eac3daf02eefb96fca3846708a28dd05730165fe50942f7f07edfef8e52fcb9369e3814aa24607e80475d0e61ad461d6b16b6cec5baae58946e; |
79 | } |