ecc_test.c 95 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627
  1. /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
  2. /* SPDX-License-Identifier: Unlicense */
  3. #include <tomcrypt_test.h>
  4. #if defined(LTC_MECC)
  5. static unsigned int sizes[] = {
  6. #ifdef LTC_ECC_SECP112R1
  7. 14,
  8. #endif
  9. #ifdef LTC_ECC_SECP128R1
  10. 16,
  11. #endif
  12. #ifdef LTC_ECC_SECP160R1
  13. 20,
  14. #endif
  15. #ifdef LTC_ECC_SECP192R1
  16. 24,
  17. #endif
  18. #ifdef LTC_ECC_SECP224R1
  19. 28,
  20. #endif
  21. #ifdef LTC_ECC_SECP256R1
  22. 32,
  23. #endif
  24. #ifdef LTC_ECC_SECP384R1
  25. 48,
  26. #endif
  27. #ifdef LTC_ECC_SECP512R1
  28. 66
  29. #endif
  30. };
  31. static const char* curvenames[] = {
  32. #ifdef LTC_ECC_SECP112R1
  33. "SECP112R1", "ECC-112",
  34. "secp112r1", /* name is case-insensitive */
  35. "S E C-P-1_1_2r1", /* should pass fuzzy matching */
  36. #endif
  37. #ifdef LTC_ECC_SECP112R2
  38. "SECP112R2",
  39. #endif
  40. #ifdef LTC_ECC_SECP128R1
  41. "SECP128R1", "ECC-128",
  42. #endif
  43. #ifdef LTC_ECC_SECP128R2
  44. "SECP128R2",
  45. #endif
  46. #ifdef LTC_ECC_SECP160R1
  47. "SECP160R1", "ECC-160",
  48. #endif
  49. #ifdef LTC_ECC_SECP160R2
  50. "SECP160R2",
  51. #endif
  52. #ifdef LTC_ECC_SECP160K1
  53. "SECP160K1",
  54. #endif
  55. #ifdef LTC_ECC_BRAINPOOLP160R1
  56. "BRAINPOOLP160R1",
  57. #endif
  58. #ifdef LTC_ECC_SECP192R1
  59. "SECP192R1", "NISTP192", "PRIME192V1", "ECC-192", "P-192",
  60. #endif
  61. #ifdef LTC_ECC_PRIME192V2
  62. "PRIME192V2",
  63. #endif
  64. #ifdef LTC_ECC_PRIME192V3
  65. "PRIME192V3",
  66. #endif
  67. #ifdef LTC_ECC_SECP192K1
  68. "SECP192K1",
  69. #endif
  70. #ifdef LTC_ECC_BRAINPOOLP192R1
  71. "BRAINPOOLP192R1",
  72. #endif
  73. #ifdef LTC_ECC_SECP224R1
  74. "SECP224R1", "NISTP224", "ECC-224", "P-224",
  75. #endif
  76. #ifdef LTC_ECC_SECP224K1
  77. "SECP224K1",
  78. #endif
  79. #ifdef LTC_ECC_BRAINPOOLP224R1
  80. "BRAINPOOLP224R1",
  81. #endif
  82. #ifdef LTC_ECC_PRIME239V1
  83. "PRIME239V1",
  84. #endif
  85. #ifdef LTC_ECC_PRIME239V2
  86. "PRIME239V2",
  87. #endif
  88. #ifdef LTC_ECC_PRIME239V3
  89. "PRIME239V3",
  90. #endif
  91. #ifdef LTC_ECC_SECP256R1
  92. "SECP256R1", "NISTP256", "PRIME256V1", "ECC-256", "P-256",
  93. #endif
  94. #ifdef LTC_ECC_SECP256K1
  95. "SECP256K1",
  96. #endif
  97. #ifdef LTC_ECC_BRAINPOOLP256R1
  98. "BRAINPOOLP256R1",
  99. #endif
  100. #ifdef LTC_ECC_BRAINPOOLP320R1
  101. "BRAINPOOLP320R1",
  102. #endif
  103. #ifdef LTC_ECC_SECP384R1
  104. "SECP384R1", "NISTP384", "ECC-384", "P-384",
  105. #endif
  106. #ifdef LTC_ECC_BRAINPOOLP384R1
  107. "BRAINPOOLP384R1",
  108. #endif
  109. #ifdef LTC_ECC_BRAINPOOLP512R1
  110. "BRAINPOOLP512R1",
  111. #endif
  112. #ifdef LTC_ECC_SECP521R1
  113. "SECP521R1", "NISTP521", "ECC-521", "P-521",
  114. #endif
  115. };
  116. #ifdef LTC_ECC_SHAMIR
  117. static int s_ecc_test_shamir(void)
  118. {
  119. void *a, *modulus, *mp, *kA, *kB, *rA, *rB;
  120. void *mu, *ma;
  121. ecc_point *G, *A, *B, *C1, *C2;
  122. int x, y, z;
  123. unsigned char buf[ECC_BUF_SIZE];
  124. DO(mp_init_multi(&kA, &kB, &rA, &rB, &modulus, &a, &mu, &ma, LTC_NULL));
  125. LTC_ARGCHK((G = ltc_ecc_new_point()) != NULL);
  126. LTC_ARGCHK((A = ltc_ecc_new_point()) != NULL);
  127. LTC_ARGCHK((B = ltc_ecc_new_point()) != NULL);
  128. LTC_ARGCHK((C1 = ltc_ecc_new_point()) != NULL);
  129. LTC_ARGCHK((C2 = ltc_ecc_new_point()) != NULL);
  130. for (x = 0; x < (int)(sizeof(sizes)/sizeof(sizes[0])); x++) {
  131. /* get the base point */
  132. for (z = 0; ltc_ecc_curves[z].prime != NULL; z++) {
  133. DO(mp_read_radix(modulus, ltc_ecc_curves[z].prime, 16));
  134. if (sizes[x] <= mp_unsigned_bin_size(modulus)) break;
  135. }
  136. LTC_ARGCHK(ltc_ecc_curves[z].prime != NULL);
  137. /* load it */
  138. DO(mp_read_radix(G->x, ltc_ecc_curves[z].Gx, 16));
  139. DO(mp_read_radix(G->y, ltc_ecc_curves[z].Gy, 16));
  140. DO(mp_set(G->z, 1));
  141. DO(mp_read_radix(a, ltc_ecc_curves[z].A, 16));
  142. DO(mp_montgomery_setup(modulus, &mp));
  143. DO(mp_montgomery_normalization(mu, modulus));
  144. DO(mp_mulmod(a, mu, modulus, ma));
  145. /* do 100 random tests */
  146. for (y = 0; y < 100; y++) {
  147. /* pick a random r1, r2 */
  148. ENSURE(yarrow_read(buf, sizes[x], &yarrow_prng) == sizes[x]);
  149. DO(mp_read_unsigned_bin(rA, buf, sizes[x]));
  150. ENSURE(yarrow_read(buf, sizes[x], &yarrow_prng) == sizes[x]);
  151. DO(mp_read_unsigned_bin(rB, buf, sizes[x]));
  152. /* compute rA * G = A */
  153. DO(ltc_mp.ecc_ptmul(rA, G, A, a, modulus, 1));
  154. /* compute rB * G = B */
  155. DO(ltc_mp.ecc_ptmul(rB, G, B, a, modulus, 1));
  156. /* pick a random kA, kB */
  157. ENSURE(yarrow_read(buf, sizes[x], &yarrow_prng) == sizes[x]);
  158. DO(mp_read_unsigned_bin(kA, buf, sizes[x]));
  159. ENSURE(yarrow_read(buf, sizes[x], &yarrow_prng) == sizes[x]);
  160. DO(mp_read_unsigned_bin(kB, buf, sizes[x]));
  161. /* now, compute kA*A + kB*B = C1 using the older method */
  162. DO(ltc_mp.ecc_ptmul(kA, A, C1, a, modulus, 0));
  163. DO(ltc_mp.ecc_ptmul(kB, B, C2, a, modulus, 0));
  164. DO(ltc_mp.ecc_ptadd(C1, C2, C1, a, modulus, mp));
  165. DO(ltc_mp.ecc_map(C1, modulus, mp));
  166. /* now compute using mul2add */
  167. DO(ltc_mp.ecc_mul2add(A, kA, B, kB, C2, ma, modulus));
  168. /* is they the sames? */
  169. if ((mp_cmp(C1->x, C2->x) != LTC_MP_EQ) || (mp_cmp(C1->y, C2->y) != LTC_MP_EQ) || (mp_cmp(C1->z, C2->z) != LTC_MP_EQ)) {
  170. fprintf(stderr, "ECC failed shamir test: size=%d, testno=%d\n", sizes[x], y);
  171. return 1;
  172. }
  173. }
  174. mp_montgomery_free(mp);
  175. }
  176. ltc_ecc_del_point(C2);
  177. ltc_ecc_del_point(C1);
  178. ltc_ecc_del_point(B);
  179. ltc_ecc_del_point(A);
  180. ltc_ecc_del_point(G);
  181. mp_clear_multi(kA, kB, rA, rB, modulus, a, mu, ma, LTC_NULL);
  182. return 0;
  183. }
  184. #endif
  185. /* https://github.com/libtom/libtomcrypt/issues/630 */
  186. static int s_ecc_issue630(void)
  187. {
  188. unsigned char protected_buffer[30], protected_buffer_copy[30];
  189. unsigned long keylen = 0;
  190. ecc_key key;
  191. int low, high;
  192. ecc_sizes(&low, &high);
  193. DO(ecc_make_key (&yarrow_prng, find_prng ("yarrow"), high, &key));
  194. if (yarrow_read(protected_buffer, sizeof(protected_buffer), &yarrow_prng) != sizeof(protected_buffer)) {
  195. return CRYPT_ERROR_READPRNG;
  196. }
  197. XMEMCPY(protected_buffer_copy, protected_buffer, sizeof(protected_buffer));
  198. COMPARE_TESTVECTOR(protected_buffer, sizeof(protected_buffer), protected_buffer_copy, sizeof(protected_buffer), "Ensure copy is equal", 0);
  199. keylen = 10;
  200. SHOULD_FAIL(ecc_get_key(&protected_buffer[10], &keylen, PK_PRIVATE, &key));
  201. COMPARE_TESTVECTOR(protected_buffer, 10, protected_buffer_copy, 10, "Start canary", 1);
  202. COMPARE_TESTVECTOR(&protected_buffer[20], 10, &protected_buffer[20], 10, "End canary", 2);
  203. ecc_free(&key);
  204. return 0;
  205. }
  206. /* https://github.com/libtom/libtomcrypt/issues/108 */
  207. static int s_ecc_issue108(void)
  208. {
  209. void *a, *modulus, *order;
  210. ecc_point *Q, *Result;
  211. int err;
  212. const ltc_ecc_curve* dp;
  213. /* init */
  214. if ((err = mp_init_multi(&modulus, &order, &a, LTC_NULL)) != CRYPT_OK) { return err; }
  215. Q = ltc_ecc_new_point();
  216. Result = ltc_ecc_new_point();
  217. /* ECC-224 AKA SECP224R1 */
  218. if ((err = ecc_find_curve("SECP224R1", &dp)) != CRYPT_OK) { goto done; }
  219. /* read A */
  220. if ((err = mp_read_radix(a, (char *)dp->A, 16)) != CRYPT_OK) { goto done; }
  221. /* read modulus */
  222. if ((err = mp_read_radix(modulus, (char *)dp->prime, 16)) != CRYPT_OK) { goto done; }
  223. /* read order */
  224. if ((err = mp_read_radix(order, (char *)dp->order, 16)) != CRYPT_OK) { goto done; }
  225. /* read Q */
  226. if ((err = mp_read_radix(Q->x, (char *)"EA3745501BBC6A70BBFDD8AEEDB18CF5073C6DC9AA7CBB5915170D60", 16)) != CRYPT_OK) { goto done; }
  227. if ((err = mp_read_radix(Q->y, (char *)"6C9CB8E68AABFEC989CAC5E2326E0448B7E69C3E56039BA21A44FDAC", 16)) != CRYPT_OK) { goto done; }
  228. mp_set(Q->z, 1);
  229. /* calculate nQ */
  230. if ((err = ltc_mp.ecc_ptmul(order, Q, Result, a, modulus, 1)) != CRYPT_OK) { goto done; }
  231. done:
  232. ltc_ecc_del_point(Result);
  233. ltc_ecc_del_point(Q);
  234. mp_clear_multi(modulus, order, a, LTC_NULL);
  235. return err;
  236. }
  237. /* https://github.com/libtom/libtomcrypt/issues/443 */
  238. /* https://github.com/libtom/libtomcrypt/issues/447 */
  239. static int s_ecc_issue443_447(void)
  240. {
  241. const ltc_ecc_curve* cu;
  242. ecc_key key;
  243. int err, stat = 0;
  244. unsigned char hash[64];
  245. unsigned long hashlen;
  246. const unsigned char msg[] = { 0x54,0x65,0x73,0x74 };
  247. /* msg+pub1+sig1 test vector is from wycheproof - ecdsa_webcrypto_test (incorrect size of signature) */
  248. const unsigned char pub1[] = {
  249. 0x04,
  250. 0x4a,0x03,0xef,0x9f,0x92,0xeb,0x26,0x8c,0xaf,0xa6,0x01,0x07,0x24,0x89,0xa5,0x63,
  251. 0x80,0xfa,0x0d,0xc4,0x31,0x71,0xd7,0x71,0x28,0x13,0xb3,0xa1,0x9a,0x1e,0xb5,0xe5,
  252. 0x3e,0x21,0x3e,0x28,0xa6,0x08,0xce,0x9a,0x2f,0x4a,0x17,0xfd,0x83,0x0c,0x66,0x54,
  253. 0x01,0x8a,0x79,0xb3,0xe0,0x26,0x3d,0x91,0xa8,0xba,0x90,0x62,0x2d,0xf6,0xf2,0xf0
  254. };
  255. const unsigned char sig1[] = { 0x05, 0x01 };
  256. /* msg+pub2+sig2 test vector is from wycheproof - ecdsa_webcrypto_test (incorrect size of signature) */
  257. const unsigned char pub2[] = {
  258. 0x04,
  259. 0x00,0x5f,0x50,0x59,0x30,0x83,0x49,0xf9,0xeb,0xbb,0x4d,0x1c,0x55,0xc0,0xaf,0xcc,0xf6,0x21,0x62,0xec,0x1d,0xd1,
  260. 0x2e,0xf3,0xed,0x90,0x66,0x56,0x92,0x4f,0xfd,0x99,0xca,0xb9,0xf0,0x6b,0x0e,0xb2,0x18,0xcf,0xf0,0x78,0xa4,0x67,
  261. 0x7a,0x5c,0xe1,0xcc,0x07,0x65,0x2b,0xc9,0x76,0xae,0xfc,0x73,0x2c,0x28,0xf6,0x7e,0xf0,0x78,0xa4,0x34,0xe9,0x99,
  262. 0x00,0xa5,0xd1,0x4d,0xf3,0x10,0x63,0x0d,0x76,0xec,0x03,0xcb,0x6f,0x9b,0x95,0xbf,0x1a,0x22,0x43,0x81,0x05,0xc8,
  263. 0x8c,0xd9,0xfd,0x3d,0xac,0x80,0xf8,0x57,0xad,0xd3,0x82,0x71,0xd8,0xba,0x90,0x16,0x84,0xb2,0x6d,0x43,0x6d,0x4a,
  264. 0x85,0x9a,0xd4,0xcd,0xa5,0xe9,0x67,0x7b,0x73,0xca,0xb3,0xf3,0xe5,0xe4,0x1a,0x3d,0x79,0x96,0x60,0x72,0x79,0xab
  265. };
  266. const unsigned char sig2[] = { 0x01, 0x01 };
  267. hashlen = sizeof(hash);
  268. DO(hash_memory(find_hash("sha256"), msg, sizeof(msg), hash, &hashlen));
  269. DO(ecc_find_curve("secp256r1", &cu));
  270. DO(ecc_set_curve(cu, &key));
  271. DO(ecc_set_key(pub1, sizeof(pub1), PK_PUBLIC, &key));
  272. err = ecc_verify_hash_rfc7518(sig1, sizeof(sig1), hash, hashlen, &stat, &key); /* should fail */
  273. ecc_free(&key);
  274. if (err != CRYPT_INVALID_PACKET) return CRYPT_FAIL_TESTVECTOR;
  275. hashlen = sizeof(hash);
  276. DO(hash_memory(find_hash("sha512"), msg, sizeof(msg), hash, &hashlen));
  277. DO(ecc_find_curve("secp521r1", &cu));
  278. DO(ecc_set_curve(cu, &key));
  279. DO(ecc_set_key(pub2, sizeof(pub2), PK_PUBLIC, &key));
  280. err = ecc_verify_hash_rfc7518(sig2, sizeof(sig2), hash, hashlen, &stat, &key); /* should fail */
  281. ecc_free(&key);
  282. if (err != CRYPT_INVALID_PACKET) return CRYPT_FAIL_TESTVECTOR;
  283. return CRYPT_OK;
  284. }
  285. static int s_ecc_test_mp(void)
  286. {
  287. void *a, *modulus, *order;
  288. ecc_point *G, *GG;
  289. int i, err, primality;
  290. char buf[4096];
  291. DO(mp_init_multi(&modulus, &order, &a, LTC_NULL));
  292. G = ltc_ecc_new_point();
  293. GG = ltc_ecc_new_point();
  294. if (G == NULL || GG == NULL) {
  295. mp_clear_multi(modulus, order, LTC_NULL);
  296. ltc_ecc_del_point(G);
  297. ltc_ecc_del_point(GG);
  298. return CRYPT_MEM;
  299. }
  300. err = CRYPT_OK;
  301. for (i = 0; ltc_ecc_curves[i].prime != NULL; i++) {
  302. DO(mp_read_radix(a, (char *)ltc_ecc_curves[i].A, 16));
  303. DO(mp_read_radix(modulus, (char *)ltc_ecc_curves[i].prime, 16));
  304. DO(mp_read_radix(order, (char *)ltc_ecc_curves[i].order, 16));
  305. /* is prime actually prime? */
  306. DO(mp_prime_is_prime(modulus, 8, &primality));
  307. if (primality == 0) {
  308. err = CRYPT_FAIL_TESTVECTOR;
  309. mp_tohex(modulus, buf);
  310. printf("Modulus failed prime check: %s\n", buf);
  311. }
  312. /* is order prime ? */
  313. DO(mp_prime_is_prime(order, 8, &primality));
  314. if (primality == 0) {
  315. err = CRYPT_FAIL_TESTVECTOR;
  316. mp_tohex(order, buf);
  317. printf("Order failed prime check: %s\n", buf);
  318. }
  319. DO(mp_read_radix(G->x, (char *)ltc_ecc_curves[i].Gx, 16));
  320. DO(mp_read_radix(G->y, (char *)ltc_ecc_curves[i].Gy, 16));
  321. mp_set(G->z, 1);
  322. /* then we should have G == (order + 1)G */
  323. DO(mp_add_d(order, 1, order));
  324. DO(ltc_mp.ecc_ptmul(order, G, GG, a, modulus, 1));
  325. if (mp_cmp(G->x, GG->x) != LTC_MP_EQ || mp_cmp(G->y, GG->y) != LTC_MP_EQ) {
  326. err = CRYPT_FAIL_TESTVECTOR;
  327. }
  328. if (err != CRYPT_OK) {
  329. goto done;
  330. }
  331. }
  332. err = CRYPT_OK;
  333. done:
  334. ltc_ecc_del_point(GG);
  335. ltc_ecc_del_point(G);
  336. mp_clear_multi(order, modulus, a, LTC_NULL);
  337. return err;
  338. }
  339. static int s_ecc_old_api(void)
  340. {
  341. unsigned char buf[4][4096], ch;
  342. unsigned long x, y, z, s;
  343. int stat, stat2;
  344. ecc_key usera, userb, pubKey, privKey;
  345. int low, high;
  346. ecc_sizes(&low, &high);
  347. if (low < 14 || high < 14 || low > 100 || high > 100 || high < low) return CRYPT_FAIL_TESTVECTOR;
  348. for (s = 0; s < (sizeof(sizes)/sizeof(sizes[0])); s++) {
  349. /* make up two keys */
  350. DO(ecc_make_key (&yarrow_prng, find_prng ("yarrow"), sizes[s], &usera));
  351. DO(ecc_make_key (&yarrow_prng, find_prng ("yarrow"), sizes[s], &userb));
  352. if (ecc_get_size(&usera) != (int)sizes[s]) return CRYPT_FAIL_TESTVECTOR;
  353. if (ecc_get_size(&userb) != (int)sizes[s]) return CRYPT_FAIL_TESTVECTOR;
  354. /* make the shared secret */
  355. x = sizeof(buf[0]);
  356. DO(ecc_shared_secret (&usera, &userb, buf[0], &x));
  357. y = sizeof(buf[1]);
  358. DO(ecc_shared_secret (&userb, &usera, buf[1], &y));
  359. DO(do_compare_testvector(buf[0], x, buf[1], y, "ecc Shared keys", s));
  360. /* now export userb */
  361. y = sizeof(buf[0]);
  362. DO(ecc_export (buf[1], &y, PK_PUBLIC, &userb));
  363. ecc_free (&userb);
  364. /* import and make the shared secret again */
  365. DO(ecc_import (buf[1], y, &userb));
  366. z = sizeof(buf[0]);
  367. DO(ecc_shared_secret (&usera, &userb, buf[2], &z));
  368. if (z != x) {
  369. fprintf(stderr, "failed. Size don't match?");
  370. return 1;
  371. }
  372. if (memcmp (buf[0], buf[2], x)) {
  373. fprintf(stderr, "Failed. Contents didn't match.");
  374. return 1;
  375. }
  376. /* export with ANSI X9.63 */
  377. y = sizeof(buf[1]);
  378. DO(ecc_ansi_x963_export(&userb, buf[1], &y));
  379. ecc_free (&userb);
  380. /* now import the ANSI key */
  381. DO(ecc_ansi_x963_import(buf[1], y, &userb));
  382. /* shared secret */
  383. z = sizeof(buf[0]);
  384. DO(ecc_shared_secret (&usera, &userb, buf[2], &z));
  385. if (z != x) {
  386. fprintf(stderr, "failed. Size don't match?");
  387. return 1;
  388. }
  389. if (memcmp (buf[0], buf[2], x)) {
  390. fprintf(stderr, "Failed. Contents didn't match.");
  391. return 1;
  392. }
  393. ecc_free (&usera);
  394. ecc_free (&userb);
  395. /* test encrypt_key */
  396. DO(ecc_make_key (&yarrow_prng, find_prng ("yarrow"), sizes[s], &usera));
  397. /* export key */
  398. x = sizeof(buf[0]);
  399. DO(ecc_export(buf[0], &x, PK_PUBLIC, &usera));
  400. DO(ecc_import(buf[0], x, &pubKey));
  401. x = sizeof(buf[0]);
  402. DO(ecc_export(buf[0], &x, PK_PRIVATE, &usera));
  403. DO(ecc_import(buf[0], x, &privKey));
  404. for (ch = 0; ch < 32; ch++) {
  405. buf[0][ch] = ch;
  406. }
  407. y = sizeof (buf[1]);
  408. DO(ecc_encrypt_key (buf[0], 32, buf[1], &y, &yarrow_prng, find_prng ("yarrow"), find_hash ("sha256"), &pubKey));
  409. zeromem (buf[0], sizeof (buf[0]));
  410. x = sizeof (buf[0]);
  411. DO(ecc_decrypt_key (buf[1], y, buf[0], &x, &privKey));
  412. if (x != 32) {
  413. fprintf(stderr, "Failed (length)");
  414. return 1;
  415. }
  416. for (ch = 0; ch < 32; ch++) {
  417. if (buf[0][ch] != ch) {
  418. fprintf(stderr, "Failed (contents)");
  419. return 1;
  420. }
  421. }
  422. /* test sign_hash */
  423. for (ch = 0; ch < 16; ch++) {
  424. buf[0][ch] = ch;
  425. }
  426. x = sizeof (buf[1]);
  427. DO(ecc_sign_hash (buf[0], 16, buf[1], &x, &yarrow_prng, find_prng ("yarrow"), &privKey));
  428. DO(ecc_verify_hash (buf[1], x, buf[0], 16, &stat, &pubKey));
  429. buf[0][0] ^= 1;
  430. DO(ecc_verify_hash (buf[1], x, buf[0], 16, &stat2, &privKey));
  431. if (!(stat == 1 && stat2 == 0)) {
  432. fprintf(stderr, "ecc_verify_hash failed %d, %d, ", stat, stat2);
  433. return 1;
  434. }
  435. /* test sign_hash_rfc7518 */
  436. for (ch = 0; ch < 16; ch++) {
  437. buf[0][ch] = ch;
  438. }
  439. x = sizeof (buf[1]);
  440. DO(ecc_sign_hash_rfc7518(buf[0], 16, buf[1], &x, &yarrow_prng, find_prng ("yarrow"), &privKey));
  441. DO(ecc_verify_hash_rfc7518(buf[1], x, buf[0], 16, &stat, &pubKey));
  442. buf[0][0] ^= 1;
  443. DO(ecc_verify_hash_rfc7518(buf[1], x, buf[0], 16, &stat2, &privKey));
  444. if (!(stat == 1 && stat2 == 0)) {
  445. fprintf(stderr, "ecc_verify_hash_rfc7518 failed %d, %d, ", stat, stat2);
  446. return 1;
  447. }
  448. ecc_free (&usera);
  449. ecc_free (&pubKey);
  450. ecc_free (&privKey);
  451. }
  452. return CRYPT_OK;
  453. }
  454. static int s_ecc_key_cmp(const int should_type, const ecc_key *should, const ecc_key *is)
  455. {
  456. if (should_type != is->type) return CRYPT_ERROR;
  457. if (should_type == PK_PRIVATE) {
  458. if (mp_cmp(should->k, is->k) != LTC_MP_EQ) return CRYPT_ERROR;
  459. }
  460. if (mp_cmp(should->dp.prime, is->dp.prime) != LTC_MP_EQ) return CRYPT_ERROR;
  461. if (mp_cmp(should->dp.A, is->dp.A) != LTC_MP_EQ) return CRYPT_ERROR;
  462. if (mp_cmp(should->dp.B, is->dp.B) != LTC_MP_EQ) return CRYPT_ERROR;
  463. if (mp_cmp(should->dp.order, is->dp.order) != LTC_MP_EQ) return CRYPT_ERROR;
  464. if (mp_cmp(should->dp.base.x, is->dp.base.x) != LTC_MP_EQ) return CRYPT_ERROR;
  465. if (mp_cmp(should->dp.base.y, is->dp.base.y) != LTC_MP_EQ) return CRYPT_ERROR;
  466. if (mp_cmp(should->pubkey.x, is->pubkey.x) != LTC_MP_EQ) return CRYPT_ERROR;
  467. if (mp_cmp(should->pubkey.y, is->pubkey.y) != LTC_MP_EQ) return CRYPT_ERROR;
  468. if (should->dp.size != is->dp.size) return CRYPT_ERROR;
  469. if (should->dp.cofactor != is->dp.cofactor) return CRYPT_ERROR;
  470. return CRYPT_OK;
  471. }
  472. static int s_ecc_new_api(void)
  473. {
  474. int i, j, stat;
  475. const ltc_ecc_curve* dp;
  476. ecc_key key, privkey, pubkey;
  477. unsigned char buf[1000];
  478. unsigned long len;
  479. unsigned char data16[16] = { 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1 };
  480. unsigned long len16;
  481. for (i = 0; i < (int)(sizeof(curvenames)/sizeof(curvenames[0])); i++) {
  482. DO(ecc_find_curve(curvenames[i], &dp));
  483. /* make new key */
  484. DO(ecc_make_key_ex(&yarrow_prng, find_prng ("yarrow"), &key, dp));
  485. len = sizeof(buf);
  486. DO(ecc_export(buf, &len, PK_PRIVATE, &key));
  487. DO(ecc_import_ex(buf, len, &privkey, dp));
  488. ecc_free(&privkey);
  489. len = sizeof(buf);
  490. DO(ecc_export(buf, &len, PK_PUBLIC, &key));
  491. DO(ecc_import_ex(buf, len, &pubkey, dp));
  492. ecc_free(&pubkey);
  493. len = sizeof(buf);
  494. DO(ecc_ansi_x963_export(&key, buf, &len));
  495. ecc_free(&key);
  496. DO(ecc_ansi_x963_import_ex(buf, len, &pubkey, dp));
  497. ecc_free(&pubkey);
  498. /* generate new key */
  499. DO(ecc_set_curve(dp, &key));
  500. DO(ecc_generate_key(&yarrow_prng, find_prng ("yarrow"), &key));
  501. len = sizeof(buf);
  502. DO(ecc_get_key(buf, &len, PK_PRIVATE, &key));
  503. ecc_free(&key);
  504. /* load exported private key */
  505. DO(ecc_set_curve(dp, &privkey));
  506. DO(ecc_set_key(buf, len, PK_PRIVATE, &privkey));
  507. if (strcmp(ltc_mp.name, "TomsFastMath") != 0) {
  508. /* XXX-FIXME: TFM does not support sqrtmod_prime */
  509. /* export compressed public key */
  510. len = sizeof(buf);
  511. DO(ecc_get_key(buf, &len, PK_PUBLIC|PK_COMPRESSED, &privkey));
  512. if (len != 1 + (unsigned)ecc_get_size(&privkey)) return CRYPT_FAIL_TESTVECTOR;
  513. /* load exported public+compressed key */
  514. DO(ecc_set_curve(dp, &pubkey));
  515. DO(ecc_set_key(buf, len, PK_PUBLIC, &pubkey));
  516. ecc_free(&pubkey);
  517. }
  518. /* export long public key */
  519. len = sizeof(buf);
  520. DO(ecc_get_key(buf, &len, PK_PUBLIC, &privkey));
  521. if (len != 1 + 2 * (unsigned)ecc_get_size(&privkey)) return CRYPT_FAIL_TESTVECTOR;
  522. /* load exported public key */
  523. DO(ecc_set_curve(dp, &pubkey));
  524. DO(ecc_set_key(buf, len, PK_PUBLIC, &pubkey));
  525. /* test signature */
  526. len = sizeof(buf);
  527. DO(ecc_sign_hash(data16, 16, buf, &len, &yarrow_prng, find_prng ("yarrow"), &privkey));
  528. stat = 0;
  529. DO(ecc_verify_hash(buf, len, data16, 16, &stat, &pubkey));
  530. if (stat != 1) return CRYPT_FAIL_TESTVECTOR;
  531. #ifdef LTC_SSH
  532. /* test SSH+ECDSA/RFC5656 signature */
  533. len = sizeof(buf);
  534. DO(ecc_sign_hash_ex(data16, 16, buf, &len, &yarrow_prng, find_prng ("yarrow"),
  535. LTC_ECCSIG_RFC5656, NULL, &privkey));
  536. stat = 0;
  537. DO(ecc_verify_hash_ex(buf, len, data16, 16, LTC_ECCSIG_RFC5656, &stat, &pubkey));
  538. if (stat != 1) return CRYPT_FAIL_TESTVECTOR;
  539. #endif
  540. #ifdef LTC_ECC_SHAMIR
  541. if (strcmp(ltc_mp.name, "TomsFastMath") != 0) {
  542. /* XXX-FIXME: TFM does not support sqrtmod_prime */
  543. int found = 0;
  544. ecc_key reckey;
  545. /* test recovery */
  546. len = sizeof(buf);
  547. DO(ecc_sign_hash(data16, 16, buf, &len, &yarrow_prng, find_prng ("yarrow"), &privkey));
  548. DO(ecc_set_curve(dp, &reckey));
  549. for (j = 0; j < 2*(1+(int)privkey.dp.cofactor); j++) {
  550. stat = ecc_recover_key(buf, len, data16, 16, j, LTC_ECCSIG_ANSIX962, &reckey);
  551. if (stat != CRYPT_OK) continue; /* last two will almost always fail, only possible if x<(prime mod order) */
  552. stat = s_ecc_key_cmp(PK_PUBLIC, &pubkey, &reckey);
  553. if (stat == CRYPT_OK) found++;
  554. }
  555. if (found != 1) return CRYPT_FAIL_TESTVECTOR; /* unique match */
  556. ecc_free(&reckey);
  557. }
  558. #endif
  559. /* test encryption */
  560. len = sizeof(buf);
  561. DO(ecc_encrypt_key(data16, 16, buf, &len, &yarrow_prng, find_prng("yarrow"), find_hash("sha256"), &pubkey));
  562. zeromem(data16, 16);
  563. len16 = 16;
  564. DO(ecc_decrypt_key(buf, len, data16, &len16, &privkey));
  565. if (len16 != 16) return CRYPT_FAIL_TESTVECTOR;
  566. for (j = 0; j < 16; j++) if (data16[j] != 0xd1) return CRYPT_FAIL_TESTVECTOR;
  567. /* cleanup */
  568. ecc_free(&privkey);
  569. ecc_free(&pubkey);
  570. }
  571. return CRYPT_OK;
  572. }
  573. static int s_ecc_import_export(void) {
  574. const ltc_ecc_curve *cu;
  575. ecc_key key, pri, pub;
  576. unsigned char out[300];
  577. unsigned long outlen;
  578. /* the following test keys were generated by:
  579. # no password
  580. openssl ecparam -name secp256k1 -genkey -out main-key.pem
  581. openssl ec -in main-key.pem -param_enc explicit -out long_pri.der -outform DER
  582. openssl ec -in main-key.pem -param_enc explicit -conv_form compressed -out long_pric.der -outform DER
  583. openssl ec -in main-key.pem -param_enc explicit -pubout -out long_pub.der -outform DER
  584. openssl ec -in main-key.pem -param_enc explicit -pubout -conv_form compressed -out long_pubc.der -outform DER
  585. openssl ec -in main-key.pem -param_enc named_curve -out short_pri.der -outform DER
  586. openssl ec -in main-key.pem -param_enc named_curve -conv_form compressed -out short_pric.der -outform DER
  587. openssl ec -in main-key.pem -param_enc named_curve -pubout -out short_pub.der -outform DER
  588. openssl ec -in main-key.pem -param_enc named_curve -pubout -conv_form compressed -out short_pubc.der -outform DER
  589. # X.509 EC certificates
  590. 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
  591. 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
  592. 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
  593. 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
  594. # pkcs8 without password
  595. openssl pkcs8 -topk8 -inform DER -outform DER -nocrypt -in long_pri.der -out long_pri_pkcs8.der
  596. openssl pkcs8 -topk8 -inform DER -outform DER -nocrypt -in long_pric.der -out long_pric_pkcs8.der
  597. openssl pkcs8 -topk8 -inform DER -outform DER -nocrypt -in short_pri.der -out short_pri_pkcs8.der
  598. openssl pkcs8 -topk8 -inform DER -outform DER -nocrypt -in short_pric.der -out short_pric_pkcs8.der
  599. # password protected - PBES1
  600. 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
  601. 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
  602. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in long_pri.der -v1 PBE-MD5-DES -out long_pri_pkcs8_pbe_md5_des.der
  603. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in long_pri.der -v1 PBE-SHA1-RC2-64 -out long_pri_pkcs8_pbe_sha1_rc2_64.der
  604. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in long_pri.der -v1 PBE-MD5-RC2-64 -out long_pri_pkcs8_pbe_md5_rc2_64.der
  605. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in long_pri.der -v1 PBE-SHA1-DES -out long_pri_pkcs8_pbe_sha1_des.der
  606. # password protected - PBES2
  607. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in long_pri.der -v2 rc2 -out long_pri_pkcs8_pbkdf2_rc2_cbc.der
  608. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in long_pri.der -v2 des -out long_pri_pkcs8_pbkdf2_des_cbc.der
  609. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in long_pri.der -v2 des3 -out long_pri_pkcs8_pbkdf2_des_ede3_cbc.der
  610. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in long_pri.der -v2 des3 -v2prf hmacWithSHA224 -out long_pri_pkcs8_pbkdf2_sha224_des_ede3_cbc.der
  611. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in long_pri.der -v2 des3 -v2prf hmacWithSHA256 -out long_pri_pkcs8_pbkdf2_sha256_des_ede3_cbc.der
  612. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in long_pri.der -v2 des3 -v2prf hmacWithSHA384 -out long_pri_pkcs8_pbkdf2_sha384_des_ede3_cbc.der
  613. openssl pkcs8 -topk8 -inform DER -outform DER -passout pass:secret -in long_pri.der -v2 des3 -v2prf hmacWithSHA512 -out long_pri_pkcs8_pbkdf2_sha512_des_ede3_cbc.der
  614. */
  615. static const unsigned char long_pri[] = { /* private + long public, explicit curve params */
  616. 0x30, 0x82, 0x01, 0x13, 0x02, 0x01, 0x01, 0x04, 0x20, 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91,
  617. 0x1b, 0xba, 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2, 0xf7, 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d,
  618. 0x9f, 0x5f, 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd, 0x23, 0xa0, 0x81, 0xa5, 0x30, 0x81, 0xa2, 0x02,
  619. 0x01, 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00,
  620. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  621. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f,
  622. 0x30, 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04, 0x41, 0x04, 0x79, 0xbe, 0x66, 0x7e, 0xf9,
  623. 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d,
  624. 0xce, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98, 0x48, 0x3a, 0xda, 0x77, 0x26,
  625. 0xa3, 0xc4, 0x65, 0x5d, 0xa4, 0xfb, 0xfc, 0x0e, 0x11, 0x08, 0xa8, 0xfd, 0x17, 0xb4, 0x48, 0xa6,
  626. 0x85, 0x54, 0x19, 0x9c, 0x47, 0xd0, 0x8f, 0xfb, 0x10, 0xd4, 0xb8, 0x02, 0x21, 0x00, 0xff, 0xff,
  627. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xba, 0xae,
  628. 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01,
  629. 0x01, 0xa1, 0x44, 0x03, 0x42, 0x00, 0x04, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1,
  630. 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5,
  631. 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16, 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a, 0xb7,
  632. 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62, 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5, 0x6e,
  633. 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d
  634. };
  635. static const unsigned char long_pri_pkcs8[] = { /* private + long public, explicit curve params, PKCS8 */
  636. 0x30, 0x82, 0x01, 0x23, 0x02, 0x01, 0x00, 0x30, 0x81, 0xae, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce,
  637. 0x3d, 0x02, 0x01, 0x30, 0x81, 0xa2, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48,
  638. 0xce, 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  639. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  640. 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04,
  641. 0x41, 0x04, 0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87,
  642. 0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8,
  643. 0x17, 0x98, 0x48, 0x3a, 0xda, 0x77, 0x26, 0xa3, 0xc4, 0x65, 0x5d, 0xa4, 0xfb, 0xfc, 0x0e, 0x11,
  644. 0x08, 0xa8, 0xfd, 0x17, 0xb4, 0x48, 0xa6, 0x85, 0x54, 0x19, 0x9c, 0x47, 0xd0, 0x8f, 0xfb, 0x10,
  645. 0xd4, 0xb8, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  646. 0xff, 0xff, 0xff, 0xff, 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5e,
  647. 0x8c, 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01, 0x01, 0x04, 0x6d, 0x30, 0x6b, 0x02, 0x01, 0x01, 0x04,
  648. 0x20, 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b, 0xba, 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2,
  649. 0xf7, 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f, 0x5f, 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd,
  650. 0x23, 0xa1, 0x44, 0x03, 0x42, 0x00, 0x04, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1,
  651. 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5,
  652. 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16, 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a, 0xb7,
  653. 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62, 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5, 0x6e,
  654. 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d
  655. };
  656. #if defined(LTC_MD2) && defined(LTC_DES)
  657. static const unsigned char long_pri_pkcs8_pbe_md2_des[] = {
  658. 0x30, 0x82, 0x01, 0x49, 0x30, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  659. 0x01, 0x30, 0x0e, 0x04, 0x08, 0xd8, 0x1c, 0x80, 0xac, 0xd9, 0xfa, 0x9d, 0xbc, 0x02, 0x02, 0x08,
  660. 0x00, 0x04, 0x82, 0x01, 0x28, 0xe1, 0xd5, 0xa8, 0x9a, 0xa8, 0x23, 0x85, 0x53, 0x18, 0xb3, 0x96,
  661. 0x67, 0x8d, 0x45, 0x72, 0xf8, 0x69, 0xc4, 0xb1, 0x01, 0x3e, 0x04, 0xf7, 0xf7, 0x5d, 0x07, 0xad,
  662. 0xec, 0x8e, 0xd6, 0x23, 0x00, 0xe7, 0x59, 0xb0, 0x98, 0xbb, 0xdb, 0x85, 0xdb, 0x59, 0x4d, 0xb5,
  663. 0x53, 0xb3, 0x32, 0x50, 0x66, 0x75, 0xc4, 0x69, 0x05, 0x07, 0xee, 0xd4, 0xd8, 0x33, 0xcd, 0x4c,
  664. 0x94, 0xad, 0x82, 0xc7, 0x89, 0x53, 0x65, 0x9f, 0x55, 0x44, 0x95, 0x20, 0xe8, 0x4a, 0xc2, 0xef,
  665. 0x41, 0xf2, 0x9d, 0xf8, 0x3d, 0x16, 0x8a, 0x6a, 0x4e, 0x85, 0x90, 0xa7, 0xf9, 0xf8, 0xac, 0x16,
  666. 0x76, 0xf2, 0x29, 0x4b, 0x93, 0xec, 0xd8, 0x17, 0x3f, 0x89, 0x84, 0x79, 0x75, 0x90, 0x5f, 0xc3,
  667. 0xf2, 0xb8, 0x1a, 0x0a, 0x25, 0xf4, 0xe2, 0x59, 0xe0, 0xea, 0xa6, 0x57, 0xc4, 0x9c, 0xce, 0xfd,
  668. 0xa8, 0xbc, 0xf6, 0x0d, 0x3a, 0x47, 0x14, 0x9d, 0x6a, 0x92, 0x77, 0xe4, 0xcb, 0x88, 0x6e, 0xfa,
  669. 0x19, 0xa4, 0x3d, 0x58, 0xdb, 0x5f, 0xc7, 0xad, 0x91, 0x64, 0xb0, 0x1f, 0xe2, 0x66, 0xc5, 0x5a,
  670. 0x28, 0x21, 0xb0, 0xc1, 0xc8, 0x73, 0x55, 0xd8, 0x43, 0x66, 0x6a, 0x5c, 0xcd, 0xb0, 0x89, 0x60,
  671. 0x59, 0x31, 0xe0, 0x2f, 0x20, 0x3b, 0x83, 0xdf, 0x27, 0xcf, 0x33, 0xcc, 0xb9, 0xb6, 0xe0, 0xec,
  672. 0x8b, 0x94, 0x4b, 0xc4, 0x1c, 0x25, 0xba, 0x97, 0x6c, 0x83, 0x22, 0x8c, 0xca, 0x9d, 0xc6, 0xaa,
  673. 0x74, 0x3f, 0x46, 0xdc, 0xba, 0x7a, 0x36, 0x04, 0xa7, 0xc8, 0x65, 0xb4, 0xf7, 0x14, 0x53, 0x8c,
  674. 0xff, 0x4d, 0x19, 0xc1, 0xdb, 0xa4, 0xcc, 0x52, 0xc2, 0xd9, 0x38, 0x16, 0x8f, 0xd8, 0x6e, 0x55,
  675. 0x41, 0xa8, 0xe0, 0x15, 0xd6, 0x2d, 0xa4, 0x37, 0x9f, 0xcc, 0x42, 0x3c, 0xcb, 0xcc, 0x92, 0x04,
  676. 0xc8, 0xcf, 0xbc, 0x60, 0xfb, 0x45, 0xff, 0x62, 0x74, 0xa1, 0xe9, 0xba, 0x1e, 0x5d, 0x44, 0x6f,
  677. 0x0e, 0xac, 0xdf, 0xde, 0xb1, 0xbb, 0x47, 0x5e, 0x0c, 0x88, 0x0a, 0x85, 0x0b, 0xa8, 0x9e, 0xcb,
  678. 0x32, 0x99, 0x8d, 0xb1, 0xdd, 0x12, 0x08, 0xeb, 0x7e, 0x45, 0x70, 0x12, 0xe3
  679. };
  680. #endif
  681. #if defined(LTC_MD2) && defined(LTC_RC2)
  682. static const unsigned char long_pri_pkcs8_pbe_md2_rc2_64[] = {
  683. 0x30, 0x82, 0x01, 0x49, 0x30, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  684. 0x04, 0x30, 0x0e, 0x04, 0x08, 0xa2, 0x28, 0xb7, 0x2a, 0x08, 0x1c, 0x4a, 0xc4, 0x02, 0x02, 0x08,
  685. 0x00, 0x04, 0x82, 0x01, 0x28, 0x78, 0x12, 0x02, 0x58, 0x9b, 0xea, 0x77, 0xba, 0x84, 0x20, 0x96,
  686. 0x63, 0xf0, 0xf3, 0x38, 0x0b, 0x98, 0x53, 0x63, 0x8d, 0xa4, 0x5a, 0xa0, 0xa9, 0x21, 0x93, 0xd0,
  687. 0x56, 0xc9, 0xd2, 0x67, 0xb2, 0x5e, 0xb5, 0x9f, 0x15, 0x8c, 0x3c, 0x9a, 0xaf, 0x9c, 0xe5, 0x8b,
  688. 0xe6, 0x61, 0xac, 0xa4, 0x26, 0x75, 0x96, 0xea, 0x73, 0xaf, 0xd6, 0xb7, 0x4c, 0x66, 0x33, 0x98,
  689. 0x9e, 0x0b, 0xf8, 0xe6, 0x9c, 0xfd, 0x83, 0x0f, 0x55, 0x86, 0x9f, 0xa9, 0xf0, 0x23, 0xcb, 0x80,
  690. 0xe5, 0x32, 0x50, 0xea, 0x5b, 0x7d, 0xe2, 0x69, 0xc4, 0x6b, 0x61, 0xb2, 0xb8, 0x81, 0xe9, 0x05,
  691. 0xcb, 0x76, 0xae, 0xa5, 0x37, 0x0f, 0x3c, 0xe6, 0xde, 0x24, 0x6a, 0x9c, 0xf2, 0x0a, 0x28, 0x6a,
  692. 0xc9, 0xec, 0xef, 0xd7, 0xda, 0xcc, 0xf4, 0x3b, 0x74, 0x36, 0xc5, 0xaf, 0x53, 0xd8, 0xf4, 0x30,
  693. 0x0b, 0xd4, 0xb6, 0x36, 0xdc, 0x90, 0x4f, 0x83, 0x44, 0x79, 0xea, 0xc9, 0xb7, 0xb2, 0xd0, 0x03,
  694. 0xa6, 0x63, 0x7e, 0x1d, 0xa8, 0x4e, 0x93, 0x16, 0x7a, 0x4f, 0xd2, 0x8b, 0xd6, 0x78, 0x7d, 0x48,
  695. 0x41, 0x7c, 0xba, 0xc3, 0x64, 0x6f, 0x11, 0x22, 0x6d, 0x40, 0xb8, 0xc9, 0x03, 0x7a, 0x2c, 0xdf,
  696. 0x76, 0x78, 0x4f, 0x5f, 0x50, 0x03, 0x7a, 0xaf, 0x78, 0x91, 0xbb, 0x2a, 0xe6, 0x5e, 0x0f, 0xf5,
  697. 0x60, 0x9e, 0x8a, 0x2f, 0xdb, 0x9e, 0x57, 0xbe, 0xf6, 0x0f, 0x76, 0x6e, 0x44, 0x91, 0x7b, 0x36,
  698. 0x88, 0x9c, 0xf9, 0xbe, 0x13, 0x3e, 0x6b, 0x85, 0x62, 0xda, 0x1f, 0xf9, 0x73, 0x98, 0x8a, 0x0d,
  699. 0xdf, 0x11, 0x74, 0x18, 0xe1, 0x1c, 0xd1, 0x3f, 0x02, 0x43, 0xd4, 0x46, 0xe3, 0x8a, 0x3b, 0x6c,
  700. 0x7f, 0x81, 0xb4, 0xc3, 0x85, 0x4f, 0x89, 0x67, 0x26, 0x5a, 0x08, 0x35, 0x31, 0xd3, 0x15, 0xbb,
  701. 0xcc, 0x7d, 0x7b, 0x99, 0x41, 0xdb, 0x43, 0xa0, 0x83, 0x84, 0x74, 0x6c, 0x0a, 0x80, 0x46, 0xdc,
  702. 0xc8, 0x88, 0x87, 0x01, 0x21, 0x19, 0xd4, 0x1e, 0xf4, 0x09, 0x0e, 0x18, 0x31, 0x91, 0x37, 0x35,
  703. 0x1d, 0x07, 0xaf, 0x87, 0x92, 0x3d, 0xf8, 0xee, 0x6f, 0x87, 0x7b, 0x52, 0x3d
  704. };
  705. #endif
  706. #if defined(LTC_MD5) && defined(LTC_DES)
  707. static const unsigned char long_pri_pkcs8_pbe_md5_des[] = {
  708. 0x30, 0x82, 0x01, 0x49, 0x30, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  709. 0x03, 0x30, 0x0e, 0x04, 0x08, 0x33, 0xe7, 0xd9, 0xf1, 0x35, 0xd9, 0x74, 0x83, 0x02, 0x02, 0x08,
  710. 0x00, 0x04, 0x82, 0x01, 0x28, 0x2f, 0x77, 0x7c, 0x48, 0xc9, 0x43, 0x6d, 0xdb, 0xd0, 0x1a, 0xef,
  711. 0xfb, 0x29, 0x5e, 0x53, 0xa3, 0x52, 0x28, 0x27, 0x76, 0xc2, 0x01, 0x76, 0x5a, 0xea, 0x98, 0xe6,
  712. 0x72, 0xdf, 0x06, 0xa2, 0xf5, 0xd0, 0x7b, 0x74, 0xe4, 0x6b, 0x98, 0xa6, 0xb5, 0xe1, 0x02, 0xf7,
  713. 0xab, 0x2c, 0xf1, 0xeb, 0xf4, 0xec, 0xa6, 0xba, 0xd3, 0xd5, 0xb2, 0x26, 0x83, 0xeb, 0xff, 0xc9,
  714. 0xf8, 0x7b, 0xbf, 0xab, 0xdc, 0xe5, 0xe4, 0x91, 0xd5, 0x48, 0xba, 0x49, 0xcb, 0xc5, 0xf1, 0x71,
  715. 0x48, 0x1e, 0x96, 0x7c, 0x10, 0xe4, 0xa9, 0x35, 0xa7, 0xe6, 0x82, 0x97, 0x6f, 0xe4, 0x64, 0xd4,
  716. 0x53, 0xa9, 0xf1, 0x1b, 0x6c, 0x31, 0xa1, 0xc7, 0x12, 0x46, 0x45, 0x6f, 0x45, 0xb2, 0x09, 0x3a,
  717. 0xfe, 0x35, 0x4e, 0xbf, 0x7d, 0xf8, 0xcf, 0x94, 0x78, 0x0c, 0x78, 0xfb, 0xce, 0xc1, 0x30, 0xcd,
  718. 0x6d, 0x6b, 0x08, 0x5e, 0xf6, 0xf5, 0x97, 0xff, 0x5e, 0x63, 0x44, 0x36, 0xa5, 0x71, 0x04, 0xe5,
  719. 0x2d, 0xd9, 0xe3, 0x41, 0x91, 0x09, 0x1e, 0xa3, 0x30, 0xff, 0x12, 0x2a, 0x7a, 0xe1, 0x8f, 0x9c,
  720. 0x38, 0x13, 0x3d, 0xc3, 0xbb, 0x68, 0xfa, 0xc0, 0xc6, 0x35, 0x77, 0xed, 0xe8, 0x73, 0xca, 0xc3,
  721. 0x87, 0x62, 0xa9, 0x0e, 0xef, 0xcf, 0x73, 0x3c, 0xb3, 0xa0, 0x1b, 0xb5, 0x5d, 0x72, 0x89, 0x82,
  722. 0xd4, 0xf6, 0x37, 0x0b, 0x57, 0x8f, 0x48, 0xd4, 0xf1, 0x10, 0xa1, 0xe5, 0x25, 0x90, 0xeb, 0xde,
  723. 0x8d, 0x2a, 0x9d, 0xfb, 0x7c, 0x0d, 0xdc, 0x38, 0x45, 0x9e, 0xa0, 0x05, 0x98, 0x4e, 0x72, 0x9f,
  724. 0x3d, 0xde, 0xc7, 0x00, 0xf9, 0xaf, 0xdc, 0x67, 0x47, 0x73, 0xf7, 0xcf, 0x63, 0x80, 0xe3, 0x05,
  725. 0xb3, 0xda, 0x9f, 0x4b, 0x27, 0xd3, 0x14, 0xc9, 0x62, 0xd5, 0x09, 0xde, 0x4d, 0xe7, 0x21, 0x67,
  726. 0xfa, 0x10, 0x34, 0x18, 0xbf, 0xde, 0xf7, 0x95, 0x25, 0x6d, 0xba, 0xe4, 0x10, 0xf0, 0x9d, 0x05,
  727. 0x7b, 0xe4, 0xb5, 0xc0, 0x21, 0xb3, 0x7d, 0xcd, 0x1d, 0x80, 0xd0, 0x10, 0xd4, 0xdb, 0x9f, 0x06,
  728. 0xd5, 0x86, 0xea, 0x62, 0x96, 0xb7, 0x31, 0x73, 0xde, 0x25, 0xd0, 0xbb, 0xb2
  729. };
  730. #endif
  731. #if defined(LTC_MD5) && defined(LTC_RC2)
  732. static const unsigned char long_pri_pkcs8_pbe_md5_rc2_64[] = {
  733. 0x30, 0x82, 0x01, 0x49, 0x30, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  734. 0x06, 0x30, 0x0e, 0x04, 0x08, 0x95, 0x82, 0x6d, 0x08, 0xe4, 0x7e, 0xae, 0x5f, 0x02, 0x02, 0x08,
  735. 0x00, 0x04, 0x82, 0x01, 0x28, 0x93, 0x2c, 0xd8, 0x27, 0xed, 0x13, 0xe1, 0x31, 0xef, 0x7c, 0x44,
  736. 0x9c, 0xce, 0x85, 0x17, 0x38, 0x5a, 0xe3, 0xd8, 0xe9, 0xfd, 0x1e, 0x81, 0xae, 0x9c, 0xd7, 0x8b,
  737. 0x11, 0x4e, 0x92, 0x08, 0x3a, 0x97, 0x2c, 0x4f, 0x9a, 0xb7, 0x10, 0xda, 0x6a, 0x06, 0x9e, 0xe2,
  738. 0xb6, 0x41, 0xf8, 0xb3, 0xd4, 0x42, 0xcc, 0x67, 0xe8, 0x25, 0x76, 0x9a, 0xc2, 0x66, 0x1a, 0x94,
  739. 0x19, 0x0c, 0xe1, 0x43, 0x27, 0x27, 0x1e, 0xad, 0xfb, 0xce, 0xb7, 0x96, 0xfb, 0x5d, 0x6d, 0xf3,
  740. 0xe1, 0x73, 0xc5, 0x1c, 0xa0, 0xbe, 0x94, 0x2c, 0xe7, 0x1c, 0x04, 0xa9, 0xfe, 0xdf, 0x15, 0x79,
  741. 0x0c, 0x5e, 0xf8, 0xe2, 0xb9, 0x4a, 0xa0, 0xc5, 0x89, 0x2c, 0xf8, 0x1d, 0x5f, 0xcc, 0xf0, 0xb6,
  742. 0xe8, 0x31, 0xeb, 0xe5, 0xb4, 0x9d, 0x2a, 0xa8, 0x8d, 0xff, 0x69, 0xf7, 0x83, 0x65, 0xbb, 0xa2,
  743. 0xdd, 0xcd, 0x97, 0x41, 0x6e, 0xfa, 0xb6, 0xe1, 0x76, 0x7e, 0xa3, 0x24, 0x9b, 0x23, 0x58, 0x0e,
  744. 0xeb, 0x08, 0x00, 0x96, 0x53, 0xae, 0x6c, 0xb9, 0xaa, 0x5c, 0x9a, 0xf8, 0xee, 0xcd, 0xfd, 0xe5,
  745. 0xc5, 0x40, 0x62, 0x58, 0x6d, 0xf0, 0x10, 0xd5, 0x85, 0xeb, 0xed, 0x8a, 0x75, 0xe9, 0x8c, 0x2b,
  746. 0xe7, 0x39, 0xaf, 0xb1, 0x15, 0xdb, 0x4f, 0xe3, 0xa5, 0x24, 0x1d, 0xd2, 0xae, 0x82, 0x88, 0x1a,
  747. 0x37, 0x4c, 0x6b, 0x30, 0x9d, 0x6f, 0x93, 0x9c, 0x87, 0x99, 0xd1, 0x1c, 0x93, 0x0c, 0xbb, 0xf9,
  748. 0x70, 0x36, 0x28, 0x56, 0x68, 0x27, 0x2f, 0x1e, 0xf1, 0x86, 0x0a, 0x23, 0x04, 0xe6, 0x72, 0x1f,
  749. 0x1b, 0x71, 0x45, 0x0b, 0xe7, 0x74, 0x45, 0x8e, 0x7f, 0x94, 0xbc, 0xcd, 0x6c, 0xf8, 0xf3, 0xed,
  750. 0x44, 0x02, 0x4d, 0x0a, 0xdd, 0xe9, 0xe4, 0x46, 0x31, 0x94, 0x28, 0x9b, 0x5f, 0x05, 0x37, 0xf4,
  751. 0x05, 0x9c, 0xa3, 0x9c, 0xdf, 0xb7, 0xfb, 0xab, 0xe0, 0x07, 0x26, 0x40, 0x79, 0x12, 0x9a, 0x78,
  752. 0xf6, 0xb6, 0x30, 0x3d, 0x4e, 0x16, 0x2e, 0x39, 0x96, 0x98, 0x2a, 0x8c, 0xa7, 0xdb, 0xa0, 0x4a,
  753. 0x3f, 0x42, 0x30, 0xd3, 0x5d, 0xd0, 0x26, 0xd0, 0xc5, 0xd5, 0xa4, 0x10, 0x10
  754. };
  755. #endif
  756. #if defined(LTC_SHA1) && defined(LTC_DES)
  757. static const unsigned char long_pri_pkcs8_pbe_sha1_des[] = {
  758. 0x30, 0x82, 0x01, 0x49, 0x30, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  759. 0x0a, 0x30, 0x0e, 0x04, 0x08, 0x7c, 0x01, 0xae, 0xc9, 0x05, 0x43, 0x40, 0x70, 0x02, 0x02, 0x08,
  760. 0x00, 0x04, 0x82, 0x01, 0x28, 0xff, 0x96, 0x47, 0x56, 0x02, 0xd5, 0xd3, 0x2a, 0xf0, 0x44, 0x47,
  761. 0x7e, 0x74, 0x28, 0x62, 0x3f, 0x2b, 0xd4, 0xa9, 0xcc, 0x2c, 0xb7, 0x03, 0xc7, 0xa6, 0x39, 0xde,
  762. 0xc1, 0x46, 0xf1, 0xcd, 0x53, 0xb8, 0x76, 0xcd, 0xb8, 0xfd, 0xe8, 0x96, 0x1d, 0x52, 0xc5, 0xc2,
  763. 0x33, 0x2c, 0x2e, 0x4a, 0xe1, 0x83, 0x2e, 0x8a, 0x3a, 0x73, 0xfe, 0x50, 0x70, 0xcf, 0x2a, 0x29,
  764. 0xd5, 0x8a, 0x77, 0x96, 0xa3, 0x29, 0x7e, 0xfa, 0x74, 0xde, 0x78, 0x31, 0xd6, 0x78, 0x0a, 0x4f,
  765. 0x67, 0x8e, 0x26, 0xc9, 0x64, 0xf3, 0xde, 0xda, 0x5d, 0x15, 0xc2, 0x6b, 0x22, 0x25, 0x9e, 0x98,
  766. 0x41, 0x71, 0x4c, 0x09, 0x56, 0x90, 0x44, 0x7d, 0x16, 0xab, 0x7e, 0xd3, 0x75, 0x54, 0xbd, 0x88,
  767. 0x85, 0x4a, 0x01, 0xf4, 0x17, 0x19, 0xe2, 0x43, 0x5f, 0x31, 0xf9, 0x0b, 0x78, 0xd3, 0xb6, 0xc8,
  768. 0xa0, 0x29, 0x65, 0x86, 0xbc, 0x4b, 0xcb, 0xe2, 0xe8, 0xe7, 0x06, 0xe2, 0x27, 0xa3, 0x6a, 0xdc,
  769. 0x9f, 0x42, 0x40, 0xc4, 0x38, 0x49, 0x3b, 0x15, 0x28, 0x82, 0x9f, 0xa0, 0x2d, 0x42, 0x30, 0xa9,
  770. 0x28, 0x84, 0x41, 0x2b, 0xa3, 0xfb, 0xf1, 0x74, 0xa1, 0xfa, 0xff, 0x9d, 0xb6, 0x7e, 0x9b, 0x9f,
  771. 0xfa, 0xbd, 0x00, 0x17, 0x17, 0xa6, 0xb5, 0x2a, 0x1f, 0x6b, 0x55, 0x6c, 0xd4, 0x4b, 0xbe, 0xbb,
  772. 0xa5, 0xa7, 0x9f, 0x0c, 0x90, 0x04, 0x91, 0x09, 0x4d, 0x82, 0xe1, 0x67, 0x21, 0x96, 0x3a, 0x3b,
  773. 0xcf, 0x7f, 0xe9, 0xb9, 0xcc, 0x56, 0xd8, 0xc7, 0xe4, 0x98, 0x30, 0x11, 0x8f, 0xfd, 0xe5, 0xbc,
  774. 0x5e, 0xc4, 0x60, 0xe9, 0xd4, 0xc6, 0xf2, 0x60, 0xf3, 0xcd, 0x36, 0xa4, 0xe4, 0x6c, 0xfe, 0xbf,
  775. 0xab, 0xd5, 0x2f, 0x12, 0xf4, 0xa2, 0xf0, 0xeb, 0x10, 0xd9, 0x74, 0xef, 0x7c, 0x37, 0x8d, 0xdd,
  776. 0xc1, 0xaa, 0x84, 0xf6, 0xf1, 0xb6, 0x5b, 0x43, 0x51, 0x06, 0x78, 0xae, 0x8e, 0x9d, 0xc5, 0xc9,
  777. 0x26, 0xdc, 0x05, 0xa3, 0x00, 0xfa, 0x4a, 0x27, 0x5f, 0x19, 0xf3, 0x88, 0x2e, 0x01, 0xb8, 0xe7,
  778. 0x23, 0x37, 0x77, 0xa1, 0xbb, 0xb0, 0x66, 0xe2, 0xba, 0x10, 0x50, 0x06, 0x65
  779. };
  780. #endif
  781. #if defined(LTC_SHA1) && defined(LTC_RC2)
  782. static const unsigned char long_pri_pkcs8_pbe_sha1_rc2_64[] = {
  783. 0x30, 0x82, 0x01, 0x49, 0x30, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  784. 0x0b, 0x30, 0x0e, 0x04, 0x08, 0x64, 0x3c, 0xdb, 0x86, 0xd9, 0xa0, 0xae, 0x3e, 0x02, 0x02, 0x08,
  785. 0x00, 0x04, 0x82, 0x01, 0x28, 0x78, 0x85, 0x55, 0x7f, 0x37, 0xb8, 0xf7, 0xff, 0x94, 0x94, 0xf3,
  786. 0xf2, 0x21, 0x05, 0x6d, 0x75, 0xca, 0x03, 0x1c, 0xa3, 0x9f, 0x47, 0x41, 0x14, 0x57, 0xdd, 0x63,
  787. 0x71, 0x6c, 0xc2, 0x51, 0x14, 0x4a, 0x0d, 0x63, 0x12, 0xa8, 0x27, 0xf6, 0x3c, 0xb7, 0x47, 0x6d,
  788. 0xa0, 0x72, 0xfe, 0x60, 0x9f, 0x1c, 0xc8, 0xe4, 0xe5, 0xfe, 0x68, 0x9d, 0x85, 0x0f, 0x8e, 0x52,
  789. 0x2e, 0x30, 0xd5, 0x81, 0xd8, 0xc9, 0x05, 0x14, 0x1b, 0x1b, 0xf3, 0xbc, 0x95, 0x6d, 0x5d, 0x94,
  790. 0x71, 0xff, 0xa8, 0xfe, 0xa7, 0x34, 0xff, 0x30, 0xbe, 0x8e, 0xe4, 0x65, 0x6b, 0xd0, 0xa2, 0x43,
  791. 0x42, 0x14, 0x63, 0x36, 0x6f, 0x5d, 0x79, 0x56, 0x1b, 0x23, 0xd6, 0xdf, 0x39, 0x75, 0x48, 0x07,
  792. 0xa2, 0x5f, 0x8d, 0x11, 0x7c, 0x95, 0x48, 0x18, 0x2d, 0xdd, 0x92, 0x14, 0x4f, 0xfd, 0x45, 0x7e,
  793. 0x60, 0x68, 0xde, 0x47, 0x04, 0x0d, 0x0a, 0xa6, 0x3a, 0x30, 0xcb, 0x29, 0xc7, 0x9e, 0x27, 0xc3,
  794. 0x2d, 0x49, 0xbd, 0x1e, 0xc5, 0xc9, 0xd8, 0xd2, 0x22, 0x72, 0xe2, 0xd0, 0x8e, 0x03, 0xe8, 0x84,
  795. 0xfd, 0x7e, 0xb8, 0x8a, 0xd7, 0x70, 0x6d, 0x0b, 0xec, 0x67, 0xd0, 0xb3, 0x08, 0x9a, 0x31, 0x32,
  796. 0x43, 0x1f, 0xa3, 0xd1, 0x6b, 0x3a, 0x63, 0xbc, 0xca, 0x25, 0x1e, 0x55, 0xd7, 0x21, 0x68, 0x77,
  797. 0xfa, 0x41, 0x70, 0xdc, 0x3a, 0xfb, 0x05, 0x19, 0xd8, 0x8a, 0xe3, 0xe7, 0xfc, 0xf1, 0xc1, 0x0d,
  798. 0xd4, 0x9e, 0x64, 0xd0, 0x91, 0xa5, 0x4d, 0x7b, 0x8b, 0xd9, 0xee, 0xa7, 0x6b, 0x2b, 0x0f, 0xd9,
  799. 0xcf, 0xb3, 0xb4, 0x5b, 0x4e, 0xcc, 0xac, 0x53, 0xe5, 0xd3, 0xdd, 0x73, 0x40, 0xa5, 0x35, 0x71,
  800. 0xeb, 0xca, 0xa7, 0xc0, 0xae, 0x70, 0xdf, 0x14, 0x83, 0xbe, 0xd8, 0x37, 0xfa, 0x8b, 0x14, 0xdb,
  801. 0x0c, 0x4e, 0x98, 0xc7, 0xe6, 0x40, 0x38, 0x94, 0x69, 0xd4, 0xd4, 0xa9, 0xb5, 0x3f, 0xec, 0xac,
  802. 0x14, 0x59, 0x46, 0xb5, 0x98, 0xb0, 0x99, 0x89, 0xea, 0xf5, 0x43, 0xb4, 0x47, 0xa9, 0xb1, 0xf2,
  803. 0x03, 0x2a, 0xaf, 0xd5, 0x5d, 0x81, 0xae, 0x3b, 0xb4, 0x52, 0x11, 0x85, 0xcb
  804. };
  805. #endif
  806. #if defined(LTC_DES)
  807. static const unsigned char long_pri_pkcs8_pbkdf2_des_cbc[] = {
  808. 0x30, 0x82, 0x01, 0x6b, 0x30, 0x3d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  809. 0x0d, 0x30, 0x30, 0x30, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05, 0x0c,
  810. 0x30, 0x0e, 0x04, 0x08, 0xda, 0x6b, 0x0a, 0x58, 0x7e, 0xd2, 0x9d, 0x38, 0x02, 0x02, 0x08, 0x00,
  811. 0x30, 0x11, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x07, 0x04, 0x08, 0xcc, 0x5c, 0x19, 0x7c, 0xa6,
  812. 0x0d, 0x01, 0x4b, 0x04, 0x82, 0x01, 0x28, 0x02, 0x9d, 0xec, 0xa4, 0xe1, 0x42, 0xc4, 0xdb, 0x18,
  813. 0x32, 0x26, 0x96, 0x8b, 0x87, 0x1a, 0xb7, 0x66, 0x8e, 0xfd, 0x23, 0x1e, 0x1e, 0x20, 0x18, 0xcd,
  814. 0x81, 0x1b, 0x67, 0x86, 0x78, 0xae, 0xb3, 0x70, 0x81, 0xf9, 0x6a, 0x26, 0x4e, 0x31, 0x64, 0xf8,
  815. 0x7e, 0xbf, 0xf3, 0xd3, 0xea, 0x7c, 0xda, 0x5d, 0x4d, 0xb7, 0xe2, 0xda, 0x9a, 0x80, 0x94, 0xd1,
  816. 0x65, 0x5f, 0x57, 0x17, 0xbc, 0xac, 0xd3, 0xb4, 0x94, 0xdc, 0xd0, 0x34, 0xe9, 0xed, 0x57, 0x97,
  817. 0x53, 0xe9, 0x24, 0x21, 0xac, 0x2b, 0xd1, 0xd9, 0x35, 0x7f, 0xf0, 0x79, 0x14, 0xce, 0x96, 0xe2,
  818. 0x55, 0xfb, 0xb9, 0x6e, 0xeb, 0xbf, 0xc8, 0xf2, 0x66, 0xc1, 0x42, 0xee, 0x94, 0x22, 0xac, 0x6a,
  819. 0xe2, 0xf6, 0xba, 0xfc, 0xeb, 0xc1, 0xd0, 0xec, 0x3c, 0x16, 0xa4, 0x36, 0x7a, 0xbf, 0xe9, 0x9d,
  820. 0x39, 0xd6, 0x32, 0x54, 0x3e, 0x86, 0xcf, 0xe4, 0x32, 0x1c, 0xc5, 0x54, 0x3f, 0x8d, 0x6e, 0xb9,
  821. 0x6c, 0x3d, 0xd7, 0x68, 0xd7, 0x67, 0xdd, 0x04, 0x0e, 0x8c, 0xfd, 0x62, 0x1a, 0x21, 0xa8, 0xcc,
  822. 0x67, 0xbd, 0x4f, 0x9b, 0x3c, 0x99, 0xd5, 0xa5, 0x98, 0x12, 0x33, 0x04, 0xcf, 0x1b, 0x58, 0x3f,
  823. 0xb2, 0x70, 0xfe, 0x92, 0xff, 0x7a, 0x73, 0xf9, 0x37, 0xd5, 0x20, 0x0e, 0x49, 0xed, 0xb3, 0x77,
  824. 0x73, 0x0f, 0x3e, 0xf8, 0x15, 0xc1, 0xfc, 0x28, 0x47, 0x10, 0xe8, 0x30, 0xee, 0xa9, 0x96, 0xcf,
  825. 0x39, 0xb6, 0x83, 0xe2, 0x84, 0x1d, 0x0e, 0x65, 0xb7, 0x02, 0x08, 0xf7, 0x8d, 0xe7, 0xf2, 0xcc,
  826. 0x52, 0xc2, 0xe6, 0x1d, 0xf6, 0x96, 0x17, 0x3e, 0x3f, 0xd8, 0x70, 0x8d, 0x2c, 0x62, 0x00, 0xf3,
  827. 0x32, 0xbd, 0x1c, 0x6b, 0x4a, 0x0c, 0xc6, 0x46, 0x61, 0x92, 0x1c, 0x01, 0x11, 0xbc, 0x55, 0xdd,
  828. 0x82, 0xd1, 0xbf, 0x2e, 0x1e, 0x97, 0xbe, 0xa7, 0x6e, 0x5a, 0xcd, 0xc6, 0x8f, 0x38, 0x24, 0x8f,
  829. 0xb8, 0x36, 0x3d, 0x06, 0x82, 0x14, 0x5b, 0x1a, 0x84, 0x1e, 0x47, 0x53, 0x3a, 0x12, 0x21, 0x23,
  830. 0xbe, 0xe4, 0xf4, 0x57, 0xc7, 0x31, 0x45, 0x24, 0x46, 0x94, 0x53, 0x0b, 0x1d, 0xcd, 0x57
  831. };
  832. #endif
  833. #if defined(LTC_DES)
  834. static const unsigned char long_pri_pkcs8_pbkdf2_des_ede3_cbc[] = {
  835. 0x30, 0x82, 0x01, 0x6e, 0x30, 0x40, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  836. 0x0d, 0x30, 0x33, 0x30, 0x1b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05, 0x0c,
  837. 0x30, 0x0e, 0x04, 0x08, 0x6a, 0x99, 0x55, 0x06, 0x40, 0xd5, 0xe6, 0xc9, 0x02, 0x02, 0x08, 0x00,
  838. 0x30, 0x14, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x03, 0x07, 0x04, 0x08, 0x7f, 0xf2,
  839. 0xa7, 0xa3, 0x2c, 0xbb, 0x8e, 0x78, 0x04, 0x82, 0x01, 0x28, 0x55, 0x4d, 0xcb, 0xab, 0xb8, 0x6e,
  840. 0xcf, 0x00, 0xd2, 0xe8, 0x1e, 0x0e, 0xe1, 0x8f, 0x51, 0x8e, 0x32, 0x68, 0xaf, 0x44, 0xa6, 0xf2,
  841. 0x9e, 0x11, 0xd7, 0x0f, 0xa7, 0xd5, 0x74, 0x77, 0xbc, 0x6b, 0x53, 0x40, 0x70, 0xb6, 0x02, 0xdb,
  842. 0xa6, 0x2e, 0xc7, 0x20, 0x15, 0x78, 0x91, 0xcc, 0x5b, 0xa7, 0x15, 0x58, 0x65, 0xeb, 0xc7, 0x6f,
  843. 0xb8, 0x14, 0xc9, 0x5f, 0x89, 0x58, 0xe2, 0xab, 0x69, 0x17, 0xe2, 0xe7, 0xe0, 0xa4, 0x59, 0xb7,
  844. 0x6a, 0xc2, 0xe5, 0xba, 0x03, 0x0e, 0xcc, 0x0a, 0xb1, 0xf0, 0x69, 0xb2, 0x90, 0xac, 0x30, 0x79,
  845. 0xd4, 0xa3, 0x90, 0xa2, 0x60, 0x37, 0x7d, 0xf8, 0xd9, 0x49, 0xa3, 0x0b, 0x6d, 0xd9, 0x98, 0x9e,
  846. 0xb0, 0x6a, 0xad, 0x97, 0x08, 0xf1, 0xfd, 0xec, 0xf8, 0xa7, 0x3c, 0xf6, 0x48, 0x81, 0x5b, 0x6d,
  847. 0x19, 0xcc, 0xed, 0x49, 0x94, 0x05, 0x6e, 0xa4, 0x9b, 0x58, 0xdd, 0xaf, 0xd7, 0x3d, 0x12, 0xe6,
  848. 0xf4, 0x12, 0x46, 0xd9, 0x82, 0xde, 0xb7, 0xc4, 0xeb, 0x1c, 0x3a, 0xef, 0x93, 0x82, 0x3d, 0xf8,
  849. 0x55, 0x88, 0xe5, 0x54, 0xd6, 0x74, 0x1c, 0x20, 0xbd, 0x40, 0x65, 0x99, 0x19, 0x5f, 0x25, 0x62,
  850. 0x35, 0x6d, 0x32, 0x64, 0xd7, 0xa1, 0x45, 0xa8, 0xc4, 0x8d, 0xe0, 0x6d, 0x14, 0x85, 0x84, 0x75,
  851. 0x62, 0x0f, 0xb0, 0xe9, 0xb1, 0xca, 0x31, 0x97, 0x22, 0x41, 0xb3, 0xf5, 0xdf, 0x5c, 0xbf, 0x3f,
  852. 0x4f, 0x01, 0xf8, 0xe7, 0xbc, 0xdc, 0xb2, 0x9a, 0x7d, 0x0c, 0x96, 0x38, 0x48, 0x7a, 0x1b, 0x89,
  853. 0x2b, 0xab, 0xa6, 0xbd, 0xee, 0x7a, 0xf8, 0x85, 0x82, 0x80, 0x8c, 0x3b, 0x05, 0x3c, 0x40, 0x69,
  854. 0x97, 0x0a, 0x4c, 0x45, 0xae, 0x38, 0x22, 0xc5, 0x95, 0xf2, 0x4f, 0x0c, 0xd5, 0x54, 0x23, 0x92,
  855. 0x9b, 0x06, 0x81, 0xca, 0xa5, 0x1e, 0x91, 0x7e, 0x2b, 0x85, 0xb4, 0xd4, 0xeb, 0xb6, 0xee, 0x22,
  856. 0x10, 0x72, 0xaf, 0x9e, 0x6d, 0xcc, 0x16, 0x24, 0x01, 0x44, 0x48, 0xaa, 0xc9, 0xf8, 0x38, 0x72,
  857. 0x7a, 0x35, 0x94, 0x20, 0x58, 0xa2, 0x1c, 0x81, 0xaf, 0x47, 0x3b, 0xb8, 0x23, 0xbb, 0x71, 0x09,
  858. 0xbf, 0x93
  859. };
  860. #endif
  861. #if defined(LTC_RC2)
  862. static const unsigned char long_pri_pkcs8_pbkdf2_rc2_cbc[] = {
  863. 0x30, 0x82, 0x01, 0x76, 0x30, 0x48, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  864. 0x0d, 0x30, 0x3b, 0x30, 0x1e, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05, 0x0c,
  865. 0x30, 0x11, 0x04, 0x08, 0xbf, 0xef, 0x1a, 0x42, 0x5d, 0xc3, 0x6b, 0x0f, 0x02, 0x02, 0x08, 0x00,
  866. 0x02, 0x01, 0x10, 0x30, 0x19, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x03, 0x02, 0x30,
  867. 0x0d, 0x02, 0x01, 0x3a, 0x04, 0x08, 0xfe, 0xf2, 0x09, 0x0c, 0xa4, 0xd0, 0xe6, 0x83, 0x04, 0x82,
  868. 0x01, 0x28, 0x61, 0x18, 0x73, 0xb7, 0x9d, 0x58, 0xc8, 0x4a, 0xf4, 0x24, 0xec, 0xb4, 0xe6, 0x24,
  869. 0xa7, 0xf0, 0x1e, 0xea, 0xc3, 0x57, 0x44, 0xb7, 0x5a, 0x77, 0xe5, 0x3c, 0x1c, 0x6a, 0x6b, 0x70,
  870. 0x6e, 0x64, 0x35, 0xa5, 0x5d, 0x32, 0xe3, 0xce, 0xe8, 0x79, 0xa4, 0x7f, 0x2b, 0xfc, 0xcb, 0x07,
  871. 0x62, 0xcd, 0xc9, 0x15, 0x30, 0xdf, 0x69, 0xae, 0xe8, 0xb4, 0x83, 0xec, 0x2a, 0xaf, 0xb3, 0x29,
  872. 0x92, 0x77, 0xf3, 0x31, 0x4d, 0x5f, 0xcb, 0xea, 0xa2, 0x4d, 0xfb, 0xa1, 0x68, 0xbe, 0x00, 0x01,
  873. 0x6d, 0x3f, 0xc6, 0xc1, 0x13, 0xee, 0xb0, 0x5a, 0x52, 0xce, 0xdc, 0x12, 0xf8, 0x42, 0x22, 0x2f,
  874. 0x57, 0x2e, 0x54, 0xac, 0x48, 0x31, 0x4d, 0x3c, 0xa1, 0x97, 0x5e, 0x17, 0x74, 0x88, 0x9b, 0x31,
  875. 0x91, 0x69, 0x00, 0x00, 0x15, 0x2c, 0xc2, 0xac, 0x70, 0x84, 0x9c, 0x7e, 0x5d, 0xc9, 0xee, 0x06,
  876. 0xcc, 0x38, 0x9d, 0x7d, 0xea, 0x71, 0xc3, 0x4f, 0x99, 0x08, 0xde, 0xb0, 0x1b, 0x3b, 0x2a, 0xbd,
  877. 0x7e, 0x01, 0x3b, 0x5e, 0xe5, 0xc2, 0x54, 0xf2, 0x30, 0xe5, 0xa0, 0xf3, 0x69, 0x87, 0x77, 0xed,
  878. 0xa1, 0x37, 0x76, 0x6a, 0xec, 0xe2, 0x9c, 0x8d, 0x4c, 0xe9, 0xf4, 0xd0, 0xca, 0xb5, 0x8f, 0xd0,
  879. 0x63, 0x17, 0x41, 0xcb, 0x29, 0x58, 0x4f, 0x2a, 0xd1, 0xe1, 0x03, 0x73, 0x09, 0xcc, 0x93, 0xc6,
  880. 0xde, 0x1e, 0x34, 0x0f, 0xb3, 0x67, 0xfd, 0x5e, 0x49, 0x16, 0x84, 0x84, 0x6a, 0x8f, 0x55, 0x22,
  881. 0x0b, 0xe4, 0xd8, 0xee, 0x2e, 0x9f, 0x25, 0x19, 0x89, 0x19, 0xe6, 0x8d, 0x64, 0x31, 0x38, 0x68,
  882. 0xfa, 0x40, 0x84, 0xca, 0x39, 0xef, 0x1a, 0x4a, 0xe9, 0x04, 0xee, 0xcc, 0x4a, 0xea, 0x19, 0x96,
  883. 0xa4, 0xcd, 0x62, 0x76, 0xb3, 0xc4, 0x2c, 0x23, 0x75, 0x24, 0xcd, 0x49, 0xe2, 0x17, 0x81, 0x45,
  884. 0x24, 0x55, 0xeb, 0xe1, 0xb4, 0xeb, 0xda, 0xc5, 0x56, 0xac, 0xfa, 0x30, 0xbd, 0x05, 0xbb, 0x03,
  885. 0x65, 0x50, 0xdc, 0xbf, 0xdf, 0xff, 0x2a, 0x80, 0x85, 0x6d, 0x6a, 0x5c, 0x93, 0xb8, 0x81, 0xc4,
  886. 0xca, 0x91, 0x08, 0x7b, 0x8a, 0x9d, 0xe9, 0x2d, 0xfc, 0x3b
  887. };
  888. #endif
  889. #if defined(LTC_SHA224) && defined(LTC_DES)
  890. static const unsigned char long_pri_pkcs8_pbkdf2_sha224_des_ede3_cbc[] = {
  891. 0x30, 0x82, 0x01, 0x7c, 0x30, 0x4e, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  892. 0x0d, 0x30, 0x41, 0x30, 0x29, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05, 0x0c,
  893. 0x30, 0x1c, 0x04, 0x08, 0xb2, 0x82, 0x71, 0xc5, 0xd6, 0x3c, 0x2b, 0x92, 0x02, 0x02, 0x08, 0x00,
  894. 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x08, 0x05, 0x00, 0x30, 0x14,
  895. 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x03, 0x07, 0x04, 0x08, 0x4a, 0x46, 0x2a, 0xa9,
  896. 0xd5, 0x9f, 0x79, 0xea, 0x04, 0x82, 0x01, 0x28, 0xc4, 0x27, 0x05, 0xa8, 0x01, 0xa7, 0xc9, 0x0d,
  897. 0x0e, 0x74, 0x06, 0x4a, 0xb8, 0x07, 0x9f, 0x7b, 0x0f, 0x82, 0xfd, 0x2c, 0xb5, 0x4f, 0x63, 0xed,
  898. 0xed, 0x86, 0x96, 0x79, 0x08, 0x2d, 0x5f, 0x6d, 0x8c, 0x83, 0xc9, 0xcc, 0xd4, 0x9b, 0x0a, 0x81,
  899. 0x60, 0x22, 0x09, 0xb9, 0x12, 0xca, 0xf1, 0xad, 0x61, 0x22, 0xf0, 0x6b, 0xdb, 0x52, 0x99, 0xae,
  900. 0x70, 0x2b, 0x61, 0x63, 0xdc, 0x2f, 0xc1, 0xd3, 0xb5, 0x28, 0xbb, 0xa1, 0xd2, 0xb7, 0xaf, 0xbb,
  901. 0x86, 0xa1, 0x1b, 0x46, 0x0a, 0xc9, 0xab, 0x44, 0xd2, 0x9c, 0x16, 0x18, 0x8b, 0x4a, 0x92, 0x56,
  902. 0x5b, 0x50, 0x39, 0x1b, 0x88, 0x50, 0x92, 0x35, 0xb8, 0x85, 0xc3, 0xaa, 0x56, 0x76, 0xde, 0xbf,
  903. 0x68, 0x91, 0x2e, 0xc8, 0x28, 0x29, 0xd8, 0x71, 0x60, 0xe3, 0xf0, 0x5a, 0x66, 0x85, 0xdd, 0x6b,
  904. 0x5c, 0xaf, 0xf1, 0x28, 0xf8, 0xdc, 0xa7, 0x8d, 0xc4, 0x9b, 0xcb, 0xb2, 0x99, 0x34, 0x4d, 0x76,
  905. 0xa0, 0x8b, 0xf2, 0x18, 0x8e, 0x42, 0xe0, 0x79, 0xc3, 0xeb, 0x0f, 0x00, 0xe7, 0xbe, 0x83, 0xdf,
  906. 0xba, 0xa5, 0xf1, 0x81, 0x05, 0x1c, 0xc9, 0xda, 0xea, 0xe1, 0xc4, 0x38, 0x24, 0x1e, 0xcf, 0xea,
  907. 0x22, 0x05, 0x75, 0x43, 0xfe, 0xfe, 0x14, 0xf7, 0x6d, 0x41, 0x67, 0xcf, 0xfd, 0x57, 0xa7, 0xfc,
  908. 0x22, 0x03, 0x14, 0xc1, 0xf6, 0x4d, 0x40, 0x4e, 0xf1, 0xec, 0x72, 0xec, 0x3c, 0xb1, 0x87, 0x44,
  909. 0xe9, 0x72, 0xc5, 0x8b, 0x48, 0xd9, 0x98, 0x08, 0x55, 0xc5, 0x40, 0x26, 0xf5, 0x8d, 0x73, 0x5e,
  910. 0x35, 0x98, 0x71, 0x09, 0x98, 0xfa, 0xb7, 0x1c, 0x35, 0xcd, 0xd4, 0xf1, 0x65, 0xb4, 0x59, 0xdb,
  911. 0x9e, 0x79, 0xe7, 0x21, 0x99, 0xd7, 0x9e, 0x8c, 0x13, 0x77, 0x0c, 0x5e, 0xae, 0x43, 0x82, 0xf1,
  912. 0x83, 0x79, 0x7d, 0x37, 0x51, 0xde, 0x65, 0x26, 0x1f, 0x8f, 0x81, 0x1c, 0x55, 0x40, 0xec, 0xaf,
  913. 0x3f, 0x0a, 0x68, 0xd2, 0xc7, 0x59, 0x47, 0xda, 0x78, 0x0c, 0x0e, 0x59, 0x6a, 0x93, 0xcd, 0x05,
  914. 0x09, 0x51, 0x47, 0xb1, 0x45, 0x3f, 0x67, 0xf8, 0x76, 0x50, 0x76, 0xa3, 0x2d, 0x31, 0x17, 0x73
  915. };
  916. #endif
  917. #if defined(LTC_SHA256) && defined(LTC_DES)
  918. static const unsigned char long_pri_pkcs8_pbkdf2_sha256_des_ede3_cbc[] = {
  919. 0x30, 0x82, 0x01, 0x7c, 0x30, 0x4e, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  920. 0x0d, 0x30, 0x41, 0x30, 0x29, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05, 0x0c,
  921. 0x30, 0x1c, 0x04, 0x08, 0x93, 0x6e, 0x0a, 0x02, 0x8e, 0x72, 0xac, 0x98, 0x02, 0x02, 0x08, 0x00,
  922. 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x09, 0x05, 0x00, 0x30, 0x14,
  923. 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x03, 0x07, 0x04, 0x08, 0x89, 0xa4, 0xc9, 0xd9,
  924. 0x82, 0xfa, 0x02, 0x76, 0x04, 0x82, 0x01, 0x28, 0xec, 0xd9, 0xee, 0xbf, 0xfa, 0xe6, 0x51, 0xdb,
  925. 0x02, 0xcb, 0xf3, 0x2c, 0x55, 0xdb, 0x83, 0x90, 0x5d, 0x9e, 0xf6, 0xbe, 0x10, 0xae, 0x35, 0x8c,
  926. 0x22, 0x39, 0xfc, 0xf9, 0xd1, 0x23, 0x27, 0x68, 0xd3, 0x15, 0x46, 0xed, 0x5d, 0x15, 0xfb, 0xdf,
  927. 0x6f, 0xe1, 0x01, 0x1c, 0xed, 0x4c, 0xfc, 0x78, 0x94, 0x47, 0x71, 0x92, 0xbc, 0xa1, 0xa6, 0x06,
  928. 0x74, 0x22, 0xcc, 0xbb, 0x49, 0x98, 0x43, 0xf1, 0xc2, 0xde, 0x4e, 0xeb, 0x56, 0x0e, 0x03, 0xc1,
  929. 0xf1, 0xc1, 0x80, 0x4b, 0x70, 0xd0, 0x8f, 0xf3, 0xd8, 0x18, 0x08, 0x41, 0x7a, 0xf9, 0x8b, 0x74,
  930. 0xe5, 0x28, 0x61, 0x77, 0x2f, 0x84, 0xb3, 0xb3, 0x68, 0xce, 0x19, 0xf0, 0xc6, 0xa9, 0xc1, 0x29,
  931. 0x96, 0xca, 0x3b, 0xdb, 0x13, 0x99, 0x86, 0xbe, 0x21, 0x0d, 0x00, 0xd7, 0x30, 0x15, 0x74, 0xfb,
  932. 0x43, 0xf7, 0x14, 0x97, 0x6d, 0xed, 0xeb, 0xe3, 0x4d, 0x67, 0x80, 0x35, 0x03, 0x69, 0x0d, 0xbe,
  933. 0xf1, 0x99, 0x6b, 0x53, 0xb7, 0xa3, 0xdf, 0xf4, 0xc3, 0xda, 0x20, 0x9b, 0xbf, 0xf9, 0x3f, 0x19,
  934. 0xae, 0xd5, 0x37, 0x91, 0x36, 0x42, 0xf3, 0x7d, 0xad, 0x40, 0x3c, 0x2a, 0x7f, 0x2d, 0xf1, 0x79,
  935. 0xee, 0x4c, 0x08, 0x3a, 0xd6, 0x35, 0x9b, 0xc9, 0xff, 0xd8, 0x41, 0x41, 0xd1, 0xc6, 0xa1, 0xba,
  936. 0x4d, 0xc6, 0xb7, 0x85, 0x05, 0xa1, 0x8e, 0xeb, 0xd1, 0xd2, 0x3a, 0x13, 0xd7, 0xbd, 0xb0, 0x02,
  937. 0xfe, 0x54, 0xfe, 0xf4, 0xfd, 0x31, 0x0c, 0x42, 0x78, 0xb9, 0x17, 0x90, 0x36, 0x17, 0xb8, 0x1a,
  938. 0x08, 0xe8, 0x7e, 0x5f, 0xbb, 0x30, 0xc2, 0xec, 0xd5, 0x08, 0xbc, 0xae, 0x2f, 0xe0, 0xca, 0xf2,
  939. 0x44, 0x2c, 0xa4, 0xb5, 0xec, 0xb9, 0xc2, 0xa3, 0x4a, 0x1a, 0x49, 0xfb, 0x3e, 0x5c, 0xb5, 0xd8,
  940. 0xb6, 0xf0, 0xbc, 0xa2, 0xda, 0xaa, 0x7a, 0x05, 0x4d, 0x06, 0xc0, 0x4b, 0x8f, 0x59, 0xce, 0x56,
  941. 0x02, 0x26, 0xb2, 0xa0, 0x5f, 0x74, 0xbb, 0x0b, 0x01, 0x1c, 0xb2, 0x0b, 0x8a, 0x80, 0xa4, 0x5d,
  942. 0x6e, 0x52, 0x24, 0xd0, 0xbe, 0xf5, 0x8e, 0x9e, 0x9e, 0x02, 0x40, 0x08, 0x99, 0xe0, 0x2c, 0xf9
  943. };
  944. #endif
  945. #if defined(LTC_SHA384) && defined(LTC_DES)
  946. static const unsigned char long_pri_pkcs8_pbkdf2_sha384_des_ede3_cbc[] = {
  947. 0x30, 0x82, 0x01, 0x7c, 0x30, 0x4e, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  948. 0x0d, 0x30, 0x41, 0x30, 0x29, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05, 0x0c,
  949. 0x30, 0x1c, 0x04, 0x08, 0xfd, 0x6c, 0xdf, 0x0b, 0x23, 0xed, 0x71, 0xf7, 0x02, 0x02, 0x08, 0x00,
  950. 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x0a, 0x05, 0x00, 0x30, 0x14,
  951. 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x03, 0x07, 0x04, 0x08, 0x99, 0xd0, 0x84, 0x7d,
  952. 0x6d, 0x4e, 0x82, 0xe1, 0x04, 0x82, 0x01, 0x28, 0xac, 0x9a, 0x2c, 0x71, 0xdf, 0x1a, 0x19, 0x38,
  953. 0xee, 0xc4, 0x9d, 0x7a, 0x27, 0xe0, 0xb9, 0x69, 0x32, 0xed, 0xe7, 0xa1, 0x77, 0x16, 0x60, 0x18,
  954. 0x7a, 0xf1, 0x47, 0xc1, 0x98, 0x48, 0xa4, 0xff, 0xab, 0x83, 0x1a, 0x7d, 0xe3, 0xdb, 0xcc, 0xf0,
  955. 0x40, 0x94, 0x3a, 0x6a, 0x3f, 0xf7, 0x88, 0x19, 0x59, 0xf4, 0xd8, 0x1b, 0x87, 0x14, 0x5b, 0x9c,
  956. 0x1f, 0xc5, 0xaf, 0x80, 0xe8, 0x06, 0xdb, 0xfa, 0x2c, 0xac, 0x61, 0x1c, 0xec, 0xec, 0x99, 0x5e,
  957. 0x06, 0x6e, 0x68, 0x4c, 0xb0, 0xc8, 0x6f, 0x74, 0x2c, 0x1e, 0x58, 0x2f, 0x49, 0x82, 0xa4, 0x2b,
  958. 0xb4, 0x4a, 0x2d, 0x77, 0x13, 0x87, 0xed, 0xbd, 0x71, 0x5a, 0x29, 0x29, 0x0c, 0x88, 0x4a, 0xf3,
  959. 0x76, 0x37, 0x7e, 0x04, 0x3c, 0x45, 0x76, 0x98, 0x22, 0x20, 0x97, 0xef, 0xae, 0x4a, 0xa9, 0x08,
  960. 0x54, 0xef, 0x43, 0xe0, 0x86, 0x54, 0x72, 0x44, 0xd1, 0x25, 0x9c, 0xb6, 0x7d, 0x88, 0xbd, 0x8f,
  961. 0xbe, 0xcb, 0xa8, 0x63, 0xfe, 0x66, 0x54, 0xa2, 0xce, 0x77, 0x19, 0x7e, 0xdd, 0xf7, 0x4d, 0xdc,
  962. 0xb1, 0xf7, 0xbf, 0x3c, 0xb5, 0xd2, 0x30, 0x9d, 0x3c, 0x35, 0x09, 0x37, 0xae, 0xae, 0x0f, 0x0b,
  963. 0x9d, 0xf5, 0x10, 0xae, 0x56, 0x83, 0x4f, 0xd8, 0xcd, 0xfe, 0xb7, 0xa9, 0x54, 0xf9, 0xb3, 0x89,
  964. 0xf6, 0x9a, 0x11, 0x60, 0x04, 0x4d, 0x80, 0xaf, 0x74, 0x73, 0x2d, 0xc4, 0x24, 0x23, 0xaa, 0x50,
  965. 0x4c, 0xf1, 0xd6, 0x2d, 0xc6, 0x74, 0xeb, 0x62, 0x02, 0xda, 0x81, 0x68, 0xc8, 0x68, 0xf0, 0x82,
  966. 0x71, 0xb2, 0xa5, 0x8e, 0x45, 0x93, 0x29, 0x94, 0x8f, 0xec, 0x11, 0x65, 0xcc, 0xd6, 0x4c, 0x2e,
  967. 0x0d, 0x4e, 0x45, 0xb4, 0x4e, 0x97, 0x38, 0xd0, 0xc2, 0x61, 0x43, 0x78, 0xa4, 0x08, 0x0a, 0x58,
  968. 0x3f, 0x66, 0xdb, 0x34, 0x42, 0x17, 0x42, 0x92, 0x04, 0x9a, 0x2d, 0x73, 0xaf, 0x58, 0x38, 0xc8,
  969. 0x3f, 0x5b, 0x83, 0x95, 0x3d, 0xae, 0xae, 0x60, 0x2b, 0x6d, 0xd9, 0xb4, 0xe3, 0x97, 0x6b, 0x49,
  970. 0xef, 0xd9, 0x68, 0xbb, 0x8d, 0x3a, 0x7e, 0xcb, 0x57, 0x33, 0xf5, 0x1a, 0x8d, 0xb4, 0x6d, 0xfb
  971. };
  972. #endif
  973. #if defined(LTC_SHA512) && defined(LTC_DES)
  974. static const unsigned char long_pri_pkcs8_pbkdf2_sha512_des_ede3_cbc[] = {
  975. 0x30, 0x82, 0x01, 0x7c, 0x30, 0x4e, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05,
  976. 0x0d, 0x30, 0x41, 0x30, 0x29, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05, 0x0c,
  977. 0x30, 0x1c, 0x04, 0x08, 0xad, 0xb1, 0xe1, 0x21, 0xdc, 0xe5, 0x09, 0xee, 0x02, 0x02, 0x08, 0x00,
  978. 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x0b, 0x05, 0x00, 0x30, 0x14,
  979. 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x03, 0x07, 0x04, 0x08, 0x1a, 0x8b, 0x81, 0x3b,
  980. 0x97, 0x7d, 0xfa, 0x51, 0x04, 0x82, 0x01, 0x28, 0x6d, 0x6f, 0x93, 0x77, 0xcb, 0x52, 0x2d, 0x3b,
  981. 0x82, 0x12, 0x80, 0xce, 0x9e, 0x69, 0x03, 0xe4, 0x64, 0xa1, 0x4b, 0x8e, 0x60, 0x51, 0x4d, 0x08,
  982. 0xe1, 0x25, 0x5d, 0xe6, 0xed, 0x20, 0x23, 0x4c, 0x4e, 0xa3, 0xe8, 0xab, 0x7a, 0xf8, 0x54, 0x65,
  983. 0x22, 0x92, 0x0c, 0x45, 0xab, 0x1c, 0xe2, 0x68, 0x4e, 0xf3, 0xa9, 0x61, 0xd6, 0x44, 0x9d, 0x55,
  984. 0x19, 0xc6, 0xd9, 0x2a, 0x0d, 0x45, 0x7d, 0xca, 0xa4, 0x41, 0xb5, 0x6d, 0xd5, 0x09, 0xf2, 0xb6,
  985. 0x81, 0x95, 0x64, 0xdb, 0x2b, 0xed, 0x83, 0x6b, 0x44, 0xa6, 0xce, 0x36, 0x8d, 0x23, 0x89, 0xb6,
  986. 0xf3, 0xb0, 0xe0, 0xcf, 0x57, 0x72, 0xc7, 0x61, 0x3f, 0x29, 0xb9, 0xea, 0xe8, 0x7a, 0xca, 0x43,
  987. 0x90, 0x79, 0x81, 0x8a, 0xe2, 0x3c, 0xd1, 0xa6, 0xd9, 0x09, 0xd8, 0x7d, 0xd0, 0x90, 0x69, 0x7e,
  988. 0xdd, 0x40, 0xde, 0xba, 0x11, 0xc6, 0x6f, 0x75, 0xfc, 0xc3, 0x99, 0x43, 0xd2, 0xa4, 0x16, 0x2e,
  989. 0x95, 0x99, 0x12, 0x77, 0xe8, 0x86, 0x9a, 0xf9, 0x97, 0xf4, 0x43, 0x99, 0x1d, 0x7b, 0xe0, 0x69,
  990. 0xb0, 0xe9, 0x45, 0xd0, 0x0b, 0xaa, 0xd0, 0xa9, 0x90, 0x85, 0x39, 0xd9, 0xe0, 0xe4, 0xe5, 0xf3,
  991. 0xcf, 0xb6, 0x60, 0x63, 0x51, 0x0b, 0xd8, 0x3d, 0xa2, 0x0f, 0xf6, 0x53, 0x09, 0x2e, 0x11, 0xc4,
  992. 0xe6, 0xe3, 0xfa, 0xfb, 0x9f, 0x4d, 0xf4, 0xef, 0xb2, 0xf6, 0x9b, 0xc6, 0xb3, 0x75, 0x66, 0xfd,
  993. 0x1b, 0x44, 0xba, 0x3c, 0xa8, 0x51, 0xbe, 0x97, 0xf1, 0x54, 0xb5, 0xcc, 0x6f, 0x5f, 0x1d, 0x9b,
  994. 0xee, 0xed, 0x7a, 0x82, 0xfa, 0x40, 0x39, 0xa7, 0xf5, 0x8e, 0x5e, 0x42, 0xfa, 0x37, 0xcc, 0xe8,
  995. 0x99, 0x38, 0xc1, 0xab, 0x83, 0xb8, 0x3c, 0x25, 0x17, 0x5f, 0xb7, 0x45, 0x0f, 0xcd, 0xec, 0x2a,
  996. 0x47, 0x07, 0x02, 0xba, 0x92, 0xc1, 0x79, 0xf1, 0x95, 0xc7, 0x83, 0x46, 0xd7, 0x9e, 0x04, 0x96,
  997. 0x3c, 0x5d, 0x7e, 0x70, 0xe6, 0x2b, 0x72, 0x70, 0x42, 0x66, 0x17, 0x0e, 0xc3, 0xcf, 0x32, 0x28,
  998. 0x0c, 0xf9, 0x46, 0x38, 0xb7, 0x64, 0xd6, 0x51, 0xf9, 0xbd, 0x57, 0xf2, 0x7a, 0xcc, 0x02, 0xe3
  999. };
  1000. #endif
  1001. static const unsigned char long_pric[] = { /* private + compressed public, explicit curve params */
  1002. 0x30, 0x81, 0xd3, 0x02, 0x01, 0x01, 0x04, 0x20, 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b,
  1003. 0xba, 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2, 0xf7, 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f,
  1004. 0x5f, 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd, 0x23, 0xa0, 0x81, 0x85, 0x30, 0x81, 0x82, 0x02, 0x01,
  1005. 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00, 0xff,
  1006. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1007. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f, 0x30,
  1008. 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04, 0x21, 0x02, 0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc,
  1009. 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce,
  1010. 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff,
  1011. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xba, 0xae, 0xdc,
  1012. 0xe6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01, 0x01,
  1013. 0xa1, 0x24, 0x03, 0x22, 0x00, 0x03, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf,
  1014. 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9,
  1015. 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16
  1016. };
  1017. static const unsigned char long_pric_pkcs8[] = { /* private + compressed public, explicit curve params, PKCS8 */
  1018. 0x30, 0x81, 0xe3, 0x02, 0x01, 0x00, 0x30, 0x81, 0x8e, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d,
  1019. 0x02, 0x01, 0x30, 0x81, 0x82, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce,
  1020. 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1021. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1022. 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04, 0x21,
  1023. 0x02, 0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b,
  1024. 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17,
  1025. 0x98, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1026. 0xff, 0xff, 0xff, 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5e, 0x8c,
  1027. 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01, 0x01, 0x04, 0x4d, 0x30, 0x4b, 0x02, 0x01, 0x01, 0x04, 0x20,
  1028. 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b, 0xba, 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2, 0xf7,
  1029. 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f, 0x5f, 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd, 0x23,
  1030. 0xa1, 0x24, 0x03, 0x22, 0x00, 0x03, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf,
  1031. 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9,
  1032. 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16
  1033. };
  1034. static const unsigned char long_pub[] = { /* long public, explicit curve params */
  1035. 0x30, 0x81, 0xf5, 0x30, 0x81, 0xae, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x30,
  1036. 0x81, 0xa2, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01,
  1037. 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1038. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff,
  1039. 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04, 0x41, 0x04, 0x79, 0xbe,
  1040. 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, 0x02, 0x9b,
  1041. 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98, 0x48, 0x3a,
  1042. 0xda, 0x77, 0x26, 0xa3, 0xc4, 0x65, 0x5d, 0xa4, 0xfb, 0xfc, 0x0e, 0x11, 0x08, 0xa8, 0xfd, 0x17,
  1043. 0xb4, 0x48, 0xa6, 0x85, 0x54, 0x19, 0x9c, 0x47, 0xd0, 0x8f, 0xfb, 0x10, 0xd4, 0xb8, 0x02, 0x21,
  1044. 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1045. 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41,
  1046. 0x41, 0x02, 0x01, 0x01, 0x03, 0x42, 0x00, 0x04, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e,
  1047. 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e,
  1048. 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16, 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a,
  1049. 0xb7, 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62, 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5,
  1050. 0x6e, 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d
  1051. };
  1052. static const unsigned char long_pubc[] = { /* compressed public, explicit curve params */
  1053. 0x30, 0x81, 0xb5, 0x30, 0x81, 0x8e, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x30,
  1054. 0x81, 0x82, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01,
  1055. 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1056. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff,
  1057. 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04, 0x21, 0x02, 0x79, 0xbe,
  1058. 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, 0x02, 0x9b,
  1059. 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98, 0x02, 0x21,
  1060. 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1061. 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41,
  1062. 0x41, 0x02, 0x01, 0x01, 0x03, 0x22, 0x00, 0x03, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e,
  1063. 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e,
  1064. 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16
  1065. };
  1066. static const unsigned char short_pri[] = { /* private + long public, curve by OID */
  1067. 0x30, 0x74, 0x02, 0x01, 0x01, 0x04, 0x20, 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b, 0xba,
  1068. 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2, 0xf7, 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f, 0x5f,
  1069. 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd, 0x23, 0xa0, 0x07, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x0a,
  1070. 0xa1, 0x44, 0x03, 0x42, 0x00, 0x04, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf,
  1071. 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9,
  1072. 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16, 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a, 0xb7, 0x6c,
  1073. 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62, 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5, 0x6e, 0x4b,
  1074. 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d
  1075. };
  1076. static const unsigned char short_pri_pkcs8[] = { /* private + long public, curve by OID, PKCS8 */
  1077. 0x30, 0x81, 0x84, 0x02, 0x01, 0x00, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02,
  1078. 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x0a, 0x04, 0x6d, 0x30, 0x6b, 0x02, 0x01, 0x01, 0x04,
  1079. 0x20, 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b, 0xba, 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2,
  1080. 0xf7, 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f, 0x5f, 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd,
  1081. 0x23, 0xa1, 0x44, 0x03, 0x42, 0x00, 0x04, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1,
  1082. 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5,
  1083. 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16, 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a, 0xb7,
  1084. 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62, 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5, 0x6e,
  1085. 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d
  1086. };
  1087. static const unsigned char short_pric[] = { /* private + compressed public, curve by OID */
  1088. 0x30, 0x54, 0x02, 0x01, 0x01, 0x04, 0x20, 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b, 0xba,
  1089. 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2, 0xf7, 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f, 0x5f,
  1090. 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd, 0x23, 0xa0, 0x07, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x0a,
  1091. 0xa1, 0x24, 0x03, 0x22, 0x00, 0x03, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf,
  1092. 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9,
  1093. 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16
  1094. };
  1095. static const unsigned char short_pric_pkcs8[] = { /* private + compressed public, curve by OID, PKCS8 */
  1096. 0x30, 0x64, 0x02, 0x01, 0x00, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01,
  1097. 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x0a, 0x04, 0x4d, 0x30, 0x4b, 0x02, 0x01, 0x01, 0x04, 0x20,
  1098. 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b, 0xba, 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2, 0xf7,
  1099. 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f, 0x5f, 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd, 0x23,
  1100. 0xa1, 0x24, 0x03, 0x22, 0x00, 0x03, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf,
  1101. 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9,
  1102. 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16
  1103. };
  1104. static const unsigned char short_pub[] = { /* long public, curve by OID */
  1105. 0x30, 0x56, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b,
  1106. 0x81, 0x04, 0x00, 0x0a, 0x03, 0x42, 0x00, 0x04, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e,
  1107. 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e,
  1108. 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16, 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a,
  1109. 0xb7, 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62, 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5,
  1110. 0x6e, 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d
  1111. };
  1112. static const unsigned char short_pubc[] = { /* compressed public, curve by OID */
  1113. 0x30, 0x36, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b,
  1114. 0x81, 0x04, 0x00, 0x0a, 0x03, 0x22, 0x00, 0x03, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e,
  1115. 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e,
  1116. 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16
  1117. };
  1118. static const unsigned char raw_pri[] = { /* raw private key */
  1119. 0x0c, 0xf1, 0xad, 0x2f, 0x03, 0xf7, 0x91, 0x1b, 0xba, 0x03, 0xcf, 0x23, 0x37, 0xc8, 0xf2, 0xf7,
  1120. 0x36, 0xce, 0x65, 0xf1, 0x84, 0x2d, 0x7d, 0x9f, 0x5f, 0x9e, 0x21, 0xd9, 0x5e, 0x49, 0xbd, 0x23
  1121. };
  1122. static const unsigned char raw_pub[] = { /* raw public key - long form */
  1123. 0x04, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba,
  1124. 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5,
  1125. 0x16, 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a, 0xb7, 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63,
  1126. 0x62, 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5, 0x6e, 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79,
  1127. 0x4d
  1128. };
  1129. static const unsigned char raw_pubc[] = { /* raw public key - compressed form */
  1130. 0x03, 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba,
  1131. 0xb6, 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5,
  1132. 0x16
  1133. };
  1134. static const unsigned char x509_cert_long[] = { /* X.509 cert, long pubkey, explicit curve params */
  1135. 0x30, 0x82, 0x02, 0x13, 0x30, 0x82, 0x01, 0xba, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00,
  1136. 0xaf, 0x14, 0xe3, 0x53, 0x36, 0x06, 0x79, 0x34, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce,
  1137. 0x3d, 0x04, 0x03, 0x04, 0x30, 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
  1138. 0x0c, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x20, 0x17,
  1139. 0x0d, 0x31, 0x37, 0x31, 0x32, 0x33, 0x30, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x18, 0x0f,
  1140. 0x33, 0x30, 0x31, 0x37, 0x30, 0x35, 0x30, 0x32, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x30,
  1141. 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0c, 0x54, 0x65, 0x73, 0x74,
  1142. 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x81, 0xf5, 0x30, 0x81, 0xae, 0x06, 0x07,
  1143. 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x30, 0x81, 0xa2, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06,
  1144. 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
  1145. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1146. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00,
  1147. 0x04, 0x01, 0x07, 0x04, 0x41, 0x04, 0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0,
  1148. 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2,
  1149. 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98, 0x48, 0x3a, 0xda, 0x77, 0x26, 0xa3, 0xc4, 0x65, 0x5d, 0xa4,
  1150. 0xfb, 0xfc, 0x0e, 0x11, 0x08, 0xa8, 0xfd, 0x17, 0xb4, 0x48, 0xa6, 0x85, 0x54, 0x19, 0x9c, 0x47,
  1151. 0xd0, 0x8f, 0xfb, 0x10, 0xd4, 0xb8, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1152. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0,
  1153. 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01, 0x01, 0x03, 0x42, 0x00, 0x04,
  1154. 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6,
  1155. 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16,
  1156. 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a, 0xb7, 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62,
  1157. 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5, 0x6e, 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d,
  1158. 0xa3, 0x50, 0x30, 0x4e, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x66,
  1159. 0xc9, 0x90, 0x3c, 0x8a, 0x81, 0xa3, 0x1c, 0x20, 0x61, 0xd2, 0xf3, 0xf5, 0xae, 0xa8, 0x85, 0x70,
  1160. 0xf9, 0x1f, 0x2c, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14,
  1161. 0x66, 0xc9, 0x90, 0x3c, 0x8a, 0x81, 0xa3, 0x1c, 0x20, 0x61, 0xd2, 0xf3, 0xf5, 0xae, 0xa8, 0x85,
  1162. 0x70, 0xf9, 0x1f, 0x2c, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01,
  1163. 0x01, 0xff, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x04, 0x03, 0x47,
  1164. 0x00, 0x30, 0x44, 0x02, 0x1f, 0x2a, 0x62, 0x64, 0x05, 0x67, 0xb0, 0x2c, 0xa0, 0xa3, 0xb8, 0x61,
  1165. 0x4e, 0x87, 0x06, 0x69, 0xf2, 0xda, 0x78, 0xd6, 0x0e, 0x8d, 0x9b, 0xf1, 0x43, 0x5f, 0xf6, 0x40,
  1166. 0x9d, 0x9d, 0xbd, 0xce, 0x02, 0x21, 0x00, 0xe9, 0x6f, 0x79, 0xb4, 0x4a, 0x00, 0xf7, 0xfa, 0x81,
  1167. 0x25, 0x29, 0xec, 0x79, 0xb2, 0xfa, 0x86, 0xf8, 0x84, 0xd1, 0x78, 0xe7, 0xf8, 0xfd, 0x76, 0x2d,
  1168. 0x4f, 0xfe, 0x02, 0x72, 0xba, 0x6c, 0xca
  1169. };
  1170. static const unsigned char x509_cert_longc[] = { /* X.509 cert, compressed pubkey, explicit curve params */
  1171. 0x30, 0x82, 0x01, 0xd3, 0x30, 0x82, 0x01, 0x7a, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00,
  1172. 0x90, 0x5b, 0x48, 0x32, 0x37, 0x4b, 0x72, 0x54, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce,
  1173. 0x3d, 0x04, 0x03, 0x04, 0x30, 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
  1174. 0x0c, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x20, 0x17,
  1175. 0x0d, 0x31, 0x37, 0x31, 0x32, 0x33, 0x30, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x18, 0x0f,
  1176. 0x33, 0x30, 0x31, 0x37, 0x30, 0x35, 0x30, 0x32, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x30,
  1177. 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0c, 0x54, 0x65, 0x73, 0x74,
  1178. 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x81, 0xb5, 0x30, 0x81, 0x8e, 0x06, 0x07,
  1179. 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x30, 0x81, 0x82, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06,
  1180. 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
  1181. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1182. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00,
  1183. 0x04, 0x01, 0x07, 0x04, 0x21, 0x02, 0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0,
  1184. 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2,
  1185. 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1186. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0,
  1187. 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01, 0x01, 0x03, 0x22, 0x00, 0x03,
  1188. 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6,
  1189. 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16,
  1190. 0xa3, 0x50, 0x30, 0x4e, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xca,
  1191. 0x2a, 0xa1, 0x12, 0x97, 0x96, 0x2c, 0x85, 0xd3, 0x1f, 0xb1, 0x34, 0x7c, 0x26, 0xe9, 0xd6, 0x49,
  1192. 0x9f, 0x98, 0xcf, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14,
  1193. 0xca, 0x2a, 0xa1, 0x12, 0x97, 0x96, 0x2c, 0x85, 0xd3, 0x1f, 0xb1, 0x34, 0x7c, 0x26, 0xe9, 0xd6,
  1194. 0x49, 0x9f, 0x98, 0xcf, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01,
  1195. 0x01, 0xff, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x04, 0x03, 0x47,
  1196. 0x00, 0x30, 0x44, 0x02, 0x20, 0x24, 0x7a, 0xc1, 0xb4, 0x7d, 0x1c, 0x3c, 0x23, 0xc6, 0xad, 0xea,
  1197. 0x04, 0x27, 0x27, 0x65, 0xb8, 0x72, 0x93, 0x46, 0xc9, 0xe9, 0x60, 0x8f, 0xca, 0x96, 0x30, 0x60,
  1198. 0xb3, 0x22, 0xf7, 0x3b, 0x01, 0x02, 0x20, 0x48, 0x30, 0x2a, 0x58, 0x18, 0x46, 0xdb, 0x50, 0x3e,
  1199. 0xad, 0xc3, 0xca, 0xcd, 0x6d, 0x83, 0xd4, 0xc3, 0xc4, 0xa4, 0x8f, 0x37, 0xc3, 0x1d, 0x83, 0x3c,
  1200. 0xd3, 0x1f, 0x8f, 0x38, 0x29, 0x75, 0x2c
  1201. };
  1202. static const unsigned char x509_cert_short[] = { /* X.509 cert, long pubkey, curve by OID */
  1203. 0x30, 0x82, 0x01, 0x74, 0x30, 0x82, 0x01, 0x1a, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00,
  1204. 0xbd, 0x81, 0x04, 0x29, 0x43, 0x12, 0x79, 0xce, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce,
  1205. 0x3d, 0x04, 0x03, 0x04, 0x30, 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
  1206. 0x0c, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x20, 0x17,
  1207. 0x0d, 0x31, 0x37, 0x31, 0x32, 0x33, 0x30, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x18, 0x0f,
  1208. 0x33, 0x30, 0x31, 0x37, 0x30, 0x35, 0x30, 0x32, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x30,
  1209. 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0c, 0x54, 0x65, 0x73, 0x74,
  1210. 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x56, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86,
  1211. 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x0a, 0x03, 0x42, 0x00, 0x04,
  1212. 0x2a, 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6,
  1213. 0x7f, 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16,
  1214. 0x91, 0xbd, 0xb2, 0xb9, 0x1b, 0x40, 0x10, 0x5a, 0xb7, 0x6c, 0x6e, 0x32, 0x5b, 0xf7, 0x63, 0x62,
  1215. 0x94, 0x24, 0x24, 0xdb, 0xec, 0x3f, 0x8b, 0xe5, 0x6e, 0x4b, 0x64, 0x37, 0x31, 0x24, 0x79, 0x4d,
  1216. 0xa3, 0x50, 0x30, 0x4e, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x66,
  1217. 0xc9, 0x90, 0x3c, 0x8a, 0x81, 0xa3, 0x1c, 0x20, 0x61, 0xd2, 0xf3, 0xf5, 0xae, 0xa8, 0x85, 0x70,
  1218. 0xf9, 0x1f, 0x2c, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14,
  1219. 0x66, 0xc9, 0x90, 0x3c, 0x8a, 0x81, 0xa3, 0x1c, 0x20, 0x61, 0xd2, 0xf3, 0xf5, 0xae, 0xa8, 0x85,
  1220. 0x70, 0xf9, 0x1f, 0x2c, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01,
  1221. 0x01, 0xff, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x04, 0x03, 0x48,
  1222. 0x00, 0x30, 0x45, 0x02, 0x21, 0x00, 0x9b, 0x4e, 0xb2, 0x6a, 0xcc, 0xfa, 0x02, 0x69, 0x22, 0x6a,
  1223. 0x32, 0x9c, 0x0c, 0xaa, 0x4c, 0xdf, 0xbb, 0x9b, 0x22, 0xfb, 0xd6, 0xec, 0x5d, 0xf9, 0x87, 0x82,
  1224. 0xeb, 0x37, 0xb8, 0x32, 0x7c, 0xd6, 0x02, 0x20, 0x50, 0x8b, 0x9f, 0xc1, 0xa8, 0x4a, 0xff, 0x49,
  1225. 0x0d, 0x7e, 0x04, 0x2d, 0x93, 0x3e, 0xdb, 0x30, 0xbc, 0x93, 0xd1, 0x16, 0x1d, 0x99, 0xbd, 0x3f,
  1226. 0xfa, 0x2a, 0x6d, 0xe0, 0x2a, 0x83, 0x55, 0x5d
  1227. };
  1228. static const unsigned char x509_cert_shortc[] = { /* X.509 cert, compressed pubkey, curve by OID */
  1229. 0x30, 0x82, 0x01, 0x54, 0x30, 0x81, 0xfa, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0x85,
  1230. 0x45, 0x77, 0x75, 0x02, 0x95, 0xf7, 0x06, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d,
  1231. 0x04, 0x03, 0x04, 0x30, 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0c,
  1232. 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x20, 0x17, 0x0d,
  1233. 0x31, 0x37, 0x31, 0x32, 0x33, 0x30, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x18, 0x0f, 0x33,
  1234. 0x30, 0x31, 0x37, 0x30, 0x35, 0x30, 0x32, 0x32, 0x30, 0x33, 0x33, 0x34, 0x31, 0x5a, 0x30, 0x17,
  1235. 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0c, 0x54, 0x65, 0x73, 0x74, 0x20,
  1236. 0x43, 0x65, 0x72, 0x74, 0x20, 0x45, 0x43, 0x30, 0x36, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48,
  1237. 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x0a, 0x03, 0x22, 0x00, 0x03, 0x2a,
  1238. 0xf9, 0x0b, 0xda, 0xbe, 0x71, 0x66, 0x9e, 0xd1, 0xcf, 0x12, 0xd0, 0x24, 0xaf, 0xba, 0xb6, 0x7f,
  1239. 0xfb, 0x96, 0x27, 0x3e, 0x2f, 0xbd, 0x1e, 0xd5, 0xf9, 0x8d, 0x6c, 0x73, 0x9d, 0xc5, 0x16, 0xa3,
  1240. 0x50, 0x30, 0x4e, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xca, 0x2a,
  1241. 0xa1, 0x12, 0x97, 0x96, 0x2c, 0x85, 0xd3, 0x1f, 0xb1, 0x34, 0x7c, 0x26, 0xe9, 0xd6, 0x49, 0x9f,
  1242. 0x98, 0xcf, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xca,
  1243. 0x2a, 0xa1, 0x12, 0x97, 0x96, 0x2c, 0x85, 0xd3, 0x1f, 0xb1, 0x34, 0x7c, 0x26, 0xe9, 0xd6, 0x49,
  1244. 0x9f, 0x98, 0xcf, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01,
  1245. 0xff, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x04, 0x03, 0x49, 0x00,
  1246. 0x30, 0x46, 0x02, 0x21, 0x00, 0xa4, 0xf9, 0x41, 0x2b, 0x4b, 0x56, 0xa5, 0xd4, 0x8c, 0xdf, 0xb0,
  1247. 0x14, 0xe3, 0xe7, 0xed, 0xcc, 0xc4, 0x46, 0x42, 0x04, 0xec, 0x15, 0x9f, 0xe1, 0xb2, 0x00, 0x07,
  1248. 0x8c, 0xc1, 0xf9, 0x25, 0xed, 0x02, 0x21, 0x00, 0x81, 0xd8, 0xc4, 0x3a, 0x9f, 0xdf, 0xc1, 0x70,
  1249. 0x9d, 0x7b, 0x70, 0x3e, 0xf5, 0x7d, 0xa4, 0xfd, 0x3c, 0xc6, 0x49, 0x93, 0xd3, 0x5b, 0xef, 0xc9,
  1250. 0xae, 0x97, 0xaf, 0x64, 0x64, 0xf9, 0x69, 0xd8
  1251. };
  1252. if (ltc_mp.sqrtmod_prime == NULL) return CRYPT_NOP; /* we need compressed points which requires sqrtmod_prime */
  1253. DO(ecc_import_openssl(short_pub, sizeof(short_pub), &pub));
  1254. DO(ecc_import_openssl(short_pri, sizeof(short_pri), &pri));
  1255. DO(ecc_find_curve("SECP256K1", &cu));
  1256. /* import - raw keys */
  1257. DO(ecc_set_curve(cu, &key));
  1258. DO(ecc_set_key(raw_pri, sizeof(raw_pri), PK_PRIVATE, &key));
  1259. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1260. ecc_free(&key);
  1261. DO(ecc_set_curve(cu, &key));
  1262. DO(ecc_set_key(raw_pub, sizeof(raw_pub), PK_PUBLIC, &key));
  1263. DO(s_ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1264. ecc_free(&key);
  1265. DO(ecc_set_curve(cu, &key));
  1266. DO(ecc_set_key(raw_pubc, sizeof(raw_pubc), PK_PUBLIC, &key));
  1267. DO(s_ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1268. ecc_free(&key);
  1269. /* import - openssl compatible DER format */
  1270. DO(ecc_import_openssl(long_pri, sizeof(long_pri), &key));
  1271. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1272. ecc_free(&key);
  1273. DO(ecc_import_openssl(long_pric, sizeof(long_pric), &key));
  1274. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1275. ecc_free(&key);
  1276. DO(ecc_import_openssl(long_pub, sizeof(long_pub), &key));
  1277. DO(s_ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1278. ecc_free(&key);
  1279. DO(ecc_import_openssl(long_pubc, sizeof(long_pubc), &key));
  1280. DO(s_ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1281. ecc_free(&key);
  1282. DO(ecc_import_openssl(short_pri, sizeof(short_pri), &key));
  1283. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1284. ecc_free(&key);
  1285. DO(ecc_import_openssl(short_pric, sizeof(short_pric), &key));
  1286. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1287. ecc_free(&key);
  1288. DO(ecc_import_openssl(short_pub, sizeof(short_pub), &key));
  1289. DO(s_ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1290. ecc_free(&key);
  1291. DO(ecc_import_openssl(short_pubc, sizeof(short_pubc), &key));
  1292. DO(s_ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1293. ecc_free(&key);
  1294. /* import - private PKCS8 format - no password */
  1295. DO(ecc_import_pkcs8(long_pri_pkcs8, sizeof(long_pri_pkcs8), NULL, 0, &key));
  1296. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1297. ecc_free(&key);
  1298. DO(ecc_import_pkcs8(long_pric_pkcs8, sizeof(long_pric_pkcs8), NULL, 0, &key));
  1299. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1300. ecc_free(&key);
  1301. DO(ecc_import_pkcs8(short_pri_pkcs8, sizeof(short_pri_pkcs8), NULL, 0, &key));
  1302. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1303. ecc_free(&key);
  1304. DO(ecc_import_pkcs8(short_pric_pkcs8, sizeof(short_pric_pkcs8), NULL, 0, &key));
  1305. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1306. ecc_free(&key);
  1307. /* import - private PKCS8 format - password protected (PBES1 algorithms) */
  1308. #ifdef LTC_MD2
  1309. DO(ecc_import_pkcs8(long_pri_pkcs8_pbe_md2_des, sizeof(long_pri_pkcs8_pbe_md2_des), "secret", 6, &key));
  1310. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1311. ecc_free(&key);
  1312. #endif
  1313. #ifdef LTC_MD5
  1314. DO(ecc_import_pkcs8(long_pri_pkcs8_pbe_md5_des, sizeof(long_pri_pkcs8_pbe_md5_des), "secret", 6, &key));
  1315. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1316. ecc_free(&key);
  1317. #endif
  1318. #ifdef LTC_SHA1
  1319. DO(ecc_import_pkcs8(long_pri_pkcs8_pbe_sha1_des, sizeof(long_pri_pkcs8_pbe_sha1_des), "secret", 6, &key));
  1320. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1321. ecc_free(&key);
  1322. #endif
  1323. #if defined(LTC_RC2) && defined(LTC_MD2)
  1324. DO(ecc_import_pkcs8(long_pri_pkcs8_pbe_md2_rc2_64, sizeof(long_pri_pkcs8_pbe_md2_rc2_64), "secret", 6, &key));
  1325. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1326. ecc_free(&key);
  1327. #endif
  1328. #if defined(LTC_RC2) && defined(LTC_MD5)
  1329. DO(ecc_import_pkcs8(long_pri_pkcs8_pbe_md5_rc2_64, sizeof(long_pri_pkcs8_pbe_md5_rc2_64), "secret", 6, &key));
  1330. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1331. ecc_free(&key);
  1332. #endif
  1333. #if defined(LTC_RC2) && defined(LTC_SHA1)
  1334. DO(ecc_import_pkcs8(long_pri_pkcs8_pbe_sha1_rc2_64, sizeof(long_pri_pkcs8_pbe_sha1_rc2_64), "secret", 6, &key));
  1335. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1336. ecc_free(&key);
  1337. #endif
  1338. /* import - private PKCS8 format - password protected (PBES2 algorithms) */
  1339. #if defined(LTC_RC2)
  1340. DO(ecc_import_pkcs8(long_pri_pkcs8_pbkdf2_rc2_cbc, sizeof(long_pri_pkcs8_pbkdf2_rc2_cbc), "secret", 6, &key));
  1341. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1342. ecc_free(&key);
  1343. #endif
  1344. #if defined(LTC_DES)
  1345. DO(ecc_import_pkcs8(long_pri_pkcs8_pbkdf2_des_cbc, sizeof(long_pri_pkcs8_pbkdf2_des_cbc), "secret", 6, &key));
  1346. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1347. ecc_free(&key);
  1348. #endif
  1349. #if defined(LTC_DES)
  1350. DO(ecc_import_pkcs8(long_pri_pkcs8_pbkdf2_des_ede3_cbc, sizeof(long_pri_pkcs8_pbkdf2_des_ede3_cbc), "secret", 6, &key));
  1351. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1352. ecc_free(&key);
  1353. #endif
  1354. #if defined(LTC_SHA224) && defined(LTC_DES)
  1355. DO(ecc_import_pkcs8(long_pri_pkcs8_pbkdf2_sha224_des_ede3_cbc, sizeof(long_pri_pkcs8_pbkdf2_sha224_des_ede3_cbc), "secret", 6, &key));
  1356. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1357. ecc_free(&key);
  1358. #endif
  1359. #if defined(LTC_SHA256) && defined(LTC_DES)
  1360. DO(ecc_import_pkcs8(long_pri_pkcs8_pbkdf2_sha256_des_ede3_cbc, sizeof(long_pri_pkcs8_pbkdf2_sha256_des_ede3_cbc), "secret", 6, &key));
  1361. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1362. ecc_free(&key);
  1363. #endif
  1364. #if defined(LTC_SHA384) && defined(LTC_DES)
  1365. DO(ecc_import_pkcs8(long_pri_pkcs8_pbkdf2_sha384_des_ede3_cbc, sizeof(long_pri_pkcs8_pbkdf2_sha384_des_ede3_cbc), "secret", 6, &key));
  1366. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1367. ecc_free(&key);
  1368. #endif
  1369. #if defined(LTC_SHA512) && defined(LTC_DES)
  1370. DO(ecc_import_pkcs8(long_pri_pkcs8_pbkdf2_sha512_des_ede3_cbc, sizeof(long_pri_pkcs8_pbkdf2_sha512_des_ede3_cbc), "secret", 6, &key));
  1371. DO(s_ecc_key_cmp(PK_PRIVATE, &pri, &key));
  1372. ecc_free(&key);
  1373. #endif
  1374. /* import - X.509 EC certificates */
  1375. DO(ecc_import_x509(x509_cert_long, sizeof(x509_cert_long), &key));
  1376. DO(s_ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1377. ecc_free(&key);
  1378. DO(ecc_import_x509(x509_cert_longc, sizeof(x509_cert_longc), &key));
  1379. DO(s_ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1380. ecc_free(&key);
  1381. DO(ecc_import_x509(x509_cert_short, sizeof(x509_cert_short), &key));
  1382. DO(s_ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1383. ecc_free(&key);
  1384. DO(ecc_import_x509(x509_cert_shortc, sizeof(x509_cert_shortc), &key));
  1385. DO(s_ecc_key_cmp(PK_PUBLIC, &pub, &key));
  1386. ecc_free(&key);
  1387. /* export - openssl compatible DER format */
  1388. outlen = sizeof(out);
  1389. DO(ecc_export_openssl(out, &outlen, PK_PRIVATE, &pri));
  1390. if (compare_testvector(out, outlen, long_pri, sizeof(long_pri), "e-long_pri", 0)) return CRYPT_ERROR;
  1391. outlen = sizeof(out);
  1392. DO(ecc_export_openssl(out, &outlen, PK_PRIVATE|PK_COMPRESSED, &pri));
  1393. if (compare_testvector(out, outlen, long_pric, sizeof(long_pric), "e-long_pric", 0)) return CRYPT_ERROR;
  1394. outlen = sizeof(out);
  1395. DO(ecc_export_openssl(out, &outlen, PK_PUBLIC, &pub));
  1396. if (compare_testvector(out, outlen, long_pub, sizeof(long_pub), "e-long_pub", 0)) return CRYPT_ERROR;
  1397. outlen = sizeof(out);
  1398. DO(ecc_export_openssl(out, &outlen, PK_PUBLIC|PK_COMPRESSED, &pub));
  1399. if (compare_testvector(out, outlen, long_pubc, sizeof(long_pubc), "e-long_pubc", 0)) return CRYPT_ERROR;
  1400. outlen = sizeof(out);
  1401. DO(ecc_export_openssl(out, &outlen, PK_PRIVATE|PK_CURVEOID, &pri));
  1402. if (compare_testvector(out, outlen, short_pri, sizeof(short_pri), "e-short_pri", 0)) return CRYPT_ERROR;
  1403. outlen = sizeof(out);
  1404. DO(ecc_export_openssl(out, &outlen, PK_PRIVATE|PK_CURVEOID|PK_COMPRESSED, &pri));
  1405. if (compare_testvector(out, outlen, short_pric, sizeof(short_pric), "e-short_pric", 0)) return CRYPT_ERROR;
  1406. outlen = sizeof(out);
  1407. DO(ecc_export_openssl(out, &outlen, PK_PUBLIC|PK_CURVEOID, &pub));
  1408. if (compare_testvector(out, outlen, short_pub, sizeof(short_pub), "e-short_pub", 0)) return CRYPT_ERROR;
  1409. outlen = sizeof(out);
  1410. DO(ecc_export_openssl(out, &outlen, PK_PUBLIC|PK_CURVEOID|PK_COMPRESSED, &pub));
  1411. if (compare_testvector(out, outlen, short_pubc, sizeof(short_pubc), "e-short_pubc", 0)) return CRYPT_ERROR;
  1412. /* export - raw keys */
  1413. outlen = sizeof(out);
  1414. DO(ecc_get_key(out, &outlen, PK_PRIVATE, &pri));
  1415. if (compare_testvector(out, outlen, raw_pri, sizeof(raw_pri), "e-raw_pri", 0)) return CRYPT_ERROR;
  1416. outlen = sizeof(out);
  1417. DO(ecc_get_key(out, &outlen, PK_PUBLIC, &pub));
  1418. if (compare_testvector(out, outlen, raw_pub, sizeof(raw_pub), "e-raw_pub", 0)) return CRYPT_ERROR;
  1419. outlen = sizeof(out);
  1420. DO(ecc_get_key(out, &outlen, PK_PUBLIC|PK_COMPRESSED, &pub));
  1421. if (compare_testvector(out, outlen, raw_pubc, sizeof(raw_pubc), "e-raw_pubc", 0)) return CRYPT_ERROR;
  1422. ecc_free(&pri);
  1423. ecc_free(&pub);
  1424. return CRYPT_OK;
  1425. }
  1426. #ifdef LTC_ECC_SHAMIR
  1427. static int s_ecc_test_recovery(void)
  1428. {
  1429. int i, recid, stat;
  1430. const ltc_ecc_curve* dp;
  1431. ecc_key key, privkey, pubkey, reckey;
  1432. unsigned char buf[1000];
  1433. unsigned long len;
  1434. unsigned char data16[16] = { 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1 };
  1435. unsigned char eth_hash[] = { /* Keccak-256 hash of "Hello World" */
  1436. 0x59, 0x2f, 0xa7, 0x43, 0x88, 0x9f, 0xc7, 0xf9, 0x2a, 0xc2, 0xa3, 0x7b, 0xb1, 0xf5, 0xba, 0x1d,
  1437. 0xaf, 0x2a, 0x5c, 0x84, 0x74, 0x1c, 0xa0, 0xe0, 0x06, 0x1d, 0x24, 0x3a, 0x2e, 0x67, 0x07, 0xba
  1438. };
  1439. unsigned char eth_pubkey[] = { /* Public part of randomly-generated key pair */
  1440. 0x04,
  1441. 0xc6, 0x99, 0x5f, 0xdc, 0xf4, 0xf2, 0xda, 0x6e, 0x79, 0xe0, 0x47, 0x12, 0xd3, 0xbe, 0x22, 0xe7,
  1442. 0x65, 0xc6, 0xa3, 0x32, 0x89, 0x1b, 0x34, 0xba, 0xc1, 0xb7, 0x01, 0x83, 0xed, 0xdd, 0xf1, 0xcc,
  1443. 0xbf, 0x20, 0xdd, 0xcd, 0x05, 0x4e, 0x49, 0xc8, 0xcb, 0x66, 0x6c, 0xb7, 0x71, 0x2f, 0x7e, 0xc1,
  1444. 0xd6, 0x1a, 0x4a, 0x42, 0x3d, 0xe5, 0xc2, 0x8d, 0x74, 0x03, 0x81, 0xe7, 0xea, 0xc5, 0x3c, 0x10
  1445. };
  1446. unsigned char eth_sig[] = { /* Signature of eth_hash to be verified against eth_pubkey */
  1447. 0xbd, 0x6d, 0xbb, 0xbe, 0x2d, 0xe7, 0x1d, 0x00, 0xae, 0x18, 0x57, 0x12, 0x1d, 0x63, 0xa5, 0x1b,
  1448. 0x0b, 0x42, 0x71, 0xa2, 0x80, 0x49, 0xe0, 0x5c, 0xfa, 0xc8, 0x1a, 0x0d, 0x8a, 0x88, 0x67, 0x56,
  1449. 0xf6, 0x67, 0x1b, 0x41, 0x46, 0x09, 0x4e, 0xd0, 0x44, 0x25, 0x18, 0xfd, 0xf4, 0xcd, 0x62, 0xa3,
  1450. 0xb7, 0x3c, 0x97, 0x55, 0xfa, 0x69, 0xf8, 0xef, 0xe9, 0xcf, 0x12, 0xaf, 0x48, 0x25, 0xe3, 0xe0,
  1451. 0x1b
  1452. };
  1453. /* XXX-FIXME: TFM does not support sqrtmod_prime */
  1454. if (strcmp(ltc_mp.name, "TomsFastMath") == 0) return CRYPT_NOP;
  1455. #ifdef LTC_ECC_SECP256K1
  1456. DO(ecc_find_curve("SECP256K1", &dp));
  1457. DO(ecc_set_curve(dp, &pubkey));
  1458. DO(ecc_set_key(eth_pubkey, sizeof(eth_pubkey), PK_PUBLIC, &pubkey));
  1459. DO(ecc_set_curve(dp, &reckey));
  1460. stat = ecc_recover_key(eth_sig, sizeof(eth_sig)-1, eth_hash, sizeof(eth_hash), 0, LTC_ECCSIG_RFC7518, &reckey);
  1461. if (stat != CRYPT_OK) return CRYPT_FAIL_TESTVECTOR;
  1462. DO(s_ecc_key_cmp(PK_PUBLIC, &pubkey, &reckey));
  1463. ecc_free(&reckey);
  1464. DO(ecc_set_curve(dp, &reckey));
  1465. stat = ecc_recover_key(eth_sig, sizeof(eth_sig), eth_hash, sizeof(eth_hash), -1, LTC_ECCSIG_ETH27, &reckey);
  1466. if (stat != CRYPT_OK) return CRYPT_FAIL_TESTVECTOR;
  1467. DO(s_ecc_key_cmp(PK_PUBLIC, &pubkey, &reckey));
  1468. ecc_free(&reckey);
  1469. ecc_free(&pubkey);
  1470. #endif
  1471. for (i = 0; i < (int)(sizeof(curvenames)/sizeof(curvenames[0])); i++) {
  1472. DO(ecc_find_curve(curvenames[i], &dp));
  1473. /* generate new key */
  1474. DO(ecc_set_curve(dp, &key));
  1475. DO(ecc_generate_key(&yarrow_prng, find_prng ("yarrow"), &key));
  1476. /* export private key */
  1477. len = sizeof(buf);
  1478. DO(ecc_get_key(buf, &len, PK_PRIVATE, &key));
  1479. ecc_free(&key);
  1480. /* load exported private key */
  1481. DO(ecc_set_curve(dp, &privkey));
  1482. DO(ecc_set_key(buf, len, PK_PRIVATE, &privkey));
  1483. /* export long public key */
  1484. len = sizeof(buf);
  1485. DO(ecc_get_key(buf, &len, PK_PUBLIC, &privkey));
  1486. if (len != 1 + 2 * (unsigned)ecc_get_size(&privkey)) return CRYPT_FAIL_TESTVECTOR;
  1487. /* load exported public key */
  1488. DO(ecc_set_curve(dp, &pubkey));
  1489. DO(ecc_set_key(buf, len, PK_PUBLIC, &pubkey));
  1490. /* test signature */
  1491. len = sizeof(buf);
  1492. recid = 0;
  1493. DO(ecc_sign_hash_ex(data16, 16, buf, &len, &yarrow_prng, find_prng ("yarrow"), LTC_ECCSIG_RFC7518, &recid, &privkey));
  1494. /* test verification */
  1495. stat = 0;
  1496. DO(ecc_verify_hash_ex(buf, len, data16, 16, LTC_ECCSIG_RFC7518, &stat, &pubkey));
  1497. if (stat != 1) return CRYPT_FAIL_TESTVECTOR;
  1498. /* test recovery */
  1499. DO(ecc_set_curve(dp, &reckey));
  1500. stat = ecc_recover_key(buf, len, data16, 16, recid, LTC_ECCSIG_RFC7518, &reckey);
  1501. if (stat != CRYPT_OK) return CRYPT_FAIL_TESTVECTOR;
  1502. DO(s_ecc_key_cmp(PK_PUBLIC, &pubkey, &reckey));
  1503. /* cleanup */
  1504. ecc_free(&reckey);
  1505. ecc_free(&privkey);
  1506. ecc_free(&pubkey);
  1507. }
  1508. return CRYPT_OK;
  1509. }
  1510. #endif
  1511. int ecc_test(void)
  1512. {
  1513. if (ltc_mp.name == NULL) return CRYPT_NOP;
  1514. DO(s_ecc_old_api()); /* up to 1.18 */
  1515. DO(s_ecc_new_api());
  1516. DO(s_ecc_import_export());
  1517. DO(s_ecc_test_mp());
  1518. DO(s_ecc_issue108());
  1519. DO(s_ecc_issue443_447());
  1520. DO(s_ecc_issue630());
  1521. #ifdef LTC_ECC_SHAMIR
  1522. DO(s_ecc_test_shamir());
  1523. DO(s_ecc_test_recovery());
  1524. #endif
  1525. return CRYPT_OK;
  1526. }
  1527. #endif