New test.
[mono.git] / mcs / class / Mono.Security / Test / Mono.Math / ModInverseBigTest.cs
1 //
2 // MonoTests.Mono.Math.ModInverseBigTest.cs
3 //
4 // Authors:
5 //      Ben Maurer
6 //
7 // Copyright (c) 2003 Ben Maurer. All rights reserved
8 //
9
10 using System;
11 using Mono.Math;
12 using NUnit.Framework;
13
14 namespace MonoTests.Mono.Math {
15
16         public abstract class ModInverseBig_Base : BigIntegerTestSet {
17
18                 BigInteger A, B, AmodinvB;
19
20                 public ModInverseBig_Base () 
21                 {
22                         A = new BigInteger (a);
23                         B = new BigInteger (b);
24                         AmodinvB = new BigInteger (ExpectedAmodinvB);
25                 }
26                 
27                 public abstract uint[] a {
28                         get;
29                 }
30                 public abstract uint[] b {
31                         get;
32                 }
33
34                 public abstract uint[] ExpectedAmodinvB {
35                         get;
36                 }
37
38                 [Test]
39                 public void ModInvPP () 
40                 {
41                         Expect (A.ModInverse (B), AmodinvB);
42                 }
43         }
44         
45         public class ModInverseBig_Rand512a1024b : ModInverseBig_Base {
46
47         
48                 public override uint[] a {
49                         get {
50                                 return new uint[] {
51                                         0x48fd8f2e, 0xa791b900, 0x19e53aaa, 0x6d45758a, 0xeb8be610, 0x25c42285,
52                                         0xabff3066, 0xcdcb9969, 0xa08fd7c1, 0x1c382419, 0xcd6b685b, 0x23e8bcaf,
53                                         0x592a0f82, 0x2b54b60b, 0xbb67f3c2, 0x64313461
54                                 };
55                         }
56                 }
57
58                 public override uint[] b {
59                         get {
60                                 return new uint[] {
61                                         0x3617f5e4, 0xd32a40dc, 0x358f7c09, 0x976b345b, 0x4dc05c63, 0x91ed990d,
62                                         0xfc66b0a6, 0x0a36dd7e, 0x7a5ea721, 0xf28b577e, 0xf014cbf6, 0x597b4094,
63                                         0x177f8253, 0x6587a352, 0x67fedcf0, 0x61ee389e, 0xff86cc7d, 0x9817cd3a,
64                                         0x632d6730, 0x3082112a, 0x48509e74, 0x198c7802, 0x69d8c4c6, 0x727313e9,
65                                         0x1e11ae51, 0xa72a33bb, 0xc9059cc7, 0xc9fc6268, 0x34ed466b, 0x11e49879,
66                                         0x8eb7ebf5, 0x98b53108
67                                 };
68                         }
69                 }
70
71                 public override uint[] ExpectedAmodinvB {
72                         get {
73                                 return new uint[] {
74                                         0x045fbad9, 0x61867c14, 0xb30ff1f7, 0x5deaf4c1, 0xd19e0b62, 0xc4ed73af,
75                                         0x9501dbd4, 0x0b052e1c, 0xd3e944c3, 0xeddc333b, 0x1444c1f9, 0x38ca61b7,
76                                         0xceec8a0d, 0xec8f2814, 0xa2099df4, 0x2a0ddbd0, 0x9193985d, 0x09f89197,
77                                         0xb58e7229, 0x45c1f891, 0x93553056, 0x462dbe6a, 0xb70c95d0, 0x7cf80ae9,
78                                         0x7833e1bf, 0x88329c50, 0xdbde3ef8, 0x7a426200, 0x4335234a, 0x2556ba2c,
79                                         0x94cc2109, 0x046645c1
80                                 };
81                         }
82                 }
83         }
84
85         public class ModInverseBig_Rand256a1024b : ModInverseBig_Base {
86
87         
88                 public override uint[] a {
89                         get {
90                                 return new uint[] {
91                                         0xcc2e79fa, 0x6901026e, 0xc4fdb0d4, 0xb4173ce7, 0xf7f96af1, 0x8339780b,
92                                         0x22268620, 0x382c75a4
93                                 };
94                         }
95                 }
96
97                 public override uint[] b {
98                         get {
99                                 return new uint[] {
100                                         0x4b23ac44, 0xbddfc733, 0x3ea2a85b, 0x02daa1d8, 0x2b31cf00, 0x2503a376,
101                                         0xa3d47c77, 0x829266d7, 0x1e29fad8, 0x4f0e3788, 0xc9c128d7, 0x13ea53eb,
102                                         0x85fc86b1, 0xbad2c0c4, 0xd87dcdad, 0x0a09ba8c, 0x126a0ede, 0x1fe390c7,
103                                         0x12c5a679, 0xf23557e1, 0x8e7b1934, 0xc102f83b, 0x934de6d6, 0x254aee03,
104                                         0x34f02315, 0x33edbb07, 0x97a87ecf, 0xbf534337, 0xe347ae90, 0xf2eb1176,
105                                         0x5459c63b, 0x8f3b0f75
106                                 };
107                         }
108                 }
109
110                 public override uint[] ExpectedAmodinvB {
111                         get {
112                                 return new uint[] {
113                                         0x12d80123, 0x9b288afc, 0x466ed241, 0x8bf1804d, 0x73cd667f, 0x8eb1eb34,
114                                         0x513df007, 0x464c7245, 0xf3b97899, 0xd5cb92c7, 0xdefdb611, 0x5258e545,
115                                         0xe8b66c76, 0xd11c58e3, 0xab1fc29a, 0x9718099e, 0xa4040d4e, 0x29980874,
116                                         0xda2b4e0d, 0xfed020de, 0x6bde01e6, 0x15b084af, 0x9657aa64, 0x760c64f0,
117                                         0x6bba8099, 0xef1a409e, 0xf80b1ec7, 0x4a69256b, 0xf867ec36, 0xd3659a2a,
118                                         0xf23ec3a5, 0x04349da9
119                                 };
120                         }
121                 }
122         }
123         
124         public class ModInverseBig_Rand256a512b : ModInverseBig_Base {
125
126                 public override uint[] a {
127                         get {
128                                 return new uint[] {
129                                         0x2e9342c8, 0x1ac6b23d, 0xeb18d3f9, 0x2b076025, 0x030232ee, 0xd1cb7f22,
130                                         0xfbfe74df, 0xabadc589
131                                 };
132                         }
133                 }
134
135                 public override uint[] b {
136                         get {
137                                 return new uint[] {
138                                         0x7e0a43ca, 0xf05d9c52, 0x28e68cf6, 0xf168b591, 0x88c17e79, 0xcb075c3b,
139                                         0x92a16680, 0xd7dccd53, 0xe6da1248, 0xe71811b7, 0x4d0a3c42, 0x1ebb46cc,
140                                         0x71d4dd69, 0x07a642d9, 0x8eae29d0, 0xcbd278b4
141                                 };
142                         }
143                 }
144
145                 public override uint[] ExpectedAmodinvB {
146                         get {
147                                 return new uint[] {
148                                         0x77dc2534, 0xf81a1bc7, 0xfbd6b350, 0x809b2c31, 0x3e04ad9f, 0x5101b59f,
149                                         0xcee28213, 0x726356fe, 0xeb7d0a6b, 0x01ed7bd7, 0x27ff2f04, 0xa3cbd6a4,
150                                         0xcd6a849d, 0x029c9a79, 0xb82d5da2, 0x87af9e81
151                                 };
152                         }
153                 }
154         }
155
156         public class ModInverseBig_Rand1024a5b : ModInverseBig_Base {
157
158                 public override uint[] a {
159                         get {
160                                 return new uint[] {
161                                         0x60cc0502, 0xebe19e1b, 0xfc64fd47, 0xfc34fbac, 0x81b3b346, 0x57e9ebf8,
162                                         0x96501b67, 0xc95eb1cc, 0x2e126045, 0xa56ec13b, 0x2f812165, 0xb4391e46,
163                                         0xb245069a, 0xfeb836b6, 0xebeceb62, 0xedd9f9bc, 0x9bdd63ba, 0xac491f92,
164                                         0xb8ab6898, 0x8a5ea88d, 0xf7f24993, 0x75e86618, 0x4e939376, 0x7a2ac365,
165                                         0xb270f14c, 0x416fb9bc, 0x77af8352, 0x488e1a5f, 0xe22e8cda, 0xcaa72806,
166                                         0xf649f663, 0xefee082d
167                                 };
168                         }
169                 }
170
171                 public override uint[] b {
172                         get {
173                                 return new uint[] {
174                                         0x11
175                                 };
176                         }
177                 }
178
179                 public override uint[] ExpectedAmodinvB {
180                         get {
181                                 return new uint[] {
182                                         0x2
183                                 };
184                         }
185                 }
186         }
187
188         public class ModInverseBig_Rand3a1024b : ModInverseBig_Base {
189
190                 public override uint[] a {
191                         get {
192                                 return new uint[] {
193                                         0x5
194                                 };
195                         }
196                 }
197
198                 public override uint[] b {
199                         get {
200                                 return new uint[] {
201                                         0x3919ec8a, 0x8c713779, 0xb87d2db0, 0x7922df91, 0x34bf77e1, 0x49c08156,
202                                         0x9ffb8ed5, 0x522a42e9, 0xdf18b1ff, 0x1cfdc432, 0x8564555b, 0x2b800684,
203                                         0xa46bad82, 0x175a04ea, 0x87e4d513, 0xfb956ebc, 0xb74745e6, 0x85f45bf5,
204                                         0xe580bb11, 0x290bfc35, 0x8d8782d8, 0x1054ea4e, 0x93eb86bb, 0xe7ea2e42,
205                                         0x762c2945, 0x23e59e46, 0x833fe0b2, 0x3797025f, 0xabc64408, 0x94d0c8ac,
206                                         0x2a31e00b, 0xd4d28ab0
207                                 };
208                         }
209                 }
210
211                 public override uint[] ExpectedAmodinvB {
212                         get {
213                                 return new uint[] {
214                                         0x2dae56d5, 0x3d275f94, 0x939757c0, 0x60e8b2da, 0x90992cb4, 0x3b006778,
215                                         0x7ffc7244, 0x41bb68bb, 0x18e08e65, 0xb0cb035b, 0x9de9dde2, 0x8933386a,
216                                         0x1d22f134, 0xdf7b3722, 0x0650aa76, 0x62ddf230, 0x929f6b1e, 0xd1904991,
217                                         0x8466fc0d, 0xba6ffcf7, 0xa46c68ac, 0xd9dd883e, 0xdcbc6bc9, 0x8654f1ce,
218                                         0xc4f02104, 0x1cb7b1d2, 0x0299808e, 0x92df3519, 0x5638366d, 0x43da3a23,
219                                         0x54f4b33c, 0xaa42088d
220                                 };
221                         }
222                 }
223         }       
224 }