| 1 | # Test group abstraction, and a bunch of other things. |
| 2 | |
| 3 | check { |
| 4 | "prime { 29, 7, 16 }" "ok"; |
| 5 | "prime { 29, 6, 5 }" "not a subgroup"; |
| 6 | "prime { 21, 2, 2 }" "p is not prime"; |
| 7 | "prime { 29, 14, 9 }" "group order not prime"; |
| 8 | |
| 9 | "ec { secp224r1 }" "ok"; |
| 10 | |
| 11 | "prime { catacomb-ll-160-1024 }" "ok"; |
| 12 | |
| 13 | "ec { |
| 14 | prime: |
| 15 | 0xdb7c2abf62e35e668076bead208b |
| 16 | primeproj: |
| 17 | 0xdb7c2abf62e35e668076bead2088, 0x659ef8ba043916eede8911702b22 |
| 18 | 0x09487239995a5ee76b55f9c2f098, 0xa89ce5af8724c0a23e0e0ff77500 |
| 19 | 0xdb7c2abf62e35e7628dfac6561c5 * 1 |
| 20 | }" "ok"; |
| 21 | |
| 22 | "ec { |
| 23 | prime: |
| 24 | 0xdb7c2abf62e35e668076bead208b |
| 25 | primeproj: |
| 26 | 0xdb7c2abf62e35e668076bead2088, 0x659ef8ba043916eede8911702b22 |
| 27 | 0x09487239995a5ee76b55f9c2f098, 0xa89ce5af8724c0a23e0e0ff77500 |
| 28 | 0xdb7c2abf62e35e7628dfac6561c5 * 2 |
| 29 | }" "incorrect or ambiguous cofactor"; |
| 30 | |
| 31 | # --- This one's oakley-155 --- |
| 32 | |
| 33 | "ec { |
| 34 | binpoly: 0x0800000000000000000000004000000000000001 |
| 35 | binproj: 0, 0x7338F |
| 36 | 0xaa089ae4666a422e714651ad9372213fa65a93, |
| 37 | 0x12d29c630dda76010397809a6816be6d2ffa815 |
| 38 | 0xaaaaaaaaaaaaaaaaaab1fcf1e206f421a3ea1b * 12 |
| 39 | }" "degree not prime"; |
| 40 | |
| 41 | } |
| 42 | |
| 43 | checkelt { |
| 44 | "prime { 29, 7, 16 }" 16 0; |
| 45 | "prime { 29, 7, 16 }" 2 -1; |
| 46 | |
| 47 | "ec { secp112r1 } " |
| 48 | "0x09487239995a5ee76b55f9c2f098, 0xa89ce5af8724c0a23e0e0ff77500" |
| 49 | 0; |
| 50 | |
| 51 | "ec { |
| 52 | binpoly: 0x0800000000000000000000004000000000000001 |
| 53 | binproj: 0, 0x7338F |
| 54 | 0xaa089ae4666a422e714651ad9372213fa65a93, |
| 55 | 0x12d29c630dda76010397809a6816be6d2ffa815 |
| 56 | 0xaaaaaaaaaaaaaaaaaab1fcf1e206f421a3ea1b * 12 |
| 57 | }" |
| 58 | "0x7b, 0x1c8" |
| 59 | -1; |
| 60 | |
| 61 | } |
| 62 | |
| 63 | mul { |
| 64 | "prime { 29, 7, 16 }" 8 7 27; |
| 65 | |
| 66 | "prime { catacomb-ll-128-512 }" |
| 67 | 3344609493517948819439808013094817124423784439045485500527919676470975342917009634212031124646834193243018749323077268170586751415510015906107400678608590 |
| 68 | 32459289443738057373904596685867555624839649360339363831766212033645755638497600605981483758068704145575847399920657057013890131443911836862688141735006 |
| 69 | 3947634573386515057215934636174241616115542585724861166389751782289048647501330677434616929656928819642658111077814577650964230037753641582364366136933940; |
| 70 | |
| 71 | "ec { nist-p192 }" |
| 72 | "0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012, |
| 73 | 0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811" |
| 74 | "0xdafebf5828783f2ad35534631588a3f629a70fb16982a888, |
| 75 | 0xdd6bda0d993da0fa46b27bbc141b868f59331afa5c7e93ab" |
| 76 | "0x76e32a2557599e6edcd283201fb2b9aadfd0d359cbb263da, |
| 77 | 0x782c37e372ba4520aa62e0fed121d49ef3b543660cfd05fd"; |
| 78 | } |
| 79 | |
| 80 | sqr { |
| 81 | "prime { 29, 7, 16 }" 8 6; |
| 82 | |
| 83 | "prime { catacomb-ll-128-512 }" |
| 84 | 3344609493517948819439808013094817124423784439045485500527919676470975342917009634212031124646834193243018749323077268170586751415510015906107400678608590 |
| 85 | 1140714521254648115393410274780412972862841854751618635120376750594285456137894804866135103112174518443866054055338095672091997366768745026933347678925721; |
| 86 | |
| 87 | "ec { nist-p192 }" |
| 88 | "0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012, |
| 89 | 0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811" |
| 90 | "0xdafebf5828783f2ad35534631588a3f629a70fb16982a888, |
| 91 | 0xdd6bda0d993da0fa46b27bbc141b868f59331afa5c7e93ab"; |
| 92 | } |
| 93 | |
| 94 | inv { |
| 95 | "prime { 29, 7, 16 }" 9 13; |
| 96 | |
| 97 | "prime { catacomb-ll-128-512 }" |
| 98 | 3344609493517948819439808013094817124423784439045485500527919676470975342917009634212031124646834193243018749323077268170586751415510015906107400678608590 |
| 99 | 5876676858790113051879264634636727534122591023949326683791506203503263391580079717512212895466773363712551406785344528808275608153699681298608650332072384; |
| 100 | |
| 101 | "ec { nist-p192 }" |
| 102 | "0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012, |
| 103 | 0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811" |
| 104 | "0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012, |
| 105 | 0xf8e6d46a003725879cefee1294db32298c06885ee186b7ee"; |
| 106 | } |
| 107 | |
| 108 | div { |
| 109 | "prime { 29, 7, 16 }" 9 5 25; |
| 110 | |
| 111 | "prime { catacomb-ll-128-512 }" |
| 112 | 3344609493517948819439808013094817124423784439045485500527919676470975342917009634212031124646834193243018749323077268170586751415510015906107400678608590 |
| 113 | 1926426135381827210395257472845875618319108487720857260583372274154852182951667715700282388176779441854588992736540698662997833538400244234146123792411051 |
| 114 | 24069337702503046127918930405335466791703796668849861281722901639361967869381088162761943434867448224639537469251486209856612215080111132649928233405085; |
| 115 | |
| 116 | "ec { nist-p192 }" |
| 117 | "0x76e32a2557599e6edcd283201fb2b9aadfd0d359cbb263da, |
| 118 | 0x782c37e372ba4520aa62e0fed121d49ef3b543660cfd05fd" |
| 119 | "0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012, |
| 120 | 0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811" |
| 121 | "0xdafebf5828783f2ad35534631588a3f629a70fb16982a888, |
| 122 | 0xdd6bda0d993da0fa46b27bbc141b868f59331afa5c7e93ab"; |
| 123 | } |
| 124 | |
| 125 | exp { |
| 126 | "prime { 29, 7, 16 }" 3 12 16; |
| 127 | |
| 128 | "prime { 29, 7, 16 }" 3 -12 20; |
| 129 | |
| 130 | "prime { catacomb-ll-128-512 }" |
| 131 | 3344609493517948819439808013094817124423784439045485500527919676470975342917009634212031124646834193243018749323077268170586751415510015906107400678608590 |
| 132 | 147362842169670001895012880214773009850 |
| 133 | 5743039465765061017258257285641279669186626264432710496849307123351095219091264933384359874588390730293795471675184250790999035405886273905917889887366080; |
| 134 | |
| 135 | "prime { catacomb-ll-128-512 }" |
| 136 | 3344609493517948819439808013094817124423784439045485500527919676470975342917009634212031124646834193243018749323077268170586751415510015906107400678608590 |
| 137 | -147362842169670001895012880214773009850 |
| 138 | 3548613102603269389984811279864031309564549180885835723408511495891024326106890973751615845620404633717662823827170012116865930893524976817060348977482376; |
| 139 | |
| 140 | "ec { nist-p192 }" |
| 141 | "0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012, |
| 142 | 0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811" |
| 143 | 6277101735386680763835789423176059013767194773182842284081 |
| 144 | inf; |
| 145 | |
| 146 | "ec { nist-p192 }" |
| 147 | "0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012, |
| 148 | 0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811" |
| 149 | 3131675836296406071791252329528905062261497366991742517193 |
| 150 | "0x7f55059a125dd0d2b40dc3a712248b2848a5e5fa11111f71, |
| 151 | 0xc6e91094cb34131e539c3db25f7f32670ef8dfe03a88b6fb"; |
| 152 | |
| 153 | "ec { nist-p192 }" |
| 154 | "0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012, |
| 155 | 0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811" |
| 156 | 3131675836296406071791252329528905062261497366991742517193 |
| 157 | "0x7f55059a125dd0d2b40dc3a712248b2848a5e5fa11111f71, |
| 158 | 0xc6e91094cb34131e539c3db25f7f32670ef8dfe03a88b6fb"; |
| 159 | |
| 160 | "ec { nist-p192 }" |
| 161 | "0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012, |
| 162 | 0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811" |
| 163 | -3131675836296406071791252329528905062261497366991742517193 |
| 164 | "0x7f55059a125dd0d2b40dc3a712248b2848a5e5fa11111f71, |
| 165 | 0x3916ef6b34cbece1ac63c24da080cd97f107201fc5774904"; |
| 166 | } |
| 167 | |
| 168 | mexp-1 { |
| 169 | "prime { 29, 7, 16 }" 3 12 16; |
| 170 | "prime { 29, 7, 16 }" 3 -12 20; |
| 171 | |
| 172 | "ec { nist-p192 }" |
| 173 | "0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012, |
| 174 | 0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811" |
| 175 | 3131675836296406071791252329528905062261497366991742517193 |
| 176 | "0x7f55059a125dd0d2b40dc3a712248b2848a5e5fa11111f71, |
| 177 | 0xc6e91094cb34131e539c3db25f7f32670ef8dfe03a88b6fb"; |
| 178 | |
| 179 | "ec { nist-p192 }" |
| 180 | "0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012, |
| 181 | 0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811" |
| 182 | -3131675836296406071791252329528905062261497366991742517193 |
| 183 | "0x7f55059a125dd0d2b40dc3a712248b2848a5e5fa11111f71, |
| 184 | 0x3916ef6b34cbece1ac63c24da080cd97f107201fc5774904"; |
| 185 | } |
| 186 | |
| 187 | mexp-2 { |
| 188 | "prime { 29, 7, 16 }" 3 12 8 2 9; |
| 189 | "prime { 29, 7, 16 }" 3 -12 8 2 4; |
| 190 | |
| 191 | "prime { catacomb-ll-128-512 }" |
| 192 | 3344609493517948819439808013094817124423784439045485500527919676470975342917009634212031124646834193243018749323077268170586751415510015906107400678608590 |
| 193 | -147362842169670001895012880214773009850 |
| 194 | 130340428707563070626027539288099297037336608388990593367322442443880297841210613523501678207607756678300142264348927299637006055881968995671289567513600 |
| 195 | 91626412351157168611316239052073981423 |
| 196 | 1022777063245982511046303002728993765008184164346724419524981660559588777350492245381260023136750231183070065817596986237402046431653662723677455952067221; |
| 197 | |
| 198 | "ec { nist-p192 }" |
| 199 | "0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012, |
| 200 | 0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811" |
| 201 | -3131675836296406071791252329528905062261497366991742517193 |
| 202 | "0xea711858c23d92f9964655910bc90a197a915e90111cf11b, |
| 203 | 0x664189a1d8b2bb24f2b2ac64b19e2178118842e6ba9f4ad5" |
| 204 | 1110875761630725856340142297645383444629395595869672555585 |
| 205 | "0xaa25bb0bf38b06821e8641c1afb8bc078dbe11c3cf9bc97, |
| 206 | 0xf1a4c09d621fb52736f6010ae90e9bc9771ac017a62098f9"; |
| 207 | } |
| 208 | |
| 209 | toint { |
| 210 | "prime { 29, 7, 16 }" 15 0 15; |
| 211 | "prime { 29, 7, 16 }" 0 0 0; |
| 212 | |
| 213 | "ec { nist-p192 }" inf -1 0; |
| 214 | |
| 215 | "ec { nist-p192 }" |
| 216 | "0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012, |
| 217 | 0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811" |
| 218 | 0 602046282375688656758213480587526111916698976636884684818; |
| 219 | } |
| 220 | |
| 221 | fromint { |
| 222 | "prime { 29, 7, 16 }" 15 0 15; |
| 223 | "prime { 29, 7, 16 }" 0 0 0; |
| 224 | "prime { 29, 7, 16 }" 39527306161272833161358334459 0 19; |
| 225 | |
| 226 | "ec { nist-p192 }" 1 -1 inf; |
| 227 | "ec { nist-p192 }" 0 |
| 228 | 0 "0, 0x7b685605ee600cb363db5ea912f2bb5e3a0a2e0e60360f12"; |
| 229 | } |
| 230 | |
| 231 | toec { |
| 232 | "prime { 29, 7, 16 }" 0 -1 inf; |
| 233 | "ec { nist-p192 }" inf 0 inf; |
| 234 | "ec { secp112r1 }" |
| 235 | "0x09487239995a5ee76b55f9c2f098, 0xa89ce5af8724c0a23e0e0ff77500" |
| 236 | 0 |
| 237 | "0x09487239995a5ee76b55f9c2f098, 0xa89ce5af8724c0a23e0e0ff77500"; |
| 238 | } |
| 239 | |
| 240 | fromec { |
| 241 | "prime { 29, 7, 16 }" inf -1 0; |
| 242 | "prime { 29, 7, 16 }" "39527306161272833161358334459, 9" 0 19; |
| 243 | |
| 244 | "ec { secp112r1 }" inf 0 inf; |
| 245 | "ec { nist-p192 }" "1, 5" -1 inf; |
| 246 | |
| 247 | "ec { secp112r1 }" |
| 248 | "0x09487239995a5ee76b55f9c2f098, 0xa89ce5af8724c0a23e0e0ff77500" |
| 249 | 0 |
| 250 | "0x09487239995a5ee76b55f9c2f098, 0xa89ce5af8724c0a23e0e0ff77500"; |
| 251 | } |
| 252 | |
| 253 | tobuf { |
| 254 | "prime { 29, 7, 16 }" 22 -1 "00"; |
| 255 | "prime { 29, 7, 16 }" 22 0 "000116"; |
| 256 | "prime { 29, 7, 16 }" 0 -1 "0000"; |
| 257 | "prime { 29, 7, 16 }" 0 0 "000100"; |
| 258 | |
| 259 | "ec { secp112r1 }" inf 0 "0000"; |
| 260 | "ec { secp112r1 }" |
| 261 | "0x09487239995a5ee76b55f9c2f098, 0xa89ce5af8724c0a23e0e0ff77500" |
| 262 | 0 "000e09487239995a5ee76b55f9c2f098000ea89ce5af8724c0a23e0e0ff77500"; |
| 263 | "ec { nist-p192 }" |
| 264 | "0, 0x8497a9fa119ff34c9c24a156ed0d44a0c5f5d1f19fc9f0ed" |
| 265 | 0 "00010000188497a9fa119ff34c9c24a156ed0d44a0c5f5d1f19fc9f0ed"; |
| 266 | } |
| 267 | |
| 268 | frombuf { |
| 269 | "prime { 29, 7, 16 }" "00" -1 0; |
| 270 | "prime { 29, 7, 16 }" "000116" 3 22; |
| 271 | "prime { 29, 7, 16 }" "00000e" 2 0; |
| 272 | "prime { 29, 7, 16 }" "000100ff" 3 0; |
| 273 | |
| 274 | "ec { secp112r1 }" "0000" 2 inf; |
| 275 | "ec { secp112r1 }" |
| 276 | "000e09487239995a5ee76b55f9c2f098000ea89ce5af8724c0a23e0e0ff77500f00d" |
| 277 | 32 "0x09487239995a5ee76b55f9c2f098, 0xa89ce5af8724c0a23e0e0ff77500"; |
| 278 | "ec { secp112r1 }" "0001000001001ee7" -1 inf; |
| 279 | "ec { nist-p192 }" |
| 280 | "00010000188497a9fa119ff34c9c24a156ed0d44a0c5f5d1f19fc9f0eddead" |
| 281 | 29, "0, 0x8497a9fa119ff34c9c24a156ed0d44a0c5f5d1f19fc9f0ed"; |
| 282 | } |
| 283 | |
| 284 | toraw { |
| 285 | "prime { 29, 7, 16 }" 22 -1 ""; |
| 286 | "prime { 29, 7, 16 }" 22 0 "16"; |
| 287 | "prime { 29, 7, 16 }" 0 -1 ""; |
| 288 | "prime { 29, 7, 16 }" 0 0 "00"; |
| 289 | "prime { 4294967311, 364289, 18767 }" 4285559121 0 "00ff707151"; |
| 290 | "prime { 4294967311, 364289, 18767 }" 4285559121 -1 "ff707151"; |
| 291 | |
| 292 | "ec { secp112r1 }" inf 0 "00"; |
| 293 | "ec { secp112r1 }" |
| 294 | "0x09487239995a5ee76b55f9c2f098, 0xa89ce5af8724c0a23e0e0ff77500" |
| 295 | 0 "0409487239995a5ee76b55f9c2f098a89ce5af8724c0a23e0e0ff77500"; |
| 296 | "ec { nist-p192 }" |
| 297 | "0, 0x8497a9fa119ff34c9c24a156ed0d44a0c5f5d1f19fc9f0ed" |
| 298 | 0 "040000000000000000000000000000000000000000000000008497a9fa119ff34c9c24a156ed0d44a0c5f5d1f19fc9f0ed"; |
| 299 | } |
| 300 | |
| 301 | fromraw { |
| 302 | "prime { 29, 7, 16 }" "" -1 0; |
| 303 | "prime { 29, 7, 16 }" "160bad" 1 22; |
| 304 | "prime { 29, 7, 16 }" "00" 1 0; |
| 305 | "prime { 4294967311, 364289, 18767 }" "00ff707151e7c0" 5 4285559121; |
| 306 | "prime { 4294967311, 364289, 18767 }" "ff707151" -1 0; |
| 307 | |
| 308 | "ec { secp112r1 }" "" -1 inf; |
| 309 | "ec { secp112r1 }" "00" 1 inf; |
| 310 | "ec { secp112r1 }" |
| 311 | "0409487239995a5ee76b55f9c2f098a89ce5af8724c0a23e0e0ff775" -1 inf; |
| 312 | "ec { secp112r1 }" |
| 313 | "0409487239995a5ee76b55f9c2f098a89ce5af8724c0a23e0e0ff77500" |
| 314 | 29 "0x09487239995a5ee76b55f9c2f098, 0xa89ce5af8724c0a23e0e0ff77500"; |
| 315 | "ec { nist-p192 }" |
| 316 | "070000000000000000000000000000000000000000000000008497a9fa119ff34c9c24a156ed0d44a0c5f5d1f19fc9f0ed00deadbeef" |
| 317 | 49 "0, 0x8497a9fa119ff34c9c24a156ed0d44a0c5f5d1f19fc9f0ed"; |
| 318 | } |