d3409d5e |
1 | # Test vectors for MP functions |
2 | # |
342c3212 |
3 | # $Id: mp,v 1.3 1999/12/10 23:25:51 mdw Exp $ |
d3409d5e |
4 | |
5 | add { |
6 | 5 4 9; 5 -4 1; -5 4 -1; -5 -4 -9; |
7 | 0xffffffff 1 0x100000000; |
8 | } |
9 | |
10 | sub { |
11 | 5 4 1; 5 -4 9; -5 4 -9; -5 -4 -1; |
12 | 4 5 -1; 4 -5 9; -4 5 -9; -4 -5 1; |
13 | } |
14 | |
15 | mul { |
16 | 5 4 20; -5 4 -20; 5 -4 -20; -5 -4 20; |
17 | 0x10000 0x10000 0x100000000; |
18 | } |
19 | |
20 | div { |
21 | 9 4 2 1; -9 4 -3 3; 9 -4 -3 -3; -9 -4 2 -1; |
22 | } |
23 | |
24 | gcd { |
342c3212 |
25 | |
26 | # --- Simple tests --- |
27 | |
d3409d5e |
28 | 16 12 4 -2 3; |
29 | 12 16 4 -1 1; |
30 | 693 609 21 -181 206; |
31 | 4398082908043 90980984098081324 1 -32483863573352089 1570292150447; |
32 | |
342c3212 |
33 | # --- Negative argument tests --- |
34 | |
35 | 16 -12 4 -2 -3; |
36 | -16 12 4 2 3; |
37 | -12 -16 4 1 -1; |
38 | -12 16 4 1 1; |
39 | -693 609 21 181 206; |
40 | 693 -609 21 -181 -206; |
41 | |
42 | # --- Zero argument tests --- |
43 | |
44 | 15 0 15 1 0; |
45 | 0 15 15 0 1; |
46 | -5 0 5 -1 0; |
47 | 0 -5 5 0 -1; |
48 | 0 0 0 0 0; |
49 | |
50 | # --- Random number tests --- |
51 | |
d3409d5e |
52 | 829561629303257626084392170900075 32498098450983560651904114638965 |
53 | 5 -22841190347053190672253237276815 583054885752979049202923618992482; |
54 | |
55 | 5509672937670943767152343650729669537671508 |
56 | 398326674296699796695672966992514673531 |
57 | 17 |
58 | -191606556147997561067126486929677861359 |
59 | 2650310725368604614586643627755316700713319; |
60 | |
61 | 324098408098290809832490802984098208098324 |
62 | 23430980840982340982098409823089098443 |
63 | 1 |
64 | -4158709420138833210339208344965073815 |
65 | 57523460582278135926717203882531035926727; |
66 | |
67 | # --- RSA test --- |
68 | # |
69 | # The first number is (p - 1)(q - 1) from `mpmont'. The second is a |
70 | # random number (it's actually prime, but that doesn't matter) which I |
71 | # can use as an RSA encryption exponent. The last is the partner |
72 | # decryption exponent, produced using the extended GCD algorithm. |
73 | |
74 | 665251164384574309450646977867043764321191240895546832784045453360 |
75 | 5945908509680983480596809586040589085680968709809890671 |
76 | 1 |
77 | -4601007896041464028712478963832994007038251361995647370 |
78 | 514778499400157641662814932021958856708417966520837469125919104431; |
79 | } |
5b00a0ea |
80 | |
81 | jacobi { |
82 | 4 5 1; |
83 | 6 7 -1; |
84 | 15 27 0; |
85 | 2132498039840981 98729378979237498798347932749951 1; |
86 | } |