ecc_test.c 119 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059
  1. /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
  2. /* SPDX-License-Identifier: Unlicense */
  3. #include <tomcrypt_test.h>
  4. #if defined(LTC_MECC)
  5. const unsigned char ltc_ecc_long_pri_test_key[] = { /* private + long public, explicit curve params */
  6. 0x30, 0x82, 0x01, 0x13, 0x02, 0x01, 0x01, 0x04, 0x20, 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91,
  7. 0x1b, 0xba, 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2, 0xf7, 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d,
  8. 0x9f, 0x5f, 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd, 0x23, 0xa0, 0x81, 0xa5, 0x30, 0x81, 0xa2, 0x02,
  9. 0x01, 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00,
  10. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  11. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f,
  12. 0x30, 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04, 0x41, 0x04, 0x79, 0xbe, 0x66, 0x7e, 0xf9,
  13. 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d,
  14. 0xce, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98, 0x48, 0x3a, 0xda, 0x77, 0x26,
  15. 0xa3, 0xc4, 0x65, 0x5d, 0xa4, 0xfb, 0xfc, 0x0e, 0x11, 0x08, 0xa8, 0xfd, 0x17, 0xb4, 0x48, 0xa6,
  16. 0x85, 0x54, 0x19, 0x9c, 0x47, 0xd0, 0x8f, 0xfb, 0x10, 0xd4, 0xb8, 0x02, 0x21, 0x00, 0xff, 0xff,
  17. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xba, 0xae,
  18. 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01,
  19. 0x01, 0xa1, 0x44, 0x03, 0x42, 0x00, 0x04, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1,
  20. 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5,
  21. 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16, 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a, 0xb7,
  22. 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62, 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5, 0x6e,
  23. 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d
  24. };
  25. const unsigned long ltc_ecc_long_pri_test_key_sz = sizeof(ltc_ecc_long_pri_test_key);
  26. static unsigned int sizes[] = {
  27. #ifdef LTC_ECC_SECP112R1
  28. 14,
  29. #endif
  30. #ifdef LTC_ECC_SECP128R1
  31. 16,
  32. #endif
  33. #ifdef LTC_ECC_SECP160R1
  34. 20,
  35. #endif
  36. #ifdef LTC_ECC_SECP192R1
  37. 24,
  38. #endif
  39. #ifdef LTC_ECC_SECP224R1
  40. 28,
  41. #endif
  42. #ifdef LTC_ECC_SECP256R1
  43. 32,
  44. #endif
  45. #ifdef LTC_ECC_SECP384R1
  46. 48,
  47. #endif
  48. #ifdef LTC_ECC_SECP512R1
  49. 66
  50. #endif
  51. };
  52. static const char* curvenames[] = {
  53. #ifdef LTC_ECC_SECP112R1
  54. "SECP112R1", "ECC-112",
  55. "secp112r1", /* name is case-insensitive */
  56. "S E C-P-1_1_2r1", /* should pass fuzzy matching */
  57. #endif
  58. #ifdef LTC_ECC_SECP112R2
  59. "SECP112R2",
  60. #endif
  61. #ifdef LTC_ECC_SECP128R1
  62. "SECP128R1", "ECC-128",
  63. #endif
  64. #ifdef LTC_ECC_SECP128R2
  65. "SECP128R2",
  66. #endif
  67. #ifdef LTC_ECC_SECP160R1
  68. "SECP160R1", "ECC-160",
  69. #endif
  70. #ifdef LTC_ECC_SECP160R2
  71. "SECP160R2",
  72. #endif
  73. #ifdef LTC_ECC_SECP160K1
  74. "SECP160K1",
  75. #endif
  76. #ifdef LTC_ECC_BRAINPOOLP160R1
  77. "BRAINPOOLP160R1",
  78. #endif
  79. #ifdef LTC_ECC_SECP192R1
  80. "SECP192R1", "NISTP192", "PRIME192V1", "ECC-192", "P-192",
  81. #endif
  82. #ifdef LTC_ECC_PRIME192V2
  83. "PRIME192V2",
  84. #endif
  85. #ifdef LTC_ECC_PRIME192V3
  86. "PRIME192V3",
  87. #endif
  88. #ifdef LTC_ECC_SECP192K1
  89. "SECP192K1",
  90. #endif
  91. #ifdef LTC_ECC_BRAINPOOLP192R1
  92. "BRAINPOOLP192R1",
  93. #endif
  94. #ifdef LTC_ECC_SECP224R1
  95. "SECP224R1", "NISTP224", "ECC-224", "P-224",
  96. #endif
  97. #ifdef LTC_ECC_SECP224K1
  98. "SECP224K1",
  99. #endif
  100. #ifdef LTC_ECC_BRAINPOOLP224R1
  101. "BRAINPOOLP224R1",
  102. #endif
  103. #ifdef LTC_ECC_PRIME239V1
  104. "PRIME239V1",
  105. #endif
  106. #ifdef LTC_ECC_PRIME239V2
  107. "PRIME239V2",
  108. #endif
  109. #ifdef LTC_ECC_PRIME239V3
  110. "PRIME239V3",
  111. #endif
  112. #ifdef LTC_ECC_SECP256R1
  113. "SECP256R1", "NISTP256", "PRIME256V1", "ECC-256", "P-256",
  114. #endif
  115. #ifdef LTC_ECC_SECP256K1
  116. "SECP256K1",
  117. #endif
  118. #ifdef LTC_ECC_BRAINPOOLP256R1
  119. "BRAINPOOLP256R1",
  120. #endif
  121. #ifdef LTC_ECC_BRAINPOOLP320R1
  122. "BRAINPOOLP320R1",
  123. #endif
  124. #ifdef LTC_ECC_SECP384R1
  125. "SECP384R1", "NISTP384", "ECC-384", "P-384",
  126. #endif
  127. #ifdef LTC_ECC_BRAINPOOLP384R1
  128. "BRAINPOOLP384R1",
  129. #endif
  130. #ifdef LTC_ECC_BRAINPOOLP512R1
  131. "BRAINPOOLP512R1",
  132. #endif
  133. #ifdef LTC_ECC_SECP521R1
  134. "SECP521R1", "NISTP521", "ECC-521", "P-521",
  135. #endif
  136. };
  137. #ifdef LTC_ECC_SHAMIR
  138. static int s_ecc_test_shamir(void)
  139. {
  140. void *a, *modulus, *mp, *kA, *kB, *rA, *rB;
  141. void *mu, *ma;
  142. ecc_point *G, *A, *B, *C1, *C2;
  143. int x, y, z;
  144. unsigned char buf[ECC_BUF_SIZE];
  145. DO(ltc_mp_init_multi(&kA, &kB, &rA, &rB, &modulus, &a, &mu, &ma, LTC_NULL));
  146. LTC_ARGCHK((G = ltc_ecc_new_point()) != NULL);
  147. LTC_ARGCHK((A = ltc_ecc_new_point()) != NULL);
  148. LTC_ARGCHK((B = ltc_ecc_new_point()) != NULL);
  149. LTC_ARGCHK((C1 = ltc_ecc_new_point()) != NULL);
  150. LTC_ARGCHK((C2 = ltc_ecc_new_point()) != NULL);
  151. for (x = 0; x < (int)LTC_ARRAY_SIZE(sizes); x++) {
  152. /* get the base point */
  153. for (z = 0; ltc_ecc_curves[z].prime != NULL; z++) {
  154. DO(ltc_mp_read_radix(modulus, ltc_ecc_curves[z].prime, 16));
  155. if (sizes[x] <= ltc_mp_unsigned_bin_size(modulus)) break;
  156. }
  157. LTC_ARGCHK(ltc_ecc_curves[z].prime != NULL);
  158. /* load it */
  159. DO(ltc_mp_read_radix(G->x, ltc_ecc_curves[z].Gx, 16));
  160. DO(ltc_mp_read_radix(G->y, ltc_ecc_curves[z].Gy, 16));
  161. DO(ltc_mp_set(G->z, 1));
  162. DO(ltc_mp_read_radix(a, ltc_ecc_curves[z].A, 16));
  163. DO(ltc_mp_montgomery_setup(modulus, &mp));
  164. DO(ltc_mp_montgomery_normalization(mu, modulus));
  165. DO(ltc_mp_mulmod(a, mu, modulus, ma));
  166. /* do 100 random tests */
  167. for (y = 0; y < 100; y++) {
  168. /* pick a random r1, r2 */
  169. ENSURE(yarrow_read(buf, sizes[x], &yarrow_prng) == sizes[x]);
  170. DO(ltc_mp_read_unsigned_bin(rA, buf, sizes[x]));
  171. ENSURE(yarrow_read(buf, sizes[x], &yarrow_prng) == sizes[x]);
  172. DO(ltc_mp_read_unsigned_bin(rB, buf, sizes[x]));
  173. /* compute rA * G = A */
  174. DO(ltc_mp.ecc_ptmul(rA, G, A, a, modulus, 1));
  175. /* compute rB * G = B */
  176. DO(ltc_mp.ecc_ptmul(rB, G, B, a, modulus, 1));
  177. /* pick a random kA, kB */
  178. ENSURE(yarrow_read(buf, sizes[x], &yarrow_prng) == sizes[x]);
  179. DO(ltc_mp_read_unsigned_bin(kA, buf, sizes[x]));
  180. ENSURE(yarrow_read(buf, sizes[x], &yarrow_prng) == sizes[x]);
  181. DO(ltc_mp_read_unsigned_bin(kB, buf, sizes[x]));
  182. /* now, compute kA*A + kB*B = C1 using the older method */
  183. DO(ltc_mp.ecc_ptmul(kA, A, C1, a, modulus, 0));
  184. DO(ltc_mp.ecc_ptmul(kB, B, C2, a, modulus, 0));
  185. DO(ltc_mp.ecc_ptadd(C1, C2, C1, a, modulus, mp));
  186. DO(ltc_mp.ecc_map(C1, modulus, mp));
  187. /* now compute using mul2add */
  188. DO(ltc_mp.ecc_mul2add(A, kA, B, kB, C2, ma, modulus));
  189. /* is they the sames? */
  190. if ((ltc_mp_cmp(C1->x, C2->x) != LTC_MP_EQ) || (ltc_mp_cmp(C1->y, C2->y) != LTC_MP_EQ) || (ltc_mp_cmp(C1->z, C2->z) != LTC_MP_EQ)) {
  191. fprintf(stderr, "ECC failed shamir test: size=%d, testno=%d\n", sizes[x], y);
  192. return 1;
  193. }
  194. }
  195. ltc_mp_montgomery_free(mp);
  196. }
  197. ltc_ecc_del_point(C2);
  198. ltc_ecc_del_point(C1);
  199. ltc_ecc_del_point(B);
  200. ltc_ecc_del_point(A);
  201. ltc_ecc_del_point(G);
  202. ltc_mp_deinit_multi(kA, kB, rA, rB, modulus, a, mu, ma, LTC_NULL);
  203. return 0;
  204. }
  205. #endif
  206. /* https://github.com/libtom/libtomcrypt/issues/630 */
  207. static int s_ecc_issue630(void)
  208. {
  209. unsigned char protected_buffer[30], protected_buffer_copy[30];
  210. unsigned long keylen = 0;
  211. ecc_key key;
  212. int low, high;
  213. ecc_sizes(&low, &high);
  214. DO(ecc_make_key (&yarrow_prng, find_prng ("yarrow"), high, &key));
  215. if (yarrow_read(protected_buffer, sizeof(protected_buffer), &yarrow_prng) != sizeof(protected_buffer)) {
  216. return CRYPT_ERROR_READPRNG;
  217. }
  218. XMEMCPY(protected_buffer_copy, protected_buffer, sizeof(protected_buffer));
  219. COMPARE_TESTVECTOR(protected_buffer, sizeof(protected_buffer), protected_buffer_copy, sizeof(protected_buffer), "Ensure copy is equal", 0);
  220. keylen = 10;
  221. SHOULD_FAIL(ecc_get_key(&protected_buffer[10], &keylen, PK_PRIVATE, &key));
  222. COMPARE_TESTVECTOR(protected_buffer, 10, protected_buffer_copy, 10, "Start canary", 1);
  223. COMPARE_TESTVECTOR(&protected_buffer[20], 10, &protected_buffer[20], 10, "End canary", 2);
  224. ecc_free(&key);
  225. return 0;
  226. }
  227. /* https://github.com/libtom/libtomcrypt/issues/108 */
  228. static int s_ecc_issue108(void)
  229. {
  230. void *a, *modulus, *order;
  231. ecc_point *Q, *Result;
  232. int err;
  233. const ltc_ecc_curve* dp;
  234. /* init */
  235. if ((err = ltc_mp_init_multi(&modulus, &order, &a, LTC_NULL)) != CRYPT_OK) { return err; }
  236. Q = ltc_ecc_new_point();
  237. Result = ltc_ecc_new_point();
  238. /* ECC-224 AKA SECP224R1 */
  239. if ((err = ecc_find_curve("SECP224R1", &dp)) != CRYPT_OK) { goto done; }
  240. /* read A */
  241. if ((err = ltc_mp_read_radix(a, dp->A, 16)) != CRYPT_OK) { goto done; }
  242. /* read modulus */
  243. if ((err = ltc_mp_read_radix(modulus, dp->prime, 16)) != CRYPT_OK) { goto done; }
  244. /* read order */
  245. if ((err = ltc_mp_read_radix(order, dp->order, 16)) != CRYPT_OK) { goto done; }
  246. /* read Q */
  247. if ((err = ltc_mp_read_radix(Q->x, "EA3745501BBC6A70BBFDD8AEEDB18CF5073C6DC9AA7CBB5915170D60", 16)) != CRYPT_OK) { goto done; }
  248. if ((err = ltc_mp_read_radix(Q->y, "6C9CB8E68AABFEC989CAC5E2326E0448B7E69C3E56039BA21A44FDAC", 16)) != CRYPT_OK) { goto done; }
  249. ltc_mp_set(Q->z, 1);
  250. /* calculate nQ */
  251. if ((err = ltc_mp.ecc_ptmul(order, Q, Result, a, modulus, 1)) != CRYPT_OK) { goto done; }
  252. done:
  253. ltc_ecc_del_point(Result);
  254. ltc_ecc_del_point(Q);
  255. ltc_mp_deinit_multi(modulus, order, a, LTC_NULL);
  256. return err;
  257. }
  258. /* https://github.com/libtom/libtomcrypt/issues/443 */
  259. /* https://github.com/libtom/libtomcrypt/issues/447 */
  260. static int s_ecc_issue443_447(void)
  261. {
  262. const ltc_ecc_curve* cu;
  263. ecc_key key;
  264. int err, stat = 0;
  265. unsigned char hash[64];
  266. unsigned long hashlen;
  267. const unsigned char msg[] = { 0x54,0x65,0x73,0x74 };
  268. /* msg+pub1+sig1 test vector is from wycheproof - ecdsa_webcrypto_test (incorrect size of signature) */
  269. const unsigned char pub1[] = {
  270. 0x04,
  271. 0x4a,0x03,0xef,0x9f,0x92,0xeb,0x26,0x8c,0xaf,0xa6,0x01,0x07,0x24,0x89,0xa5,0x63,
  272. 0x80,0xfa,0x0d,0xc4,0x31,0x71,0xd7,0x71,0x28,0x13,0xb3,0xa1,0x9a,0x1e,0xb5,0xe5,
  273. 0x3e,0x21,0x3e,0x28,0xa6,0x08,0xce,0x9a,0x2f,0x4a,0x17,0xfd,0x83,0x0c,0x66,0x54,
  274. 0x01,0x8a,0x79,0xb3,0xe0,0x26,0x3d,0x91,0xa8,0xba,0x90,0x62,0x2d,0xf6,0xf2,0xf0
  275. };
  276. const unsigned char sig1[] = { 0x05, 0x01 };
  277. /* msg+pub2+sig2 test vector is from wycheproof - ecdsa_webcrypto_test (incorrect size of signature) */
  278. const unsigned char pub2[] = {
  279. 0x04,
  280. 0x00,0x5f,0x50,0x59,0x30,0x83,0x49,0xf9,0xeb,0xbb,0x4d,0x1c,0x55,0xc0,0xaf,0xcc,0xf6,0x21,0x62,0xec,0x1d,0xd1,
  281. 0x2e,0xf3,0xed,0x90,0x66,0x56,0x92,0x4f,0xfd,0x99,0xca,0xb9,0xf0,0x6b,0x0e,0xb2,0x18,0xcf,0xf0,0x78,0xa4,0x67,
  282. 0x7a,0x5c,0xe1,0xcc,0x07,0x65,0x2b,0xc9,0x76,0xae,0xfc,0x73,0x2c,0x28,0xf6,0x7e,0xf0,0x78,0xa4,0x34,0xe9,0x99,
  283. 0x00,0xa5,0xd1,0x4d,0xf3,0x10,0x63,0x0d,0x76,0xec,0x03,0xcb,0x6f,0x9b,0x95,0xbf,0x1a,0x22,0x43,0x81,0x05,0xc8,
  284. 0x8c,0xd9,0xfd,0x3d,0xac,0x80,0xf8,0x57,0xad,0xd3,0x82,0x71,0xd8,0xba,0x90,0x16,0x84,0xb2,0x6d,0x43,0x6d,0x4a,
  285. 0x85,0x9a,0xd4,0xcd,0xa5,0xe9,0x67,0x7b,0x73,0xca,0xb3,0xf3,0xe5,0xe4,0x1a,0x3d,0x79,0x96,0x60,0x72,0x79,0xab
  286. };
  287. const unsigned char sig2[] = { 0x01, 0x01 };
  288. hashlen = sizeof(hash);
  289. DO(hash_memory(find_hash("sha256"), msg, sizeof(msg), hash, &hashlen));
  290. DO(ecc_find_curve("secp256r1", &cu));
  291. DO(ecc_set_curve(cu, &key));
  292. DO(ecc_set_key(pub1, sizeof(pub1), PK_PUBLIC, &key));
  293. err = ecc_verify_hash_rfc7518(sig1, sizeof(sig1), hash, hashlen, &stat, &key); /* should fail */
  294. ecc_free(&key);
  295. if (err != CRYPT_INVALID_PACKET) return CRYPT_FAIL_TESTVECTOR;
  296. hashlen = sizeof(hash);
  297. DO(hash_memory(find_hash("sha512"), msg, sizeof(msg), hash, &hashlen));
  298. DO(ecc_find_curve("secp521r1", &cu));
  299. DO(ecc_set_curve(cu, &key));
  300. DO(ecc_set_key(pub2, sizeof(pub2), PK_PUBLIC, &key));
  301. err = ecc_verify_hash_rfc7518(sig2, sizeof(sig2), hash, hashlen, &stat, &key); /* should fail */
  302. ecc_free(&key);
  303. if (err != CRYPT_INVALID_PACKET) return CRYPT_FAIL_TESTVECTOR;
  304. return CRYPT_OK;
  305. }
  306. static int s_ecc_test_mp(void)
  307. {
  308. void *a, *modulus, *order;
  309. ecc_point *G, *GG;
  310. int i, err, primality;
  311. char buf[4096];
  312. DO(ltc_mp_init_multi(&modulus, &order, &a, LTC_NULL));
  313. G = ltc_ecc_new_point();
  314. GG = ltc_ecc_new_point();
  315. if (G == NULL || GG == NULL) {
  316. ltc_mp_deinit_multi(modulus, order, LTC_NULL);
  317. ltc_ecc_del_point(G);
  318. ltc_ecc_del_point(GG);
  319. return CRYPT_MEM;
  320. }
  321. err = CRYPT_OK;
  322. for (i = 0; ltc_ecc_curves[i].prime != NULL; i++) {
  323. DO(ltc_mp_read_radix(a, ltc_ecc_curves[i].A, 16));
  324. DO(ltc_mp_read_radix(modulus, ltc_ecc_curves[i].prime, 16));
  325. DO(ltc_mp_read_radix(order, ltc_ecc_curves[i].order, 16));
  326. /* is prime actually prime? */
  327. DO(ltc_mp_prime_is_prime(modulus, 8, &primality));
  328. if (primality == 0) {
  329. err = CRYPT_FAIL_TESTVECTOR;
  330. ltc_mp_tohex(modulus, buf);
  331. printf("Modulus failed prime check: %s\n", buf);
  332. }
  333. /* is order prime ? */
  334. DO(ltc_mp_prime_is_prime(order, 8, &primality));
  335. if (primality == 0) {
  336. err = CRYPT_FAIL_TESTVECTOR;
  337. ltc_mp_tohex(order, buf);
  338. printf("Order failed prime check: %s\n", buf);
  339. }
  340. DO(ltc_mp_read_radix(G->x, ltc_ecc_curves[i].Gx, 16));
  341. DO(ltc_mp_read_radix(G->y, ltc_ecc_curves[i].Gy, 16));
  342. ltc_mp_set(G->z, 1);
  343. /* then we should have G == (order + 1)G */
  344. DO(ltc_mp_add_d(order, 1, order));
  345. DO(ltc_mp.ecc_ptmul(order, G, GG, a, modulus, 1));
  346. if (ltc_mp_cmp(G->x, GG->x) != LTC_MP_EQ || ltc_mp_cmp(G->y, GG->y) != LTC_MP_EQ) {
  347. err = CRYPT_FAIL_TESTVECTOR;
  348. }
  349. if (err != CRYPT_OK) {
  350. goto done;
  351. }
  352. }
  353. err = CRYPT_OK;
  354. done:
  355. ltc_ecc_del_point(GG);
  356. ltc_ecc_del_point(G);
  357. ltc_mp_deinit_multi(order, modulus, a, LTC_NULL);
  358. return err;
  359. }
  360. static int s_ecc_old_api(void)
  361. {
  362. unsigned char buf[4][4096], ch;
  363. unsigned long x, y, z, s;
  364. int stat, stat2;
  365. ecc_key usera, userb, pubKey, privKey;
  366. int low, high;
  367. ecc_sizes(&low, &high);
  368. if (low < 14 || high < 14 || low > 100 || high > 100 || high < low) return CRYPT_FAIL_TESTVECTOR;
  369. for (s = 0; s < LTC_ARRAY_SIZE(sizes); s++) {
  370. /* make up two keys */
  371. DO(ecc_make_key (&yarrow_prng, find_prng ("yarrow"), sizes[s], &usera));
  372. DO(ecc_make_key (&yarrow_prng, find_prng ("yarrow"), sizes[s], &userb));
  373. if (ecc_get_size(&usera) != (int)sizes[s]) return CRYPT_FAIL_TESTVECTOR;
  374. if (ecc_get_size(&userb) != (int)sizes[s]) return CRYPT_FAIL_TESTVECTOR;
  375. /* make the shared secret */
  376. x = sizeof(buf[0]);
  377. DO(ecc_shared_secret (&usera, &userb, buf[0], &x));
  378. y = sizeof(buf[1]);
  379. DO(ecc_shared_secret (&userb, &usera, buf[1], &y));
  380. COMPARE_TESTVECTOR(buf[0], x, buf[1], y, "ecc Shared keys", s);
  381. /* now export userb */
  382. y = sizeof(buf[0]);
  383. DO(ecc_export (buf[1], &y, PK_PUBLIC, &userb));
  384. ecc_free (&userb);
  385. /* import and make the shared secret again */
  386. DO(ecc_import (buf[1], y, &userb));
  387. z = sizeof(buf[0]);
  388. DO(ecc_shared_secret (&usera, &userb, buf[2], &z));
  389. if (z != x) {
  390. fprintf(stderr, "failed. Size don't match?");
  391. return 1;
  392. }
  393. if (memcmp (buf[0], buf[2], x)) {
  394. fprintf(stderr, "Failed. Contents didn't match.");
  395. return 1;
  396. }
  397. /* export with ANSI X9.63 */
  398. y = sizeof(buf[1]);
  399. DO(ecc_ansi_x963_export(&userb, buf[1], &y));
  400. ecc_free (&userb);
  401. /* now import the ANSI key */
  402. DO(ecc_ansi_x963_import(buf[1], y, &userb));
  403. /* shared secret */
  404. z = sizeof(buf[0]);
  405. DO(ecc_shared_secret (&usera, &userb, buf[2], &z));
  406. if (z != x) {
  407. fprintf(stderr, "failed. Size don't match?");
  408. return 1;
  409. }
  410. if (memcmp (buf[0], buf[2], x)) {
  411. fprintf(stderr, "Failed. Contents didn't match.");
  412. return 1;
  413. }
  414. ecc_free (&usera);
  415. ecc_free (&userb);
  416. /* test encrypt_key */
  417. DO(ecc_make_key (&yarrow_prng, find_prng ("yarrow"), sizes[s], &usera));
  418. /* export key */
  419. x = sizeof(buf[0]);
  420. DO(ecc_export(buf[0], &x, PK_PUBLIC, &usera));
  421. DO(ecc_import(buf[0], x, &pubKey));
  422. x = sizeof(buf[0]);
  423. DO(ecc_export(buf[0], &x, PK_PRIVATE, &usera));
  424. DO(ecc_import(buf[0], x, &privKey));
  425. for (ch = 0; ch < 32; ch++) {
  426. buf[0][ch] = ch;
  427. }
  428. y = sizeof (buf[1]);
  429. DO(ecc_encrypt_key (buf[0], 32, buf[1], &y, &yarrow_prng, find_prng ("yarrow"), find_hash ("sha256"), &pubKey));
  430. zeromem (buf[0], sizeof (buf[0]));
  431. x = sizeof (buf[0]);
  432. DO(ecc_decrypt_key (buf[1], y, buf[0], &x, &privKey));
  433. if (x != 32) {
  434. fprintf(stderr, "Failed (length)");
  435. return 1;
  436. }
  437. for (ch = 0; ch < 32; ch++) {
  438. if (buf[0][ch] != ch) {
  439. fprintf(stderr, "Failed (contents)");
  440. return 1;
  441. }
  442. }
  443. /* test sign_hash */
  444. for (ch = 0; ch < 16; ch++) {
  445. buf[0][ch] = ch;
  446. }
  447. x = sizeof (buf[1]);
  448. DO(ecc_sign_hash (buf[0], 16, buf[1], &x, &yarrow_prng, find_prng ("yarrow"), &privKey));
  449. DO(ecc_verify_hash (buf[1], x, buf[0], 16, &stat, &pubKey));
  450. buf[0][0] ^= 1;
  451. DO(ecc_verify_hash (buf[1], x, buf[0], 16, &stat2, &privKey));
  452. if (!(stat == 1 && stat2 == 0)) {
  453. fprintf(stderr, "ecc_verify_hash failed %d, %d, ", stat, stat2);
  454. return 1;
  455. }
  456. /* test sign_hash_rfc7518 */
  457. for (ch = 0; ch < 16; ch++) {
  458. buf[0][ch] = ch;
  459. }
  460. x = sizeof (buf[1]);
  461. DO(ecc_sign_hash_rfc7518(buf[0], 16, buf[1], &x, &yarrow_prng, find_prng ("yarrow"), &privKey));
  462. DO(ecc_verify_hash_rfc7518(buf[1], x, buf[0], 16, &stat, &pubKey));
  463. buf[0][0] ^= 1;
  464. DO(ecc_verify_hash_rfc7518(buf[1], x, buf[0], 16, &stat2, &privKey));
  465. if (!(stat == 1 && stat2 == 0)) {
  466. fprintf(stderr, "ecc_verify_hash_rfc7518 failed %d, %d, ", stat, stat2);
  467. return 1;
  468. }
  469. ecc_free (&usera);
  470. ecc_free (&pubKey);
  471. ecc_free (&privKey);
  472. }
  473. return CRYPT_OK;
  474. }
  475. int ecc_key_cmp(const int should_type, const ecc_key *should, const ecc_key *is)
  476. {
  477. if (should_type != is->type) return CRYPT_ERROR;
  478. if (should_type == PK_PRIVATE) {
  479. if (ltc_mp_cmp(should->k, is->k) != LTC_MP_EQ) return CRYPT_ERROR;
  480. }
  481. if (ltc_mp_cmp(should->dp.prime, is->dp.prime) != LTC_MP_EQ) return CRYPT_ERROR;
  482. if (ltc_mp_cmp(should->dp.A, is->dp.A) != LTC_MP_EQ) return CRYPT_ERROR;
  483. if (ltc_mp_cmp(should->dp.B, is->dp.B) != LTC_MP_EQ) return CRYPT_ERROR;
  484. if (ltc_mp_cmp(should->dp.order, is->dp.order) != LTC_MP_EQ) return CRYPT_ERROR;
  485. if (ltc_mp_cmp(should->dp.base.x, is->dp.base.x) != LTC_MP_EQ) return CRYPT_ERROR;
  486. if (ltc_mp_cmp(should->dp.base.y, is->dp.base.y) != LTC_MP_EQ) return CRYPT_ERROR;
  487. if (ltc_mp_cmp(should->pubkey.x, is->pubkey.x) != LTC_MP_EQ) return CRYPT_ERROR;
  488. if (ltc_mp_cmp(should->pubkey.y, is->pubkey.y) != LTC_MP_EQ) return CRYPT_ERROR;
  489. if (should->dp.size != is->dp.size) return CRYPT_ERROR;
  490. if (should->dp.cofactor != is->dp.cofactor) return CRYPT_ERROR;
  491. return CRYPT_OK;
  492. }
  493. static int s_ecc_new_api(void)
  494. {
  495. int i, j, stat;
  496. const ltc_ecc_curve* dp;
  497. ecc_key key, privkey, pubkey;
  498. unsigned char buf[1000];
  499. unsigned long len;
  500. unsigned char data16[16] = { 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1 };
  501. unsigned long len16;
  502. for (i = 0; i < (int)LTC_ARRAY_SIZE(curvenames); i++) {
  503. DO(ecc_find_curve(curvenames[i], &dp));
  504. /* make new key */
  505. DO(ecc_make_key_ex(&yarrow_prng, find_prng ("yarrow"), &key, dp));
  506. len = sizeof(buf);
  507. DO(ecc_export(buf, &len, PK_PRIVATE, &key));
  508. DO(ecc_import_ex(buf, len, &privkey, dp));
  509. ecc_free(&privkey);
  510. len = sizeof(buf);
  511. DO(ecc_export(buf, &len, PK_PUBLIC, &key));
  512. DO(ecc_import_ex(buf, len, &pubkey, dp));
  513. ecc_free(&pubkey);
  514. len = sizeof(buf);
  515. DO(ecc_ansi_x963_export(&key, buf, &len));
  516. ecc_free(&key);
  517. DO(ecc_ansi_x963_import_ex(buf, len, &pubkey, dp));
  518. ecc_free(&pubkey);
  519. /* generate new key */
  520. DO(ecc_set_curve(dp, &key));
  521. DO(ecc_generate_key(&yarrow_prng, find_prng ("yarrow"), &key));
  522. len = sizeof(buf);
  523. DO(ecc_get_key(buf, &len, PK_PRIVATE, &key));
  524. ecc_free(&key);
  525. /* load exported private key */
  526. DO(ecc_set_curve(dp, &privkey));
  527. DO(ecc_set_key(buf, len, PK_PRIVATE, &privkey));
  528. if (strcmp(ltc_mp.name, "TomsFastMath") != 0) {
  529. /* XXX-FIXME: TFM does not support sqrtmod_prime */
  530. /* export compressed public key */
  531. len = sizeof(buf);
  532. DO(ecc_get_key(buf, &len, PK_PUBLIC|PK_COMPRESSED, &privkey));
  533. if (len != 1 + (unsigned)ecc_get_size(&privkey)) return CRYPT_FAIL_TESTVECTOR;
  534. /* load exported public+compressed key */
  535. DO(ecc_set_curve(dp, &pubkey));
  536. DO(ecc_set_key(buf, len, PK_PUBLIC, &pubkey));
  537. ecc_free(&pubkey);
  538. }
  539. /* export long public key */
  540. len = sizeof(buf);
  541. DO(ecc_get_key(buf, &len, PK_PUBLIC, &privkey));
  542. if (len != 1 + 2 * (unsigned)ecc_get_size(&privkey)) return CRYPT_FAIL_TESTVECTOR;
  543. /* load exported public key */
  544. DO(ecc_set_curve(dp, &pubkey));
  545. DO(ecc_set_key(buf, len, PK_PUBLIC, &pubkey));
  546. /* test signature */
  547. len = sizeof(buf);
  548. DO(ecc_sign_hash(data16, 16, buf, &len, &yarrow_prng, find_prng ("yarrow"), &privkey));
  549. stat = 0;
  550. DO(ecc_verify_hash(buf, len, data16, 16, &stat, &pubkey));
  551. if (stat != 1) return CRYPT_FAIL_TESTVECTOR;
  552. #ifdef LTC_SSH
  553. /* test SSH+ECDSA/RFC5656 signature */
  554. len = sizeof(buf);
  555. DO(ecc_sign_hash_rfc5656(data16, 16, buf, &len, &yarrow_prng, find_prng ("yarrow"), &privkey));
  556. stat = 0;
  557. DO(ecc_verify_hash_rfc5656(buf, len, data16, 16, &stat, &pubkey));
  558. if (stat != 1) return CRYPT_FAIL_TESTVECTOR;
  559. #endif
  560. #ifdef LTC_ECC_SHAMIR
  561. if (strcmp(ltc_mp.name, "TomsFastMath") != 0) {
  562. /* XXX-FIXME: TFM does not support sqrtmod_prime */
  563. int found = 0;
  564. ecc_key reckey;
  565. /* test recovery */
  566. len = sizeof(buf);
  567. DO(ecc_sign_hash(data16, 16, buf, &len, &yarrow_prng, find_prng ("yarrow"), &privkey));
  568. DO(ecc_set_curve(dp, &reckey));
  569. for (j = 0; j < 2*(1+(int)privkey.dp.cofactor); j++) {
  570. stat = ecc_recover_key(buf, len, data16, 16, j, LTC_ECCSIG_ANSIX962, &reckey);
  571. if (stat != CRYPT_OK) continue; /* last two will almost always fail, only possible if x<(prime mod order) */
  572. stat = ecc_key_cmp(PK_PUBLIC, &pubkey, &reckey);
  573. if (stat == CRYPT_OK) found++;
  574. }
  575. if (found != 1) return CRYPT_FAIL_TESTVECTOR; /* unique match */
  576. ecc_free(&reckey);
  577. }
  578. #endif
  579. /* test encryption */
  580. len = sizeof(buf);
  581. DO(ecc_encrypt_key(data16, 16, buf, &len, &yarrow_prng, find_prng("yarrow"), find_hash("sha256"), &pubkey));
  582. zeromem(data16, 16);
  583. len16 = 16;
  584. DO(ecc_decrypt_key(buf, len, data16, &len16, &privkey));
  585. if (len16 != 16) return CRYPT_FAIL_TESTVECTOR;
  586. for (j = 0; j < 16; j++) if (data16[j] != 0xd1) return CRYPT_FAIL_TESTVECTOR;
  587. /* cleanup */
  588. ecc_free(&privkey);
  589. ecc_free(&pubkey);
  590. }
  591. return CRYPT_OK;
  592. }
  593. static int s_ecc_rfc6979(void)
  594. {
  595. const struct {
  596. const char *curve, *x, *Ux, *Uy;
  597. struct {
  598. const char *k, *r, *s;
  599. } signatures[11];
  600. } tests[] = {
  601. {
  602. "P-192",
  603. "6FAB034934E4C0FC9AE67F5B5659A9D7D1FEFD187EE09FD4",
  604. "AC2C77F529F91689FEA0EA5EFEC7F210D8EEA0B9E047ED56",
  605. "3BC723E57670BD4887EBC732C523063D0A7C957BC97C1C43",
  606. {
  607. {
  608. "37D7CA00D2C7B0E5E412AC03BD44BA837FDD5B28CD3B0021",
  609. "98C6BD12B23EAF5E2A2045132086BE3EB8EBD62ABF6698FF",
  610. "57A22B07DEA9530F8DE9471B1DC6624472E8E2844BC25B64",
  611. },
  612. {
  613. "4381526B3FC1E7128F202E194505592F01D5FF4C5AF015D8",
  614. "A1F00DAD97AEEC91C95585F36200C65F3C01812AA60378F5",
  615. "E07EC1304C7C6C9DEBBE980B9692668F81D4DE7922A0F97A",
  616. },
  617. {
  618. "32B1B6D7D42A05CB449065727A84804FB1A3E34D8F261496",
  619. "4B0B8CE98A92866A2820E20AA6B75B56382E0F9BFD5ECB55",
  620. "CCDB006926EA9565CBADC840829D8C384E06DE1F1E381B85",
  621. },
  622. {
  623. "4730005C4FCB01834C063A7B6760096DBE284B8252EF4311",
  624. "DA63BF0B9ABCF948FBB1E9167F136145F7A20426DCC287D5",
  625. "C3AA2C960972BD7A2003A57E1C4C77F0578F8AE95E31EC5E",
  626. },
  627. {
  628. "A2AC7AB055E4F20692D49209544C203A7D1F2C0BFBC75DB1",
  629. "4D60C5AB1996BD848343B31C00850205E2EA6922DAC2E4B8",
  630. "3F6E837448F027A1BF4B34E796E32A811CBB4050908D8F67",
  631. },
  632. {
  633. "D9CF9C3D3297D3260773A1DA7418DB5537AB8DD93DE7FA25",
  634. "0F2141A0EBBC44D2E1AF90A50EBCFCE5E197B3B7D4DE036D",
  635. "EB18BC9E1F3D7387500CB99CF5F7C157070A8961E38700B7",
  636. },
  637. {
  638. "F5DC805F76EF851800700CCE82E7B98D8911B7D510059FBE",
  639. "6945A1C1D1B2206B8145548F633BB61CEF04891BAF26ED34",
  640. "B7FB7FDFC339C0B9BD61A9F5A8EAF9BE58FC5CBA2CB15293",
  641. },
  642. {
  643. "5C4CE89CF56D9E7C77C8585339B006B97B5F0680B4306C6C",
  644. "3A718BD8B4926C3B52EE6BBE67EF79B18CB6EB62B1AD97AE",
  645. "5662E6848A4A19B1F1AE2F72ACD4B8BBE50F1EAC65D9124F",
  646. },
  647. {
  648. "5AFEFB5D3393261B828DB6C91FBC68C230727B030C975693",
  649. "B234B60B4DB75A733E19280A7A6034BD6B1EE88AF5332367",
  650. "7994090B2D59BB782BE57E74A44C9A1C700413F8ABEFE77A",
  651. },
  652. {
  653. "0758753A5254759C7CFBAD2E2D9B0792EEE44136C9480527",
  654. "FE4F4AE86A58B6507946715934FE2D8FF9D95B6B098FE739",
  655. "74CF5605C98FBA0E1EF34D4B5A1577A7DCF59457CAE52290",
  656. },
  657. {
  658. NULL, NULL, NULL
  659. }
  660. }
  661. },
  662. {
  663. "P-224",
  664. "F220266E1105BFE3083E03EC7A3A654651F45E37167E88600BF257C1",
  665. "CF08DA5AD719E42707FA431292DEA11244D64FC51610D94B130D6C",
  666. "EEAB6F3DEBE455E3DBF85416F7030CBD94F34F2D6F232C69F3C1385A",
  667. {
  668. {
  669. "7EEFADD91110D8DE6C2C470831387C50D3357F7F4D477054B8B426BC",
  670. "22226F9D40A96E19C4A301CE5B74B115303C0F3A4FD30FC257FB57AC",
  671. "66D1CDD83E3AF75605DD6E2FEFF196D30AA7ED7A2EDF7AF475403D69",
  672. },
  673. {
  674. "C1D1F2F10881088301880506805FEB4825FE09ACB6816C36991AA06D",
  675. "1CDFE6662DDE1E4A1EC4CDEDF6A1F5A2FB7FBD9145C12113E6ABFD3E",
  676. "A6694FD7718A21053F225D3F46197CA699D45006C06F871808F43EBC",
  677. },
  678. {
  679. "AD3029E0278F80643DE33917CE6908C70A8FF50A411F06E41DEDFCDC",
  680. "61AA3DA010E8E8406C656BC477A7A7189895E7E840CDFE8FF42307BA",
  681. "BC814050DAB5D23770879494F9E0A680DC1AF7161991BDE692B10101",
  682. },
  683. {
  684. "52B40F5A9D3D13040F494E83D3906C6079F29981035C7BD51E5CAC40",
  685. "0B115E5E36F0F9EC81F1325A5952878D745E19D7BB3EABFABA77E953",
  686. "830F34CCDFE826CCFDC81EB4129772E20E122348A2BBD889A1B1AF1D",
  687. },
  688. {
  689. "9DB103FFEDEDF9CFDBA05184F925400C1653B8501BAB89CEA0FBEC14",
  690. "074BD1D979D5F32BF958DDC61E4FB4872ADCAFEB2256497CDAC30397",
  691. "A4CECA196C3D5A1FF31027B33185DC8EE43F288B21AB342E5D8EB084",
  692. },
  693. {
  694. "2519178F82C3F0E4F87ED5883A4E114E5B7A6E374043D8EFD329C253",
  695. "DEAA646EC2AF2EA8AD53ED66B2E2DDAA49A12EFD8356561451F3E21C",
  696. "95987796F6CF2062AB8135271DE56AE55366C045F6D9593F53787BD2",
  697. },
  698. {
  699. "DF8B38D40DCA3E077D0AC520BF56B6D565134D9B5F2EAE0D34900524",
  700. "C441CE8E261DED634E4CF84910E4C5D1D22C5CF3B732BB204DBEF019",
  701. "902F42847A63BDC5F6046ADA114953120F99442D76510150F372A3F4",
  702. },
  703. {
  704. "FF86F57924DA248D6E44E8154EB69F0AE2AEBAEE9931D0B5A969F904",
  705. "AD04DDE87B84747A243A631EA47A1BA6D1FAA059149AD2440DE6FBA6",
  706. "178D49B1AE90E3D8B629BE3DB5683915F4E8C99FDF6E666CF37ADCFD",
  707. },
  708. {
  709. "7046742B839478C1B5BD31DB2E862AD868E1A45C863585B5F22BDC2D",
  710. "389B92682E399B26518A95506B52C03BC9379A9DADF3391A21FB0EA4",
  711. "414A718ED3249FF6DBC5B50C27F71F01F070944DA22AB1F78F559AAB",
  712. },
  713. {
  714. "E39C2AA4EA6BE2306C72126D40ED77BF9739BB4D6EF2BBB1DCB6169D",
  715. "049F050477C5ADD858CAC56208394B5A55BAEBBE887FDF765047C17C",
  716. "077EB13E7005929CEFA3CD0403C7CDCC077ADF4E44F3C41B2F60ECFF",
  717. },
  718. {
  719. NULL, NULL, NULL
  720. }
  721. }
  722. },
  723. {
  724. "P-256",
  725. "C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721",
  726. "60FED4BA255A9D31C961EB74C6356D68C049B8923B61FA6CE669622E60F29FB6",
  727. "7903FE1008B8BC99A41AE9E95628BC64F2F1B20C2D7E9F5177A3C294D4462299",
  728. {
  729. {
  730. "882905F1227FD620FBF2ABF21244F0BA83D0DC3A9103DBBEE43A1FB858109DB4",
  731. "61340C88C3AAEBEB4F6D667F672CA9759A6CCAA9FA8811313039EE4A35471D32",
  732. "6D7F147DAC089441BB2E2FE8F7A3FA264B9C475098FDCF6E00D7C996E1B8B7EB",
  733. },
  734. {
  735. "103F90EE9DC52E5E7FB5132B7033C63066D194321491862059967C715985D473",
  736. "53B2FFF5D1752B2C689DF257C04C40A587FABABB3F6FC2702F1343AF7CA9AA3F",
  737. "B9AFB64FDC03DC1A131C7D2386D11E349F070AA432A4ACC918BEA988BF75C74C",
  738. },
  739. {
  740. "A6E3C57DD01ABE90086538398355DD4C3B17AA873382B0F24D6129493D8AAD60",
  741. "EFD48B2AACB6A8FD1140DD9CD45E81D69D2C877B56AAF991C34D0EA84EAF3716",
  742. "F7CB1C942D657C41D436C7A1B6E29F65F3E900DBB9AFF4064DC4AB2F843ACDA8",
  743. },
  744. {
  745. "09F634B188CEFD98E7EC88B1AA9852D734D0BC272F7D2A47DECC6EBEB375AAD4",
  746. "0EAFEA039B20E9B42309FB1D89E213057CBF973DC0CFC8F129EDDDC800EF7719",
  747. "4861F0491E6998B9455193E34E7B0D284DDD7149A74B95B9261F13ABDE940954",
  748. },
  749. {
  750. "5FA81C63109BADB88C1F367B47DA606DA28CAD69AA22C4FE6AD7DF73A7173AA5",
  751. "8496A60B5E9B47C825488827E0495B0E3FA109EC4568FD3F8D1097678EB97F00",
  752. "2362AB1ADBE2B8ADF9CB9EDAB740EA6049C028114F2460F96554F61FAE3302FE",
  753. },
  754. {
  755. "8C9520267C55D6B980DF741E56B4ADEE114D84FBFA2E62137954164028632A2E",
  756. "0CBCC86FD6ABD1D99E703E1EC50069EE5C0B4BA4B9AC60E409E8EC5910D81A89",
  757. "01B9D7B73DFAA60D5651EC4591A0136F87653E0FD780C3B1BC872FFDEAE479B1",
  758. },
  759. {
  760. "669F4426F2688B8BE0DB3A6BD1989BDAEFFF84B649EEB84F3DD26080F667FAA7",
  761. "C37EDB6F0AE79D47C3C27E962FA269BB4F441770357E114EE511F662EC34A692",
  762. "C820053A05791E521FCAAD6042D40AEA1D6B1A540138558F47D0719800E18F2D",
  763. },
  764. {
  765. "D16B6AE827F17175E040871A1C7EC3500192C4C92677336EC2537ACAEE0008E0",
  766. "F1ABB023518351CD71D881567B1EA663ED3EFCF6C5132B354F28D3B0B7D38367",
  767. "019F4113742A2B14BD25926B49C649155F267E60D3814B4C0CC84250E46F0083",
  768. },
  769. {
  770. "16AEFFA357260B04B1DD199693960740066C1A8F3E8EDD79070AA914D361B3B8",
  771. "83910E8B48BB0C74244EBDF7F07A1C5413D61472BD941EF3920E623FBCCEBEB6",
  772. "8DDBEC54CF8CD5874883841D712142A56A8D0F218F5003CB0296B6B509619F2C",
  773. },
  774. {
  775. "6915D11632ACA3C40D5D51C08DAF9C555933819548784480E93499000D9F0B7F",
  776. "461D93F31B6540894788FD206C07CFA0CC35F46FA3C91816FFF1040AD1581A04",
  777. "39AF9F15DE0DB8D97E72719C74820D304CE5226E32DEDAE67519E840D1194E55",
  778. },
  779. {
  780. NULL, NULL, NULL
  781. }
  782. }
  783. },
  784. {
  785. "P-384",
  786. "6B9D3DAD2E1B8C1C05B19875B6659F4DE23C3B667BF297BA9AA47740787137D896D5724E4C70A825F872C9EA60D2EDF5",
  787. "EC3A4E415B4E19A4568618029F427FA5DA9A8BC4AE92E02E06AAE5286B300C64DEF8F0EA9055866064A254515480BC13",
  788. "8015D9B72D7D57244EA8EF9AC0C621896708A59367F9DFB9F54CA84B3F1C9DB1288B231C3AE0D4FE7344FD2533264720",
  789. {
  790. {
  791. "4471EF7518BB2C7C20F62EAE1C387AD0C5E8E470995DB4ACF694466E6AB096630F29E5938D25106C3C340045A2DB01A7",
  792. "EC748D839243D6FBEF4FC5C4859A7DFFD7F3ABDDF72014540C16D73309834FA37B9BA002899F6FDA3A4A9386790D4EB2",
  793. "A3BCFA947BEEF4732BF247AC17F71676CB31A847B9FF0CBC9C9ED4C1A5B3FACF26F49CA031D4857570CCB5CA4424A443",
  794. },
  795. {
  796. "A4E4D2F0E729EB786B31FC20AD5D849E304450E0AE8E3E341134A5C1AFA03CAB8083EE4E3C45B06A5899EA56C51B5879",
  797. "42356E76B55A6D9B4631C865445DBE54E056D3B3431766D0509244793C3F9366450F76EE3DE43F5A125333A6BE060122",
  798. "9DA0C81787064021E78DF658F2FBB0B042BF304665DB721F077A4298B095E4834C082C03D83028EFBF93A3C23940CA8D",
  799. },
  800. {
  801. "180AE9F9AEC5438A44BC159A1FCB277C7BE54FA20E7CF404B490650A8ACC414E375572342863C899F9F2EDF9747A9B60",
  802. "21B13D1E013C7FA1392D03C5F99AF8B30C570C6F98D4EA8E354B63A21D3DAA33BDE1E888E63355D92FA2B3C36D8FB2CD",
  803. "F3AA443FB107745BF4BD77CB3891674632068A10CA67E3D45DB2266FA7D1FEEBEFDC63ECCD1AC42EC0CB8668A4FA0AB0",
  804. },
  805. {
  806. "94ED910D1A099DAD3254E9242AE85ABDE4BA15168EAF0CA87A555FD56D10FBCA2907E3E83BA95368623B8C4686915CF9",
  807. "94EDBB92A5ECB8AAD4736E56C691916B3F88140666CE9FA73D64C4EA95AD133C81A648152E44ACF96E36DD1E80FABE46",
  808. "99EF4AEB15F178CEA1FE40DB2603138F130E740A19624526203B6351D0A3A94FA329C145786E679E7B82C71A38628AC8",
  809. },
  810. {
  811. "92FC3C7183A883E24216D1141F1A8976C5B0DD797DFA597E3D7B32198BD35331A4E966532593A52980D0E3AAA5E10EC3",
  812. "ED0959D5880AB2D869AE7F6C2915C6D60F96507F9CB3E047C0046861DA4A799CFE30F35CC900056D7C99CD7882433709",
  813. "512C8CCEEE3890A84058CE1E22DBC2198F42323CE8ACA9135329F03C068E5112DC7CC3EF3446DEFCEB01A45C2667FDD5",
  814. },
  815. {
  816. "66CC2C8F4D303FC962E5FF6A27BD79F84EC812DDAE58CF5243B64A4AD8094D47EC3727F3A3C186C15054492E30698497",
  817. "4BC35D3A50EF4E30576F58CD96CE6BF638025EE624004A1F7789A8B8E43D0678ACD9D29876DAF46638645F7F404B11C7",
  818. "D5A6326C494ED3FF614703878961C0FDE7B2C278F9A65FD8C4B7186201A2991695BA1C84541327E966FA7B50F7382282",
  819. },
  820. {
  821. "18FA39DB95AA5F561F30FA3591DC59C0FA3653A80DAFFA0B48D1A4C6DFCBFF6E3D33BE4DC5EB8886A8ECD093F2935726",
  822. "E8C9D0B6EA72A0E7837FEA1D14A1A9557F29FAA45D3E7EE888FC5BF954B5E62464A9A817C47FF78B8C11066B24080E72",
  823. "07041D4A7A0379AC7232FF72E6F77B6DDB8F09B16CCE0EC3286B2BD43FA8C6141C53EA5ABEF0D8231077A04540A96B66",
  824. },
  825. {
  826. "0CFAC37587532347DC3389FDC98286BBA8C73807285B184C83E62E26C401C0FAA48DD070BA79921A3457ABFF2D630AD7",
  827. "6D6DEFAC9AB64DABAFE36C6BF510352A4CC27001263638E5B16D9BB51D451559F918EEDAF2293BE5B475CC8F0188636B",
  828. "2D46F3BECBCC523D5F1A1256BF0C9B024D879BA9E838144C8BA6BAEB4B53B47D51AB373F9845C0514EEFB14024787265",
  829. },
  830. {
  831. "015EE46A5BF88773ED9123A5AB0807962D193719503C527B031B4C2D225092ADA71F4A459BC0DA98ADB95837DB8312EA",
  832. "8203B63D3C853E8D77227FB377BCF7B7B772E97892A80F36AB775D509D7A5FEB0542A7F0812998DA8F1DD3CA3CF023DB",
  833. "DDD0760448D42D8A43AF45AF836FCE4DE8BE06B485E9B61B827C2F13173923E06A739F040649A667BF3B828246BAA5A5",
  834. },
  835. {
  836. "3780C4F67CB15518B6ACAE34C9F83568D2E12E47DEAB6C50A4E4EE5319D1E8CE0E2CC8A136036DC4B9C00E6888F66B6C",
  837. "A0D5D090C9980FAF3C2CE57B7AE951D31977DD11C775D314AF55F76C676447D06FB6495CD21B4B6E340FC236584FB277",
  838. "976984E59B4C77B0E8E4460DCA3D9F20E07B9BB1F63BEEFAF576F6B2E8B224634A2092CD3792E0159AD9CEE37659C736",
  839. },
  840. {
  841. NULL, NULL, NULL
  842. }
  843. }
  844. },
  845. {
  846. "P-521",
  847. "00FAD06DAA62BA3B25D2FB40133DA757205DE67F5BB0018FEE8C86E1B68C7E75CAA896EB32F1F47C70855836A6D16FCC1466F6D8FBEC67DB89EC0C08B0E996B83538",
  848. "1894550D0785932E00EAA23B694F213F8C3121F86DC97A04E5A7167DB4E5BCD371123D46E45DB6B5D5370A7F20FB633155D38FFA16D2BD761DCAC474B9A2F5023A4",
  849. "493101C962CD4D2FDDF782285E64584139C2F91B47F87FF82354D6630F746A28A0DB25741B5B34A828008B22ACC23F924FAAFBD4D33F81EA66956DFEAA2BFDFCF5",
  850. {
  851. {
  852. "89C071B419E1C2820962321787258469511958E80582E95D8378E0C2CCDB3CB42BEDE42F50E3FA3C71F5A76724281D31D9C89F0F91FC1BE4918DB1C03A5838D0F9",
  853. "00343B6EC45728975EA5CBA6659BBB6062A5FF89EEA58BE3C80B619F322C87910FE092F7D45BB0F8EEE01ED3F20BABEC079D202AE677B243AB40B5431D497C55D75D",
  854. "00E7B0E675A9B24413D448B8CC119D2BF7B2D2DF032741C096634D6D65D0DBE3D5694625FB9E8104D3B842C1B0E2D0B98BEA19341E8676AEF66AE4EBA3D5475D5D16",
  855. },
  856. {
  857. "0121415EC2CD7726330A61F7F3FA5DE14BE9436019C4DB8CB4041F3B54CF31BE0493EE3F427FB906393D895A19C9523F3A1D54BB8702BD4AA9C99DAB2597B92113F3",
  858. "01776331CFCDF927D666E032E00CF776187BC9FDD8E69D0DABB4109FFE1B5E2A30715F4CC923A4A5E94D2503E9ACFED92857B7F31D7152E0F8C00C15FF3D87E2ED2E",
  859. "0050CB5265417FE2320BBB5A122B8E1A32BD699089851128E360E620A30C7E17BA41A666AF126CE100E5799B153B60528D5300D08489CA9178FB610A2006C254B41F",
  860. },
  861. {
  862. "EDF38AFCAAECAB4383358B34D67C9F2216C8382AAEA44A3DAD5FDC9C32575761793FEF24EB0FC276DFC4F6E3EC476752F043CF01415387470BCBD8678ED2C7E1A0",
  863. "01511BB4D675114FE266FC4372B87682BAECC01D3CC62CF2303C92B3526012659D16876E25C7C1E57648F23B73564D67F61C6F14D527D54972810421E7D87589E1A7",
  864. "004A171143A83163D6DF460AAF61522695F207A58B95C0644D87E52AA1A347916E4F7A72930B1BC06DBE22CE3F58264AFD23704CBB63B29B931F7DE6C9D949A7ECFC",
  865. },
  866. {
  867. "01546A108BC23A15D6F21872F7DED661FA8431DDBD922D0DCDB77CC878C8553FFAD064C95A920A750AC9137E527390D2D92F153E66196966EA554D9ADFCB109C4211",
  868. "01EA842A0E17D2DE4F92C15315C63DDF72685C18195C2BB95E572B9C5136CA4B4B576AD712A52BE9730627D16054BA40CC0B8D3FF035B12AE75168397F5D50C67451",
  869. "01F21A3CEE066E1961025FB048BD5FE2B7924D0CD797BABE0A83B66F1E35EEAF5FDE143FA85DC394A7DEE766523393784484BDF3E00114A1C857CDE1AA203DB65D61",
  870. },
  871. {
  872. "01DAE2EA071F8110DC26882D4D5EAE0621A3256FC8847FB9022E2B7D28E6F10198B1574FDD03A9053C08A1854A168AA5A57470EC97DD5CE090124EF52A2F7ECBFFD3",
  873. "00C328FAFCBD79DD77850370C46325D987CB525569FB63C5D3BC53950E6D4C5F174E25A1EE9017B5D450606ADD152B534931D7D4E8455CC91F9B15BF05EC36E377FA",
  874. "00617CCE7CF5064806C467F678D3B4080D6F1CC50AF26CA209417308281B68AF282623EAA63E5B5C0723D8B8C37FF0777B1A20F8CCB1DCCC43997F1EE0E44DA4A67A",
  875. },
  876. {
  877. "00BB9F2BF4FE1038CCF4DABD7139A56F6FD8BB1386561BD3C6A4FC818B20DF5DDBA80795A947107A1AB9D12DAA615B1ADE4F7A9DC05E8E6311150F47F5C57CE8B222",
  878. "013BAD9F29ABE20DE37EBEB823C252CA0F63361284015A3BF430A46AAA80B87B0693F0694BD88AFE4E661FC33B094CD3B7963BED5A727ED8BD6A3A202ABE009D0367",
  879. "01E9BB81FF7944CA409AD138DBBEE228E1AFCC0C890FC78EC8604639CB0DBDC90F717A99EAD9D272855D00162EE9527567DD6A92CBD629805C0445282BBC916797FF",
  880. },
  881. {
  882. "0040D09FCF3C8A5F62CF4FB223CBBB2B9937F6B0577C27020A99602C25A01136987E452988781484EDBBCF1C47E554E7FC901BC3085E5206D9F619CFF07E73D6F706",
  883. "01C7ED902E123E6815546065A2C4AF977B22AA8EADDB68B2C1110E7EA44D42086BFE4A34B67DDC0E17E96536E358219B23A706C6A6E16BA77B65E1C595D43CAE17FB",
  884. "0177336676304FCB343CE028B38E7B4FBA76C1C1B277DA18CAD2A8478B2A9A9F5BEC0F3BA04F35DB3E4263569EC6AADE8C92746E4C82F8299AE1B8F1739F8FD519A4",
  885. },
  886. {
  887. "001DE74955EFAABC4C4F17F8E84D881D1310B5392D7700275F82F145C61E843841AF09035BF7A6210F5A431A6A9E81C9323354A9E69135D44EBD2FCAA7731B909258",
  888. "000E871C4A14F993C6C7369501900C4BC1E9C7B0B4BA44E04868B30B41D8071042EB28C4C250411D0CE08CD197E4188EA4876F279F90B3D8D74A3C76E6F1E4656AA8",
  889. "00CD52DBAA33B063C3A6CD8058A1FB0A46A4754B034FCC644766CA14DA8CA5CA9FDE00E88C1AD60CCBA759025299079D7A427EC3CC5B619BFBC828E7769BCD694E86",
  890. },
  891. {
  892. "01F1FC4A349A7DA9A9E116BFDD055DC08E78252FF8E23AC276AC88B1770AE0B5DCEB1ED14A4916B769A523CE1E90BA22846AF11DF8B300C38818F713DADD85DE0C88",
  893. "014BEE21A18B6D8B3C93FAB08D43E739707953244FDBE924FA926D76669E7AC8C89DF62ED8975C2D8397A65A49DCC09F6B0AC62272741924D479354D74FF6075578C",
  894. "0133330865C067A0EAF72362A65E2D7BC4E461E8C8995C3B6226A21BD1AA78F0ED94FE536A0DCA35534F0CD1510C41525D163FE9D74D134881E35141ED5E8E95B979",
  895. },
  896. {
  897. "016200813020EC986863BEDFC1B121F605C1215645018AEA1A7B215A564DE9EB1B38A67AA1128B80CE391C4FB71187654AAA3431027BFC7F395766CA988C964DC56D",
  898. "013E99020ABF5CEE7525D16B69B229652AB6BDF2AFFCAEF38773B4B7D08725F10CDB93482FDCC54EDCEE91ECA4166B2A7C6265EF0CE2BD7051B7CEF945BABD47EE6D",
  899. "01FBD0013C674AA79CB39849527916CE301C66EA7CE8B80682786AD60F98F7E78A19CA69EFF5C57400E3B3A0AD66CE0978214D13BAF4E9AC60752F7B155E2DE4DCE3",
  900. },
  901. {
  902. NULL, NULL, NULL
  903. }
  904. }
  905. },
  906. {
  907. NULL
  908. }
  909. };
  910. const void *inputs[] = {
  911. "sample",
  912. "test"
  913. };
  914. const char hashes[][7] = {
  915. "sha1",
  916. "sha224",
  917. "sha256",
  918. "sha384",
  919. "sha512"
  920. };
  921. const ltc_ecc_curve* dp;
  922. ecc_key key;
  923. unsigned char pk[MAXBLOCKSIZE], hash[MAXBLOCKSIZE], sig[512], should[512];
  924. char name[128], tmp[MAXBLOCKSIZE];
  925. unsigned int t, s, i, h;
  926. unsigned long pklen, hashlen, curvelen, inputlen, siglen, shouldlen, shouldlen2;
  927. for (t = 0; tests[t].curve; ++t) {
  928. curvelen = XSTRLEN(tests[t].curve);
  929. XMEMCPY(name, tests[t].curve, curvelen);
  930. name[curvelen++] = '-';
  931. DOX(ecc_find_curve(tests[t].curve, &dp), tests[t].curve);
  932. pklen = sizeof(pk);
  933. DOX(base16_decode(tests[t].x, XSTRLEN(tests[t].x), pk, &pklen), tests[t].curve);
  934. DOX(ecc_set_curve(dp, &key), tests[t].curve);
  935. DOX(ecc_set_key(pk, pklen, PK_PRIVATE, &key), tests[t].curve);
  936. name[curvelen] = 'U';
  937. name[curvelen + 1] = 'x';
  938. name[curvelen + 2] = '\0';
  939. ltc_mp.write_radix(key.pubkey.x, tmp, 16);
  940. COMPARE_TESTVECTOR(tmp, XSTRLEN(tmp), tests[t].Ux, XSTRLEN(tests[t].Ux), name, t * 1000);
  941. name[curvelen + 1] = 'y';
  942. ltc_mp.write_radix(key.pubkey.y, tmp, 16);
  943. COMPARE_TESTVECTOR(tmp, XSTRLEN(tmp), tests[t].Uy, XSTRLEN(tests[t].Uy), name, t * 1000);
  944. i = h = 0;
  945. for (s = 0; tests[t].signatures[s].k; ++s) {
  946. if (h == 0) {
  947. inputlen = XSTRLEN(inputs[i]);
  948. XMEMCPY(&name[curvelen], inputs[i], inputlen);
  949. name[curvelen + inputlen++] = '-';
  950. }
  951. XMEMCPY(&name[curvelen + inputlen], hashes[h], 7);
  952. hashlen = sizeof(hash);
  953. DOX(hash_memory(find_hash(hashes[h]), inputs[i], XSTRLEN(inputs[i]), hash, &hashlen), name);
  954. ECC_SET_RFC6979_HASH_ALG(&key, hashes[h]);
  955. siglen = sizeof(sig);
  956. DOX(ecc_sign_hash_rfc7518(hash, hashlen, sig, &siglen, &yarrow_prng, find_prng ("yarrow"), &key), name);
  957. XMEMSET(should, 0, sizeof(should));
  958. shouldlen = sizeof(should);
  959. DOX(base16_decode(tests[t].signatures[s].r, XSTRLEN(tests[t].signatures[s].r), should, &shouldlen), name);
  960. shouldlen2 = sizeof(should) - shouldlen;
  961. DOX(base16_decode(tests[t].signatures[s].s, XSTRLEN(tests[t].signatures[s].s), should + shouldlen, &shouldlen2), name);
  962. COMPARE_TESTVECTOR(sig, siglen, should, shouldlen + shouldlen2, name, (t * 1000 | s * 100 | i * 10 | h));
  963. h++;
  964. if (h == 5) {
  965. h = 0;
  966. i++;
  967. }
  968. }
  969. ecc_free(&key);
  970. }
  971. return CRYPT_OK;
  972. }
  973. static int password_get(void **p, unsigned long *l, void *u)
  974. {
  975. LTC_UNUSED_PARAM(u);
  976. *p = strdup("secret");
  977. *l = 6;
  978. return 0;
  979. }
  980. static int s_ecc_import_export(void) {
  981. const ltc_ecc_curve *cu;
  982. ecc_key key, pri, pub;
  983. unsigned char out[300];
  984. unsigned long outlen;
  985. /* the following test keys were generated by:
  986. # no password
  987. openssl ecparam -name secp256k1 -genkey -out main-key.pem
  988. openssl ec -in main-key.pem -param_enc explicit -out long_pri.der -outform DER
  989. openssl ec -in main-key.pem -param_enc explicit -conv_form compressed -out long_pric.der -outform DER
  990. openssl ec -in main-key.pem -param_enc explicit -pubout -out long_pub.der -outform DER
  991. openssl ec -in main-key.pem -param_enc explicit -pubout -conv_form compressed -out long_pubc.der -outform DER
  992. openssl ec -in main-key.pem -param_enc named_curve -out short_pri.der -outform DER
  993. openssl ec -in main-key.pem -param_enc named_curve -conv_form compressed -out short_pric.der -outform DER
  994. openssl ec -in main-key.pem -param_enc named_curve -pubout -out short_pub.der -outform DER
  995. openssl ec -in main-key.pem -param_enc named_curve -pubout -conv_form compressed -out short_pubc.der -outform DER
  996. # X.509 EC certificates
  997. openssl req -new -x509 -keyform der -key long_pri.der -sha512 -subj '/CN=Test Cert EC' -out x509_cert_long.der -outform der -days 365000
  998. openssl req -new -x509 -keyform der -key long_pric.der -sha512 -subj '/CN=Test Cert EC' -out x509_cert_longc.der -outform der -days 365000
  999. openssl req -new -x509 -keyform der -key short_pri.der -sha512 -subj '/CN=Test Cert EC' -out x509_cert_short.der -outform der -days 365000
  1000. openssl req -new -x509 -keyform der -key short_pric.der -sha512 -subj '/CN=Test Cert EC' -out x509_cert_shortc.der -outform der -days 365000
  1001. # pkcs8 without password
  1002. openssl pkcs8 -topk8 -inform DER -outform DER -nocrypt -in long_pri.der -out long_pri_pkcs8.der
  1003. openssl pkcs8 -topk8 -inform DER -outform DER -nocrypt -in long_pric.der -out long_pric_pkcs8.der
  1004. openssl pkcs8 -topk8 -inform DER -outform DER -nocrypt -in short_pri.der -out short_pri_pkcs8.der
  1005. openssl pkcs8 -topk8 -inform DER -outform DER -nocrypt -in short_pric.der -out short_pric_pkcs8.der
  1006. # password protected - PBES1
  1007. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in long_pri.der -v1 PBE-MD2-DES -out long_pri_pkcs8_pbe_md2_des.der
  1008. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in long_pri.der -v1 PBE-MD2-RC2-64 -out long_pri_pkcs8_pbe_md2_rc2_64.der
  1009. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in ltc_ecc_long_pri_test_key.der -v1 PBE-MD5-DES -out long_pri_pkcs8_pbe_md5_des.der
  1010. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in ltc_ecc_long_pri_test_key.der -v1 PBE-SHA1-RC2-64 -out long_pri_pkcs8_pbe_sha1_rc2_64.der
  1011. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in ltc_ecc_long_pri_test_key.der -v1 PBE-MD5-RC2-64 -out long_pri_pkcs8_pbe_md5_rc2_64.der
  1012. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in ltc_ecc_long_pri_test_key.der -v1 PBE-SHA1-DES -out long_pri_pkcs8_pbe_sha1_des.der
  1013. # password protected - PBES2
  1014. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in ltc_ecc_long_pri_test_key.der -v2 rc2 -out long_pri_pkcs8_pbkdf2_rc2_cbc.der
  1015. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in ltc_ecc_long_pri_test_key.der -v2 des -out long_pri_pkcs8_pbkdf2_des_cbc.der
  1016. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in ltc_ecc_long_pri_test_key.der -v2 des3 -out long_pri_pkcs8_pbkdf2_des_ede3_cbc.der
  1017. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in ltc_ecc_long_pri_test_key.der -v2 des3 -v2prf hmacWithSHA224 -out long_pri_pkcs8_pbkdf2_sha224_des_ede3_cbc.der
  1018. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in ltc_ecc_long_pri_test_key.der -v2 des3 -v2prf hmacWithSHA256 -out long_pri_pkcs8_pbkdf2_sha256_des_ede3_cbc.der
  1019. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in ltc_ecc_long_pri_test_key.der -v2 des3 -v2prf hmacWithSHA384 -out long_pri_pkcs8_pbkdf2_sha384_des_ede3_cbc.der
  1020. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in ltc_ecc_long_pri_test_key.der -v2 des3 -v2prf hmacWithSHA512 -out long_pri_pkcs8_pbkdf2_sha512_des_ede3_cbc.der
  1021. */
  1022. /* static const unsigned char ltc_ecc_long_pri_test_key[] defined globally */
  1023. static const unsigned char long_pri_pkcs8[] = { /* private + long public, explicit curve params, PKCS8 */
  1024. 0x30, 0x82, 0x01, 0x23, 0x02, 0x01, 0x00, 0x30, 0x81, 0xae, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce,
  1025. 0x3d, 0x02, 0x01, 0x30, 0x81, 0xa2, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48,
  1026. 0xce, 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1027. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1028. 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04,
  1029. 0x41, 0x04, 0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87,
  1030. 0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8,
  1031. 0x17, 0x98, 0x48, 0x3a, 0xda, 0x77, 0x26, 0xa3, 0xc4, 0x65, 0x5d, 0xa4, 0xfb, 0xfc, 0x0e, 0x11,
  1032. 0x08, 0xa8, 0xfd, 0x17, 0xb4, 0x48, 0xa6, 0x85, 0x54, 0x19, 0x9c, 0x47, 0xd0, 0x8f, 0xfb, 0x10,
  1033. 0xd4, 0xb8, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1034. 0xff, 0xff, 0xff, 0xff, 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5e,
  1035. 0x8c, 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01, 0x01, 0x04, 0x6d, 0x30, 0x6b, 0x02, 0x01, 0x01, 0x04,
  1036. 0x20, 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b, 0xba, 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2,
  1037. 0xf7, 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f, 0x5f, 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd,
  1038. 0x23, 0xa1, 0x44, 0x03, 0x42, 0x00, 0x04, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1,
  1039. 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5,
  1040. 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16, 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a, 0xb7,
  1041. 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62, 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5, 0x6e,
  1042. 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d
  1043. };
  1044. #if defined(LTC_MD2) && defined(LTC_DES)
  1045. static const unsigned char long_pri_pkcs8_pbe_md2_des[] = {
  1046. 0x30, 0x82, 0x01, 0x49, 0x30, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  1047. 0x01, 0x30, 0x0e, 0x04, 0x08, 0xd8, 0x1c, 0x80, 0xac, 0xd9, 0xfa, 0x9d, 0xbc, 0x02, 0x02, 0x08,
  1048. 0x00, 0x04, 0x82, 0x01, 0x28, 0xe1, 0xd5, 0xa8, 0x9a, 0xa8, 0x23, 0x85, 0x53, 0x18, 0xb3, 0x96,
  1049. 0x67, 0x8d, 0x45, 0x72, 0xf8, 0x69, 0xc4, 0xb1, 0x01, 0x3e, 0x04, 0xf7, 0xf7, 0x5d, 0x07, 0xad,
  1050. 0xec, 0x8e, 0xd6, 0x23, 0x00, 0xe7, 0x59, 0xb0, 0x98, 0xbb, 0xdb, 0x85, 0xdb, 0x59, 0x4d, 0xb5,
  1051. 0x53, 0xb3, 0x32, 0x50, 0x66, 0x75, 0xc4, 0x69, 0x05, 0x07, 0xee, 0xd4, 0xd8, 0x33, 0xcd, 0x4c,
  1052. 0x94, 0xad, 0x82, 0xc7, 0x89, 0x53, 0x65, 0x9f, 0x55, 0x44, 0x95, 0x20, 0xe8, 0x4a, 0xc2, 0xef,
  1053. 0x41, 0xf2, 0x9d, 0xf8, 0x3d, 0x16, 0x8a, 0x6a, 0x4e, 0x85, 0x90, 0xa7, 0xf9, 0xf8, 0xac, 0x16,
  1054. 0x76, 0xf2, 0x29, 0x4b, 0x93, 0xec, 0xd8, 0x17, 0x3f, 0x89, 0x84, 0x79, 0x75, 0x90, 0x5f, 0xc3,
  1055. 0xf2, 0xb8, 0x1a, 0x0a, 0x25, 0xf4, 0xe2, 0x59, 0xe0, 0xea, 0xa6, 0x57, 0xc4, 0x9c, 0xce, 0xfd,
  1056. 0xa8, 0xbc, 0xf6, 0x0d, 0x3a, 0x47, 0x14, 0x9d, 0x6a, 0x92, 0x77, 0xe4, 0xcb, 0x88, 0x6e, 0xfa,
  1057. 0x19, 0xa4, 0x3d, 0x58, 0xdb, 0x5f, 0xc7, 0xad, 0x91, 0x64, 0xb0, 0x1f, 0xe2, 0x66, 0xc5, 0x5a,
  1058. 0x28, 0x21, 0xb0, 0xc1, 0xc8, 0x73, 0x55, 0xd8, 0x43, 0x66, 0x6a, 0x5c, 0xcd, 0xb0, 0x89, 0x60,
  1059. 0x59, 0x31, 0xe0, 0x2f, 0x20, 0x3b, 0x83, 0xdf, 0x27, 0xcf, 0x33, 0xcc, 0xb9, 0xb6, 0xe0, 0xec,
  1060. 0x8b, 0x94, 0x4b, 0xc4, 0x1c, 0x25, 0xba, 0x97, 0x6c, 0x83, 0x22, 0x8c, 0xca, 0x9d, 0xc6, 0xaa,
  1061. 0x74, 0x3f, 0x46, 0xdc, 0xba, 0x7a, 0x36, 0x04, 0xa7, 0xc8, 0x65, 0xb4, 0xf7, 0x14, 0x53, 0x8c,
  1062. 0xff, 0x4d, 0x19, 0xc1, 0xdb, 0xa4, 0xcc, 0x52, 0xc2, 0xd9, 0x38, 0x16, 0x8f, 0xd8, 0x6e, 0x55,
  1063. 0x41, 0xa8, 0xe0, 0x15, 0xd6, 0x2d, 0xa4, 0x37, 0x9f, 0xcc, 0x42, 0x3c, 0xcb, 0xcc, 0x92, 0x04,
  1064. 0xc8, 0xcf, 0xbc, 0x60, 0xfb, 0x45, 0xff, 0x62, 0x74, 0xa1, 0xe9, 0xba, 0x1e, 0x5d, 0x44, 0x6f,
  1065. 0x0e, 0xac, 0xdf, 0xde, 0xb1, 0xbb, 0x47, 0x5e, 0x0c, 0x88, 0x0a, 0x85, 0x0b, 0xa8, 0x9e, 0xcb,
  1066. 0x32, 0x99, 0x8d, 0xb1, 0xdd, 0x12, 0x08, 0xeb, 0x7e, 0x45, 0x70, 0x12, 0xe3
  1067. };
  1068. #endif
  1069. #if defined(LTC_MD2) && defined(LTC_RC2)
  1070. static const unsigned char long_pri_pkcs8_pbe_md2_rc2_64[] = {
  1071. 0x30, 0x82, 0x01, 0x49, 0x30, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  1072. 0x04, 0x30, 0x0e, 0x04, 0x08, 0xa2, 0x28, 0xb7, 0x2a, 0x08, 0x1c, 0x4a, 0xc4, 0x02, 0x02, 0x08,
  1073. 0x00, 0x04, 0x82, 0x01, 0x28, 0x78, 0x12, 0x02, 0x58, 0x9b, 0xea, 0x77, 0xba, 0x84, 0x20, 0x96,
  1074. 0x63, 0xf0, 0xf3, 0x38, 0x0b, 0x98, 0x53, 0x63, 0x8d, 0xa4, 0x5a, 0xa0, 0xa9, 0x21, 0x93, 0xd0,
  1075. 0x56, 0xc9, 0xd2, 0x67, 0xb2, 0x5e, 0xb5, 0x9f, 0x15, 0x8c, 0x3c, 0x9a, 0xaf, 0x9c, 0xe5, 0x8b,
  1076. 0xe6, 0x61, 0xac, 0xa4, 0x26, 0x75, 0x96, 0xea, 0x73, 0xaf, 0xd6, 0xb7, 0x4c, 0x66, 0x33, 0x98,
  1077. 0x9e, 0x0b, 0xf8, 0xe6, 0x9c, 0xfd, 0x83, 0x0f, 0x55, 0x86, 0x9f, 0xa9, 0xf0, 0x23, 0xcb, 0x80,
  1078. 0xe5, 0x32, 0x50, 0xea, 0x5b, 0x7d, 0xe2, 0x69, 0xc4, 0x6b, 0x61, 0xb2, 0xb8, 0x81, 0xe9, 0x05,
  1079. 0xcb, 0x76, 0xae, 0xa5, 0x37, 0x0f, 0x3c, 0xe6, 0xde, 0x24, 0x6a, 0x9c, 0xf2, 0x0a, 0x28, 0x6a,
  1080. 0xc9, 0xec, 0xef, 0xd7, 0xda, 0xcc, 0xf4, 0x3b, 0x74, 0x36, 0xc5, 0xaf, 0x53, 0xd8, 0xf4, 0x30,
  1081. 0x0b, 0xd4, 0xb6, 0x36, 0xdc, 0x90, 0x4f, 0x83, 0x44, 0x79, 0xea, 0xc9, 0xb7, 0xb2, 0xd0, 0x03,
  1082. 0xa6, 0x63, 0x7e, 0x1d, 0xa8, 0x4e, 0x93, 0x16, 0x7a, 0x4f, 0xd2, 0x8b, 0xd6, 0x78, 0x7d, 0x48,
  1083. 0x41, 0x7c, 0xba, 0xc3, 0x64, 0x6f, 0x11, 0x22, 0x6d, 0x40, 0xb8, 0xc9, 0x03, 0x7a, 0x2c, 0xdf,
  1084. 0x76, 0x78, 0x4f, 0x5f, 0x50, 0x03, 0x7a, 0xaf, 0x78, 0x91, 0xbb, 0x2a, 0xe6, 0x5e, 0x0f, 0xf5,
  1085. 0x60, 0x9e, 0x8a, 0x2f, 0xdb, 0x9e, 0x57, 0xbe, 0xf6, 0x0f, 0x76, 0x6e, 0x44, 0x91, 0x7b, 0x36,
  1086. 0x88, 0x9c, 0xf9, 0xbe, 0x13, 0x3e, 0x6b, 0x85, 0x62, 0xda, 0x1f, 0xf9, 0x73, 0x98, 0x8a, 0x0d,
  1087. 0xdf, 0x11, 0x74, 0x18, 0xe1, 0x1c, 0xd1, 0x3f, 0x02, 0x43, 0xd4, 0x46, 0xe3, 0x8a, 0x3b, 0x6c,
  1088. 0x7f, 0x81, 0xb4, 0xc3, 0x85, 0x4f, 0x89, 0x67, 0x26, 0x5a, 0x08, 0x35, 0x31, 0xd3, 0x15, 0xbb,
  1089. 0xcc, 0x7d, 0x7b, 0x99, 0x41, 0xdb, 0x43, 0xa0, 0x83, 0x84, 0x74, 0x6c, 0x0a, 0x80, 0x46, 0xdc,
  1090. 0xc8, 0x88, 0x87, 0x01, 0x21, 0x19, 0xd4, 0x1e, 0xf4, 0x09, 0x0e, 0x18, 0x31, 0x91, 0x37, 0x35,
  1091. 0x1d, 0x07, 0xaf, 0x87, 0x92, 0x3d, 0xf8, 0xee, 0x6f, 0x87, 0x7b, 0x52, 0x3d
  1092. };
  1093. #endif
  1094. #if defined(LTC_MD5) && defined(LTC_DES)
  1095. static const unsigned char long_pri_pkcs8_pbe_md5_des[] = {
  1096. 0x30, 0x82, 0x01, 0x49, 0x30, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  1097. 0x03, 0x30, 0x0e, 0x04, 0x08, 0x33, 0xe7, 0xd9, 0xf1, 0x35, 0xd9, 0x74, 0x83, 0x02, 0x02, 0x08,
  1098. 0x00, 0x04, 0x82, 0x01, 0x28, 0x2f, 0x77, 0x7c, 0x48, 0xc9, 0x43, 0x6d, 0xdb, 0xd0, 0x1a, 0xef,
  1099. 0xfb, 0x29, 0x5e, 0x53, 0xa3, 0x52, 0x28, 0x27, 0x76, 0xc2, 0x01, 0x76, 0x5a, 0xea, 0x98, 0xe6,
  1100. 0x72, 0xdf, 0x06, 0xa2, 0xf5, 0xd0, 0x7b, 0x74, 0xe4, 0x6b, 0x98, 0xa6, 0xb5, 0xe1, 0x02, 0xf7,
  1101. 0xab, 0x2c, 0xf1, 0xeb, 0xf4, 0xec, 0xa6, 0xba, 0xd3, 0xd5, 0xb2, 0x26, 0x83, 0xeb, 0xff, 0xc9,
  1102. 0xf8, 0x7b, 0xbf, 0xab, 0xdc, 0xe5, 0xe4, 0x91, 0xd5, 0x48, 0xba, 0x49, 0xcb, 0xc5, 0xf1, 0x71,
  1103. 0x48, 0x1e, 0x96, 0x7c, 0x10, 0xe4, 0xa9, 0x35, 0xa7, 0xe6, 0x82, 0x97, 0x6f, 0xe4, 0x64, 0xd4,
  1104. 0x53, 0xa9, 0xf1, 0x1b, 0x6c, 0x31, 0xa1, 0xc7, 0x12, 0x46, 0x45, 0x6f, 0x45, 0xb2, 0x09, 0x3a,
  1105. 0xfe, 0x35, 0x4e, 0xbf, 0x7d, 0xf8, 0xcf, 0x94, 0x78, 0x0c, 0x78, 0xfb, 0xce, 0xc1, 0x30, 0xcd,
  1106. 0x6d, 0x6b, 0x08, 0x5e, 0xf6, 0xf5, 0x97, 0xff, 0x5e, 0x63, 0x44, 0x36, 0xa5, 0x71, 0x04, 0xe5,
  1107. 0x2d, 0xd9, 0xe3, 0x41, 0x91, 0x09, 0x1e, 0xa3, 0x30, 0xff, 0x12, 0x2a, 0x7a, 0xe1, 0x8f, 0x9c,
  1108. 0x38, 0x13, 0x3d, 0xc3, 0xbb, 0x68, 0xfa, 0xc0, 0xc6, 0x35, 0x77, 0xed, 0xe8, 0x73, 0xca, 0xc3,
  1109. 0x87, 0x62, 0xa9, 0x0e, 0xef, 0xcf, 0x73, 0x3c, 0xb3, 0xa0, 0x1b, 0xb5, 0x5d, 0x72, 0x89, 0x82,
  1110. 0xd4, 0xf6, 0x37, 0x0b, 0x57, 0x8f, 0x48, 0xd4, 0xf1, 0x10, 0xa1, 0xe5, 0x25, 0x90, 0xeb, 0xde,
  1111. 0x8d, 0x2a, 0x9d, 0xfb, 0x7c, 0x0d, 0xdc, 0x38, 0x45, 0x9e, 0xa0, 0x05, 0x98, 0x4e, 0x72, 0x9f,
  1112. 0x3d, 0xde, 0xc7, 0x00, 0xf9, 0xaf, 0xdc, 0x67, 0x47, 0x73, 0xf7, 0xcf, 0x63, 0x80, 0xe3, 0x05,
  1113. 0xb3, 0xda, 0x9f, 0x4b, 0x27, 0xd3, 0x14, 0xc9, 0x62, 0xd5, 0x09, 0xde, 0x4d, 0xe7, 0x21, 0x67,
  1114. 0xfa, 0x10, 0x34, 0x18, 0xbf, 0xde, 0xf7, 0x95, 0x25, 0x6d, 0xba, 0xe4, 0x10, 0xf0, 0x9d, 0x05,
  1115. 0x7b, 0xe4, 0xb5, 0xc0, 0x21, 0xb3, 0x7d, 0xcd, 0x1d, 0x80, 0xd0, 0x10, 0xd4, 0xdb, 0x9f, 0x06,
  1116. 0xd5, 0x86, 0xea, 0x62, 0x96, 0xb7, 0x31, 0x73, 0xde, 0x25, 0xd0, 0xbb, 0xb2
  1117. };
  1118. #endif
  1119. #if defined(LTC_MD5) && defined(LTC_RC2)
  1120. static const unsigned char long_pri_pkcs8_pbe_md5_rc2_64[] = {
  1121. 0x30, 0x82, 0x01, 0x49, 0x30, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  1122. 0x06, 0x30, 0x0e, 0x04, 0x08, 0x95, 0x82, 0x6d, 0x08, 0xe4, 0x7e, 0xae, 0x5f, 0x02, 0x02, 0x08,
  1123. 0x00, 0x04, 0x82, 0x01, 0x28, 0x93, 0x2c, 0xd8, 0x27, 0xed, 0x13, 0xe1, 0x31, 0xef, 0x7c, 0x44,
  1124. 0x9c, 0xce, 0x85, 0x17, 0x38, 0x5a, 0xe3, 0xd8, 0xe9, 0xfd, 0x1e, 0x81, 0xae, 0x9c, 0xd7, 0x8b,
  1125. 0x11, 0x4e, 0x92, 0x08, 0x3a, 0x97, 0x2c, 0x4f, 0x9a, 0xb7, 0x10, 0xda, 0x6a, 0x06, 0x9e, 0xe2,
  1126. 0xb6, 0x41, 0xf8, 0xb3, 0xd4, 0x42, 0xcc, 0x67, 0xe8, 0x25, 0x76, 0x9a, 0xc2, 0x66, 0x1a, 0x94,
  1127. 0x19, 0x0c, 0xe1, 0x43, 0x27, 0x27, 0x1e, 0xad, 0xfb, 0xce, 0xb7, 0x96, 0xfb, 0x5d, 0x6d, 0xf3,
  1128. 0xe1, 0x73, 0xc5, 0x1c, 0xa0, 0xbe, 0x94, 0x2c, 0xe7, 0x1c, 0x04, 0xa9, 0xfe, 0xdf, 0x15, 0x79,
  1129. 0x0c, 0x5e, 0xf8, 0xe2, 0xb9, 0x4a, 0xa0, 0xc5, 0x89, 0x2c, 0xf8, 0x1d, 0x5f, 0xcc, 0xf0, 0xb6,
  1130. 0xe8, 0x31, 0xeb, 0xe5, 0xb4, 0x9d, 0x2a, 0xa8, 0x8d, 0xff, 0x69, 0xf7, 0x83, 0x65, 0xbb, 0xa2,
  1131. 0xdd, 0xcd, 0x97, 0x41, 0x6e, 0xfa, 0xb6, 0xe1, 0x76, 0x7e, 0xa3, 0x24, 0x9b, 0x23, 0x58, 0x0e,
  1132. 0xeb, 0x08, 0x00, 0x96, 0x53, 0xae, 0x6c, 0xb9, 0xaa, 0x5c, 0x9a, 0xf8, 0xee, 0xcd, 0xfd, 0xe5,
  1133. 0xc5, 0x40, 0x62, 0x58, 0x6d, 0xf0, 0x10, 0xd5, 0x85, 0xeb, 0xed, 0x8a, 0x75, 0xe9, 0x8c, 0x2b,
  1134. 0xe7, 0x39, 0xaf, 0xb1, 0x15, 0xdb, 0x4f, 0xe3, 0xa5, 0x24, 0x1d, 0xd2, 0xae, 0x82, 0x88, 0x1a,
  1135. 0x37, 0x4c, 0x6b, 0x30, 0x9d, 0x6f, 0x93, 0x9c, 0x87, 0x99, 0xd1, 0x1c, 0x93, 0x0c, 0xbb, 0xf9,
  1136. 0x70, 0x36, 0x28, 0x56, 0x68, 0x27, 0x2f, 0x1e, 0xf1, 0x86, 0x0a, 0x23, 0x04, 0xe6, 0x72, 0x1f,
  1137. 0x1b, 0x71, 0x45, 0x0b, 0xe7, 0x74, 0x45, 0x8e, 0x7f, 0x94, 0xbc, 0xcd, 0x6c, 0xf8, 0xf3, 0xed,
  1138. 0x44, 0x02, 0x4d, 0x0a, 0xdd, 0xe9, 0xe4, 0x46, 0x31, 0x94, 0x28, 0x9b, 0x5f, 0x05, 0x37, 0xf4,
  1139. 0x05, 0x9c, 0xa3, 0x9c, 0xdf, 0xb7, 0xfb, 0xab, 0xe0, 0x07, 0x26, 0x40, 0x79, 0x12, 0x9a, 0x78,
  1140. 0xf6, 0xb6, 0x30, 0x3d, 0x4e, 0x16, 0x2e, 0x39, 0x96, 0x98, 0x2a, 0x8c, 0xa7, 0xdb, 0xa0, 0x4a,
  1141. 0x3f, 0x42, 0x30, 0xd3, 0x5d, 0xd0, 0x26, 0xd0, 0xc5, 0xd5, 0xa4, 0x10, 0x10
  1142. };
  1143. #endif
  1144. #if defined(LTC_SHA1) && defined(LTC_DES)
  1145. static const unsigned char long_pri_pkcs8_pbe_sha1_des[] = {
  1146. 0x30, 0x82, 0x01, 0x49, 0x30, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  1147. 0x0a, 0x30, 0x0e, 0x04, 0x08, 0x7c, 0x01, 0xae, 0xc9, 0x05, 0x43, 0x40, 0x70, 0x02, 0x02, 0x08,
  1148. 0x00, 0x04, 0x82, 0x01, 0x28, 0xff, 0x96, 0x47, 0x56, 0x02, 0xd5, 0xd3, 0x2a, 0xf0, 0x44, 0x47,
  1149. 0x7e, 0x74, 0x28, 0x62, 0x3f, 0x2b, 0xd4, 0xa9, 0xcc, 0x2c, 0xb7, 0x03, 0xc7, 0xa6, 0x39, 0xde,
  1150. 0xc1, 0x46, 0xf1, 0xcd, 0x53, 0xb8, 0x76, 0xcd, 0xb8, 0xfd, 0xe8, 0x96, 0x1d, 0x52, 0xc5, 0xc2,
  1151. 0x33, 0x2c, 0x2e, 0x4a, 0xe1, 0x83, 0x2e, 0x8a, 0x3a, 0x73, 0xfe, 0x50, 0x70, 0xcf, 0x2a, 0x29,
  1152. 0xd5, 0x8a, 0x77, 0x96, 0xa3, 0x29, 0x7e, 0xfa, 0x74, 0xde, 0x78, 0x31, 0xd6, 0x78, 0x0a, 0x4f,
  1153. 0x67, 0x8e, 0x26, 0xc9, 0x64, 0xf3, 0xde, 0xda, 0x5d, 0x15, 0xc2, 0x6b, 0x22, 0x25, 0x9e, 0x98,
  1154. 0x41, 0x71, 0x4c, 0x09, 0x56, 0x90, 0x44, 0x7d, 0x16, 0xab, 0x7e, 0xd3, 0x75, 0x54, 0xbd, 0x88,
  1155. 0x85, 0x4a, 0x01, 0xf4, 0x17, 0x19, 0xe2, 0x43, 0x5f, 0x31, 0xf9, 0x0b, 0x78, 0xd3, 0xb6, 0xc8,
  1156. 0xa0, 0x29, 0x65, 0x86, 0xbc, 0x4b, 0xcb, 0xe2, 0xe8, 0xe7, 0x06, 0xe2, 0x27, 0xa3, 0x6a, 0xdc,
  1157. 0x9f, 0x42, 0x40, 0xc4, 0x38, 0x49, 0x3b, 0x15, 0x28, 0x82, 0x9f, 0xa0, 0x2d, 0x42, 0x30, 0xa9,
  1158. 0x28, 0x84, 0x41, 0x2b, 0xa3, 0xfb, 0xf1, 0x74, 0xa1, 0xfa, 0xff, 0x9d, 0xb6, 0x7e, 0x9b, 0x9f,
  1159. 0xfa, 0xbd, 0x00, 0x17, 0x17, 0xa6, 0xb5, 0x2a, 0x1f, 0x6b, 0x55, 0x6c, 0xd4, 0x4b, 0xbe, 0xbb,
  1160. 0xa5, 0xa7, 0x9f, 0x0c, 0x90, 0x04, 0x91, 0x09, 0x4d, 0x82, 0xe1, 0x67, 0x21, 0x96, 0x3a, 0x3b,
  1161. 0xcf, 0x7f, 0xe9, 0xb9, 0xcc, 0x56, 0xd8, 0xc7, 0xe4, 0x98, 0x30, 0x11, 0x8f, 0xfd, 0xe5, 0xbc,
  1162. 0x5e, 0xc4, 0x60, 0xe9, 0xd4, 0xc6, 0xf2, 0x60, 0xf3, 0xcd, 0x36, 0xa4, 0xe4, 0x6c, 0xfe, 0xbf,
  1163. 0xab, 0xd5, 0x2f, 0x12, 0xf4, 0xa2, 0xf0, 0xeb, 0x10, 0xd9, 0x74, 0xef, 0x7c, 0x37, 0x8d, 0xdd,
  1164. 0xc1, 0xaa, 0x84, 0xf6, 0xf1, 0xb6, 0x5b, 0x43, 0x51, 0x06, 0x78, 0xae, 0x8e, 0x9d, 0xc5, 0xc9,
  1165. 0x26, 0xdc, 0x05, 0xa3, 0x00, 0xfa, 0x4a, 0x27, 0x5f, 0x19, 0xf3, 0x88, 0x2e, 0x01, 0xb8, 0xe7,
  1166. 0x23, 0x37, 0x77, 0xa1, 0xbb, 0xb0, 0x66, 0xe2, 0xba, 0x10, 0x50, 0x06, 0x65
  1167. };
  1168. #endif
  1169. #if defined(LTC_SHA1) && defined(LTC_RC2)
  1170. static const unsigned char long_pri_pkcs8_pbe_sha1_rc2_64[] = {
  1171. 0x30, 0x82, 0x01, 0x49, 0x30, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  1172. 0x0b, 0x30, 0x0e, 0x04, 0x08, 0x64, 0x3c, 0xdb, 0x86, 0xd9, 0xa0, 0xae, 0x3e, 0x02, 0x02, 0x08,
  1173. 0x00, 0x04, 0x82, 0x01, 0x28, 0x78, 0x85, 0x55, 0x7f, 0x37, 0xb8, 0xf7, 0xff, 0x94, 0x94, 0xf3,
  1174. 0xf2, 0x21, 0x05, 0x6d, 0x75, 0xca, 0x03, 0x1c, 0xa3, 0x9f, 0x47, 0x41, 0x14, 0x57, 0xdd, 0x63,
  1175. 0x71, 0x6c, 0xc2, 0x51, 0x14, 0x4a, 0x0d, 0x63, 0x12, 0xa8, 0x27, 0xf6, 0x3c, 0xb7, 0x47, 0x6d,
  1176. 0xa0, 0x72, 0xfe, 0x60, 0x9f, 0x1c, 0xc8, 0xe4, 0xe5, 0xfe, 0x68, 0x9d, 0x85, 0x0f, 0x8e, 0x52,
  1177. 0x2e, 0x30, 0xd5, 0x81, 0xd8, 0xc9, 0x05, 0x14, 0x1b, 0x1b, 0xf3, 0xbc, 0x95, 0x6d, 0x5d, 0x94,
  1178. 0x71, 0xff, 0xa8, 0xfe, 0xa7, 0x34, 0xff, 0x30, 0xbe, 0x8e, 0xe4, 0x65, 0x6b, 0xd0, 0xa2, 0x43,
  1179. 0x42, 0x14, 0x63, 0x36, 0x6f, 0x5d, 0x79, 0x56, 0x1b, 0x23, 0xd6, 0xdf, 0x39, 0x75, 0x48, 0x07,
  1180. 0xa2, 0x5f, 0x8d, 0x11, 0x7c, 0x95, 0x48, 0x18, 0x2d, 0xdd, 0x92, 0x14, 0x4f, 0xfd, 0x45, 0x7e,
  1181. 0x60, 0x68, 0xde, 0x47, 0x04, 0x0d, 0x0a, 0xa6, 0x3a, 0x30, 0xcb, 0x29, 0xc7, 0x9e, 0x27, 0xc3,
  1182. 0x2d, 0x49, 0xbd, 0x1e, 0xc5, 0xc9, 0xd8, 0xd2, 0x22, 0x72, 0xe2, 0xd0, 0x8e, 0x03, 0xe8, 0x84,
  1183. 0xfd, 0x7e, 0xb8, 0x8a, 0xd7, 0x70, 0x6d, 0x0b, 0xec, 0x67, 0xd0, 0xb3, 0x08, 0x9a, 0x31, 0x32,
  1184. 0x43, 0x1f, 0xa3, 0xd1, 0x6b, 0x3a, 0x63, 0xbc, 0xca, 0x25, 0x1e, 0x55, 0xd7, 0x21, 0x68, 0x77,
  1185. 0xfa, 0x41, 0x70, 0xdc, 0x3a, 0xfb, 0x05, 0x19, 0xd8, 0x8a, 0xe3, 0xe7, 0xfc, 0xf1, 0xc1, 0x0d,
  1186. 0xd4, 0x9e, 0x64, 0xd0, 0x91, 0xa5, 0x4d, 0x7b, 0x8b, 0xd9, 0xee, 0xa7, 0x6b, 0x2b, 0x0f, 0xd9,
  1187. 0xcf, 0xb3, 0xb4, 0x5b, 0x4e, 0xcc, 0xac, 0x53, 0xe5, 0xd3, 0xdd, 0x73, 0x40, 0xa5, 0x35, 0x71,
  1188. 0xeb, 0xca, 0xa7, 0xc0, 0xae, 0x70, 0xdf, 0x14, 0x83, 0xbe, 0xd8, 0x37, 0xfa, 0x8b, 0x14, 0xdb,
  1189. 0x0c, 0x4e, 0x98, 0xc7, 0xe6, 0x40, 0x38, 0x94, 0x69, 0xd4, 0xd4, 0xa9, 0xb5, 0x3f, 0xec, 0xac,
  1190. 0x14, 0x59, 0x46, 0xb5, 0x98, 0xb0, 0x99, 0x89, 0xea, 0xf5, 0x43, 0xb4, 0x47, 0xa9, 0xb1, 0xf2,
  1191. 0x03, 0x2a, 0xaf, 0xd5, 0x5d, 0x81, 0xae, 0x3b, 0xb4, 0x52, 0x11, 0x85, 0xcb
  1192. };
  1193. #endif
  1194. #if defined(LTC_DES)
  1195. static const unsigned char long_pri_pkcs8_pbkdf2_des_cbc[] = {
  1196. 0x30, 0x82, 0x01, 0x6b, 0x30, 0x3d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  1197. 0x0d, 0x30, 0x30, 0x30, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05, 0x0c,
  1198. 0x30, 0x0e, 0x04, 0x08, 0xda, 0x6b, 0x0a, 0x58, 0x7e, 0xd2, 0x9d, 0x38, 0x02, 0x02, 0x08, 0x00,
  1199. 0x30, 0x11, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x07, 0x04, 0x08, 0xcc, 0x5c, 0x19, 0x7c, 0xa6,
  1200. 0x0d, 0x01, 0x4b, 0x04, 0x82, 0x01, 0x28, 0x02, 0x9d, 0xec, 0xa4, 0xe1, 0x42, 0xc4, 0xdb, 0x18,
  1201. 0x32, 0x26, 0x96, 0x8b, 0x87, 0x1a, 0xb7, 0x66, 0x8e, 0xfd, 0x23, 0x1e, 0x1e, 0x20, 0x18, 0xcd,
  1202. 0x81, 0x1b, 0x67, 0x86, 0x78, 0xae, 0xb3, 0x70, 0x81, 0xf9, 0x6a, 0x26, 0x4e, 0x31, 0x64, 0xf8,
  1203. 0x7e, 0xbf, 0xf3, 0xd3, 0xea, 0x7c, 0xda, 0x5d, 0x4d, 0xb7, 0xe2, 0xda, 0x9a, 0x80, 0x94, 0xd1,
  1204. 0x65, 0x5f, 0x57, 0x17, 0xbc, 0xac, 0xd3, 0xb4, 0x94, 0xdc, 0xd0, 0x34, 0xe9, 0xed, 0x57, 0x97,
  1205. 0x53, 0xe9, 0x24, 0x21, 0xac, 0x2b, 0xd1, 0xd9, 0x35, 0x7f, 0xf0, 0x79, 0x14, 0xce, 0x96, 0xe2,
  1206. 0x55, 0xfb, 0xb9, 0x6e, 0xeb, 0xbf, 0xc8, 0xf2, 0x66, 0xc1, 0x42, 0xee, 0x94, 0x22, 0xac, 0x6a,
  1207. 0xe2, 0xf6, 0xba, 0xfc, 0xeb, 0xc1, 0xd0, 0xec, 0x3c, 0x16, 0xa4, 0x36, 0x7a, 0xbf, 0xe9, 0x9d,
  1208. 0x39, 0xd6, 0x32, 0x54, 0x3e, 0x86, 0xcf, 0xe4, 0x32, 0x1c, 0xc5, 0x54, 0x3f, 0x8d, 0x6e, 0xb9,
  1209. 0x6c, 0x3d, 0xd7, 0x68, 0xd7, 0x67, 0xdd, 0x04, 0x0e, 0x8c, 0xfd, 0x62, 0x1a, 0x21, 0xa8, 0xcc,
  1210. 0x67, 0xbd, 0x4f, 0x9b, 0x3c, 0x99, 0xd5, 0xa5, 0x98, 0x12, 0x33, 0x04, 0xcf, 0x1b, 0x58, 0x3f,
  1211. 0xb2, 0x70, 0xfe, 0x92, 0xff, 0x7a, 0x73, 0xf9, 0x37, 0xd5, 0x20, 0x0e, 0x49, 0xed, 0xb3, 0x77,
  1212. 0x73, 0x0f, 0x3e, 0xf8, 0x15, 0xc1, 0xfc, 0x28, 0x47, 0x10, 0xe8, 0x30, 0xee, 0xa9, 0x96, 0xcf,
  1213. 0x39, 0xb6, 0x83, 0xe2, 0x84, 0x1d, 0x0e, 0x65, 0xb7, 0x02, 0x08, 0xf7, 0x8d, 0xe7, 0xf2, 0xcc,
  1214. 0x52, 0xc2, 0xe6, 0x1d, 0xf6, 0x96, 0x17, 0x3e, 0x3f, 0xd8, 0x70, 0x8d, 0x2c, 0x62, 0x00, 0xf3,
  1215. 0x32, 0xbd, 0x1c, 0x6b, 0x4a, 0x0c, 0xc6, 0x46, 0x61, 0x92, 0x1c, 0x01, 0x11, 0xbc, 0x55, 0xdd,
  1216. 0x82, 0xd1, 0xbf, 0x2e, 0x1e, 0x97, 0xbe, 0xa7, 0x6e, 0x5a, 0xcd, 0xc6, 0x8f, 0x38, 0x24, 0x8f,
  1217. 0xb8, 0x36, 0x3d, 0x06, 0x82, 0x14, 0x5b, 0x1a, 0x84, 0x1e, 0x47, 0x53, 0x3a, 0x12, 0x21, 0x23,
  1218. 0xbe, 0xe4, 0xf4, 0x57, 0xc7, 0x31, 0x45, 0x24, 0x46, 0x94, 0x53, 0x0b, 0x1d, 0xcd, 0x57
  1219. };
  1220. #endif
  1221. #if defined(LTC_DES)
  1222. static const unsigned char long_pri_pkcs8_pbkdf2_des_ede3_cbc[] = {
  1223. 0x30, 0x82, 0x01, 0x6e, 0x30, 0x40, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  1224. 0x0d, 0x30, 0x33, 0x30, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05, 0x0c,
  1225. 0x30, 0x0e, 0x04, 0x08, 0x6a, 0x99, 0x55, 0x06, 0x40, 0xd5, 0xe6, 0xc9, 0x02, 0x02, 0x08, 0x00,
  1226. 0x30, 0x14, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x03, 0x07, 0x04, 0x08, 0x7f, 0xf2,
  1227. 0xa7, 0xa3, 0x2c, 0xbb, 0x8e, 0x78, 0x04, 0x82, 0x01, 0x28, 0x55, 0x4d, 0xcb, 0xab, 0xb8, 0x6e,
  1228. 0xcf, 0x00, 0xd2, 0xe8, 0x1e, 0x0e, 0xe1, 0x8f, 0x51, 0x8e, 0x32, 0x68, 0xaf, 0x44, 0xa6, 0xf2,
  1229. 0x9e, 0x11, 0xd7, 0x0f, 0xa7, 0xd5, 0x74, 0x77, 0xbc, 0x6b, 0x53, 0x40, 0x70, 0xb6, 0x02, 0xdb,
  1230. 0xa6, 0x2e, 0xc7, 0x20, 0x15, 0x78, 0x91, 0xcc, 0x5b, 0xa7, 0x15, 0x58, 0x65, 0xeb, 0xc7, 0x6f,
  1231. 0xb8, 0x14, 0xc9, 0x5f, 0x89, 0x58, 0xe2, 0xab, 0x69, 0x17, 0xe2, 0xe7, 0xe0, 0xa4, 0x59, 0xb7,
  1232. 0x6a, 0xc2, 0xe5, 0xba, 0x03, 0x0e, 0xcc, 0x0a, 0xb1, 0xf0, 0x69, 0xb2, 0x90, 0xac, 0x30, 0x79,
  1233. 0xd4, 0xa3, 0x90, 0xa2, 0x60, 0x37, 0x7d, 0xf8, 0xd9, 0x49, 0xa3, 0x0b, 0x6d, 0xd9, 0x98, 0x9e,
  1234. 0xb0, 0x6a, 0xad, 0x97, 0x08, 0xf1, 0xfd, 0xec, 0xf8, 0xa7, 0x3c, 0xf6, 0x48, 0x81, 0x5b, 0x6d,
  1235. 0x19, 0xcc, 0xed, 0x49, 0x94, 0x05, 0x6e, 0xa4, 0x9b, 0x58, 0xdd, 0xaf, 0xd7, 0x3d, 0x12, 0xe6,
  1236. 0xf4, 0x12, 0x46, 0xd9, 0x82, 0xde, 0xb7, 0xc4, 0xeb, 0x1c, 0x3a, 0xef, 0x93, 0x82, 0x3d, 0xf8,
  1237. 0x55, 0x88, 0xe5, 0x54, 0xd6, 0x74, 0x1c, 0x20, 0xbd, 0x40, 0x65, 0x99, 0x19, 0x5f, 0x25, 0x62,
  1238. 0x35, 0x6d, 0x32, 0x64, 0xd7, 0xa1, 0x45, 0xa8, 0xc4, 0x8d, 0xe0, 0x6d, 0x14, 0x85, 0x84, 0x75,
  1239. 0x62, 0x0f, 0xb0, 0xe9, 0xb1, 0xca, 0x31, 0x97, 0x22, 0x41, 0xb3, 0xf5, 0xdf, 0x5c, 0xbf, 0x3f,
  1240. 0x4f, 0x01, 0xf8, 0xe7, 0xbc, 0xdc, 0xb2, 0x9a, 0x7d, 0x0c, 0x96, 0x38, 0x48, 0x7a, 0x1b, 0x89,
  1241. 0x2b, 0xab, 0xa6, 0xbd, 0xee, 0x7a, 0xf8, 0x85, 0x82, 0x80, 0x8c, 0x3b, 0x05, 0x3c, 0x40, 0x69,
  1242. 0x97, 0x0a, 0x4c, 0x45, 0xae, 0x38, 0x22, 0xc5, 0x95, 0xf2, 0x4f, 0x0c, 0xd5, 0x54, 0x23, 0x92,
  1243. 0x9b, 0x06, 0x81, 0xca, 0xa5, 0x1e, 0x91, 0x7e, 0x2b, 0x85, 0xb4, 0xd4, 0xeb, 0xb6, 0xee, 0x22,
  1244. 0x10, 0x72, 0xaf, 0x9e, 0x6d, 0xcc, 0x16, 0x24, 0x01, 0x44, 0x48, 0xaa, 0xc9, 0xf8, 0x38, 0x72,
  1245. 0x7a, 0x35, 0x94, 0x20, 0x58, 0xa2, 0x1c, 0x81, 0xaf, 0x47, 0x3b, 0xb8, 0x23, 0xbb, 0x71, 0x09,
  1246. 0xbf, 0x93
  1247. };
  1248. #endif
  1249. #if defined(LTC_RC2)
  1250. static const unsigned char long_pri_pkcs8_pbkdf2_rc2_cbc[] = {
  1251. 0x30, 0x82, 0x01, 0x76, 0x30, 0x48, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  1252. 0x0d, 0x30, 0x3b, 0x30, 0x1e, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05, 0x0c,
  1253. 0x30, 0x11, 0x04, 0x08, 0xbf, 0xef, 0x1a, 0x42, 0x5d, 0xc3, 0x6b, 0x0f, 0x02, 0x02, 0x08, 0x00,
  1254. 0x02, 0x01, 0x10, 0x30, 0x19, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x03, 0x02, 0x30,
  1255. 0x0d, 0x02, 0x01, 0x3a, 0x04, 0x08, 0xfe, 0xf2, 0x09, 0x0c, 0xa4, 0xd0, 0xe6, 0x83, 0x04, 0x82,
  1256. 0x01, 0x28, 0x61, 0x18, 0x73, 0xb7, 0x9d, 0x58, 0xc8, 0x4a, 0xf4, 0x24, 0xec, 0xb4, 0xe6, 0x24,
  1257. 0xa7, 0xf0, 0x1e, 0xea, 0xc3, 0x57, 0x44, 0xb7, 0x5a, 0x77, 0xe5, 0x3c, 0x1c, 0x6a, 0x6b, 0x70,
  1258. 0x6e, 0x64, 0x35, 0xa5, 0x5d, 0x32, 0xe3, 0xce, 0xe8, 0x79, 0xa4, 0x7f, 0x2b, 0xfc, 0xcb, 0x07,
  1259. 0x62, 0xcd, 0xc9, 0x15, 0x30, 0xdf, 0x69, 0xae, 0xe8, 0xb4, 0x83, 0xec, 0x2a, 0xaf, 0xb3, 0x29,
  1260. 0x92, 0x77, 0xf3, 0x31, 0x4d, 0x5f, 0xcb, 0xea, 0xa2, 0x4d, 0xfb, 0xa1, 0x68, 0xbe, 0x00, 0x01,
  1261. 0x6d, 0x3f, 0xc6, 0xc1, 0x13, 0xee, 0xb0, 0x5a, 0x52, 0xce, 0xdc, 0x12, 0xf8, 0x42, 0x22, 0x2f,
  1262. 0x57, 0x2e, 0x54, 0xac, 0x48, 0x31, 0x4d, 0x3c, 0xa1, 0x97, 0x5e, 0x17, 0x74, 0x88, 0x9b, 0x31,
  1263. 0x91, 0x69, 0x00, 0x00, 0x15, 0x2c, 0xc2, 0xac, 0x70, 0x84, 0x9c, 0x7e, 0x5d, 0xc9, 0xee, 0x06,
  1264. 0xcc, 0x38, 0x9d, 0x7d, 0xea, 0x71, 0xc3, 0x4f, 0x99, 0x08, 0xde, 0xb0, 0x1b, 0x3b, 0x2a, 0xbd,
  1265. 0x7e, 0x01, 0x3b, 0x5e, 0xe5, 0xc2, 0x54, 0xf2, 0x30, 0xe5, 0xa0, 0xf3, 0x69, 0x87, 0x77, 0xed,
  1266. 0xa1, 0x37, 0x76, 0x6a, 0xec, 0xe2, 0x9c, 0x8d, 0x4c, 0xe9, 0xf4, 0xd0, 0xca, 0xb5, 0x8f, 0xd0,
  1267. 0x63, 0x17, 0x41, 0xcb, 0x29, 0x58, 0x4f, 0x2a, 0xd1, 0xe1, 0x03, 0x73, 0x09, 0xcc, 0x93, 0xc6,
  1268. 0xde, 0x1e, 0x34, 0x0f, 0xb3, 0x67, 0xfd, 0x5e, 0x49, 0x16, 0x84, 0x84, 0x6a, 0x8f, 0x55, 0x22,
  1269. 0x0b, 0xe4, 0xd8, 0xee, 0x2e, 0x9f, 0x25, 0x19, 0x89, 0x19, 0xe6, 0x8d, 0x64, 0x31, 0x38, 0x68,
  1270. 0xfa, 0x40, 0x84, 0xca, 0x39, 0xef, 0x1a, 0x4a, 0xe9, 0x04, 0xee, 0xcc, 0x4a, 0xea, 0x19, 0x96,
  1271. 0xa4, 0xcd, 0x62, 0x76, 0xb3, 0xc4, 0x2c, 0x23, 0x75, 0x24, 0xcd, 0x49, 0xe2, 0x17, 0x81, 0x45,
  1272. 0x24, 0x55, 0xeb, 0xe1, 0xb4, 0xeb, 0xda, 0xc5, 0x56, 0xac, 0xfa, 0x30, 0xbd, 0x05, 0xbb, 0x03,
  1273. 0x65, 0x50, 0xdc, 0xbf, 0xdf, 0xff, 0x2a, 0x80, 0x85, 0x6d, 0x6a, 0x5c, 0x93, 0xb8, 0x81, 0xc4,
  1274. 0xca, 0x91, 0x08, 0x7b, 0x8a, 0x9d, 0xe9, 0x2d, 0xfc, 0x3b
  1275. };
  1276. #endif
  1277. #if defined(LTC_SHA224) && defined(LTC_DES)
  1278. static const unsigned char long_pri_pkcs8_pbkdf2_sha224_des_ede3_cbc[] = {
  1279. 0x30, 0x82, 0x01, 0x7c, 0x30, 0x4e, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  1280. 0x0d, 0x30, 0x41, 0x30, 0x29, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05, 0x0c,
  1281. 0x30, 0x1c, 0x04, 0x08, 0xb2, 0x82, 0x71, 0xc5, 0xd6, 0x3c, 0x2b, 0x92, 0x02, 0x02, 0x08, 0x00,
  1282. 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x08, 0x05, 0x00, 0x30, 0x14,
  1283. 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x03, 0x07, 0x04, 0x08, 0x4a, 0x46, 0x2a, 0xa9,
  1284. 0xd5, 0x9f, 0x79, 0xea, 0x04, 0x82, 0x01, 0x28, 0xc4, 0x27, 0x05, 0xa8, 0x01, 0xa7, 0xc9, 0x0d,
  1285. 0x0e, 0x74, 0x06, 0x4a, 0xb8, 0x07, 0x9f, 0x7b, 0x0f, 0x82, 0xfd, 0x2c, 0xb5, 0x4f, 0x63, 0xed,
  1286. 0xed, 0x86, 0x96, 0x79, 0x08, 0x2d, 0x5f, 0x6d, 0x8c, 0x83, 0xc9, 0xcc, 0xd4, 0x9b, 0x0a, 0x81,
  1287. 0x60, 0x22, 0x09, 0xb9, 0x12, 0xca, 0xf1, 0xad, 0x61, 0x22, 0xf0, 0x6b, 0xdb, 0x52, 0x99, 0xae,
  1288. 0x70, 0x2b, 0x61, 0x63, 0xdc, 0x2f, 0xc1, 0xd3, 0xb5, 0x28, 0xbb, 0xa1, 0xd2, 0xb7, 0xaf, 0xbb,
  1289. 0x86, 0xa1, 0x1b, 0x46, 0x0a, 0xc9, 0xab, 0x44, 0xd2, 0x9c, 0x16, 0x18, 0x8b, 0x4a, 0x92, 0x56,
  1290. 0x5b, 0x50, 0x39, 0x1b, 0x88, 0x50, 0x92, 0x35, 0xb8, 0x85, 0xc3, 0xaa, 0x56, 0x76, 0xde, 0xbf,
  1291. 0x68, 0x91, 0x2e, 0xc8, 0x28, 0x29, 0xd8, 0x71, 0x60, 0xe3, 0xf0, 0x5a, 0x66, 0x85, 0xdd, 0x6b,
  1292. 0x5c, 0xaf, 0xf1, 0x28, 0xf8, 0xdc, 0xa7, 0x8d, 0xc4, 0x9b, 0xcb, 0xb2, 0x99, 0x34, 0x4d, 0x76,
  1293. 0xa0, 0x8b, 0xf2, 0x18, 0x8e, 0x42, 0xe0, 0x79, 0xc3, 0xeb, 0x0f, 0x00, 0xe7, 0xbe, 0x83, 0xdf,
  1294. 0xba, 0xa5, 0xf1, 0x81, 0x05, 0x1c, 0xc9, 0xda, 0xea, 0xe1, 0xc4, 0x38, 0x24, 0x1e, 0xcf, 0xea,
  1295. 0x22, 0x05, 0x75, 0x43, 0xfe, 0xfe, 0x14, 0xf7, 0x6d, 0x41, 0x67, 0xcf, 0xfd, 0x57, 0xa7, 0xfc,
  1296. 0x22, 0x03, 0x14, 0xc1, 0xf6, 0x4d, 0x40, 0x4e, 0xf1, 0xec, 0x72, 0xec, 0x3c, 0xb1, 0x87, 0x44,
  1297. 0xe9, 0x72, 0xc5, 0x8b, 0x48, 0xd9, 0x98, 0x08, 0x55, 0xc5, 0x40, 0x26, 0xf5, 0x8d, 0x73, 0x5e,
  1298. 0x35, 0x98, 0x71, 0x09, 0x98, 0xfa, 0xb7, 0x1c, 0x35, 0xcd, 0xd4, 0xf1, 0x65, 0xb4, 0x59, 0xdb,
  1299. 0x9e, 0x79, 0xe7, 0x21, 0x99, 0xd7, 0x9e, 0x8c, 0x13, 0x77, 0x0c, 0x5e, 0xae, 0x43, 0x82, 0xf1,
  1300. 0x83, 0x79, 0x7d, 0x37, 0x51, 0xde, 0x65, 0x26, 0x1f, 0x8f, 0x81, 0x1c, 0x55, 0x40, 0xec, 0xaf,
  1301. 0x3f, 0x0a, 0x68, 0xd2, 0xc7, 0x59, 0x47, 0xda, 0x78, 0x0c, 0x0e, 0x59, 0x6a, 0x93, 0xcd, 0x05,
  1302. 0x09, 0x51, 0x47, 0xb1, 0x45, 0x3f, 0x67, 0xf8, 0x76, 0x50, 0x76, 0xa3, 0x2d, 0x31, 0x17, 0x73
  1303. };
  1304. #endif
  1305. #if defined(LTC_SHA256) && defined(LTC_DES)
  1306. static const unsigned char long_pri_pkcs8_pbkdf2_sha256_des_ede3_cbc[] = {
  1307. 0x30, 0x82, 0x01, 0x7c, 0x30, 0x4e, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  1308. 0x0d, 0x30, 0x41, 0x30, 0x29, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05, 0x0c,
  1309. 0x30, 0x1c, 0x04, 0x08, 0x93, 0x6e, 0x0a, 0x02, 0x8e, 0x72, 0xac, 0x98, 0x02, 0x02, 0x08, 0x00,
  1310. 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x09, 0x05, 0x00, 0x30, 0x14,
  1311. 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x03, 0x07, 0x04, 0x08, 0x89, 0xa4, 0xc9, 0xd9,
  1312. 0x82, 0xfa, 0x02, 0x76, 0x04, 0x82, 0x01, 0x28, 0xec, 0xd9, 0xee, 0xbf, 0xfa, 0xe6, 0x51, 0xdb,
  1313. 0x02, 0xcb, 0xf3, 0x2c, 0x55, 0xdb, 0x83, 0x90, 0x5d, 0x9e, 0xf6, 0xbe, 0x10, 0xae, 0x35, 0x8c,
  1314. 0x22, 0x39, 0xfc, 0xf9, 0xd1, 0x23, 0x27, 0x68, 0xd3, 0x15, 0x46, 0xed, 0x5d, 0x15, 0xfb, 0xdf,
  1315. 0x6f, 0xe1, 0x01, 0x1c, 0xed, 0x4c, 0xfc, 0x78, 0x94, 0x47, 0x71, 0x92, 0xbc, 0xa1, 0xa6, 0x06,
  1316. 0x74, 0x22, 0xcc, 0xbb, 0x49, 0x98, 0x43, 0xf1, 0xc2, 0xde, 0x4e, 0xeb, 0x56, 0x0e, 0x03, 0xc1,
  1317. 0xf1, 0xc1, 0x80, 0x4b, 0x70, 0xd0, 0x8f, 0xf3, 0xd8, 0x18, 0x08, 0x41, 0x7a, 0xf9, 0x8b, 0x74,
  1318. 0xe5, 0x28, 0x61, 0x77, 0x2f, 0x84, 0xb3, 0xb3, 0x68, 0xce, 0x19, 0xf0, 0xc6, 0xa9, 0xc1, 0x29,
  1319. 0x96, 0xca, 0x3b, 0xdb, 0x13, 0x99, 0x86, 0xbe, 0x21, 0x0d, 0x00, 0xd7, 0x30, 0x15, 0x74, 0xfb,
  1320. 0x43, 0xf7, 0x14, 0x97, 0x6d, 0xed, 0xeb, 0xe3, 0x4d, 0x67, 0x80, 0x35, 0x03, 0x69, 0x0d, 0xbe,
  1321. 0xf1, 0x99, 0x6b, 0x53, 0xb7, 0xa3, 0xdf, 0xf4, 0xc3, 0xda, 0x20, 0x9b, 0xbf, 0xf9, 0x3f, 0x19,
  1322. 0xae, 0xd5, 0x37, 0x91, 0x36, 0x42, 0xf3, 0x7d, 0xad, 0x40, 0x3c, 0x2a, 0x7f, 0x2d, 0xf1, 0x79,
  1323. 0xee, 0x4c, 0x08, 0x3a, 0xd6, 0x35, 0x9b, 0xc9, 0xff, 0xd8, 0x41, 0x41, 0xd1, 0xc6, 0xa1, 0xba,
  1324. 0x4d, 0xc6, 0xb7, 0x85, 0x05, 0xa1, 0x8e, 0xeb, 0xd1, 0xd2, 0x3a, 0x13, 0xd7, 0xbd, 0xb0, 0x02,
  1325. 0xfe, 0x54, 0xfe, 0xf4, 0xfd, 0x31, 0x0c, 0x42, 0x78, 0xb9, 0x17, 0x90, 0x36, 0x17, 0xb8, 0x1a,
  1326. 0x08, 0xe8, 0x7e, 0x5f, 0xbb, 0x30, 0xc2, 0xec, 0xd5, 0x08, 0xbc, 0xae, 0x2f, 0xe0, 0xca, 0xf2,
  1327. 0x44, 0x2c, 0xa4, 0xb5, 0xec, 0xb9, 0xc2, 0xa3, 0x4a, 0x1a, 0x49, 0xfb, 0x3e, 0x5c, 0xb5, 0xd8,
  1328. 0xb6, 0xf0, 0xbc, 0xa2, 0xda, 0xaa, 0x7a, 0x05, 0x4d, 0x06, 0xc0, 0x4b, 0x8f, 0x59, 0xce, 0x56,
  1329. 0x02, 0x26, 0xb2, 0xa0, 0x5f, 0x74, 0xbb, 0x0b, 0x01, 0x1c, 0xb2, 0x0b, 0x8a, 0x80, 0xa4, 0x5d,
  1330. 0x6e, 0x52, 0x24, 0xd0, 0xbe, 0xf5, 0x8e, 0x9e, 0x9e, 0x02, 0x40, 0x08, 0x99, 0xe0, 0x2c, 0xf9
  1331. };
  1332. #endif
  1333. #if defined(LTC_SHA384) && defined(LTC_DES)
  1334. static const unsigned char long_pri_pkcs8_pbkdf2_sha384_des_ede3_cbc[] = {
  1335. 0x30, 0x82, 0x01, 0x7c, 0x30, 0x4e, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  1336. 0x0d, 0x30, 0x41, 0x30, 0x29, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05, 0x0c,
  1337. 0x30, 0x1c, 0x04, 0x08, 0xfd, 0x6c, 0xdf, 0x0b, 0x23, 0xed, 0x71, 0xf7, 0x02, 0x02, 0x08, 0x00,
  1338. 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x0a, 0x05, 0x00, 0x30, 0x14,
  1339. 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x03, 0x07, 0x04, 0x08, 0x99, 0xd0, 0x84, 0x7d,
  1340. 0x6d, 0x4e, 0x82, 0xe1, 0x04, 0x82, 0x01, 0x28, 0xac, 0x9a, 0x2c, 0x71, 0xdf, 0x1a, 0x19, 0x38,
  1341. 0xee, 0xc4, 0x9d, 0x7a, 0x27, 0xe0, 0xb9, 0x69, 0x32, 0xed, 0xe7, 0xa1, 0x77, 0x16, 0x60, 0x18,
  1342. 0x7a, 0xf1, 0x47, 0xc1, 0x98, 0x48, 0xa4, 0xff, 0xab, 0x83, 0x1a, 0x7d, 0xe3, 0xdb, 0xcc, 0xf0,
  1343. 0x40, 0x94, 0x3a, 0x6a, 0x3f, 0xf7, 0x88, 0x19, 0x59, 0xf4, 0xd8, 0x1b, 0x87, 0x14, 0x5b, 0x9c,
  1344. 0x1f, 0xc5, 0xaf, 0x80, 0xe8, 0x06, 0xdb, 0xfa, 0x2c, 0xac, 0x61, 0x1c, 0xec, 0xec, 0x99, 0x5e,
  1345. 0x06, 0x6e, 0x68, 0x4c, 0xb0, 0xc8, 0x6f, 0x74, 0x2c, 0x1e, 0x58, 0x2f, 0x49, 0x82, 0xa4, 0x2b,
  1346. 0xb4, 0x4a, 0x2d, 0x77, 0x13, 0x87, 0xed, 0xbd, 0x71, 0x5a, 0x29, 0x29, 0x0c, 0x88, 0x4a, 0xf3,
  1347. 0x76, 0x37, 0x7e, 0x04, 0x3c, 0x45, 0x76, 0x98, 0x22, 0x20, 0x97, 0xef, 0xae, 0x4a, 0xa9, 0x08,
  1348. 0x54, 0xef, 0x43, 0xe0, 0x86, 0x54, 0x72, 0x44, 0xd1, 0x25, 0x9c, 0xb6, 0x7d, 0x88, 0xbd, 0x8f,
  1349. 0xbe, 0xcb, 0xa8, 0x63, 0xfe, 0x66, 0x54, 0xa2, 0xce, 0x77, 0x19, 0x7e, 0xdd, 0xf7, 0x4d, 0xdc,
  1350. 0xb1, 0xf7, 0xbf, 0x3c, 0xb5, 0xd2, 0x30, 0x9d, 0x3c, 0x35, 0x09, 0x37, 0xae, 0xae, 0x0f, 0x0b,
  1351. 0x9d, 0xf5, 0x10, 0xae, 0x56, 0x83, 0x4f, 0xd8, 0xcd, 0xfe, 0xb7, 0xa9, 0x54, 0xf9, 0xb3, 0x89,
  1352. 0xf6, 0x9a, 0x11, 0x60, 0x04, 0x4d, 0x80, 0xaf, 0x74, 0x73, 0x2d, 0xc4, 0x24, 0x23, 0xaa, 0x50,
  1353. 0x4c, 0xf1, 0xd6, 0x2d, 0xc6, 0x74, 0xeb, 0x62, 0x02, 0xda, 0x81, 0x68, 0xc8, 0x68, 0xf0, 0x82,
  1354. 0x71, 0xb2, 0xa5, 0x8e, 0x45, 0x93, 0x29, 0x94, 0x8f, 0xec, 0x11, 0x65, 0xcc, 0xd6, 0x4c, 0x2e,
  1355. 0x0d, 0x4e, 0x45, 0xb4, 0x4e, 0x97, 0x38, 0xd0, 0xc2, 0x61, 0x43, 0x78, 0xa4, 0x08, 0x0a, 0x58,
  1356. 0x3f, 0x66, 0xdb, 0x34, 0x42, 0x17, 0x42, 0x92, 0x04, 0x9a, 0x2d, 0x73, 0xaf, 0x58, 0x38, 0xc8,
  1357. 0x3f, 0x5b, 0x83, 0x95, 0x3d, 0xae, 0xae, 0x60, 0x2b, 0x6d, 0xd9, 0xb4, 0xe3, 0x97, 0x6b, 0x49,
  1358. 0xef, 0xd9, 0x68, 0xbb, 0x8d, 0x3a, 0x7e, 0xcb, 0x57, 0x33, 0xf5, 0x1a, 0x8d, 0xb4, 0x6d, 0xfb
  1359. };
  1360. #endif
  1361. #if defined(LTC_SHA512) && defined(LTC_DES)
  1362. static const unsigned char long_pri_pkcs8_pbkdf2_sha512_des_ede3_cbc[] = {
  1363. 0x30, 0x82, 0x01, 0x7c, 0x30, 0x4e, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  1364. 0x0d, 0x30, 0x41, 0x30, 0x29, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05, 0x0c,
  1365. 0x30, 0x1c, 0x04, 0x08, 0xad, 0xb1, 0xe1, 0x21, 0xdc, 0xe5, 0x09, 0xee, 0x02, 0x02, 0x08, 0x00,
  1366. 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x0b, 0x05, 0x00, 0x30, 0x14,
  1367. 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x03, 0x07, 0x04, 0x08, 0x1a, 0x8b, 0x81, 0x3b,
  1368. 0x97, 0x7d, 0xfa, 0x51, 0x04, 0x82, 0x01, 0x28, 0x6d, 0x6f, 0x93, 0x77, 0xcb, 0x52, 0x2d, 0x3b,
  1369. 0x82, 0x12, 0x80, 0xce, 0x9e, 0x69, 0x03, 0xe4, 0x64, 0xa1, 0x4b, 0x8e, 0x60, 0x51, 0x4d, 0x08,
  1370. 0xe1, 0x25, 0x5d, 0xe6, 0xed, 0x20, 0x23, 0x4c, 0x4e, 0xa3, 0xe8, 0xab, 0x7a, 0xf8, 0x54, 0x65,
  1371. 0x22, 0x92, 0x0c, 0x45, 0xab, 0x1c, 0xe2, 0x68, 0x4e, 0xf3, 0xa9, 0x61, 0xd6, 0x44, 0x9d, 0x55,
  1372. 0x19, 0xc6, 0xd9, 0x2a, 0x0d, 0x45, 0x7d, 0xca, 0xa4, 0x41, 0xb5, 0x6d, 0xd5, 0x09, 0xf2, 0xb6,
  1373. 0x81, 0x95, 0x64, 0xdb, 0x2b, 0xed, 0x83, 0x6b, 0x44, 0xa6, 0xce, 0x36, 0x8d, 0x23, 0x89, 0xb6,
  1374. 0xf3, 0xb0, 0xe0, 0xcf, 0x57, 0x72, 0xc7, 0x61, 0x3f, 0x29, 0xb9, 0xea, 0xe8, 0x7a, 0xca, 0x43,
  1375. 0x90, 0x79, 0x81, 0x8a, 0xe2, 0x3c, 0xd1, 0xa6, 0xd9, 0x09, 0xd8, 0x7d, 0xd0, 0x90, 0x69, 0x7e,
  1376. 0xdd, 0x40, 0xde, 0xba, 0x11, 0xc6, 0x6f, 0x75, 0xfc, 0xc3, 0x99, 0x43, 0xd2, 0xa4, 0x16, 0x2e,
  1377. 0x95, 0x99, 0x12, 0x77, 0xe8, 0x86, 0x9a, 0xf9, 0x97, 0xf4, 0x43, 0x99, 0x1d, 0x7b, 0xe0, 0x69,
  1378. 0xb0, 0xe9, 0x45, 0xd0, 0x0b, 0xaa, 0xd0, 0xa9, 0x90, 0x85, 0x39, 0xd9, 0xe0, 0xe4, 0xe5, 0xf3,
  1379. 0xcf, 0xb6, 0x60, 0x63, 0x51, 0x0b, 0xd8, 0x3d, 0xa2, 0x0f, 0xf6, 0x53, 0x09, 0x2e, 0x11, 0xc4,
  1380. 0xe6, 0xe3, 0xfa, 0xfb, 0x9f, 0x4d, 0xf4, 0xef, 0xb2, 0xf6, 0x9b, 0xc6, 0xb3, 0x75, 0x66, 0xfd,
  1381. 0x1b, 0x44, 0xba, 0x3c, 0xa8, 0x51, 0xbe, 0x97, 0xf1, 0x54, 0xb5, 0xcc, 0x6f, 0x5f, 0x1d, 0x9b,
  1382. 0xee, 0xed, 0x7a, 0x82, 0xfa, 0x40, 0x39, 0xa7, 0xf5, 0x8e, 0x5e, 0x42, 0xfa, 0x37, 0xcc, 0xe8,
  1383. 0x99, 0x38, 0xc1, 0xab, 0x83, 0xb8, 0x3c, 0x25, 0x17, 0x5f, 0xb7, 0x45, 0x0f, 0xcd, 0xec, 0x2a,
  1384. 0x47, 0x07, 0x02, 0xba, 0x92, 0xc1, 0x79, 0xf1, 0x95, 0xc7, 0x83, 0x46, 0xd7, 0x9e, 0x04, 0x96,
  1385. 0x3c, 0x5d, 0x7e, 0x70, 0xe6, 0x2b, 0x72, 0x70, 0x42, 0x66, 0x17, 0x0e, 0xc3, 0xcf, 0x32, 0x28,
  1386. 0x0c, 0xf9, 0x46, 0x38, 0xb7, 0x64, 0xd6, 0x51, 0xf9, 0xbd, 0x57, 0xf2, 0x7a, 0xcc, 0x02, 0xe3
  1387. };
  1388. #endif
  1389. static const unsigned char long_pric[] = { /* private + compressed public, explicit curve params */
  1390. 0x30, 0x81, 0xd3, 0x02, 0x01, 0x01, 0x04, 0x20, 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b,
  1391. 0xba, 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2, 0xf7, 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f,
  1392. 0x5f, 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd, 0x23, 0xa0, 0x81, 0x85, 0x30, 0x81, 0x82, 0x02, 0x01,
  1393. 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00, 0xff,
  1394. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1395. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f, 0x30,
  1396. 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04, 0x21, 0x02, 0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc,
  1397. 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce,
  1398. 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff,
  1399. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xba, 0xae, 0xdc,
  1400. 0xe6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01, 0x01,
  1401. 0xa1, 0x24, 0x03, 0x22, 0x00, 0x03, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf,
  1402. 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9,
  1403. 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16
  1404. };
  1405. static const unsigned char long_pric_pkcs8[] = { /* private + compressed public, explicit curve params, PKCS8 */
  1406. 0x30, 0x81, 0xe3, 0x02, 0x01, 0x00, 0x30, 0x81, 0x8e, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d,
  1407. 0x02, 0x01, 0x30, 0x81, 0x82, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce,
  1408. 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1409. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1410. 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04, 0x21,
  1411. 0x02, 0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b,
  1412. 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17,
  1413. 0x98, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1414. 0xff, 0xff, 0xff, 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5e, 0x8c,
  1415. 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01, 0x01, 0x04, 0x4d, 0x30, 0x4b, 0x02, 0x01, 0x01, 0x04, 0x20,
  1416. 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b, 0xba, 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2, 0xf7,
  1417. 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f, 0x5f, 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd, 0x23,
  1418. 0xa1, 0x24, 0x03, 0x22, 0x00, 0x03, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf,
  1419. 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9,
  1420. 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16
  1421. };
  1422. static const unsigned char long_pub[] = { /* long public, explicit curve params */
  1423. 0x30, 0x81, 0xf5, 0x30, 0x81, 0xae, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x30,
  1424. 0x81, 0xa2, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01,
  1425. 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1426. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff,
  1427. 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04, 0x41, 0x04, 0x79, 0xbe,
  1428. 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, 0x02, 0x9b,
  1429. 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98, 0x48, 0x3a,
  1430. 0xda, 0x77, 0x26, 0xa3, 0xc4, 0x65, 0x5d, 0xa4, 0xfb, 0xfc, 0x0e, 0x11, 0x08, 0xa8, 0xfd, 0x17,
  1431. 0xb4, 0x48, 0xa6, 0x85, 0x54, 0x19, 0x9c, 0x47, 0xd0, 0x8f, 0xfb, 0x10, 0xd4, 0xb8, 0x02, 0x21,
  1432. 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1433. 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41,
  1434. 0x41, 0x02, 0x01, 0x01, 0x03, 0x42, 0x00, 0x04, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e,
  1435. 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e,
  1436. 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16, 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a,
  1437. 0xb7, 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62, 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5,
  1438. 0x6e, 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d
  1439. };
  1440. static const unsigned char long_pubc[] = { /* compressed public, explicit curve params */
  1441. 0x30, 0x81, 0xb5, 0x30, 0x81, 0x8e, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x30,
  1442. 0x81, 0x82, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01,
  1443. 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1444. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff,
  1445. 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04, 0x21, 0x02, 0x79, 0xbe,
  1446. 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, 0x02, 0x9b,
  1447. 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98, 0x02, 0x21,
  1448. 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1449. 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41,
  1450. 0x41, 0x02, 0x01, 0x01, 0x03, 0x22, 0x00, 0x03, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e,
  1451. 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e,
  1452. 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16
  1453. };
  1454. static const unsigned char short_pri[] = { /* private + long public, curve by OID */
  1455. 0x30, 0x74, 0x02, 0x01, 0x01, 0x04, 0x20, 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b, 0xba,
  1456. 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2, 0xf7, 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f, 0x5f,
  1457. 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd, 0x23, 0xa0, 0x07, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x0a,
  1458. 0xa1, 0x44, 0x03, 0x42, 0x00, 0x04, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf,
  1459. 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9,
  1460. 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16, 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a, 0xb7, 0x6c,
  1461. 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62, 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5, 0x6e, 0x4b,
  1462. 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d
  1463. };
  1464. static const unsigned char short_pri_pkcs8[] = { /* private + long public, curve by OID, PKCS8 */
  1465. 0x30, 0x81, 0x84, 0x02, 0x01, 0x00, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02,
  1466. 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x0a, 0x04, 0x6d, 0x30, 0x6b, 0x02, 0x01, 0x01, 0x04,
  1467. 0x20, 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b, 0xba, 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2,
  1468. 0xf7, 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f, 0x5f, 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd,
  1469. 0x23, 0xa1, 0x44, 0x03, 0x42, 0x00, 0x04, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1,
  1470. 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5,
  1471. 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16, 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a, 0xb7,
  1472. 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62, 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5, 0x6e,
  1473. 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d
  1474. };
  1475. static const unsigned char short_pric[] = { /* private + compressed public, curve by OID */
  1476. 0x30, 0x54, 0x02, 0x01, 0x01, 0x04, 0x20, 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b, 0xba,
  1477. 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2, 0xf7, 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f, 0x5f,
  1478. 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd, 0x23, 0xa0, 0x07, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x0a,
  1479. 0xa1, 0x24, 0x03, 0x22, 0x00, 0x03, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf,
  1480. 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9,
  1481. 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16
  1482. };
  1483. static const unsigned char short_pric_pkcs8[] = { /* private + compressed public, curve by OID, PKCS8 */
  1484. 0x30, 0x64, 0x02, 0x01, 0x00, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01,
  1485. 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x0a, 0x04, 0x4d, 0x30, 0x4b, 0x02, 0x01, 0x01, 0x04, 0x20,
  1486. 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b, 0xba, 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2, 0xf7,
  1487. 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f, 0x5f, 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd, 0x23,
  1488. 0xa1, 0x24, 0x03, 0x22, 0x00, 0x03, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf,
  1489. 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9,
  1490. 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16
  1491. };
  1492. static const unsigned char short_pub[] = { /* long public, curve by OID */
  1493. 0x30, 0x56, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b,
  1494. 0x81, 0x04, 0x00, 0x0a, 0x03, 0x42, 0x00, 0x04, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e,
  1495. 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e,
  1496. 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16, 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a,
  1497. 0xb7, 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62, 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5,
  1498. 0x6e, 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d
  1499. };
  1500. static const unsigned char short_pubc[] = { /* compressed public, curve by OID */
  1501. 0x30, 0x36, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b,
  1502. 0x81, 0x04, 0x00, 0x0a, 0x03, 0x22, 0x00, 0x03, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e,
  1503. 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e,
  1504. 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16
  1505. };
  1506. static const unsigned char raw_pri[] = { /* raw private key */
  1507. 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b, 0xba, 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2, 0xf7,
  1508. 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f, 0x5f, 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd, 0x23
  1509. };
  1510. static const unsigned char raw_pub[] = { /* raw public key - long form */
  1511. 0x04, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba,
  1512. 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5,
  1513. 0x16, 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a, 0xb7, 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63,
  1514. 0x62, 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5, 0x6e, 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79,
  1515. 0x4d
  1516. };
  1517. static const unsigned char raw_pubc[] = { /* raw public key - compressed form */
  1518. 0x03, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba,
  1519. 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5,
  1520. 0x16
  1521. };
  1522. static const unsigned char x509_cert_long[] = { /* X.509 cert, long pubkey, explicit curve params */
  1523. 0x30, 0x82, 0x02, 0x13, 0x30, 0x82, 0x01, 0xba, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00,
  1524. 0xaf, 0x14, 0xe3, 0x53, 0x36, 0x06, 0x79, 0x34, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce,
  1525. 0x3d, 0x04, 0x03, 0x04, 0x30, 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
  1526. 0x0c, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x20, 0x17,
  1527. 0x0d, 0x31, 0x37, 0x31, 0x32, 0x33, 0x30, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x18, 0x0f,
  1528. 0x33, 0x30, 0x31, 0x37, 0x30, 0x35, 0x30, 0x32, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x30,
  1529. 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0c, 0x54, 0x65, 0x73, 0x74,
  1530. 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x81, 0xf5, 0x30, 0x81, 0xae, 0x06, 0x07,
  1531. 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x30, 0x81, 0xa2, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06,
  1532. 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
  1533. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1534. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00,
  1535. 0x04, 0x01, 0x07, 0x04, 0x41, 0x04, 0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0,
  1536. 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2,
  1537. 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98, 0x48, 0x3a, 0xda, 0x77, 0x26, 0xa3, 0xc4, 0x65, 0x5d, 0xa4,
  1538. 0xfb, 0xfc, 0x0e, 0x11, 0x08, 0xa8, 0xfd, 0x17, 0xb4, 0x48, 0xa6, 0x85, 0x54, 0x19, 0x9c, 0x47,
  1539. 0xd0, 0x8f, 0xfb, 0x10, 0xd4, 0xb8, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1540. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0,
  1541. 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01, 0x01, 0x03, 0x42, 0x00, 0x04,
  1542. 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6,
  1543. 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16,
  1544. 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a, 0xb7, 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62,
  1545. 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5, 0x6e, 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d,
  1546. 0xa3, 0x50, 0x30, 0x4e, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x66,
  1547. 0xc9, 0x90, 0x3c, 0x8a, 0x81, 0xa3, 0x1c, 0x20, 0x61, 0xd2, 0xf3, 0xf5, 0xae, 0xa8, 0x85, 0x70,
  1548. 0xf9, 0x1f, 0x2c, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14,
  1549. 0x66, 0xc9, 0x90, 0x3c, 0x8a, 0x81, 0xa3, 0x1c, 0x20, 0x61, 0xd2, 0xf3, 0xf5, 0xae, 0xa8, 0x85,
  1550. 0x70, 0xf9, 0x1f, 0x2c, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01,
  1551. 0x01, 0xff, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x04, 0x03, 0x47,
  1552. 0x00, 0x30, 0x44, 0x02, 0x1f, 0x2a, 0x62, 0x64, 0x05, 0x67, 0xb0, 0x2c, 0xa0, 0xa3, 0xb8, 0x61,
  1553. 0x4e, 0x87, 0x06, 0x69, 0xf2, 0xda, 0x78, 0xd6, 0x0e, 0x8d, 0x9b, 0xf1, 0x43, 0x5f, 0xf6, 0x40,
  1554. 0x9d, 0x9d, 0xbd, 0xce, 0x02, 0x21, 0x00, 0xe9, 0x6f, 0x79, 0xb4, 0x4a, 0x00, 0xf7, 0xfa, 0x81,
  1555. 0x25, 0x29, 0xec, 0x79, 0xb2, 0xfa, 0x86, 0xf8, 0x84, 0xd1, 0x78, 0xe7, 0xf8, 0xfd, 0x76, 0x2d,
  1556. 0x4f, 0xfe, 0x02, 0x72, 0xba, 0x6c, 0xca
  1557. };
  1558. static const unsigned char x509_cert_longc[] = { /* X.509 cert, compressed pubkey, explicit curve params */
  1559. 0x30, 0x82, 0x01, 0xd3, 0x30, 0x82, 0x01, 0x7a, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00,
  1560. 0x90, 0x5b, 0x48, 0x32, 0x37, 0x4b, 0x72, 0x54, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce,
  1561. 0x3d, 0x04, 0x03, 0x04, 0x30, 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
  1562. 0x0c, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x20, 0x17,
  1563. 0x0d, 0x31, 0x37, 0x31, 0x32, 0x33, 0x30, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x18, 0x0f,
  1564. 0x33, 0x30, 0x31, 0x37, 0x30, 0x35, 0x30, 0x32, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x30,
  1565. 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0c, 0x54, 0x65, 0x73, 0x74,
  1566. 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x81, 0xb5, 0x30, 0x81, 0x8e, 0x06, 0x07,
  1567. 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x30, 0x81, 0x82, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06,
  1568. 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
  1569. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1570. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00,
  1571. 0x04, 0x01, 0x07, 0x04, 0x21, 0x02, 0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0,
  1572. 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2,
  1573. 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1574. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0,
  1575. 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01, 0x01, 0x03, 0x22, 0x00, 0x03,
  1576. 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6,
  1577. 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16,
  1578. 0xa3, 0x50, 0x30, 0x4e, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xca,
  1579. 0x2a, 0xa1, 0x12, 0x97, 0x96, 0x2c, 0x85, 0xd3, 0x1f, 0xb1, 0x34, 0x7c, 0x26, 0xe9, 0xd6, 0x49,
  1580. 0x9f, 0x98, 0xcf, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14,
  1581. 0xca, 0x2a, 0xa1, 0x12, 0x97, 0x96, 0x2c, 0x85, 0xd3, 0x1f, 0xb1, 0x34, 0x7c, 0x26, 0xe9, 0xd6,
  1582. 0x49, 0x9f, 0x98, 0xcf, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01,
  1583. 0x01, 0xff, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x04, 0x03, 0x47,
  1584. 0x00, 0x30, 0x44, 0x02, 0x20, 0x24, 0x7a, 0xc1, 0xb4, 0x7d, 0x1c, 0x3c, 0x23, 0xc6, 0xad, 0xea,
  1585. 0x04, 0x27, 0x27, 0x65, 0xb8, 0x72, 0x93, 0x46, 0xc9, 0xe9, 0x60, 0x8f, 0xca, 0x96, 0x30, 0x60,
  1586. 0xb3, 0x22, 0xf7, 0x3b, 0x01, 0x02, 0x20, 0x48, 0x30, 0x2a, 0x58, 0x18, 0x46, 0xdb, 0x50, 0x3e,
  1587. 0xad, 0xc3, 0xca, 0xcd, 0x6d, 0x83, 0xd4, 0xc3, 0xc4, 0xa4, 0x8f, 0x37, 0xc3, 0x1d, 0x83, 0x3c,
  1588. 0xd3, 0x1f, 0x8f, 0x38, 0x29, 0x75, 0x2c
  1589. };
  1590. static const unsigned char x509_cert_short[] = { /* X.509 cert, long pubkey, curve by OID */
  1591. 0x30, 0x82, 0x01, 0x74, 0x30, 0x82, 0x01, 0x1a, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00,
  1592. 0xbd, 0x81, 0x04, 0x29, 0x43, 0x12, 0x79, 0xce, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce,
  1593. 0x3d, 0x04, 0x03, 0x04, 0x30, 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
  1594. 0x0c, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x20, 0x17,
  1595. 0x0d, 0x31, 0x37, 0x31, 0x32, 0x33, 0x30, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x18, 0x0f,
  1596. 0x33, 0x30, 0x31, 0x37, 0x30, 0x35, 0x30, 0x32, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x30,
  1597. 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0c, 0x54, 0x65, 0x73, 0x74,
  1598. 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x56, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86,
  1599. 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x0a, 0x03, 0x42, 0x00, 0x04,
  1600. 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6,
  1601. 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16,
  1602. 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a, 0xb7, 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62,
  1603. 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5, 0x6e, 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d,
  1604. 0xa3, 0x50, 0x30, 0x4e, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x66,
  1605. 0xc9, 0x90, 0x3c, 0x8a, 0x81, 0xa3, 0x1c, 0x20, 0x61, 0xd2, 0xf3, 0xf5, 0xae, 0xa8, 0x85, 0x70,
  1606. 0xf9, 0x1f, 0x2c, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14,
  1607. 0x66, 0xc9, 0x90, 0x3c, 0x8a, 0x81, 0xa3, 0x1c, 0x20, 0x61, 0xd2, 0xf3, 0xf5, 0xae, 0xa8, 0x85,
  1608. 0x70, 0xf9, 0x1f, 0x2c, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01,
  1609. 0x01, 0xff, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x04, 0x03, 0x48,
  1610. 0x00, 0x30, 0x45, 0x02, 0x21, 0x00, 0x9b, 0x4e, 0xb2, 0x6a, 0xcc, 0xfa, 0x02, 0x69, 0x22, 0x6a,
  1611. 0x32, 0x9c, 0x0c, 0xaa, 0x4c, 0xdf, 0xbb, 0x9b, 0x22, 0xfb, 0xd6, 0xec, 0x5d, 0xf9, 0x87, 0x82,
  1612. 0xeb, 0x37, 0xb8, 0x32, 0x7c, 0xd6, 0x02, 0x20, 0x50, 0x8b, 0x9f, 0xc1, 0xa8, 0x4a, 0xff, 0x49,
  1613. 0x0d, 0x7e, 0x04, 0x2d, 0x93, 0x3e, 0xdb, 0x30, 0xbc, 0x93, 0xd1, 0x16, 0x1d, 0x99, 0xbd, 0x3f,
  1614. 0xfa, 0x2a, 0x6d, 0xe0, 0x2a, 0x83, 0x55, 0x5d
  1615. };
  1616. static const unsigned char x509_cert_shortc[] = { /* X.509 cert, compressed pubkey, curve by OID */
  1617. 0x30, 0x82, 0x01, 0x54, 0x30, 0x81, 0xfa, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0x85,
  1618. 0x45, 0x77, 0x75, 0x02, 0x95, 0xf7, 0x06, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d,
  1619. 0x04, 0x03, 0x04, 0x30, 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0c,
  1620. 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x20, 0x17, 0x0d,
  1621. 0x31, 0x37, 0x31, 0x32, 0x33, 0x30, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x18, 0x0f, 0x33,
  1622. 0x30, 0x31, 0x37, 0x30, 0x35, 0x30, 0x32, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x30, 0x17,
  1623. 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0c, 0x54, 0x65, 0x73, 0x74, 0x20,
  1624. 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x36, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48,
  1625. 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x0a, 0x03, 0x22, 0x00, 0x03, 0x2a,
  1626. 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f,
  1627. 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16, 0xa3,
  1628. 0x50, 0x30, 0x4e, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xca, 0x2a,
  1629. 0xa1, 0x12, 0x97, 0x96, 0x2c, 0x85, 0xd3, 0x1f, 0xb1, 0x34, 0x7c, 0x26, 0xe9, 0xd6, 0x49, 0x9f,
  1630. 0x98, 0xcf, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xca,
  1631. 0x2a, 0xa1, 0x12, 0x97, 0x96, 0x2c, 0x85, 0xd3, 0x1f, 0xb1, 0x34, 0x7c, 0x26, 0xe9, 0xd6, 0x49,
  1632. 0x9f, 0x98, 0xcf, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01,
  1633. 0xff, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x04, 0x03, 0x49, 0x00,
  1634. 0x30, 0x46, 0x02, 0x21, 0x00, 0xa4, 0xf9, 0x41, 0x2b, 0x4b, 0x56, 0xa5, 0xd4, 0x8c, 0xdf, 0xb0,
  1635. 0x14, 0xe3, 0xe7, 0xed, 0xcc, 0xc4, 0x46, 0x42, 0x04, 0xec, 0x15, 0x9f, 0xe1, 0xb2, 0x00, 0x07,
  1636. 0x8c, 0xc1, 0xf9, 0x25, 0xed, 0x02, 0x21, 0x00, 0x81, 0xd8, 0xc4, 0x3a, 0x9f, 0xdf, 0xc1, 0x70,
  1637. 0x9d, 0x7b, 0x70, 0x3e, 0xf5, 0x7d, 0xa4, 0xfd, 0x3c, 0xc6, 0x49, 0x93, 0xd3, 0x5b, 0xef, 0xc9,
  1638. 0xae, 0x97, 0xaf, 0x64, 0x64, 0xf9, 0x69, 0xd8
  1639. };
  1640. password_ctx pw_ctx = { .callback = password_get };
  1641. if (ltc_mp.sqrtmod_prime == NULL) return CRYPT_NOP; /* we need compressed points which requires sqrtmod_prime */
  1642. DO(ecc_import_openssl(short_pub, sizeof(short_pub), &pub));
  1643. DO(ecc_import_openssl(short_pri, sizeof(short_pri), &pri));
  1644. DO(ecc_find_curve("SECP256K1", &cu));
  1645. /* import - raw keys */
  1646. DO(ecc_set_curve(cu, &key));
  1647. DO(ecc_set_key(raw_pri, sizeof(raw_pri), PK_PRIVATE, &key));
  1648. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1649. ecc_free(&key);
  1650. DO(ecc_set_curve(cu, &key));
  1651. DO(ecc_set_key(raw_pub, sizeof(raw_pub), PK_PUBLIC, &key));
  1652. DO(ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1653. ecc_free(&key);
  1654. DO(ecc_set_curve(cu, &key));
  1655. DO(ecc_set_key(raw_pubc, sizeof(raw_pubc), PK_PUBLIC, &key));
  1656. DO(ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1657. ecc_free(&key);
  1658. /* import - openssl compatible DER format */
  1659. DO(ecc_import_openssl(ltc_ecc_long_pri_test_key, sizeof(ltc_ecc_long_pri_test_key), &key));
  1660. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1661. ecc_free(&key);
  1662. DO(ecc_import_openssl(long_pric, sizeof(long_pric), &key));
  1663. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1664. ecc_free(&key);
  1665. DO(ecc_import_openssl(long_pub, sizeof(long_pub), &key));
  1666. DO(ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1667. ecc_free(&key);
  1668. DO(ecc_import_openssl(long_pubc, sizeof(long_pubc), &key));
  1669. DO(ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1670. ecc_free(&key);
  1671. DO(ecc_import_openssl(short_pri, sizeof(short_pri), &key));
  1672. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1673. ecc_free(&key);
  1674. DO(ecc_import_openssl(short_pric, sizeof(short_pric), &key));
  1675. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1676. ecc_free(&key);
  1677. DO(ecc_import_openssl(short_pub, sizeof(short_pub), &key));
  1678. DO(ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1679. ecc_free(&key);
  1680. DO(ecc_import_openssl(short_pubc, sizeof(short_pubc), &key));
  1681. DO(ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1682. ecc_free(&key);
  1683. /* import - private PKCS8 format - no password */
  1684. DO(ecc_import_pkcs8(long_pri_pkcs8, sizeof(long_pri_pkcs8), NULL, &key));
  1685. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1686. ecc_free(&key);
  1687. DO(ecc_import_pkcs8(long_pric_pkcs8, sizeof(long_pric_pkcs8), NULL, &key));
  1688. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1689. ecc_free(&key);
  1690. DO(ecc_import_pkcs8(short_pri_pkcs8, sizeof(short_pri_pkcs8), NULL, &key));
  1691. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1692. ecc_free(&key);
  1693. DO(ecc_import_pkcs8(short_pric_pkcs8, sizeof(short_pric_pkcs8), NULL, &key));
  1694. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1695. ecc_free(&key);
  1696. /* import - private PKCS8 format - password protected (PBES1 algorithms) */
  1697. #ifdef LTC_MD2
  1698. DO(ecc_import_pkcs8(long_pri_pkcs8_pbe_md2_des, sizeof(long_pri_pkcs8_pbe_md2_des), &pw_ctx, &key));
  1699. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1700. ecc_free(&key);
  1701. #endif
  1702. #ifdef LTC_MD5
  1703. DO(ecc_import_pkcs8(long_pri_pkcs8_pbe_md5_des, sizeof(long_pri_pkcs8_pbe_md5_des), &pw_ctx, &key));
  1704. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1705. ecc_free(&key);
  1706. #endif
  1707. #ifdef LTC_SHA1
  1708. DO(ecc_import_pkcs8(long_pri_pkcs8_pbe_sha1_des, sizeof(long_pri_pkcs8_pbe_sha1_des), &pw_ctx, &key));
  1709. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1710. ecc_free(&key);
  1711. #endif
  1712. #if defined(LTC_RC2) && defined(LTC_MD2)
  1713. DO(ecc_import_pkcs8(long_pri_pkcs8_pbe_md2_rc2_64, sizeof(long_pri_pkcs8_pbe_md2_rc2_64), &pw_ctx, &key));
  1714. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1715. ecc_free(&key);
  1716. #endif
  1717. #if defined(LTC_RC2) && defined(LTC_MD5)
  1718. DO(ecc_import_pkcs8(long_pri_pkcs8_pbe_md5_rc2_64, sizeof(long_pri_pkcs8_pbe_md5_rc2_64), &pw_ctx, &key));
  1719. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1720. ecc_free(&key);
  1721. #endif
  1722. #if defined(LTC_RC2) && defined(LTC_SHA1)
  1723. DO(ecc_import_pkcs8(long_pri_pkcs8_pbe_sha1_rc2_64, sizeof(long_pri_pkcs8_pbe_sha1_rc2_64), &pw_ctx, &key));
  1724. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1725. ecc_free(&key);
  1726. #endif
  1727. /* import - private PKCS8 format - password protected (PBES2 algorithms) */
  1728. #if defined(LTC_RC2)
  1729. DO(ecc_import_pkcs8(long_pri_pkcs8_pbkdf2_rc2_cbc, sizeof(long_pri_pkcs8_pbkdf2_rc2_cbc), &pw_ctx, &key));
  1730. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1731. ecc_free(&key);
  1732. #endif
  1733. #if defined(LTC_DES)
  1734. DO(ecc_import_pkcs8(long_pri_pkcs8_pbkdf2_des_cbc, sizeof(long_pri_pkcs8_pbkdf2_des_cbc), &pw_ctx, &key));
  1735. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1736. ecc_free(&key);
  1737. #endif
  1738. #if defined(LTC_DES)
  1739. DO(ecc_import_pkcs8(long_pri_pkcs8_pbkdf2_des_ede3_cbc, sizeof(long_pri_pkcs8_pbkdf2_des_ede3_cbc), &pw_ctx, &key));
  1740. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1741. ecc_free(&key);
  1742. #endif
  1743. #if defined(LTC_SHA224) && defined(LTC_DES)
  1744. DO(ecc_import_pkcs8(long_pri_pkcs8_pbkdf2_sha224_des_ede3_cbc, sizeof(long_pri_pkcs8_pbkdf2_sha224_des_ede3_cbc), &pw_ctx, &key));
  1745. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1746. ecc_free(&key);
  1747. #endif
  1748. #if defined(LTC_SHA256) && defined(LTC_DES)
  1749. DO(ecc_import_pkcs8(long_pri_pkcs8_pbkdf2_sha256_des_ede3_cbc, sizeof(long_pri_pkcs8_pbkdf2_sha256_des_ede3_cbc), &pw_ctx, &key));
  1750. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1751. ecc_free(&key);
  1752. #endif
  1753. #if defined(LTC_SHA384) && defined(LTC_DES)
  1754. DO(ecc_import_pkcs8(long_pri_pkcs8_pbkdf2_sha384_des_ede3_cbc, sizeof(long_pri_pkcs8_pbkdf2_sha384_des_ede3_cbc), &pw_ctx, &key));
  1755. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1756. ecc_free(&key);
  1757. #endif
  1758. #if defined(LTC_SHA512) && defined(LTC_DES)
  1759. DO(ecc_import_pkcs8(long_pri_pkcs8_pbkdf2_sha512_des_ede3_cbc, sizeof(long_pri_pkcs8_pbkdf2_sha512_des_ede3_cbc), &pw_ctx, &key));
  1760. DO(ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1761. ecc_free(&key);
  1762. #endif
  1763. /* import - X.509 EC certificates */
  1764. DO(ecc_import_x509(x509_cert_long, sizeof(x509_cert_long), &key));
  1765. DO(ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1766. ecc_free(&key);
  1767. DO(ecc_import_x509(x509_cert_longc, sizeof(x509_cert_longc), &key));
  1768. DO(ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1769. ecc_free(&key);
  1770. DO(ecc_import_x509(x509_cert_short, sizeof(x509_cert_short), &key));
  1771. DO(ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1772. ecc_free(&key);
  1773. DO(ecc_import_x509(x509_cert_shortc, sizeof(x509_cert_shortc), &key));
  1774. DO(ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1775. ecc_free(&key);
  1776. /* export - openssl compatible DER format */
  1777. outlen = sizeof(out);
  1778. DO(ecc_export_openssl(out, &outlen, PK_PRIVATE, &pri));
  1779. if (compare_testvector(out, outlen, ltc_ecc_long_pri_test_key, sizeof(ltc_ecc_long_pri_test_key), "e-ltc_ecc_long_pri_test_key", 0)) return CRYPT_ERROR;
  1780. outlen = sizeof(out);
  1781. DO(ecc_export_openssl(out, &outlen, PK_PRIVATE|PK_COMPRESSED, &pri));
  1782. if (compare_testvector(out, outlen, long_pric, sizeof(long_pric), "e-long_pric", 0)) return CRYPT_ERROR;
  1783. outlen = sizeof(out);
  1784. DO(ecc_export_openssl(out, &outlen, PK_PUBLIC, &pub));
  1785. if (compare_testvector(out, outlen, long_pub, sizeof(long_pub), "e-long_pub", 0)) return CRYPT_ERROR;
  1786. outlen = sizeof(out);
  1787. DO(ecc_export_openssl(out, &outlen, PK_PUBLIC|PK_COMPRESSED, &pub));
  1788. if (compare_testvector(out, outlen, long_pubc, sizeof(long_pubc), "e-long_pubc", 0)) return CRYPT_ERROR;
  1789. outlen = sizeof(out);
  1790. DO(ecc_export_openssl(out, &outlen, PK_PRIVATE|PK_CURVEOID, &pri));
  1791. if (compare_testvector(out, outlen, short_pri, sizeof(short_pri), "e-short_pri", 0)) return CRYPT_ERROR;
  1792. outlen = sizeof(out);
  1793. DO(ecc_export_openssl(out, &outlen, PK_PRIVATE|PK_CURVEOID|PK_COMPRESSED, &pri));
  1794. if (compare_testvector(out, outlen, short_pric, sizeof(short_pric), "e-short_pric", 0)) return CRYPT_ERROR;
  1795. outlen = sizeof(out);
  1796. DO(ecc_export_openssl(out, &outlen, PK_PUBLIC|PK_CURVEOID, &pub));
  1797. if (compare_testvector(out, outlen, short_pub, sizeof(short_pub), "e-short_pub", 0)) return CRYPT_ERROR;
  1798. outlen = sizeof(out);
  1799. DO(ecc_export_openssl(out, &outlen, PK_PUBLIC|PK_CURVEOID|PK_COMPRESSED, &pub));
  1800. if (compare_testvector(out, outlen, short_pubc, sizeof(short_pubc), "e-short_pubc", 0)) return CRYPT_ERROR;
  1801. /* export - raw keys */
  1802. outlen = sizeof(out);
  1803. DO(ecc_get_key(out, &outlen, PK_PRIVATE, &pri));
  1804. if (compare_testvector(out, outlen, raw_pri, sizeof(raw_pri), "e-raw_pri", 0)) return CRYPT_ERROR;
  1805. outlen = sizeof(out);
  1806. DO(ecc_get_key(out, &outlen, PK_PUBLIC, &pub));
  1807. if (compare_testvector(out, outlen, raw_pub, sizeof(raw_pub), "e-raw_pub", 0)) return CRYPT_ERROR;
  1808. outlen = sizeof(out);
  1809. DO(ecc_get_key(out, &outlen, PK_PUBLIC|PK_COMPRESSED, &pub));
  1810. if (compare_testvector(out, outlen, raw_pubc, sizeof(raw_pubc), "e-raw_pubc", 0)) return CRYPT_ERROR;
  1811. ecc_free(&pri);
  1812. ecc_free(&pub);
  1813. return CRYPT_OK;
  1814. }
  1815. #ifdef LTC_ECC_SHAMIR
  1816. static int s_ecc_test_ethereum(void)
  1817. {
  1818. #ifdef LTC_ECC_SECP256K1
  1819. int stat;
  1820. const ltc_ecc_curve* dp;
  1821. ecc_key key, reckey;
  1822. unsigned char buf[128];
  1823. unsigned long len;
  1824. unsigned char data16[16] = { 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1 };
  1825. DO(ecc_find_curve("SECP256K1", &dp));
  1826. DO(ecc_make_key_ex(&yarrow_prng, find_prng ("yarrow"), &key, dp));
  1827. /* test Ethereum signature */
  1828. len = sizeof(buf);
  1829. DO(ecc_sign_hash_eth27(data16, 16, buf, &len, &yarrow_prng, find_prng ("yarrow"), &key));
  1830. stat = 0;
  1831. DO(ecc_verify_hash_eth27(buf, len, data16, 16, &stat, &key));
  1832. if (stat != 1) return CRYPT_FAIL_TESTVECTOR;
  1833. /* XXX-FIXME: TFM does not support sqrtmod_prime */
  1834. if (strcmp(ltc_mp.name, "TomsFastMath") != 0) {
  1835. DO(ecc_set_curve(dp, &reckey));
  1836. DO(ecc_recover_key(buf, len, data16, 16, -1, LTC_ECCSIG_ETH27, &reckey));
  1837. DO(ecc_key_cmp(PK_PUBLIC, &key, &reckey));
  1838. /* cleanup */
  1839. ecc_free(&reckey);
  1840. }
  1841. /* cleanup */
  1842. ecc_free(&key);
  1843. return CRYPT_OK;
  1844. #else
  1845. return CRYPT_NOP;
  1846. #endif
  1847. }
  1848. static int s_ecc_test_recovery(void)
  1849. {
  1850. int i, recid, stat;
  1851. const ltc_ecc_curve* dp;
  1852. ecc_key key, privkey, pubkey, reckey;
  1853. unsigned char buf[1000];
  1854. unsigned long len;
  1855. unsigned char data16[16] = { 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1 };
  1856. unsigned char eth_hash[] = { /* Keccak-256 hash of "Hello World" */
  1857. 0x59, 0x2f, 0xa7, 0x43, 0x88, 0x9f, 0xc7, 0xf9, 0x2a, 0xc2, 0xa3, 0x7b, 0xb1, 0xf5, 0xba, 0x1d,
  1858. 0xaf, 0x2a, 0x5c, 0x84, 0x74, 0x1c, 0xa0, 0xe0, 0x06, 0x1d, 0x24, 0x3a, 0x2e, 0x67, 0x07, 0xba
  1859. };
  1860. unsigned char eth_pubkey[] = { /* Public part of randomly-generated key pair */
  1861. 0x04,
  1862. 0xc6, 0x99, 0x5f, 0xdc, 0xf4, 0xf2, 0xda, 0x6e, 0x79, 0xe0, 0x47, 0x12, 0xd3, 0xbe, 0x22, 0xe7,
  1863. 0x65, 0xc6, 0xa3, 0x32, 0x89, 0x1b, 0x34, 0xba, 0xc1, 0xb7, 0x01, 0x83, 0xed, 0xdd, 0xf1, 0xcc,
  1864. 0xbf, 0x20, 0xdd, 0xcd, 0x05, 0x4e, 0x49, 0xc8, 0xcb, 0x66, 0x6c, 0xb7, 0x71, 0x2f, 0x7e, 0xc1,
  1865. 0xd6, 0x1a, 0x4a, 0x42, 0x3d, 0xe5, 0xc2, 0x8d, 0x74, 0x03, 0x81, 0xe7, 0xea, 0xc5, 0x3c, 0x10
  1866. };
  1867. unsigned char eth_sig[] = { /* Signature of eth_hash to be verified against eth_pubkey */
  1868. 0xbd, 0x6d, 0xbb, 0xbe, 0x2d, 0xe7, 0x1d, 0x00, 0xae, 0x18, 0x57, 0x12, 0x1d, 0x63, 0xa5, 0x1b,
  1869. 0x0b, 0x42, 0x71, 0xa2, 0x80, 0x49, 0xe0, 0x5c, 0xfa, 0xc8, 0x1a, 0x0d, 0x8a, 0x88, 0x67, 0x56,
  1870. 0xf6, 0x67, 0x1b, 0x41, 0x46, 0x09, 0x4e, 0xd0, 0x44, 0x25, 0x18, 0xfd, 0xf4, 0xcd, 0x62, 0xa3,
  1871. 0xb7, 0x3c, 0x97, 0x55, 0xfa, 0x69, 0xf8, 0xef, 0xe9, 0xcf, 0x12, 0xaf, 0x48, 0x25, 0xe3, 0xe0,
  1872. 0x1b
  1873. };
  1874. /* XXX-FIXME: TFM does not support sqrtmod_prime */
  1875. if (strcmp(ltc_mp.name, "TomsFastMath") == 0) return CRYPT_NOP;
  1876. #ifdef LTC_ECC_SECP256K1
  1877. DO(ecc_find_curve("SECP256K1", &dp));
  1878. DO(ecc_set_curve(dp, &pubkey));
  1879. DO(ecc_set_key(eth_pubkey, sizeof(eth_pubkey), PK_PUBLIC, &pubkey));
  1880. DO(ecc_set_curve(dp, &reckey));
  1881. DO(ecc_recover_key(eth_sig, sizeof(eth_sig)-1, eth_hash, sizeof(eth_hash), 0, LTC_ECCSIG_RFC7518, &reckey));
  1882. DO(ecc_key_cmp(PK_PUBLIC, &pubkey, &reckey));
  1883. ecc_free(&reckey);
  1884. DO(ecc_set_curve(dp, &reckey));
  1885. DO(ecc_recover_key(eth_sig, sizeof(eth_sig), eth_hash, sizeof(eth_hash), -1, LTC_ECCSIG_ETH27, &reckey));
  1886. DO(ecc_key_cmp(PK_PUBLIC, &pubkey, &reckey));
  1887. ecc_free(&reckey);
  1888. ecc_free(&pubkey);
  1889. #endif
  1890. for (i = 0; i < (int)LTC_ARRAY_SIZE(curvenames); i++) {
  1891. DO(ecc_find_curve(curvenames[i], &dp));
  1892. /* generate new key */
  1893. DO(ecc_set_curve(dp, &key));
  1894. DO(ecc_generate_key(&yarrow_prng, find_prng ("yarrow"), &key));
  1895. /* export private key */
  1896. len = sizeof(buf);
  1897. DO(ecc_get_key(buf, &len, PK_PRIVATE, &key));
  1898. ecc_free(&key);
  1899. /* load exported private key */
  1900. DO(ecc_set_curve(dp, &privkey));
  1901. DO(ecc_set_key(buf, len, PK_PRIVATE, &privkey));
  1902. /* export long public key */
  1903. len = sizeof(buf);
  1904. DO(ecc_get_key(buf, &len, PK_PUBLIC, &privkey));
  1905. if (len != 1 + 2 * (unsigned)ecc_get_size(&privkey)) return CRYPT_FAIL_TESTVECTOR;
  1906. /* load exported public key */
  1907. DO(ecc_set_curve(dp, &pubkey));
  1908. DO(ecc_set_key(buf, len, PK_PUBLIC, &pubkey));
  1909. /* test signature */
  1910. len = sizeof(buf);
  1911. recid = 0;
  1912. DO(ecc_sign_hash_rfc7518_ex(data16, 16, buf, &len, &yarrow_prng, find_prng ("yarrow"), &recid, &privkey));
  1913. /* test verification */
  1914. stat = 0;
  1915. DO(ecc_verify_hash_rfc7518(buf, len, data16, 16, &stat, &pubkey));
  1916. if (stat != 1) return CRYPT_FAIL_TESTVECTOR;
  1917. /* test recovery */
  1918. DO(ecc_set_curve(dp, &reckey));
  1919. stat = ecc_recover_key(buf, len, data16, 16, recid, LTC_ECCSIG_RFC7518, &reckey);
  1920. if (stat != CRYPT_OK) return CRYPT_FAIL_TESTVECTOR;
  1921. DO(ecc_key_cmp(PK_PUBLIC, &pubkey, &reckey));
  1922. /* cleanup */
  1923. ecc_free(&reckey);
  1924. ecc_free(&privkey);
  1925. ecc_free(&pubkey);
  1926. }
  1927. return CRYPT_OK;
  1928. }
  1929. #endif
  1930. int ecc_test(void)
  1931. {
  1932. if (ltc_mp.name == NULL) return CRYPT_NOP;
  1933. DO(s_ecc_rfc6979());
  1934. DO(s_ecc_old_api()); /* up to 1.18 */
  1935. DO(s_ecc_new_api());
  1936. DO(s_ecc_import_export());
  1937. DO(s_ecc_test_mp());
  1938. DO(s_ecc_issue108());
  1939. DO(s_ecc_issue443_447());
  1940. DO(s_ecc_issue630());
  1941. #ifdef LTC_ECC_SHAMIR
  1942. DO(s_ecc_test_shamir());
  1943. DO(s_ecc_test_recovery());
  1944. DO(s_ecc_test_ethereum());
  1945. #endif
  1946. return CRYPT_OK;
  1947. }
  1948. #endif