self_test_data.inc 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720
  1. /*
  2. * Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. /* Macros to build Self test data */
  10. #define ITM(x) ((void *)&x), sizeof(x)
  11. #define ITM_STR(x) ((void *)&x), (sizeof(x) - 1)
  12. #define ST_KAT_PARAM_END() { "", 0, NULL, 0 }
  13. #define ST_KAT_PARAM_BIGNUM(name, data) \
  14. { name, OSSL_PARAM_UNSIGNED_INTEGER, ITM(data) }
  15. #define ST_KAT_PARAM_OCTET(name, data) \
  16. { name, OSSL_PARAM_OCTET_STRING, ITM(data) }
  17. #define ST_KAT_PARAM_UTF8STRING(name, data) \
  18. { name, OSSL_PARAM_UTF8_STRING, ITM_STR(data) }
  19. #define ST_KAT_PARAM_UTF8CHAR(name, data) \
  20. { name, OSSL_PARAM_UTF8_STRING, ITM(data) }
  21. #define ST_KAT_PARAM_INT(name, i) \
  22. { name, OSSL_PARAM_INTEGER, ITM(i) }
  23. /* used to store raw parameters for keys and algorithms */
  24. typedef struct st_kat_param_st {
  25. const char *name; /* an OSSL_PARAM name */
  26. size_t type; /* the type associated with the data */
  27. const void *data; /* unsigned char [], or char [] depending on the type */
  28. size_t data_len; /* the length of the data */
  29. } ST_KAT_PARAM;
  30. typedef struct st_kat_st {
  31. const char *desc;
  32. const char *algorithm;
  33. const unsigned char *pt;
  34. size_t pt_len;
  35. const unsigned char *expected;
  36. size_t expected_len;
  37. } ST_KAT;
  38. #define CIPHER_MODE_ENCRYPT 1
  39. #define CIPHER_MODE_DECRYPT 2
  40. #define CIPHER_MODE_ALL (CIPHER_MODE_ENCRYPT | CIPHER_MODE_DECRYPT)
  41. typedef ST_KAT ST_KAT_DIGEST;
  42. typedef struct st_kat_cipher_st {
  43. ST_KAT base;
  44. int mode;
  45. const unsigned char *key;
  46. size_t key_len;
  47. const unsigned char *iv;
  48. size_t iv_len;
  49. const unsigned char *aad;
  50. size_t aad_len;
  51. const unsigned char *tag;
  52. size_t tag_len;
  53. } ST_KAT_CIPHER;
  54. typedef struct st_kat_kdf_st {
  55. const char *desc;
  56. const char *algorithm;
  57. const ST_KAT_PARAM *params;
  58. const unsigned char *expected;
  59. size_t expected_len;
  60. } ST_KAT_KDF;
  61. typedef struct st_kat_drbg_st {
  62. const char *desc;
  63. const char *algorithm;
  64. const char *param_name;
  65. char *param_value;
  66. const unsigned char *entropyin;
  67. size_t entropyinlen;
  68. const unsigned char *nonce;
  69. size_t noncelen;
  70. const unsigned char *persstr;
  71. size_t persstrlen;
  72. const unsigned char *entropyinpr1;
  73. size_t entropyinpr1len;
  74. const unsigned char *entropyinpr2;
  75. size_t entropyinpr2len;
  76. const unsigned char *entropyaddin1;
  77. size_t entropyaddin1len;
  78. const unsigned char *entropyaddin2;
  79. size_t entropyaddin2len;
  80. const unsigned char *expected;
  81. size_t expectedlen;
  82. } ST_KAT_DRBG;
  83. typedef struct st_kat_kas_st {
  84. const char *desc;
  85. const char *algorithm;
  86. const ST_KAT_PARAM *key_group;
  87. const ST_KAT_PARAM *key_host_data;
  88. const ST_KAT_PARAM *key_peer_data;
  89. const unsigned char *expected;
  90. size_t expected_len;
  91. } ST_KAT_KAS;
  92. typedef struct st_kat_sign_st {
  93. const char *desc;
  94. const char *algorithm;
  95. const char *mdalgorithm;
  96. const ST_KAT_PARAM *key;
  97. const unsigned char *entropy;
  98. size_t entropy_len;
  99. const unsigned char *nonce;
  100. size_t nonce_len;
  101. const unsigned char *persstr;
  102. size_t persstr_len;
  103. const unsigned char *sig_expected; /* Set to NULL if this value changes */
  104. size_t sig_expected_len;
  105. } ST_KAT_SIGN;
  106. typedef struct st_kat_asym_cipher_st {
  107. const char *desc;
  108. const char *algorithm;
  109. int encrypt;
  110. const ST_KAT_PARAM *key;
  111. const ST_KAT_PARAM *postinit;
  112. const unsigned char *in;
  113. size_t in_len;
  114. const unsigned char *expected;
  115. size_t expected_len;
  116. } ST_KAT_ASYM_CIPHER;
  117. /*- DIGEST TEST DATA */
  118. static const unsigned char sha1_pt[] = "abc";
  119. static const unsigned char sha1_digest[] = {
  120. 0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A, 0xBA, 0x3E, 0x25, 0x71,
  121. 0x78, 0x50, 0xC2, 0x6C, 0x9C, 0xD0, 0xD8, 0x9D
  122. };
  123. static const unsigned char sha512_pt[] = "abc";
  124. static const unsigned char sha512_digest[] = {
  125. 0xDD, 0xAF, 0x35, 0xA1, 0x93, 0x61, 0x7A, 0xBA, 0xCC, 0x41, 0x73, 0x49,
  126. 0xAE, 0x20, 0x41, 0x31, 0x12, 0xE6, 0xFA, 0x4E, 0x89, 0xA9, 0x7E, 0xA2,
  127. 0x0A, 0x9E, 0xEE, 0xE6, 0x4B, 0x55, 0xD3, 0x9A, 0x21, 0x92, 0x99, 0x2A,
  128. 0x27, 0x4F, 0xC1, 0xA8, 0x36, 0xBA, 0x3C, 0x23, 0xA3, 0xFE, 0xEB, 0xBD,
  129. 0x45, 0x4D, 0x44, 0x23, 0x64, 0x3C, 0xE8, 0x0E, 0x2A, 0x9A, 0xC9, 0x4F,
  130. 0xA5, 0x4C, 0xA4, 0x9F
  131. };
  132. static const unsigned char sha3_256_pt[] = { 0xe7, 0x37, 0x21, 0x05 };
  133. static const unsigned char sha3_256_digest[] = {
  134. 0x3a, 0x42, 0xb6, 0x8a, 0xb0, 0x79, 0xf2, 0x8c, 0x4c, 0xa3, 0xc7, 0x52,
  135. 0x29, 0x6f, 0x27, 0x90, 0x06, 0xc4, 0xfe, 0x78, 0xb1, 0xeb, 0x79, 0xd9,
  136. 0x89, 0x77, 0x7f, 0x05, 0x1e, 0x40, 0x46, 0xae
  137. };
  138. static const ST_KAT_DIGEST st_kat_digest_tests[] =
  139. {
  140. {
  141. OSSL_SELF_TEST_DESC_MD_SHA1,
  142. "SHA1",
  143. ITM_STR(sha1_pt),
  144. ITM(sha1_digest),
  145. },
  146. {
  147. OSSL_SELF_TEST_DESC_MD_SHA2,
  148. "SHA512",
  149. ITM_STR(sha512_pt),
  150. ITM(sha512_digest),
  151. },
  152. {
  153. OSSL_SELF_TEST_DESC_MD_SHA3,
  154. "SHA3-256",
  155. ITM(sha3_256_pt),
  156. ITM(sha3_256_digest),
  157. },
  158. };
  159. /*- CIPHER TEST DATA */
  160. /* DES3 test data */
  161. static const unsigned char des_ede3_cbc_pt[] = {
  162. 0x6B, 0xC1, 0xBE, 0xE2, 0x2E, 0x40, 0x9F, 0x96,
  163. 0xE9, 0x3D, 0x7E, 0x11, 0x73, 0x93, 0x17, 0x2A,
  164. 0xAE, 0x2D, 0x8A, 0x57, 0x1E, 0x03, 0xAC, 0x9C,
  165. 0x9E, 0xB7, 0x6F, 0xAC, 0x45, 0xAF, 0x8E, 0x51
  166. };
  167. static const unsigned char des_ede3_cbc_key[] = {
  168. 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
  169. 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01,
  170. 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23
  171. };
  172. static const unsigned char des_ede3_cbc_iv[] = {
  173. 0xF6, 0x9F, 0x24, 0x45, 0xDF, 0x4F, 0x9B, 0x17
  174. };
  175. static const unsigned char des_ede3_cbc_ct[] = {
  176. 0x20, 0x79, 0xC3, 0xD5, 0x3A, 0xA7, 0x63, 0xE1,
  177. 0x93, 0xB7, 0x9E, 0x25, 0x69, 0xAB, 0x52, 0x62,
  178. 0x51, 0x65, 0x70, 0x48, 0x1F, 0x25, 0xB5, 0x0F,
  179. 0x73, 0xC0, 0xBD, 0xA8, 0x5C, 0x8E, 0x0D, 0xA7
  180. };
  181. /* AES-256 GCM test data */
  182. static const unsigned char aes_256_gcm_key[] = {
  183. 0x92, 0xe1, 0x1d, 0xcd, 0xaa, 0x86, 0x6f, 0x5c,
  184. 0xe7, 0x90, 0xfd, 0x24, 0x50, 0x1f, 0x92, 0x50,
  185. 0x9a, 0xac, 0xf4, 0xcb, 0x8b, 0x13, 0x39, 0xd5,
  186. 0x0c, 0x9c, 0x12, 0x40, 0x93, 0x5d, 0xd0, 0x8b
  187. };
  188. static const unsigned char aes_256_gcm_iv[] = {
  189. 0xac, 0x93, 0xa1, 0xa6, 0x14, 0x52, 0x99, 0xbd,
  190. 0xe9, 0x02, 0xf2, 0x1a
  191. };
  192. static const unsigned char aes_256_gcm_pt[] = {
  193. 0x2d, 0x71, 0xbc, 0xfa, 0x91, 0x4e, 0x4a, 0xc0,
  194. 0x45, 0xb2, 0xaa, 0x60, 0x95, 0x5f, 0xad, 0x24
  195. };
  196. static const unsigned char aes_256_gcm_aad[] = {
  197. 0x1e, 0x08, 0x89, 0x01, 0x6f, 0x67, 0x60, 0x1c,
  198. 0x8e, 0xbe, 0xa4, 0x94, 0x3b, 0xc2, 0x3a, 0xd6
  199. };
  200. static const unsigned char aes_256_gcm_ct[] = {
  201. 0x89, 0x95, 0xae, 0x2e, 0x6d, 0xf3, 0xdb, 0xf9,
  202. 0x6f, 0xac, 0x7b, 0x71, 0x37, 0xba, 0xe6, 0x7f
  203. };
  204. static const unsigned char aes_256_gcm_tag[] = {
  205. 0xec, 0xa5, 0xaa, 0x77, 0xd5, 0x1d, 0x4a, 0x0a,
  206. 0x14, 0xd9, 0xc5, 0x1e, 0x1d, 0xa4, 0x74, 0xab
  207. };
  208. /* AES-ECB test data */
  209. static const unsigned char aes_128_ecb_key[] = {
  210. 0x10, 0xa5, 0x88, 0x69, 0xd7, 0x4b, 0xe5, 0xa3,
  211. 0x74, 0xcf, 0x86, 0x7c, 0xfb, 0x47, 0x38, 0x59
  212. };
  213. static const unsigned char aes_128_ecb_pt[] = {
  214. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  215. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  216. };
  217. static const unsigned char aes_128_ecb_ct[] = {
  218. 0x6d, 0x25, 0x1e, 0x69, 0x44, 0xb0, 0x51, 0xe0,
  219. 0x4e, 0xaa, 0x6f, 0xb4, 0xdb, 0xf7, 0x84, 0x65
  220. };
  221. static const ST_KAT_CIPHER st_kat_cipher_tests[] = {
  222. {
  223. {
  224. OSSL_SELF_TEST_DESC_CIPHER_AES_GCM,
  225. "AES-256-GCM",
  226. ITM(aes_256_gcm_pt),
  227. ITM(aes_256_gcm_ct)
  228. },
  229. CIPHER_MODE_ENCRYPT | CIPHER_MODE_DECRYPT,
  230. ITM(aes_256_gcm_key),
  231. ITM(aes_256_gcm_iv),
  232. ITM(aes_256_gcm_aad),
  233. ITM(aes_256_gcm_tag)
  234. },
  235. {
  236. {
  237. OSSL_SELF_TEST_DESC_CIPHER_AES_ECB,
  238. "AES-128-ECB",
  239. ITM(aes_128_ecb_pt),
  240. ITM(aes_128_ecb_ct)
  241. },
  242. CIPHER_MODE_DECRYPT,
  243. ITM(aes_128_ecb_key)
  244. }
  245. };
  246. static const char hkdf_digest[] = "SHA256";
  247. static const unsigned char hkdf_secret[] = { 's', 'e', 'c', 'r', 'e', 't' };
  248. static const unsigned char hkdf_salt[] = { 's', 'a', 'l', 't' };
  249. static const unsigned char hkdf_info[] = { 'l', 'a', 'b', 'e', 'l' };
  250. static const ST_KAT_PARAM hkdf_params[] = {
  251. ST_KAT_PARAM_UTF8STRING(OSSL_KDF_PARAM_DIGEST, hkdf_digest),
  252. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_KEY, hkdf_secret),
  253. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_SALT, hkdf_salt),
  254. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_INFO, hkdf_info),
  255. ST_KAT_PARAM_END()
  256. };
  257. static const unsigned char hkdf_expected[] = {
  258. 0x2a, 0xc4, 0x36, 0x9f, 0x52, 0x59, 0x96, 0xf8,
  259. 0xde, 0x13
  260. };
  261. static const char sskdf_digest[] = "SHA224";
  262. static const unsigned char sskdf_secret[] = {
  263. 0x6d, 0xbd, 0xc2, 0x3f, 0x04, 0x54, 0x88, 0xe4,
  264. 0x06, 0x27, 0x57, 0xb0, 0x6b, 0x9e, 0xba, 0xe1,
  265. 0x83, 0xfc, 0x5a, 0x59, 0x46, 0xd8, 0x0d, 0xb9,
  266. 0x3f, 0xec, 0x6f, 0x62, 0xec, 0x07, 0xe3, 0x72,
  267. 0x7f, 0x01, 0x26, 0xae, 0xd1, 0x2c, 0xe4, 0xb2,
  268. 0x62, 0xf4, 0x7d, 0x48, 0xd5, 0x42, 0x87, 0xf8,
  269. 0x1d, 0x47, 0x4c, 0x7c, 0x3b, 0x18, 0x50, 0xe9
  270. };
  271. static const unsigned char sskdf_otherinfo[] = {
  272. 0xa1, 0xb2, 0xc3, 0xd4, 0xe5, 0x43, 0x41, 0x56,
  273. 0x53, 0x69, 0x64, 0x3c, 0x83, 0x2e, 0x98, 0x49,
  274. 0xdc, 0xdb, 0xa7, 0x1e, 0x9a, 0x31, 0x39, 0xe6,
  275. 0x06, 0xe0, 0x95, 0xde, 0x3c, 0x26, 0x4a, 0x66,
  276. 0xe9, 0x8a, 0x16, 0x58, 0x54, 0xcd, 0x07, 0x98,
  277. 0x9b, 0x1e, 0xe0, 0xec, 0x3f, 0x8d, 0xbe
  278. };
  279. static const unsigned char sskdf_expected[] = {
  280. 0xa4, 0x62, 0xde, 0x16, 0xa8, 0x9d, 0xe8, 0x46,
  281. 0x6e, 0xf5, 0x46, 0x0b, 0x47, 0xb8
  282. };
  283. static const ST_KAT_PARAM sskdf_params[] = {
  284. ST_KAT_PARAM_UTF8STRING(OSSL_KDF_PARAM_DIGEST, sskdf_digest),
  285. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_KEY, sskdf_secret),
  286. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_INFO, sskdf_otherinfo),
  287. ST_KAT_PARAM_END()
  288. };
  289. static const char x942kdf_digest[] = "SHA1";
  290. static const char x942kdf_cekalg[] = "AES-128-WRAP";
  291. static const unsigned char x942kdf_secret[] = {
  292. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  293. 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
  294. 0x10, 0x11, 0x12, 0x13
  295. };
  296. static const unsigned char x942kdf_expected[] = {
  297. 0xd6, 0xd6, 0xb0, 0x94, 0xc1, 0x02, 0x7a, 0x7d,
  298. 0xe6, 0xe3, 0x11, 0x72, 0x94, 0xa3, 0x53, 0x64
  299. };
  300. static const ST_KAT_PARAM x942kdf_params[] = {
  301. ST_KAT_PARAM_UTF8STRING(OSSL_KDF_PARAM_DIGEST, x942kdf_digest),
  302. ST_KAT_PARAM_UTF8STRING(OSSL_KDF_PARAM_CEK_ALG, x942kdf_cekalg),
  303. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_KEY, x942kdf_secret),
  304. ST_KAT_PARAM_END()
  305. };
  306. static const char x963kdf_digest[] = "SHA256";
  307. static const unsigned char x963kdf_otherinfo[] = {
  308. 0x75, 0xee, 0xf8, 0x1a, 0xa3, 0x04, 0x1e, 0x33,
  309. 0xb8, 0x09, 0x71, 0x20, 0x3d, 0x2c, 0x0c, 0x52
  310. };
  311. static const unsigned char x963kdf_secret[] = {
  312. 0x22, 0x51, 0x8b, 0x10, 0xe7, 0x0f, 0x2a, 0x3f,
  313. 0x24, 0x38, 0x10, 0xae, 0x32, 0x54, 0x13, 0x9e,
  314. 0xfb, 0xee, 0x04, 0xaa, 0x57, 0xc7, 0xaf, 0x7d
  315. };
  316. static const unsigned char x963kdf_expected[] = {
  317. 0xc4, 0x98, 0xaf, 0x77, 0x16, 0x1c, 0xc5, 0x9f,
  318. 0x29, 0x62, 0xb9, 0xa7, 0x13, 0xe2, 0xb2, 0x15,
  319. 0x15, 0x2d, 0x13, 0x97, 0x66, 0xce, 0x34, 0xa7,
  320. 0x76, 0xdf, 0x11, 0x86, 0x6a, 0x69, 0xbf, 0x2e
  321. };
  322. static const ST_KAT_PARAM x963kdf_params[] = {
  323. ST_KAT_PARAM_UTF8STRING(OSSL_KDF_PARAM_DIGEST, x963kdf_digest),
  324. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_KEY, x963kdf_secret),
  325. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_INFO, x963kdf_otherinfo),
  326. ST_KAT_PARAM_END()
  327. };
  328. static const char pbkdf2_digest[] = "SHA256";
  329. /*
  330. * Input parameters from RFC 6070, vector 5 (because it is the only one with
  331. * a salt >= 16 bytes, which NIST SP 800-132 section 5.1 requires). The
  332. * expected output is taken from
  333. * https://github.com/brycx/Test-Vector-Generation/blob/master/PBKDF2/pbkdf2-hmac-sha2-test-vectors.md,
  334. * which ran these test vectors with SHA-256.
  335. */
  336. static const unsigned char pbkdf2_password[] = {
  337. 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x50, 0x41, 0x53, 0x53,
  338. 0x57, 0x4f, 0x52, 0x44, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64
  339. };
  340. static const unsigned char pbkdf2_salt[] = {
  341. 0x73, 0x61, 0x6c, 0x74, 0x53, 0x41, 0x4c, 0x54, 0x73, 0x61, 0x6c, 0x74,
  342. 0x53, 0x41, 0x4c, 0x54, 0x73, 0x61, 0x6c, 0x74, 0x53, 0x41, 0x4c, 0x54,
  343. 0x73, 0x61, 0x6c, 0x74, 0x53, 0x41, 0x4c, 0x54, 0x73, 0x61, 0x6c, 0x74
  344. };
  345. static const unsigned char pbkdf2_expected[] = {
  346. 0x34, 0x8c, 0x89, 0xdb, 0xcb, 0xd3, 0x2b, 0x2f, 0x32, 0xd8, 0x14, 0xb8,
  347. 0x11, 0x6e, 0x84, 0xcf, 0x2b, 0x17, 0x34, 0x7e, 0xbc, 0x18, 0x00, 0x18,
  348. 0x1c
  349. };
  350. static int pbkdf2_iterations = 4096;
  351. static int pbkdf2_pkcs5 = 0;
  352. static const ST_KAT_PARAM pbkdf2_params[] = {
  353. ST_KAT_PARAM_UTF8STRING(OSSL_KDF_PARAM_DIGEST, pbkdf2_digest),
  354. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_PASSWORD, pbkdf2_password),
  355. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_SALT, pbkdf2_salt),
  356. ST_KAT_PARAM_INT(OSSL_KDF_PARAM_ITER, pbkdf2_iterations),
  357. ST_KAT_PARAM_INT(OSSL_KDF_PARAM_PKCS5, pbkdf2_pkcs5),
  358. ST_KAT_PARAM_END()
  359. };
  360. static const char sshkdf_digest[] = "SHA1";
  361. static const char sshkdf_type = EVP_KDF_SSHKDF_TYPE_INITIAL_IV_CLI_TO_SRV;
  362. static const unsigned char sshkdf_key[] = {
  363. 0x00, 0x00, 0x00, 0x80, 0x55, 0xba, 0xe9, 0x31,
  364. 0xc0, 0x7f, 0xd8, 0x24, 0xbf, 0x10, 0xad, 0xd1,
  365. 0x90, 0x2b, 0x6f, 0xbc, 0x7c, 0x66, 0x53, 0x47,
  366. 0x38, 0x34, 0x98, 0xa6, 0x86, 0x92, 0x9f, 0xf5,
  367. 0xa2, 0x5f, 0x8e, 0x40, 0xcb, 0x66, 0x45, 0xea,
  368. 0x81, 0x4f, 0xb1, 0xa5, 0xe0, 0xa1, 0x1f, 0x85,
  369. 0x2f, 0x86, 0x25, 0x56, 0x41, 0xe5, 0xed, 0x98,
  370. 0x6e, 0x83, 0xa7, 0x8b, 0xc8, 0x26, 0x94, 0x80,
  371. 0xea, 0xc0, 0xb0, 0xdf, 0xd7, 0x70, 0xca, 0xb9,
  372. 0x2e, 0x7a, 0x28, 0xdd, 0x87, 0xff, 0x45, 0x24,
  373. 0x66, 0xd6, 0xae, 0x86, 0x7c, 0xea, 0xd6, 0x3b,
  374. 0x36, 0x6b, 0x1c, 0x28, 0x6e, 0x6c, 0x48, 0x11,
  375. 0xa9, 0xf1, 0x4c, 0x27, 0xae, 0xa1, 0x4c, 0x51,
  376. 0x71, 0xd4, 0x9b, 0x78, 0xc0, 0x6e, 0x37, 0x35,
  377. 0xd3, 0x6e, 0x6a, 0x3b, 0xe3, 0x21, 0xdd, 0x5f,
  378. 0xc8, 0x23, 0x08, 0xf3, 0x4e, 0xe1, 0xcb, 0x17,
  379. 0xfb, 0xa9, 0x4a, 0x59,
  380. };
  381. static const unsigned char sshkdf_xcghash[] = {
  382. 0xa4, 0xeb, 0xd4, 0x59, 0x34, 0xf5, 0x67, 0x92,
  383. 0xb5, 0x11, 0x2d, 0xcd, 0x75, 0xa1, 0x07, 0x5f,
  384. 0xdc, 0x88, 0x92, 0x45,
  385. };
  386. static const unsigned char sshkdf_session_id[] = {
  387. 0xa4, 0xeb, 0xd4, 0x59, 0x34, 0xf5, 0x67, 0x92,
  388. 0xb5, 0x11, 0x2d, 0xcd, 0x75, 0xa1, 0x07, 0x5f,
  389. 0xdc, 0x88, 0x92, 0x45,
  390. };
  391. static const unsigned char sshkdf_expected[] = {
  392. 0xe2, 0xf6, 0x27, 0xc0, 0xb4, 0x3f, 0x1a, 0xc1,
  393. };
  394. static const ST_KAT_PARAM sshkdf_params[] = {
  395. ST_KAT_PARAM_UTF8STRING(OSSL_KDF_PARAM_DIGEST, sshkdf_digest),
  396. ST_KAT_PARAM_UTF8CHAR(OSSL_KDF_PARAM_SSHKDF_TYPE, sshkdf_type),
  397. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_KEY, sshkdf_key),
  398. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_SSHKDF_XCGHASH, sshkdf_xcghash),
  399. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_SSHKDF_SESSION_ID, sshkdf_session_id),
  400. ST_KAT_PARAM_END()
  401. };
  402. static const char tls12prf_digest[] = "SHA256";
  403. static const unsigned char tls12prf_secret[] = {
  404. 0x20, 0x2c, 0x88, 0xc0, 0x0f, 0x84, 0xa1, 0x7a,
  405. 0x20, 0x02, 0x70, 0x79, 0x60, 0x47, 0x87, 0x46,
  406. 0x11, 0x76, 0x45, 0x55, 0x39, 0xe7, 0x05, 0xbe,
  407. 0x73, 0x08, 0x90, 0x60, 0x2c, 0x28, 0x9a, 0x50,
  408. 0x01, 0xe3, 0x4e, 0xeb, 0x3a, 0x04, 0x3e, 0x5d,
  409. 0x52, 0xa6, 0x5e, 0x66, 0x12, 0x51, 0x88, 0xbf,
  410. };
  411. static const unsigned char tls12prf_seed[] = {
  412. 'k', 'e', 'y', ' ', 'e', 'x', 'p', 'a', 'n', 's', 'i', 'o', 'n',
  413. 0xae, 0x6c, 0x80, 0x6f, 0x8a, 0xd4, 0xd8, 0x07,
  414. 0x84, 0x54, 0x9d, 0xff, 0x28, 0xa4, 0xb5, 0x8f,
  415. 0xd8, 0x37, 0x68, 0x1a, 0x51, 0xd9, 0x28, 0xc3,
  416. 0xe3, 0x0e, 0xe5, 0xff, 0x14, 0xf3, 0x98, 0x68,
  417. 0x62, 0xe1, 0xfd, 0x91, 0xf2, 0x3f, 0x55, 0x8a,
  418. 0x60, 0x5f, 0x28, 0x47, 0x8c, 0x58, 0xcf, 0x72,
  419. 0x63, 0x7b, 0x89, 0x78, 0x4d, 0x95, 0x9d, 0xf7,
  420. 0xe9, 0x46, 0xd3, 0xf0, 0x7b, 0xd1, 0xb6, 0x16,
  421. };
  422. static const unsigned char tls12prf_expected[] = {
  423. 0xd0, 0x61, 0x39, 0x88, 0x9f, 0xff, 0xac, 0x1e,
  424. 0x3a, 0x71, 0x86, 0x5f, 0x50, 0x4a, 0xa5, 0xd0,
  425. 0xd2, 0xa2, 0xe8, 0x95, 0x06, 0xc6, 0xf2, 0x27,
  426. 0x9b, 0x67, 0x0c, 0x3e, 0x1b, 0x74, 0xf5, 0x31,
  427. 0x01, 0x6a, 0x25, 0x30, 0xc5, 0x1a, 0x3a, 0x0f,
  428. 0x7e, 0x1d, 0x65, 0x90, 0xd0, 0xf0, 0x56, 0x6b,
  429. 0x2f, 0x38, 0x7f, 0x8d, 0x11, 0xfd, 0x4f, 0x73,
  430. 0x1c, 0xdd, 0x57, 0x2d, 0x2e, 0xae, 0x92, 0x7f,
  431. 0x6f, 0x2f, 0x81, 0x41, 0x0b, 0x25, 0xe6, 0x96,
  432. 0x0b, 0xe6, 0x89, 0x85, 0xad, 0xd6, 0xc3, 0x84,
  433. 0x45, 0xad, 0x9f, 0x8c, 0x64, 0xbf, 0x80, 0x68,
  434. 0xbf, 0x9a, 0x66, 0x79, 0x48, 0x5d, 0x96, 0x6f,
  435. 0x1a, 0xd6, 0xf6, 0x8b, 0x43, 0x49, 0x5b, 0x10,
  436. 0xa6, 0x83, 0x75, 0x5e, 0xa2, 0xb8, 0x58, 0xd7,
  437. 0x0c, 0xca, 0xc7, 0xec, 0x8b, 0x05, 0x3c, 0x6b,
  438. 0xd4, 0x1c, 0xa2, 0x99, 0xd4, 0xe5, 0x19, 0x28,
  439. };
  440. static const ST_KAT_PARAM tls12prf_params[] = {
  441. ST_KAT_PARAM_UTF8STRING(OSSL_KDF_PARAM_DIGEST, tls12prf_digest),
  442. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_SECRET, tls12prf_secret),
  443. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_SEED, tls12prf_seed),
  444. ST_KAT_PARAM_END()
  445. };
  446. static const char kbkdf_digest[] = "SHA256";
  447. static const char kbkdf_mac[] = "HMAC";
  448. static const unsigned char kbkdf_salt[] = { 'p', 'r', 'f' };
  449. static const unsigned char kbkdf_prfinput[] = { 't', 'e', 's', 't' };
  450. static unsigned char kbkdf_key[] = {
  451. 0x37, 0x05, 0xD9, 0x60, 0x80, 0xC1, 0x77, 0x28,
  452. 0xA0, 0xE8, 0x00, 0xEA, 0xB6, 0xE0, 0xD2, 0x3C,
  453. };
  454. static unsigned char kbkdf_expected[] = {
  455. 0x9D, 0x18, 0x86, 0x16, 0xF6, 0x38, 0x52, 0xFE,
  456. 0x86, 0x91, 0x5B, 0xB8, 0x40, 0xB4, 0xA8, 0x86,
  457. 0xFF, 0x3E, 0x6B, 0xB0, 0xF8, 0x19, 0xB4, 0x9B,
  458. 0x89, 0x33, 0x93, 0xD3, 0x93, 0x85, 0x42, 0x95,
  459. };
  460. static const ST_KAT_PARAM kbkdf_params[] = {
  461. ST_KAT_PARAM_UTF8STRING(OSSL_KDF_PARAM_DIGEST, kbkdf_digest),
  462. ST_KAT_PARAM_UTF8STRING(OSSL_KDF_PARAM_MAC, kbkdf_mac),
  463. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_KEY, kbkdf_key),
  464. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_SALT, kbkdf_salt),
  465. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_INFO, kbkdf_prfinput),
  466. ST_KAT_PARAM_END()
  467. };
  468. static const char kbkdf_kmac_mac[] = "KMAC128";
  469. static unsigned char kbkdf_kmac_label[] = {
  470. 0xB5, 0xB5, 0xF3, 0x71, 0x9F, 0xBE, 0x5B, 0x3D,
  471. 0x7B, 0x8D, 0x05, 0xA1, 0xD3, 0x25, 0x19, 0x50,
  472. };
  473. static unsigned char kbkdf_kmac_context[] = {
  474. 0x36, 0x60, 0x0E, 0xF3, 0xC3, 0x70, 0xB5, 0xEF,
  475. 0x58, 0xBE, 0xF1, 0xBA, 0x1C, 0xF2, 0x74, 0xCB,
  476. };
  477. static unsigned char kbkdf_kmac_key[] = {
  478. 0xB2, 0x51, 0x4C, 0xC1, 0xD5, 0xCD, 0x7B, 0x6B,
  479. 0xA3, 0x3C, 0x90, 0x05, 0xBD, 0xAC, 0x32, 0x2A,
  480. };
  481. static unsigned char kbkdf_kmac_expected[] = {
  482. 0xB1, 0x58, 0xEE, 0xB1, 0x34, 0xA4, 0xDD, 0x9D,
  483. 0xAC, 0x52, 0xBD, 0x9E, 0x30, 0xE8, 0x0D, 0x76,
  484. 0x42, 0x57, 0x01, 0x89, 0x5F, 0x82, 0x74, 0xB9,
  485. 0xEB, 0x3E, 0x84, 0xD8, 0xA5, 0xDE, 0x6E, 0x54,
  486. };
  487. static const ST_KAT_PARAM kbkdf_kmac_params[] = {
  488. ST_KAT_PARAM_UTF8STRING(OSSL_KDF_PARAM_MAC, kbkdf_kmac_mac),
  489. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_KEY, kbkdf_kmac_key),
  490. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_SALT, kbkdf_kmac_label),
  491. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_INFO, kbkdf_kmac_context),
  492. ST_KAT_PARAM_END()
  493. };
  494. static const char tls13_kdf_digest[] = "SHA256";
  495. static int tls13_kdf_extract_mode = EVP_KDF_HKDF_MODE_EXTRACT_ONLY;
  496. static int tls13_kdf_expand_mode = EVP_KDF_HKDF_MODE_EXPAND_ONLY;
  497. static const unsigned char tls13_kdf_prefix[] = {
  498. 0x74, 0x6C, 0x73, 0x31, 0x33, 0x20 /* "tls13 " */
  499. };
  500. static const unsigned char tls13_kdf_client_early_secret_label[] = {
  501. 0x63, 0x20, 0x65, 0x20, 0x74, 0x72, 0x61, 0x66,
  502. 0x66, 0x69, 0x63 /* "c e traffic"*/
  503. };
  504. static const unsigned char tls13_kdf_psk[] = {
  505. 0xF8, 0xAF, 0x6A, 0xEA, 0x2D, 0x39, 0x7B, 0xAF,
  506. 0x29, 0x48, 0xA2, 0x5B, 0x28, 0x34, 0x20, 0x06,
  507. 0x92, 0xCF, 0xF1, 0x7E, 0xEE, 0x91, 0x65, 0xE4,
  508. 0xE2, 0x7B, 0xAB, 0xEE, 0x9E, 0xDE, 0xFD, 0x05
  509. };
  510. static const unsigned char tls13_kdf_client_hello_hash[] = {
  511. 0x7c, 0x92, 0xf6, 0x8b, 0xd5, 0xbf, 0x36, 0x38,
  512. 0xea, 0x33, 0x8a, 0x64, 0x94, 0x72, 0x2e, 0x1b,
  513. 0x44, 0x12, 0x7e, 0x1b, 0x7e, 0x8a, 0xad, 0x53,
  514. 0x5f, 0x23, 0x22, 0xa6, 0x44, 0xff, 0x22, 0xb3
  515. };
  516. static const unsigned char tls13_kdf_early_secret[] = {
  517. 0x15, 0x3B, 0x63, 0x94, 0xA9, 0xC0, 0x3C, 0xF3,
  518. 0xF5, 0xAC, 0xCC, 0x6E, 0x45, 0x5A, 0x76, 0x93,
  519. 0x28, 0x11, 0x38, 0xA1, 0xBC, 0xFA, 0x38, 0x03,
  520. 0xC2, 0x67, 0x35, 0xDD, 0x11, 0x94, 0xD2, 0x16
  521. };
  522. static const unsigned char tls13_kdf_client_early_traffic_secret[] = {
  523. 0xC8, 0x05, 0x83, 0xA9, 0x0E, 0x99, 0x5C, 0x48,
  524. 0x96, 0x00, 0x49, 0x2A, 0x5D, 0xA6, 0x42, 0xE6,
  525. 0xB1, 0xF6, 0x79, 0xBA, 0x67, 0x48, 0x28, 0x79,
  526. 0x2D, 0xF0, 0x87, 0xB9, 0x39, 0x63, 0x61, 0x71
  527. };
  528. static const ST_KAT_PARAM tls13_kdf_early_secret_params[] = {
  529. ST_KAT_PARAM_INT(OSSL_KDF_PARAM_MODE, tls13_kdf_extract_mode),
  530. ST_KAT_PARAM_UTF8STRING(OSSL_KDF_PARAM_DIGEST, tls13_kdf_digest),
  531. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_KEY, tls13_kdf_psk),
  532. ST_KAT_PARAM_END()
  533. };
  534. static const ST_KAT_PARAM tls13_kdf_client_early_secret_params[] = {
  535. ST_KAT_PARAM_INT(OSSL_KDF_PARAM_MODE, tls13_kdf_expand_mode),
  536. ST_KAT_PARAM_UTF8STRING(OSSL_KDF_PARAM_DIGEST, tls13_kdf_digest),
  537. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_KEY, tls13_kdf_early_secret),
  538. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_DATA, tls13_kdf_client_hello_hash),
  539. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_PREFIX, tls13_kdf_prefix),
  540. ST_KAT_PARAM_OCTET(OSSL_KDF_PARAM_LABEL,
  541. tls13_kdf_client_early_secret_label),
  542. ST_KAT_PARAM_END()
  543. };
  544. static const ST_KAT_KDF st_kat_kdf_tests[] =
  545. {
  546. {
  547. OSSL_SELF_TEST_DESC_KDF_TLS13_EXTRACT,
  548. OSSL_KDF_NAME_TLS1_3_KDF,
  549. tls13_kdf_early_secret_params,
  550. ITM(tls13_kdf_early_secret)
  551. },
  552. {
  553. OSSL_SELF_TEST_DESC_KDF_TLS13_EXPAND,
  554. OSSL_KDF_NAME_TLS1_3_KDF,
  555. tls13_kdf_client_early_secret_params,
  556. ITM(tls13_kdf_client_early_traffic_secret)
  557. },
  558. {
  559. OSSL_SELF_TEST_DESC_KDF_TLS12_PRF,
  560. OSSL_KDF_NAME_TLS1_PRF,
  561. tls12prf_params,
  562. ITM(tls12prf_expected)
  563. },
  564. {
  565. OSSL_SELF_TEST_DESC_KDF_PBKDF2,
  566. OSSL_KDF_NAME_PBKDF2,
  567. pbkdf2_params,
  568. ITM(pbkdf2_expected)
  569. },
  570. {
  571. OSSL_SELF_TEST_DESC_KDF_SSHKDF,
  572. OSSL_KDF_NAME_SSHKDF,
  573. sshkdf_params,
  574. ITM(sshkdf_expected)
  575. },
  576. {
  577. OSSL_SELF_TEST_DESC_KDF_KBKDF,
  578. OSSL_KDF_NAME_KBKDF,
  579. kbkdf_params,
  580. ITM(kbkdf_expected)
  581. },
  582. {
  583. OSSL_SELF_TEST_DESC_KDF_KBKDF_KMAC,
  584. OSSL_KDF_NAME_KBKDF,
  585. kbkdf_kmac_params,
  586. ITM(kbkdf_kmac_expected)
  587. },
  588. {
  589. OSSL_SELF_TEST_DESC_KDF_HKDF,
  590. OSSL_KDF_NAME_HKDF,
  591. hkdf_params,
  592. ITM(hkdf_expected)
  593. },
  594. {
  595. OSSL_SELF_TEST_DESC_KDF_SSKDF,
  596. OSSL_KDF_NAME_SSKDF,
  597. sskdf_params,
  598. ITM(sskdf_expected)
  599. },
  600. {
  601. OSSL_SELF_TEST_DESC_KDF_X963KDF,
  602. OSSL_KDF_NAME_X963KDF,
  603. x963kdf_params,
  604. ITM(x963kdf_expected)
  605. },
  606. {
  607. OSSL_SELF_TEST_DESC_KDF_X942KDF,
  608. OSSL_KDF_NAME_X942KDF_ASN1,
  609. x942kdf_params,
  610. ITM(x942kdf_expected)
  611. },
  612. };
  613. /*-
  614. * DRBG test vectors are a small subset of
  615. * https://csrc.nist.rip/groups/STM/cavp/documents/drbg/drbgtestvectors.zip
  616. * Using the folder drbgvectors_pr_true
  617. * Generated for CAVS 14.3.
  618. */
  619. /*
  620. * Hash_DRBG.rsp
  621. *
  622. * [SHA-256]
  623. * [PredictionResistance = True]
  624. * [EntropyInputLen = 256]
  625. * [NonceLen = 128]
  626. * [PersonalizationStringLen = 256]
  627. * [AdditionalInputLen = 256]
  628. * [ReturnedBitsLen = 1024]
  629. *
  630. * COUNT = 14
  631. */
  632. static const unsigned char drbg_hash_sha256_pr_entropyin[] = {
  633. 0x06, 0x6d, 0xc8, 0xce, 0x75, 0xb2, 0x89, 0x66, 0xa6, 0x85, 0x16, 0x3f,
  634. 0xe2, 0xa4, 0xd4, 0x27, 0xfb, 0xdb, 0x61, 0x66, 0x50, 0x61, 0x6b, 0xa2,
  635. 0x82, 0xfc, 0x33, 0x2b, 0x4e, 0x6f, 0x12, 0x20
  636. };
  637. static const unsigned char drbg_hash_sha256_pr_nonce[] = {
  638. 0x55, 0x9f, 0x7c, 0x64, 0x89, 0x70, 0x83, 0xec, 0x2d, 0x73, 0x70, 0xd9,
  639. 0xf0, 0xe5, 0x07, 0x1f
  640. };
  641. static const unsigned char drbg_hash_sha256_pr_persstr[] = {
  642. 0x88, 0x6f, 0x54, 0x9a, 0xad, 0x1a, 0xc6, 0x3d, 0x18, 0xcb, 0xcc, 0x66,
  643. 0x85, 0xda, 0xa2, 0xc2, 0xf7, 0x9e, 0xb0, 0x89, 0x4c, 0xb4, 0xae, 0xf1,
  644. 0xac, 0x54, 0x4f, 0xce, 0x57, 0xf1, 0x5e, 0x11
  645. };
  646. static const unsigned char drbg_hash_sha256_pr_entropyinpr0[] = {
  647. 0xff, 0x80, 0xb7, 0xd2, 0x6a, 0x05, 0xbc, 0x8a, 0x7a, 0xbe, 0x53, 0x28,
  648. 0x6b, 0x0e, 0xeb, 0x73, 0x3b, 0x71, 0x5a, 0x20, 0x5b, 0xfa, 0x4f, 0xf6,
  649. 0x37, 0x03, 0xde, 0xad, 0xb6, 0xea, 0x0e, 0xf4
  650. };
  651. static const unsigned char drbg_hash_sha256_pr_entropyinpr1[] = {
  652. 0xc7, 0x38, 0x32, 0x53, 0x46, 0x81, 0xed, 0xe3, 0x7e, 0x03, 0x84, 0x6d,
  653. 0x3c, 0x84, 0x17, 0x67, 0x29, 0x7d, 0x24, 0x6c, 0x68, 0x92, 0x41, 0xd2,
  654. 0xe7, 0x75, 0xbe, 0x7e, 0xc9, 0x96, 0x29, 0x3d
  655. };
  656. static const unsigned char drbg_hash_sha256_pr_addin0[] = {
  657. 0xb7, 0x21, 0x5f, 0x14, 0xac, 0x7b, 0xaf, 0xd0, 0xa9, 0x17, 0x72, 0xba,
  658. 0x22, 0xf7, 0x19, 0xaf, 0xbd, 0x20, 0xb3, 0x11, 0x63, 0x6c, 0x2b, 0x1e,
  659. 0x83, 0xe4, 0xa8, 0x23, 0x35, 0x3f, 0xc6, 0xea
  660. };
  661. static const unsigned char drbg_hash_sha256_pr_addin1[] = {
  662. 0xce, 0xd3, 0x1f, 0x7e, 0x0d, 0xae, 0x5b, 0xb5, 0xc0, 0x43, 0xe2, 0x46,
  663. 0xb2, 0x94, 0x73, 0xe2, 0xfd, 0x39, 0x51, 0x2e, 0xad, 0x45, 0x69, 0xee,
  664. 0xe3, 0xe3, 0x80, 0x33, 0x14, 0xab, 0xa7, 0xa3
  665. };
  666. static const unsigned char drbg_hash_sha256_pr_expected[] = {
  667. 0x60, 0xc2, 0x34, 0xcf, 0xaf, 0xb4, 0x68, 0x03, 0x3b, 0xf1, 0x95, 0xe5,
  668. 0x78, 0xce, 0x26, 0x6e, 0x14, 0x65, 0x32, 0x6a, 0x96, 0xa9, 0xe0, 0x3f,
  669. 0x8b, 0x89, 0x36, 0x70, 0xef, 0x62, 0x75, 0x4d, 0x5e, 0x80, 0xd5, 0x53,
  670. 0xa1, 0xf8, 0x49, 0x50, 0x20, 0x8b, 0x93, 0x43, 0x07, 0x9f, 0x2e, 0xf8,
  671. 0x56, 0xe9, 0xc5, 0x70, 0x61, 0x85, 0x97, 0xb5, 0xdc, 0x82, 0xa2, 0xda,
  672. 0xea, 0xa3, 0xfd, 0x9b, 0x2f, 0xd2, 0xa0, 0xd7, 0x1b, 0xc6, 0x29, 0x35,
  673. 0xcc, 0xb8, 0x3d, 0xa0, 0x67, 0x98, 0x05, 0xa0, 0xe3, 0x1e, 0xfe, 0xe4,
  674. 0xf0, 0xe5, 0x13, 0xb0, 0x83, 0x17, 0xfa, 0xca, 0x93, 0x5e, 0x38, 0x29,
  675. 0x48, 0xd2, 0x72, 0xdb, 0x76, 0x3e, 0x6d, 0xf3, 0x25, 0x10, 0xff, 0x1b,
  676. 0x99, 0xff, 0xf8, 0xc6, 0x0e, 0xb0, 0xdd, 0x29, 0x2e, 0xbc, 0xbb, 0xc8,
  677. 0x0a, 0x01, 0x6e, 0xd3, 0xb0, 0x0e, 0x4e, 0xab
  678. };
  679. /*
  680. * CTR_DRBG.rsp
  681. *
  682. * [AES-128 use df]
  683. * [PredictionResistance = True]
  684. * [EntropyInputLen = 128]
  685. * [NonceLen = 64]
  686. * [PersonalizationStringLen = 128]
  687. * [AdditionalInputLen = 128]
  688. * [ReturnedBitsLen = 512]
  689. *
  690. * COUNT = 0
  691. */
  692. static const unsigned char drbg_ctr_aes128_pr_df_entropyin[] = {
  693. 0x92, 0x89, 0x8f, 0x31, 0xfa, 0x1c, 0xff, 0x6d, 0x18, 0x2f, 0x26, 0x06,
  694. 0x43, 0xdf, 0xf8, 0x18
  695. };
  696. static const unsigned char drbg_ctr_aes128_pr_df_nonce[] = {
  697. 0xc2, 0xa4, 0xd9, 0x72, 0xc3, 0xb9, 0xb6, 0x97
  698. };
  699. static const unsigned char drbg_ctr_aes128_pr_df_persstr[] = {
  700. 0xea, 0x65, 0xee, 0x60, 0x26, 0x4e, 0x7e, 0xb6, 0x0e, 0x82, 0x68, 0xc4,
  701. 0x37, 0x3c, 0x5c, 0x0b
  702. };
  703. static const unsigned char drbg_ctr_aes128_pr_df_entropyinpr0[] = {
  704. 0x20, 0x72, 0x8a, 0x06, 0xf8, 0x6f, 0x8d, 0xd4, 0x41, 0xe2, 0x72, 0xb7,
  705. 0xc4, 0x2c, 0xe8, 0x10
  706. };
  707. static const unsigned char drbg_ctr_aes128_pr_df_entropyinpr1[] = {
  708. 0x3d, 0xb0, 0xf0, 0x94, 0xf3, 0x05, 0x50, 0x33, 0x17, 0x86, 0x3e, 0x22,
  709. 0x08, 0xf7, 0xa5, 0x01
  710. };
  711. static const unsigned char drbg_ctr_aes128_pr_df_addin0[] = {
  712. 0x1a, 0x40, 0xfa, 0xe3, 0xcc, 0x6c, 0x7c, 0xa0, 0xf8, 0xda, 0xba, 0x59,
  713. 0x23, 0x6d, 0xad, 0x1d
  714. };
  715. static const unsigned char drbg_ctr_aes128_pr_df_addin1[] = {
  716. 0x9f, 0x72, 0x76, 0x6c, 0xc7, 0x46, 0xe5, 0xed, 0x2e, 0x53, 0x20, 0x12,
  717. 0xbc, 0x59, 0x31, 0x8c
  718. };
  719. static const unsigned char drbg_ctr_aes128_pr_df_expected[] = {
  720. 0x5a, 0x35, 0x39, 0x87, 0x0f, 0x4d, 0x22, 0xa4, 0x09, 0x24, 0xee, 0x71,
  721. 0xc9, 0x6f, 0xac, 0x72, 0x0a, 0xd6, 0xf0, 0x88, 0x82, 0xd0, 0x83, 0x28,
  722. 0x73, 0xec, 0x3f, 0x93, 0xd8, 0xab, 0x45, 0x23, 0xf0, 0x7e, 0xac, 0x45,
  723. 0x14, 0x5e, 0x93, 0x9f, 0xb1, 0xd6, 0x76, 0x43, 0x3d, 0xb6, 0xe8, 0x08,
  724. 0x88, 0xf6, 0xda, 0x89, 0x08, 0x77, 0x42, 0xfe, 0x1a, 0xf4, 0x3f, 0xc4,
  725. 0x23, 0xc5, 0x1f, 0x68
  726. };
  727. /*
  728. * HMAC_DRBG.rsp
  729. *
  730. * [SHA-1]
  731. * [PredictionResistance = True]
  732. * [EntropyInputLen = 128]
  733. * [NonceLen = 64]
  734. * [PersonalizationStringLen = 128]
  735. * [AdditionalInputLen = 128]
  736. * [ReturnedBitsLen = 640]
  737. *
  738. * COUNT = 0
  739. */
  740. static const unsigned char drbg_hmac_sha1_pr_entropyin[] = {
  741. 0x68, 0x0f, 0xac, 0xe9, 0x0d, 0x7b, 0xca, 0x21, 0xd4, 0xa0, 0xed, 0xb7,
  742. 0x79, 0x9e, 0xe5, 0xd8
  743. };
  744. static const unsigned char drbg_hmac_sha1_pr_nonce[] = {
  745. 0xb7, 0xbe, 0x9e, 0xed, 0xdd, 0x0e, 0x3b, 0x4b
  746. };
  747. static const unsigned char drbg_hmac_sha1_pr_persstr[] = {
  748. 0xf5, 0x8c, 0x40, 0xae, 0x70, 0xf7, 0xa5, 0x56, 0x48, 0xa9, 0x31, 0xa0,
  749. 0xa9, 0x31, 0x3d, 0xd7
  750. };
  751. static const unsigned char drbg_hmac_sha1_pr_entropyinpr0[] = {
  752. 0x7c, 0xaf, 0xe2, 0x31, 0x63, 0x0a, 0xa9, 0x5a, 0x74, 0x2c, 0x4e, 0x5f,
  753. 0x5f, 0x22, 0xc6, 0xa4
  754. };
  755. static const unsigned char drbg_hmac_sha1_pr_entropyinpr1[] = {
  756. 0x1c, 0x0d, 0x77, 0x92, 0x89, 0x88, 0x27, 0x94, 0x8a, 0x58, 0x9f, 0x82,
  757. 0x2d, 0x1a, 0xf7, 0xa6
  758. };
  759. static const unsigned char drbg_hmac_sha1_pr_addin0[] = {
  760. 0xdc, 0x36, 0x63, 0xf0, 0x62, 0x78, 0x9c, 0xd1, 0x5c, 0xbb, 0x20, 0xc3,
  761. 0xc1, 0x8c, 0xd9, 0xd7
  762. };
  763. static const unsigned char drbg_hmac_sha1_pr_addin1[] = {
  764. 0xfe, 0x85, 0xb0, 0xab, 0x14, 0xc6, 0x96, 0xe6, 0x9c, 0x24, 0xe7, 0xb5,
  765. 0xa1, 0x37, 0x12, 0x0c
  766. };
  767. static const unsigned char drbg_hmac_sha1_pr_expected[] = {
  768. 0x68, 0x00, 0x4b, 0x3a, 0x28, 0xf7, 0xf0, 0x1c, 0xf9, 0xe9, 0xb5, 0x71,
  769. 0x20, 0x79, 0xef, 0x80, 0x87, 0x1b, 0x08, 0xb9, 0xa9, 0x1b, 0xcd, 0x2b,
  770. 0x9f, 0x09, 0x4d, 0xa4, 0x84, 0x80, 0xb3, 0x4c, 0xaf, 0xd5, 0x59, 0x6b,
  771. 0x0c, 0x0a, 0x48, 0xe1, 0x48, 0xda, 0xbc, 0x6f, 0x77, 0xb8, 0xff, 0xaf,
  772. 0x18, 0x70, 0x28, 0xe1, 0x04, 0x13, 0x7a, 0x4f, 0xeb, 0x1c, 0x72, 0xb0,
  773. 0xc4, 0x4f, 0xe8, 0xb1, 0xaf, 0xab, 0xa5, 0xbc, 0xfd, 0x86, 0x67, 0xf2,
  774. 0xf5, 0x5b, 0x46, 0x06, 0x63, 0x2e, 0x3c, 0xbc
  775. };
  776. static const ST_KAT_DRBG st_kat_drbg_tests[] =
  777. {
  778. {
  779. OSSL_SELF_TEST_DESC_DRBG_HASH,
  780. "HASH-DRBG", "digest", "SHA256",
  781. ITM(drbg_hash_sha256_pr_entropyin),
  782. ITM(drbg_hash_sha256_pr_nonce),
  783. ITM(drbg_hash_sha256_pr_persstr),
  784. ITM(drbg_hash_sha256_pr_entropyinpr0),
  785. ITM(drbg_hash_sha256_pr_entropyinpr1),
  786. ITM(drbg_hash_sha256_pr_addin0),
  787. ITM(drbg_hash_sha256_pr_addin1),
  788. ITM(drbg_hash_sha256_pr_expected)
  789. },
  790. {
  791. OSSL_SELF_TEST_DESC_DRBG_CTR,
  792. "CTR-DRBG", "cipher", "AES-128-CTR",
  793. ITM(drbg_ctr_aes128_pr_df_entropyin),
  794. ITM(drbg_ctr_aes128_pr_df_nonce),
  795. ITM(drbg_ctr_aes128_pr_df_persstr),
  796. ITM(drbg_ctr_aes128_pr_df_entropyinpr0),
  797. ITM(drbg_ctr_aes128_pr_df_entropyinpr1),
  798. ITM(drbg_ctr_aes128_pr_df_addin0),
  799. ITM(drbg_ctr_aes128_pr_df_addin1),
  800. ITM(drbg_ctr_aes128_pr_df_expected)
  801. },
  802. {
  803. OSSL_SELF_TEST_DESC_DRBG_HMAC,
  804. "HMAC-DRBG", "digest", "SHA1",
  805. ITM(drbg_hmac_sha1_pr_entropyin),
  806. ITM(drbg_hmac_sha1_pr_nonce),
  807. ITM(drbg_hmac_sha1_pr_persstr),
  808. ITM(drbg_hmac_sha1_pr_entropyinpr0),
  809. ITM(drbg_hmac_sha1_pr_entropyinpr1),
  810. ITM(drbg_hmac_sha1_pr_addin0),
  811. ITM(drbg_hmac_sha1_pr_addin1),
  812. ITM(drbg_hmac_sha1_pr_expected)
  813. }
  814. };
  815. /* KEY EXCHANGE TEST DATA */
  816. #ifndef OPENSSL_NO_DH
  817. /* DH KAT */
  818. static const unsigned char dh_p[] = {
  819. 0xdc, 0xca, 0x15, 0x11, 0xb2, 0x31, 0x32, 0x25,
  820. 0xf5, 0x21, 0x16, 0xe1, 0x54, 0x27, 0x89, 0xe0,
  821. 0x01, 0xf0, 0x42, 0x5b, 0xcc, 0xc7, 0xf3, 0x66,
  822. 0xf7, 0x40, 0x64, 0x07, 0xf1, 0xc9, 0xfa, 0x8b,
  823. 0xe6, 0x10, 0xf1, 0x77, 0x8b, 0xb1, 0x70, 0xbe,
  824. 0x39, 0xdb, 0xb7, 0x6f, 0x85, 0xbf, 0x24, 0xce,
  825. 0x68, 0x80, 0xad, 0xb7, 0x62, 0x9f, 0x7c, 0x6d,
  826. 0x01, 0x5e, 0x61, 0xd4, 0x3f, 0xa3, 0xee, 0x4d,
  827. 0xe1, 0x85, 0xf2, 0xcf, 0xd0, 0x41, 0xff, 0xde,
  828. 0x9d, 0x41, 0x84, 0x07, 0xe1, 0x51, 0x38, 0xbb,
  829. 0x02, 0x1d, 0xae, 0xb3, 0x5f, 0x76, 0x2d, 0x17,
  830. 0x82, 0xac, 0xc6, 0x58, 0xd3, 0x2b, 0xd4, 0xb0,
  831. 0x23, 0x2c, 0x92, 0x7d, 0xd3, 0x8f, 0xa0, 0x97,
  832. 0xb3, 0xd1, 0x85, 0x9f, 0xa8, 0xac, 0xaf, 0xb9,
  833. 0x8f, 0x06, 0x66, 0x08, 0xfc, 0x64, 0x4e, 0xc7,
  834. 0xdd, 0xb6, 0xf0, 0x85, 0x99, 0xf9, 0x2a, 0xc1,
  835. 0xb5, 0x98, 0x25, 0xda, 0x84, 0x32, 0x07, 0x7d,
  836. 0xef, 0x69, 0x56, 0x46, 0x06, 0x3c, 0x20, 0x82,
  837. 0x3c, 0x95, 0x07, 0xab, 0x6f, 0x01, 0x76, 0xd4,
  838. 0x73, 0x0d, 0x99, 0x0d, 0xbb, 0xe6, 0x36, 0x1c,
  839. 0xd8, 0xb2, 0xb9, 0x4d, 0x3d, 0x2f, 0x32, 0x9b,
  840. 0x82, 0x09, 0x9b, 0xd6, 0x61, 0xf4, 0x29, 0x50,
  841. 0xf4, 0x03, 0xdf, 0x3e, 0xde, 0x62, 0xa3, 0x31,
  842. 0x88, 0xb0, 0x27, 0x98, 0xba, 0x82, 0x3f, 0x44,
  843. 0xb9, 0x46, 0xfe, 0x9d, 0xf6, 0x77, 0xa0, 0xc5,
  844. 0xa1, 0x23, 0x8e, 0xaa, 0x97, 0xb7, 0x0f, 0x80,
  845. 0xda, 0x8c, 0xac, 0x88, 0xe0, 0x92, 0xb1, 0x12,
  846. 0x70, 0x60, 0xff, 0xbf, 0x45, 0x57, 0x99, 0x94,
  847. 0x01, 0x1d, 0xc2, 0xfa, 0xa5, 0xe7, 0xf6, 0xc7,
  848. 0x62, 0x45, 0xe1, 0xcc, 0x31, 0x22, 0x31, 0xc1,
  849. 0x7d, 0x1c, 0xa6, 0xb1, 0x90, 0x07, 0xef, 0x0d,
  850. 0xb9, 0x9f, 0x9c, 0xb6, 0x0e, 0x1d, 0x5f, 0x69
  851. };
  852. static const unsigned char dh_q[] = {
  853. 0x89, 0x8b, 0x22, 0x67, 0x17, 0xef, 0x03, 0x9e,
  854. 0x60, 0x3e, 0x82, 0xe5, 0xc7, 0xaf, 0xe4, 0x83,
  855. 0x74, 0xac, 0x5f, 0x62, 0x5c, 0x54, 0xf1, 0xea,
  856. 0x11, 0xac, 0xb5, 0x7d
  857. };
  858. static const unsigned char dh_g[] = {
  859. 0x5e, 0xf7, 0xb8, 0x8f, 0x2d, 0xf6, 0x01, 0x39,
  860. 0x35, 0x1d, 0xfb, 0xfe, 0x12, 0x66, 0x80, 0x5f,
  861. 0xdf, 0x35, 0x6c, 0xdf, 0xd1, 0x3a, 0x4d, 0xa0,
  862. 0x05, 0x0c, 0x7e, 0xde, 0x24, 0x6d, 0xf5, 0x9f,
  863. 0x6a, 0xbf, 0x96, 0xad, 0xe5, 0xf2, 0xb2, 0x8f,
  864. 0xfe, 0x88, 0xd6, 0xbc, 0xe7, 0xf7, 0x89, 0x4a,
  865. 0x3d, 0x53, 0x5f, 0xc8, 0x21, 0x26, 0xdd, 0xd4,
  866. 0x24, 0x87, 0x2e, 0x16, 0xb8, 0x38, 0xdf, 0x8c,
  867. 0x51, 0xe9, 0x01, 0x6f, 0x88, 0x9c, 0x7c, 0x20,
  868. 0x3e, 0x98, 0xa8, 0xb6, 0x31, 0xf9, 0xc7, 0x25,
  869. 0x63, 0xd3, 0x8a, 0x49, 0x58, 0x9a, 0x07, 0x53,
  870. 0xd3, 0x58, 0xe7, 0x83, 0x31, 0x8c, 0xef, 0xd9,
  871. 0x67, 0x7c, 0x7b, 0x2d, 0xbb, 0x77, 0xd6, 0xdc,
  872. 0xe2, 0xa1, 0x96, 0x37, 0x95, 0xca, 0x64, 0xb9,
  873. 0x2d, 0x1c, 0x9a, 0xac, 0x6d, 0x0e, 0x8d, 0x43,
  874. 0x1d, 0xe5, 0xe5, 0x00, 0x60, 0xdf, 0xf7, 0x86,
  875. 0x89, 0xc9, 0xec, 0xa1, 0xc1, 0x24, 0x8c, 0x16,
  876. 0xed, 0x09, 0xc7, 0xad, 0x41, 0x2a, 0x17, 0x40,
  877. 0x6d, 0x2b, 0x52, 0x5a, 0xa1, 0xca, 0xbb, 0x23,
  878. 0x7b, 0x97, 0x34, 0xec, 0x7b, 0x8c, 0xe3, 0xfa,
  879. 0xe0, 0x2f, 0x29, 0xc5, 0xef, 0xed, 0x30, 0xd6,
  880. 0x91, 0x87, 0xda, 0x10, 0x9c, 0x2c, 0x9f, 0xe2,
  881. 0xaa, 0xdb, 0xb0, 0xc2, 0x2a, 0xf5, 0x4c, 0x61,
  882. 0x66, 0x55, 0x00, 0x0c, 0x43, 0x1c, 0x6b, 0x4a,
  883. 0x37, 0x97, 0x63, 0xb0, 0xa9, 0x16, 0x58, 0xef,
  884. 0xc8, 0x4e, 0x8b, 0x06, 0x35, 0x8c, 0x8b, 0x4f,
  885. 0x21, 0x37, 0x10, 0xfd, 0x10, 0x17, 0x2c, 0xf3,
  886. 0x9b, 0x83, 0x0c, 0x2d, 0xd8, 0x4a, 0x0c, 0x8a,
  887. 0xb8, 0x25, 0x16, 0xec, 0xab, 0x99, 0x5f, 0xa4,
  888. 0x21, 0x5e, 0x02, 0x3e, 0x4e, 0xcf, 0x80, 0x74,
  889. 0xc3, 0x9d, 0x6c, 0x88, 0xb7, 0x0d, 0x1e, 0xe4,
  890. 0xe9, 0x6f, 0xdc, 0x20, 0xea, 0x11, 0x5c, 0x32
  891. };
  892. static const unsigned char dh_priv[] = {
  893. 0x14, 0x33, 0xe0, 0xb5, 0xa9, 0x17, 0xb6, 0x0a,
  894. 0x30, 0x23, 0xf2, 0xf8, 0xaa, 0x2c, 0x2d, 0x70,
  895. 0xd2, 0x96, 0x8a, 0xba, 0x9a, 0xea, 0xc8, 0x15,
  896. 0x40, 0xb8, 0xfc, 0xe6
  897. };
  898. static const unsigned char dh_pub[] = {
  899. 0x95, 0xdd, 0x33, 0x8d, 0x29, 0xe5, 0x71, 0x04,
  900. 0x92, 0xb9, 0x18, 0x31, 0x7b, 0x72, 0xa3, 0x69,
  901. 0x36, 0xe1, 0x95, 0x1a, 0x2e, 0xe5, 0xa5, 0x59,
  902. 0x16, 0x99, 0xc0, 0x48, 0x6d, 0x0d, 0x4f, 0x9b,
  903. 0xdd, 0x6d, 0x5a, 0x3f, 0x6b, 0x98, 0x89, 0x0c,
  904. 0x62, 0xb3, 0x76, 0x52, 0xd3, 0x6e, 0x71, 0x21,
  905. 0x11, 0xe6, 0x8a, 0x73, 0x55, 0x37, 0x25, 0x06,
  906. 0x99, 0xef, 0xe3, 0x30, 0x53, 0x73, 0x91, 0xfb,
  907. 0xc2, 0xc5, 0x48, 0xbc, 0x5a, 0xc3, 0xe5, 0xb2,
  908. 0x33, 0x86, 0xc3, 0xee, 0xf5, 0xeb, 0x43, 0xc0,
  909. 0x99, 0xd7, 0x0a, 0x52, 0x02, 0x68, 0x7e, 0x83,
  910. 0x96, 0x42, 0x48, 0xfc, 0xa9, 0x1f, 0x40, 0x90,
  911. 0x8e, 0x8f, 0xb3, 0x31, 0x93, 0x15, 0xf6, 0xd2,
  912. 0x60, 0x6d, 0x7f, 0x7c, 0xd5, 0x2c, 0xc6, 0xe7,
  913. 0xc5, 0x84, 0x3a, 0xfb, 0x22, 0x51, 0x9c, 0xf0,
  914. 0xf0, 0xf9, 0xd3, 0xa0, 0xa4, 0xe8, 0xc8, 0x88,
  915. 0x99, 0xef, 0xed, 0xe7, 0x36, 0x43, 0x51, 0xfb,
  916. 0x6a, 0x36, 0x3e, 0xe7, 0x17, 0xe5, 0x44, 0x5a,
  917. 0xda, 0xb4, 0xc9, 0x31, 0xa6, 0x48, 0x39, 0x97,
  918. 0xb8, 0x7d, 0xad, 0x83, 0x67, 0x7e, 0x4d, 0x1d,
  919. 0x3a, 0x77, 0x75, 0xe0, 0xf6, 0xd0, 0x0f, 0xdf,
  920. 0x73, 0xc7, 0xad, 0x80, 0x1e, 0x66, 0x5a, 0x0e,
  921. 0x5a, 0x79, 0x6d, 0x0a, 0x03, 0x80, 0xa1, 0x9f,
  922. 0xa1, 0x82, 0xef, 0xc8, 0xa0, 0x4f, 0x5e, 0x4d,
  923. 0xb9, 0x0d, 0x1a, 0x86, 0x37, 0xf9, 0x5d, 0xb1,
  924. 0x64, 0x36, 0xbd, 0xc8, 0xf3, 0xfc, 0x09, 0x6c,
  925. 0x4f, 0xf7, 0xf2, 0x34, 0xbe, 0x8f, 0xef, 0x47,
  926. 0x9a, 0xc4, 0xb0, 0xdc, 0x4b, 0x77, 0x26, 0x3e,
  927. 0x07, 0xd9, 0x95, 0x9d, 0xe0, 0xf1, 0xbf, 0x3f,
  928. 0x0a, 0xe3, 0xd9, 0xd5, 0x0e, 0x4b, 0x89, 0xc9,
  929. 0x9e, 0x3e, 0xa1, 0x21, 0x73, 0x43, 0xdd, 0x8c,
  930. 0x65, 0x81, 0xac, 0xc4, 0x95, 0x9c, 0x91, 0xd3
  931. };
  932. static const unsigned char dh_peer_pub[] = {
  933. 0x1f, 0xc1, 0xda, 0x34, 0x1d, 0x1a, 0x84, 0x6a,
  934. 0x96, 0xb7, 0xbe, 0x24, 0x34, 0x0f, 0x87, 0x7d,
  935. 0xd0, 0x10, 0xaa, 0x03, 0x56, 0xd5, 0xad, 0x58,
  936. 0xaa, 0xe9, 0xc7, 0xb0, 0x8f, 0x74, 0x9a, 0x32,
  937. 0x23, 0x51, 0x10, 0xb5, 0xd8, 0x8e, 0xb5, 0xdb,
  938. 0xfa, 0x97, 0x8d, 0x27, 0xec, 0xc5, 0x30, 0xf0,
  939. 0x2d, 0x31, 0x14, 0x00, 0x5b, 0x64, 0xb1, 0xc0,
  940. 0xe0, 0x24, 0xcb, 0x8a, 0xe2, 0x16, 0x98, 0xbc,
  941. 0xa9, 0xe6, 0x0d, 0x42, 0x80, 0x86, 0x22, 0xf1,
  942. 0x81, 0xc5, 0x6e, 0x1d, 0xe7, 0xa9, 0x6e, 0x6e,
  943. 0xfe, 0xe9, 0xd6, 0x65, 0x67, 0xe9, 0x1b, 0x97,
  944. 0x70, 0x42, 0xc7, 0xe3, 0xd0, 0x44, 0x8f, 0x05,
  945. 0xfb, 0x77, 0xf5, 0x22, 0xb9, 0xbf, 0xc8, 0xd3,
  946. 0x3c, 0xc3, 0xc3, 0x1e, 0xd3, 0xb3, 0x1f, 0x0f,
  947. 0xec, 0xb6, 0xdb, 0x4f, 0x6e, 0xa3, 0x11, 0xe7,
  948. 0x7a, 0xfd, 0xbc, 0xd4, 0x7a, 0xee, 0x1b, 0xb1,
  949. 0x50, 0xf2, 0x16, 0x87, 0x35, 0x78, 0xfb, 0x96,
  950. 0x46, 0x8e, 0x8f, 0x9f, 0x3d, 0xe8, 0xef, 0xbf,
  951. 0xce, 0x75, 0x62, 0x4b, 0x1d, 0xf0, 0x53, 0x22,
  952. 0xa3, 0x4f, 0x14, 0x63, 0xe8, 0x39, 0xe8, 0x98,
  953. 0x4c, 0x4a, 0xd0, 0xa9, 0x6e, 0x1a, 0xc8, 0x42,
  954. 0xe5, 0x31, 0x8c, 0xc2, 0x3c, 0x06, 0x2a, 0x8c,
  955. 0xa1, 0x71, 0xb8, 0xd5, 0x75, 0x98, 0x0d, 0xde,
  956. 0x7f, 0xc5, 0x6f, 0x15, 0x36, 0x52, 0x38, 0x20,
  957. 0xd4, 0x31, 0x92, 0xbf, 0xd5, 0x1e, 0x8e, 0x22,
  958. 0x89, 0x78, 0xac, 0xa5, 0xb9, 0x44, 0x72, 0xf3,
  959. 0x39, 0xca, 0xeb, 0x99, 0x31, 0xb4, 0x2b, 0xe3,
  960. 0x01, 0x26, 0x8b, 0xc9, 0x97, 0x89, 0xc9, 0xb2,
  961. 0x55, 0x71, 0xc3, 0xc0, 0xe4, 0xcb, 0x3f, 0x00,
  962. 0x7f, 0x1a, 0x51, 0x1c, 0xbb, 0x53, 0xc8, 0x51,
  963. 0x9c, 0xdd, 0x13, 0x02, 0xab, 0xca, 0x6c, 0x0f,
  964. 0x34, 0xf9, 0x67, 0x39, 0xf1, 0x7f, 0xf4, 0x8b
  965. };
  966. static const unsigned char dh_secret_expected[] = {
  967. 0x08, 0xff, 0x33, 0xbb, 0x2e, 0xcf, 0xf4, 0x9a,
  968. 0x7d, 0x4a, 0x79, 0x12, 0xae, 0xb1, 0xbb, 0x6a,
  969. 0xb5, 0x11, 0x64, 0x1b, 0x4a, 0x76, 0x77, 0x0c,
  970. 0x8c, 0xc1, 0xbc, 0xc2, 0x33, 0x34, 0x3d, 0xfe,
  971. 0x70, 0x0d, 0x11, 0x81, 0x3d, 0x2c, 0x9e, 0xd2,
  972. 0x3b, 0x21, 0x1c, 0xa9, 0xe8, 0x78, 0x69, 0x21,
  973. 0xed, 0xca, 0x28, 0x3c, 0x68, 0xb1, 0x61, 0x53,
  974. 0xfa, 0x01, 0xe9, 0x1a, 0xb8, 0x2c, 0x90, 0xdd,
  975. 0xab, 0x4a, 0x95, 0x81, 0x67, 0x70, 0xa9, 0x87,
  976. 0x10, 0xe1, 0x4c, 0x92, 0xab, 0x83, 0xb6, 0xe4,
  977. 0x6e, 0x1e, 0x42, 0x6e, 0xe8, 0x52, 0x43, 0x0d,
  978. 0x61, 0x87, 0xda, 0xa3, 0x72, 0x0a, 0x6b, 0xcd,
  979. 0x73, 0x23, 0x5c, 0x6b, 0x0f, 0x94, 0x1f, 0x33,
  980. 0x64, 0xf5, 0x04, 0x20, 0x55, 0x1a, 0x4b, 0xfe,
  981. 0xaf, 0xe2, 0xbc, 0x43, 0x85, 0x05, 0xa5, 0x9a,
  982. 0x4a, 0x40, 0xda, 0xca, 0x7a, 0x89, 0x5a, 0x73,
  983. 0xdb, 0x57, 0x5c, 0x74, 0xc1, 0x3a, 0x23, 0xad,
  984. 0x88, 0x32, 0x95, 0x7d, 0x58, 0x2d, 0x38, 0xf0,
  985. 0xa6, 0x16, 0x5f, 0xb0, 0xd7, 0xe9, 0xb8, 0x79,
  986. 0x9e, 0x42, 0xfd, 0x32, 0x20, 0xe3, 0x32, 0xe9,
  987. 0x81, 0x85, 0xa0, 0xc9, 0x42, 0x97, 0x57, 0xb2,
  988. 0xd0, 0xd0, 0x2c, 0x17, 0xdb, 0xaa, 0x1f, 0xf6,
  989. 0xed, 0x93, 0xd7, 0xe7, 0x3e, 0x24, 0x1e, 0xae,
  990. 0xd9, 0x0c, 0xaf, 0x39, 0x4d, 0x2b, 0xc6, 0x57,
  991. 0x0f, 0x18, 0xc8, 0x1f, 0x2b, 0xe5, 0xd0, 0x1a,
  992. 0x2c, 0xa9, 0x9f, 0xf1, 0x42, 0xb5, 0xd9, 0x63,
  993. 0xf9, 0xf5, 0x00, 0x32, 0x5e, 0x75, 0x56, 0xf9,
  994. 0x58, 0x49, 0xb3, 0xff, 0xc7, 0x47, 0x94, 0x86,
  995. 0xbe, 0x1d, 0x45, 0x96, 0xa3, 0x10, 0x6b, 0xd5,
  996. 0xcb, 0x4f, 0x61, 0xc5, 0x7e, 0xc5, 0xf1, 0x00,
  997. 0xfb, 0x7a, 0x0c, 0x82, 0xa1, 0x0b, 0x82, 0x52,
  998. 0x6a, 0x97, 0xd1, 0xd9, 0x7d, 0x98, 0xea, 0xf6
  999. };
  1000. static const ST_KAT_PARAM dh_group[] = {
  1001. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_FFC_P, dh_p),
  1002. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_FFC_Q, dh_q),
  1003. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_FFC_G, dh_g),
  1004. ST_KAT_PARAM_END()
  1005. };
  1006. /* The host's private key */
  1007. static const ST_KAT_PARAM dh_host_key[] = {
  1008. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_PUB_KEY, dh_pub),
  1009. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_PRIV_KEY, dh_priv),
  1010. ST_KAT_PARAM_END()
  1011. };
  1012. /* The peer's public key */
  1013. static const ST_KAT_PARAM dh_peer_key[] = {
  1014. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_PUB_KEY, dh_peer_pub),
  1015. ST_KAT_PARAM_END()
  1016. };
  1017. #endif /* OPENSSL_NO_DH */
  1018. #ifndef OPENSSL_NO_EC
  1019. static const char ecdh_curve_name[] = "prime256v1";
  1020. static const unsigned char ecdh_privd[] = {
  1021. 0x33, 0xd0, 0x43, 0x83, 0xa9, 0x89, 0x56, 0x03,
  1022. 0xd2, 0xd7, 0xfe, 0x6b, 0x01, 0x6f, 0xe4, 0x59,
  1023. 0xcc, 0x0d, 0x9a, 0x24, 0x6c, 0x86, 0x1b, 0x2e,
  1024. 0xdc, 0x4b, 0x4d, 0x35, 0x43, 0xe1, 0x1b, 0xad
  1025. };
  1026. static const unsigned char ecdh_pub[] = {
  1027. 0x04,
  1028. 0x1b, 0x93, 0x67, 0x55, 0x1c, 0x55, 0x9f, 0x63,
  1029. 0xd1, 0x22, 0xa4, 0xd8, 0xd1, 0x0a, 0x60, 0x6d,
  1030. 0x02, 0xa5, 0x77, 0x57, 0xc8, 0xa3, 0x47, 0x73,
  1031. 0x3a, 0x6a, 0x08, 0x28, 0x39, 0xbd, 0xc9, 0xd2,
  1032. 0x80, 0xec, 0xe9, 0xa7, 0x08, 0x29, 0x71, 0x2f,
  1033. 0xc9, 0x56, 0x82, 0xee, 0x9a, 0x85, 0x0f, 0x6d,
  1034. 0x7f, 0x59, 0x5f, 0x8c, 0xd1, 0x96, 0x0b, 0xdf,
  1035. 0x29, 0x3e, 0x49, 0x07, 0x88, 0x3f, 0x9a, 0x29
  1036. };
  1037. static const unsigned char ecdh_peer_pub[] = {
  1038. 0x04,
  1039. 0x1f, 0x72, 0xbd, 0x2a, 0x3e, 0xeb, 0x6c, 0x76,
  1040. 0xe5, 0x5d, 0x69, 0x75, 0x24, 0xbf, 0x2f, 0x5b,
  1041. 0x96, 0xb2, 0x91, 0x62, 0x06, 0x35, 0xcc, 0xb2,
  1042. 0x4b, 0x31, 0x1b, 0x0c, 0x6f, 0x06, 0x9f, 0x86,
  1043. 0xcf, 0xc8, 0xac, 0xd5, 0x4f, 0x4d, 0x77, 0xf3,
  1044. 0x70, 0x4a, 0x8f, 0x04, 0x9a, 0xb1, 0x03, 0xc7,
  1045. 0xeb, 0xd5, 0x94, 0x78, 0x61, 0xab, 0x78, 0x0c,
  1046. 0x4a, 0x2d, 0x6b, 0xf3, 0x2f, 0x2e, 0x4a, 0xbc
  1047. };
  1048. static const ST_KAT_PARAM ecdh_group[] = {
  1049. ST_KAT_PARAM_UTF8STRING(OSSL_PKEY_PARAM_GROUP_NAME, ecdh_curve_name),
  1050. ST_KAT_PARAM_END()
  1051. };
  1052. static const ST_KAT_PARAM ecdh_host_key[] = {
  1053. ST_KAT_PARAM_OCTET(OSSL_PKEY_PARAM_PUB_KEY, ecdh_pub),
  1054. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_PRIV_KEY, ecdh_privd),
  1055. ST_KAT_PARAM_END()
  1056. };
  1057. static const ST_KAT_PARAM ecdh_peer_key[] = {
  1058. ST_KAT_PARAM_OCTET(OSSL_PKEY_PARAM_PUB_KEY, ecdh_peer_pub),
  1059. ST_KAT_PARAM_END()
  1060. };
  1061. static const unsigned char ecdh_secret_expected[] = {
  1062. 0x45, 0x2a, 0x2f, 0x0d, 0x24, 0xe6, 0x8d, 0xd0,
  1063. 0xda, 0x59, 0x7b, 0x0c, 0xec, 0x9b, 0x4c, 0x38,
  1064. 0x41, 0xdd, 0xce, 0xb3, 0xcc, 0xf1, 0x90, 0x8e,
  1065. 0x30, 0xdb, 0x5b, 0x5f, 0x97, 0xea, 0xe0, 0xc2
  1066. };
  1067. #endif /* OPENSSL_NO_EC */
  1068. #if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_EC)
  1069. static const ST_KAT_KAS st_kat_kas_tests[] =
  1070. {
  1071. # ifndef OPENSSL_NO_DH
  1072. {
  1073. OSSL_SELF_TEST_DESC_KA_DH,
  1074. "DH",
  1075. dh_group,
  1076. dh_host_key,
  1077. dh_peer_key,
  1078. ITM(dh_secret_expected)
  1079. },
  1080. # endif /* OPENSSL_NO_DH */
  1081. # ifndef OPENSSL_NO_EC
  1082. {
  1083. OSSL_SELF_TEST_DESC_KA_ECDH,
  1084. "EC",
  1085. ecdh_group,
  1086. ecdh_host_key,
  1087. ecdh_peer_key,
  1088. ITM(ecdh_secret_expected)
  1089. },
  1090. # endif /* OPENSSL_NO_EC */
  1091. };
  1092. #endif /* !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_EC) */
  1093. /* RSA key data */
  1094. static const unsigned char rsa_n[] = {
  1095. 0xDB, 0x10, 0x1A, 0xC2, 0xA3, 0xF1, 0xDC, 0xFF,
  1096. 0x13, 0x6B, 0xED, 0x44, 0xDF, 0xF0, 0x02, 0x6D,
  1097. 0x13, 0xC7, 0x88, 0xDA, 0x70, 0x6B, 0x54, 0xF1,
  1098. 0xE8, 0x27, 0xDC, 0xC3, 0x0F, 0x99, 0x6A, 0xFA,
  1099. 0xC6, 0x67, 0xFF, 0x1D, 0x1E, 0x3C, 0x1D, 0xC1,
  1100. 0xB5, 0x5F, 0x6C, 0xC0, 0xB2, 0x07, 0x3A, 0x6D,
  1101. 0x41, 0xE4, 0x25, 0x99, 0xAC, 0xFC, 0xD2, 0x0F,
  1102. 0x02, 0xD3, 0xD1, 0x54, 0x06, 0x1A, 0x51, 0x77,
  1103. 0xBD, 0xB6, 0xBF, 0xEA, 0xA7, 0x5C, 0x06, 0xA9,
  1104. 0x5D, 0x69, 0x84, 0x45, 0xD7, 0xF5, 0x05, 0xBA,
  1105. 0x47, 0xF0, 0x1B, 0xD7, 0x2B, 0x24, 0xEC, 0xCB,
  1106. 0x9B, 0x1B, 0x10, 0x8D, 0x81, 0xA0, 0xBE, 0xB1,
  1107. 0x8C, 0x33, 0xE4, 0x36, 0xB8, 0x43, 0xEB, 0x19,
  1108. 0x2A, 0x81, 0x8D, 0xDE, 0x81, 0x0A, 0x99, 0x48,
  1109. 0xB6, 0xF6, 0xBC, 0xCD, 0x49, 0x34, 0x3A, 0x8F,
  1110. 0x26, 0x94, 0xE3, 0x28, 0x82, 0x1A, 0x7C, 0x8F,
  1111. 0x59, 0x9F, 0x45, 0xE8, 0x5D, 0x1A, 0x45, 0x76,
  1112. 0x04, 0x56, 0x05, 0xA1, 0xD0, 0x1B, 0x8C, 0x77,
  1113. 0x6D, 0xAF, 0x53, 0xFA, 0x71, 0xE2, 0x67, 0xE0,
  1114. 0x9A, 0xFE, 0x03, 0xA9, 0x85, 0xD2, 0xC9, 0xAA,
  1115. 0xBA, 0x2A, 0xBC, 0xF4, 0xA0, 0x08, 0xF5, 0x13,
  1116. 0x98, 0x13, 0x5D, 0xF0, 0xD9, 0x33, 0x34, 0x2A,
  1117. 0x61, 0xC3, 0x89, 0x55, 0xF0, 0xAE, 0x1A, 0x9C,
  1118. 0x22, 0xEE, 0x19, 0x05, 0x8D, 0x32, 0xFE, 0xEC,
  1119. 0x9C, 0x84, 0xBA, 0xB7, 0xF9, 0x6C, 0x3A, 0x4F,
  1120. 0x07, 0xFC, 0x45, 0xEB, 0x12, 0xE5, 0x7B, 0xFD,
  1121. 0x55, 0xE6, 0x29, 0x69, 0xD1, 0xC2, 0xE8, 0xB9,
  1122. 0x78, 0x59, 0xF6, 0x79, 0x10, 0xC6, 0x4E, 0xEB,
  1123. 0x6A, 0x5E, 0xB9, 0x9A, 0xC7, 0xC4, 0x5B, 0x63,
  1124. 0xDA, 0xA3, 0x3F, 0x5E, 0x92, 0x7A, 0x81, 0x5E,
  1125. 0xD6, 0xB0, 0xE2, 0x62, 0x8F, 0x74, 0x26, 0xC2,
  1126. 0x0C, 0xD3, 0x9A, 0x17, 0x47, 0xE6, 0x8E, 0xAB
  1127. };
  1128. static const unsigned char rsa_e[] = { 0x01, 0x00, 0x01 };
  1129. static const unsigned char rsa_d[] = {
  1130. 0x52, 0x41, 0xF4, 0xDA, 0x7B, 0xB7, 0x59, 0x55,
  1131. 0xCA, 0xD4, 0x2F, 0x0F, 0x3A, 0xCB, 0xA4, 0x0D,
  1132. 0x93, 0x6C, 0xCC, 0x9D, 0xC1, 0xB2, 0xFB, 0xFD,
  1133. 0xAE, 0x40, 0x31, 0xAC, 0x69, 0x52, 0x21, 0x92,
  1134. 0xB3, 0x27, 0xDF, 0xEA, 0xEE, 0x2C, 0x82, 0xBB,
  1135. 0xF7, 0x40, 0x32, 0xD5, 0x14, 0xC4, 0x94, 0x12,
  1136. 0xEC, 0xB8, 0x1F, 0xCA, 0x59, 0xE3, 0xC1, 0x78,
  1137. 0xF3, 0x85, 0xD8, 0x47, 0xA5, 0xD7, 0x02, 0x1A,
  1138. 0x65, 0x79, 0x97, 0x0D, 0x24, 0xF4, 0xF0, 0x67,
  1139. 0x6E, 0x75, 0x2D, 0xBF, 0x10, 0x3D, 0xA8, 0x7D,
  1140. 0xEF, 0x7F, 0x60, 0xE4, 0xE6, 0x05, 0x82, 0x89,
  1141. 0x5D, 0xDF, 0xC6, 0xD2, 0x6C, 0x07, 0x91, 0x33,
  1142. 0x98, 0x42, 0xF0, 0x02, 0x00, 0x25, 0x38, 0xC5,
  1143. 0x85, 0x69, 0x8A, 0x7D, 0x2F, 0x95, 0x6C, 0x43,
  1144. 0x9A, 0xB8, 0x81, 0xE2, 0xD0, 0x07, 0x35, 0xAA,
  1145. 0x05, 0x41, 0xC9, 0x1E, 0xAF, 0xE4, 0x04, 0x3B,
  1146. 0x19, 0xB8, 0x73, 0xA2, 0xAC, 0x4B, 0x1E, 0x66,
  1147. 0x48, 0xD8, 0x72, 0x1F, 0xAC, 0xF6, 0xCB, 0xBC,
  1148. 0x90, 0x09, 0xCA, 0xEC, 0x0C, 0xDC, 0xF9, 0x2C,
  1149. 0xD7, 0xEB, 0xAE, 0xA3, 0xA4, 0x47, 0xD7, 0x33,
  1150. 0x2F, 0x8A, 0xCA, 0xBC, 0x5E, 0xF0, 0x77, 0xE4,
  1151. 0x97, 0x98, 0x97, 0xC7, 0x10, 0x91, 0x7D, 0x2A,
  1152. 0xA6, 0xFF, 0x46, 0x83, 0x97, 0xDE, 0xE9, 0xE2,
  1153. 0x17, 0x03, 0x06, 0x14, 0xE2, 0xD7, 0xB1, 0x1D,
  1154. 0x77, 0xAF, 0x51, 0x27, 0x5B, 0x5E, 0x69, 0xB8,
  1155. 0x81, 0xE6, 0x11, 0xC5, 0x43, 0x23, 0x81, 0x04,
  1156. 0x62, 0xFF, 0xE9, 0x46, 0xB8, 0xD8, 0x44, 0xDB,
  1157. 0xA5, 0xCC, 0x31, 0x54, 0x34, 0xCE, 0x3E, 0x82,
  1158. 0xD6, 0xBF, 0x7A, 0x0B, 0x64, 0x21, 0x6D, 0x88,
  1159. 0x7E, 0x5B, 0x45, 0x12, 0x1E, 0x63, 0x8D, 0x49,
  1160. 0xA7, 0x1D, 0xD9, 0x1E, 0x06, 0xCD, 0xE8, 0xBA,
  1161. 0x2C, 0x8C, 0x69, 0x32, 0xEA, 0xBE, 0x60, 0x71
  1162. };
  1163. static const unsigned char rsa_p[] = {
  1164. 0xFA, 0xAC, 0xE1, 0x37, 0x5E, 0x32, 0x11, 0x34,
  1165. 0xC6, 0x72, 0x58, 0x2D, 0x91, 0x06, 0x3E, 0x77,
  1166. 0xE7, 0x11, 0x21, 0xCD, 0x4A, 0xF8, 0xA4, 0x3F,
  1167. 0x0F, 0xEF, 0x31, 0xE3, 0xF3, 0x55, 0xA0, 0xB9,
  1168. 0xAC, 0xB6, 0xCB, 0xBB, 0x41, 0xD0, 0x32, 0x81,
  1169. 0x9A, 0x8F, 0x7A, 0x99, 0x30, 0x77, 0x6C, 0x68,
  1170. 0x27, 0xE2, 0x96, 0xB5, 0x72, 0xC9, 0xC3, 0xD4,
  1171. 0x42, 0xAA, 0xAA, 0xCA, 0x95, 0x8F, 0xFF, 0xC9,
  1172. 0x9B, 0x52, 0x34, 0x30, 0x1D, 0xCF, 0xFE, 0xCF,
  1173. 0x3C, 0x56, 0x68, 0x6E, 0xEF, 0xE7, 0x6C, 0xD7,
  1174. 0xFB, 0x99, 0xF5, 0x4A, 0xA5, 0x21, 0x1F, 0x2B,
  1175. 0xEA, 0x93, 0xE8, 0x98, 0x26, 0xC4, 0x6E, 0x42,
  1176. 0x21, 0x5E, 0xA0, 0xA1, 0x2A, 0x58, 0x35, 0xBB,
  1177. 0x10, 0xE7, 0xBA, 0x27, 0x0A, 0x3B, 0xB3, 0xAF,
  1178. 0xE2, 0x75, 0x36, 0x04, 0xAC, 0x56, 0xA0, 0xAB,
  1179. 0x52, 0xDE, 0xCE, 0xDD, 0x2C, 0x28, 0x77, 0x03
  1180. };
  1181. static const unsigned char rsa_q[] = {
  1182. 0xDF, 0xB7, 0x52, 0xB6, 0xD7, 0xC0, 0xE2, 0x96,
  1183. 0xE7, 0xC9, 0xFE, 0x5D, 0x71, 0x5A, 0xC4, 0x40,
  1184. 0x96, 0x2F, 0xE5, 0x87, 0xEA, 0xF3, 0xA5, 0x77,
  1185. 0x11, 0x67, 0x3C, 0x8D, 0x56, 0x08, 0xA7, 0xB5,
  1186. 0x67, 0xFA, 0x37, 0xA8, 0xB8, 0xCF, 0x61, 0xE8,
  1187. 0x63, 0xD8, 0x38, 0x06, 0x21, 0x2B, 0x92, 0x09,
  1188. 0xA6, 0x39, 0x3A, 0xEA, 0xA8, 0xB4, 0x45, 0x4B,
  1189. 0x36, 0x10, 0x4C, 0xE4, 0x00, 0x66, 0x71, 0x65,
  1190. 0xF8, 0x0B, 0x94, 0x59, 0x4F, 0x8C, 0xFD, 0xD5,
  1191. 0x34, 0xA2, 0xE7, 0x62, 0x84, 0x0A, 0xA7, 0xBB,
  1192. 0xDB, 0xD9, 0x8A, 0xCD, 0x05, 0xE1, 0xCC, 0x57,
  1193. 0x7B, 0xF1, 0xF1, 0x1F, 0x11, 0x9D, 0xBA, 0x3E,
  1194. 0x45, 0x18, 0x99, 0x1B, 0x41, 0x64, 0x43, 0xEE,
  1195. 0x97, 0x5D, 0x77, 0x13, 0x5B, 0x74, 0x69, 0x73,
  1196. 0x87, 0x95, 0x05, 0x07, 0xBE, 0x45, 0x07, 0x17,
  1197. 0x7E, 0x4A, 0x69, 0x22, 0xF3, 0xDB, 0x05, 0x39
  1198. };
  1199. static const unsigned char rsa_dp[] = {
  1200. 0x5E, 0xD8, 0xDC, 0xDA, 0x53, 0x44, 0xC4, 0x67,
  1201. 0xE0, 0x92, 0x51, 0x34, 0xE4, 0x83, 0xA5, 0x4D,
  1202. 0x3E, 0xDB, 0xA7, 0x9B, 0x82, 0xBB, 0x73, 0x81,
  1203. 0xFC, 0xE8, 0x77, 0x4B, 0x15, 0xBE, 0x17, 0x73,
  1204. 0x49, 0x9B, 0x5C, 0x98, 0xBC, 0xBD, 0x26, 0xEF,
  1205. 0x0C, 0xE9, 0x2E, 0xED, 0x19, 0x7E, 0x86, 0x41,
  1206. 0x1E, 0x9E, 0x48, 0x81, 0xDD, 0x2D, 0xE4, 0x6F,
  1207. 0xC2, 0xCD, 0xCA, 0x93, 0x9E, 0x65, 0x7E, 0xD5,
  1208. 0xEC, 0x73, 0xFD, 0x15, 0x1B, 0xA2, 0xA0, 0x7A,
  1209. 0x0F, 0x0D, 0x6E, 0xB4, 0x53, 0x07, 0x90, 0x92,
  1210. 0x64, 0x3B, 0x8B, 0xA9, 0x33, 0xB3, 0xC5, 0x94,
  1211. 0x9B, 0x4C, 0x5D, 0x9C, 0x7C, 0x46, 0xA4, 0xA5,
  1212. 0x56, 0xF4, 0xF3, 0xF8, 0x27, 0x0A, 0x7B, 0x42,
  1213. 0x0D, 0x92, 0x70, 0x47, 0xE7, 0x42, 0x51, 0xA9,
  1214. 0xC2, 0x18, 0xB1, 0x58, 0xB1, 0x50, 0x91, 0xB8,
  1215. 0x61, 0x41, 0xB6, 0xA9, 0xCE, 0xD4, 0x7C, 0xBB
  1216. };
  1217. static const unsigned char rsa_dq[] = {
  1218. 0x54, 0x09, 0x1F, 0x0F, 0x03, 0xD8, 0xB6, 0xC5,
  1219. 0x0C, 0xE8, 0xB9, 0x9E, 0x0C, 0x38, 0x96, 0x43,
  1220. 0xD4, 0xA6, 0xC5, 0x47, 0xDB, 0x20, 0x0E, 0xE5,
  1221. 0xBD, 0x29, 0xD4, 0x7B, 0x1A, 0xF8, 0x41, 0x57,
  1222. 0x49, 0x69, 0x9A, 0x82, 0xCC, 0x79, 0x4A, 0x43,
  1223. 0xEB, 0x4D, 0x8B, 0x2D, 0xF2, 0x43, 0xD5, 0xA5,
  1224. 0xBE, 0x44, 0xFD, 0x36, 0xAC, 0x8C, 0x9B, 0x02,
  1225. 0xF7, 0x9A, 0x03, 0xE8, 0x19, 0xA6, 0x61, 0xAE,
  1226. 0x76, 0x10, 0x93, 0x77, 0x41, 0x04, 0xAB, 0x4C,
  1227. 0xED, 0x6A, 0xCC, 0x14, 0x1B, 0x99, 0x8D, 0x0C,
  1228. 0x6A, 0x37, 0x3B, 0x86, 0x6C, 0x51, 0x37, 0x5B,
  1229. 0x1D, 0x79, 0xF2, 0xA3, 0x43, 0x10, 0xC6, 0xA7,
  1230. 0x21, 0x79, 0x6D, 0xF9, 0xE9, 0x04, 0x6A, 0xE8,
  1231. 0x32, 0xFF, 0xAE, 0xFD, 0x1C, 0x7B, 0x8C, 0x29,
  1232. 0x13, 0xA3, 0x0C, 0xB2, 0xAD, 0xEC, 0x6C, 0x0F,
  1233. 0x8D, 0x27, 0x12, 0x7B, 0x48, 0xB2, 0xDB, 0x31
  1234. };
  1235. static const unsigned char rsa_qInv[] = {
  1236. 0x8D, 0x1B, 0x05, 0xCA, 0x24, 0x1F, 0x0C, 0x53,
  1237. 0x19, 0x52, 0x74, 0x63, 0x21, 0xFA, 0x78, 0x46,
  1238. 0x79, 0xAF, 0x5C, 0xDE, 0x30, 0xA4, 0x6C, 0x20,
  1239. 0x38, 0xE6, 0x97, 0x39, 0xB8, 0x7A, 0x70, 0x0D,
  1240. 0x8B, 0x6C, 0x6D, 0x13, 0x74, 0xD5, 0x1C, 0xDE,
  1241. 0xA9, 0xF4, 0x60, 0x37, 0xFE, 0x68, 0x77, 0x5E,
  1242. 0x0B, 0x4E, 0x5E, 0x03, 0x31, 0x30, 0xDF, 0xD6,
  1243. 0xAE, 0x85, 0xD0, 0x81, 0xBB, 0x61, 0xC7, 0xB1,
  1244. 0x04, 0x5A, 0xC4, 0x6D, 0x56, 0x1C, 0xD9, 0x64,
  1245. 0xE7, 0x85, 0x7F, 0x88, 0x91, 0xC9, 0x60, 0x28,
  1246. 0x05, 0xE2, 0xC6, 0x24, 0x8F, 0xDD, 0x61, 0x64,
  1247. 0xD8, 0x09, 0xDE, 0x7E, 0xD3, 0x4A, 0x61, 0x1A,
  1248. 0xD3, 0x73, 0x58, 0x4B, 0xD8, 0xA0, 0x54, 0x25,
  1249. 0x48, 0x83, 0x6F, 0x82, 0x6C, 0xAF, 0x36, 0x51,
  1250. 0x2A, 0x5D, 0x14, 0x2F, 0x41, 0x25, 0x00, 0xDD,
  1251. 0xF8, 0xF3, 0x95, 0xFE, 0x31, 0x25, 0x50, 0x12
  1252. };
  1253. static const ST_KAT_PARAM rsa_crt_key[] = {
  1254. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_RSA_N, rsa_n),
  1255. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_RSA_E, rsa_e),
  1256. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_RSA_D, rsa_d),
  1257. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_RSA_FACTOR1, rsa_p),
  1258. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_RSA_FACTOR2, rsa_q),
  1259. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_RSA_EXPONENT1, rsa_dp),
  1260. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_RSA_EXPONENT2, rsa_dq),
  1261. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_RSA_COEFFICIENT1, rsa_qInv),
  1262. ST_KAT_PARAM_END()
  1263. };
  1264. static const ST_KAT_PARAM rsa_pub_key[] = {
  1265. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_RSA_N, rsa_n),
  1266. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_RSA_E, rsa_e),
  1267. ST_KAT_PARAM_END()
  1268. };
  1269. static const ST_KAT_PARAM rsa_priv_key[] = {
  1270. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_RSA_N, rsa_n),
  1271. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_RSA_E, rsa_e),
  1272. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_RSA_D, rsa_d),
  1273. ST_KAT_PARAM_END()
  1274. };
  1275. /*-
  1276. * Using OSSL_PKEY_RSA_PAD_MODE_NONE directly in the expansion of the
  1277. * ST_KAT_PARAM_UTF8STRING macro below causes a failure on ancient
  1278. * HP/UX PA-RISC compilers.
  1279. */
  1280. static const char pad_mode_none[] = OSSL_PKEY_RSA_PAD_MODE_NONE;
  1281. static const ST_KAT_PARAM rsa_enc_params[] = {
  1282. ST_KAT_PARAM_UTF8STRING(OSSL_ASYM_CIPHER_PARAM_PAD_MODE, pad_mode_none),
  1283. ST_KAT_PARAM_END()
  1284. };
  1285. static const unsigned char rsa_expected_sig[256] = {
  1286. 0xad, 0xbe, 0x2a, 0xaf, 0x16, 0x85, 0xc5, 0x00,
  1287. 0x91, 0x3e, 0xd0, 0x49, 0xfb, 0x3a, 0x81, 0xb9,
  1288. 0x6c, 0x28, 0xbc, 0xbf, 0xea, 0x96, 0x5f, 0xe4,
  1289. 0x9f, 0x99, 0xf7, 0x18, 0x8c, 0xec, 0x60, 0x28,
  1290. 0xeb, 0x29, 0x02, 0x49, 0xfc, 0xda, 0xd7, 0x78,
  1291. 0x68, 0xf8, 0xe1, 0xe9, 0x4d, 0x20, 0x6d, 0x32,
  1292. 0xa6, 0xde, 0xfc, 0xe4, 0xda, 0xcc, 0x6c, 0x75,
  1293. 0x36, 0x6b, 0xff, 0x5a, 0xac, 0x01, 0xa8, 0xc2,
  1294. 0xa9, 0xe6, 0x8b, 0x18, 0x3e, 0xec, 0xea, 0x4c,
  1295. 0x4a, 0x9e, 0x00, 0x09, 0xd1, 0x8a, 0x69, 0x1b,
  1296. 0x8b, 0xd9, 0xad, 0x37, 0xe5, 0x7c, 0xff, 0x7d,
  1297. 0x59, 0x56, 0x3e, 0xa0, 0xc6, 0x32, 0xd8, 0x35,
  1298. 0x2f, 0xff, 0xfb, 0x05, 0x02, 0xcd, 0xd7, 0x19,
  1299. 0xb9, 0x00, 0x86, 0x2a, 0xcf, 0xaa, 0x78, 0x16,
  1300. 0x4b, 0xf1, 0xa7, 0x59, 0xef, 0x7d, 0xe8, 0x74,
  1301. 0x23, 0x5c, 0xb2, 0xd4, 0x8a, 0x99, 0xa5, 0xbc,
  1302. 0xfa, 0x63, 0xd8, 0xf7, 0xbd, 0xc6, 0x00, 0x13,
  1303. 0x06, 0x02, 0x9a, 0xd4, 0xa7, 0xb4, 0x3d, 0x61,
  1304. 0xab, 0xf1, 0xc2, 0x95, 0x59, 0x9b, 0x3d, 0x67,
  1305. 0x1f, 0xde, 0x57, 0xb6, 0xb6, 0x9f, 0xb0, 0x87,
  1306. 0xd6, 0x51, 0xd5, 0x3e, 0x00, 0xe2, 0xc9, 0xa0,
  1307. 0x03, 0x66, 0xbc, 0x01, 0xb3, 0x8e, 0xfa, 0xf1,
  1308. 0x15, 0xeb, 0x26, 0xf1, 0x5d, 0x81, 0x90, 0xb4,
  1309. 0x1c, 0x00, 0x7c, 0x83, 0x4a, 0xa5, 0xde, 0x64,
  1310. 0xae, 0xea, 0x6c, 0x43, 0xc3, 0x20, 0x77, 0x77,
  1311. 0x42, 0x12, 0x24, 0xf5, 0xe3, 0x70, 0xdd, 0x59,
  1312. 0x48, 0x9c, 0xef, 0xd4, 0x8a, 0x3c, 0x29, 0x6a,
  1313. 0x0c, 0x9c, 0xf2, 0x13, 0xa4, 0x1c, 0x2f, 0x49,
  1314. 0xcd, 0xb4, 0xaa, 0x28, 0x40, 0x34, 0xc6, 0x75,
  1315. 0xba, 0x30, 0xe6, 0xd8, 0x5b, 0x2f, 0x08, 0xd0,
  1316. 0x29, 0xa5, 0x39, 0xfb, 0x6e, 0x3b, 0x0f, 0x52,
  1317. 0x2c, 0x68, 0xf0, 0x37, 0xa9, 0xd2, 0x56, 0xd6
  1318. };
  1319. static const unsigned char rsa_asym_plaintext_encrypt[256] = {
  1320. 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
  1321. 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
  1322. };
  1323. static const unsigned char rsa_asym_expected_encrypt[256] = {
  1324. 0x54, 0xac, 0x23, 0x96, 0x1d, 0x82, 0x5d, 0x8b,
  1325. 0x8f, 0x36, 0x33, 0xd0, 0xf4, 0x02, 0xa2, 0x61,
  1326. 0xb1, 0x13, 0xd4, 0x4a, 0x46, 0x06, 0x37, 0x3c,
  1327. 0xbf, 0x40, 0x05, 0x3c, 0xc6, 0x3b, 0x64, 0xdc,
  1328. 0x22, 0x22, 0xaf, 0x36, 0x79, 0x62, 0x45, 0xf0,
  1329. 0x97, 0x82, 0x22, 0x44, 0x86, 0x4a, 0x7c, 0xfa,
  1330. 0xac, 0x03, 0x21, 0x84, 0x3f, 0x31, 0xad, 0x2a,
  1331. 0xa4, 0x6e, 0x7a, 0xc5, 0x93, 0xf3, 0x0f, 0xfc,
  1332. 0xf1, 0x62, 0xce, 0x82, 0x12, 0x45, 0xc9, 0x35,
  1333. 0xb0, 0x7a, 0xcd, 0x99, 0x8c, 0x91, 0x6b, 0x5a,
  1334. 0xd3, 0x46, 0xdb, 0xf9, 0x9e, 0x52, 0x49, 0xbd,
  1335. 0x1e, 0xe8, 0xda, 0xac, 0x61, 0x47, 0xc2, 0xda,
  1336. 0xfc, 0x1e, 0xfb, 0x74, 0xd7, 0xd6, 0xc1, 0x18,
  1337. 0x86, 0x3e, 0x20, 0x9c, 0x7a, 0xe1, 0x04, 0xb7,
  1338. 0x38, 0x43, 0xb1, 0x4e, 0xa0, 0xd8, 0xc1, 0x39,
  1339. 0x4d, 0xe1, 0xd3, 0xb0, 0xb3, 0xf1, 0x82, 0x87,
  1340. 0x1f, 0x74, 0xb5, 0x69, 0xfd, 0x33, 0xd6, 0x21,
  1341. 0x7c, 0x61, 0x60, 0x28, 0xca, 0x70, 0xdb, 0xa0,
  1342. 0xbb, 0xc8, 0x73, 0xa9, 0x82, 0xf8, 0x6b, 0xd8,
  1343. 0xf0, 0xc9, 0x7b, 0x20, 0xdf, 0x9d, 0xfb, 0x8c,
  1344. 0xd4, 0xa2, 0x89, 0xe1, 0x9b, 0x04, 0xad, 0xaa,
  1345. 0x11, 0x6c, 0x8f, 0xce, 0x83, 0x29, 0x56, 0x69,
  1346. 0xbb, 0x00, 0x3b, 0xef, 0xca, 0x2d, 0xcd, 0x52,
  1347. 0xc8, 0xf1, 0xb3, 0x9b, 0xb4, 0x4f, 0x6d, 0x9c,
  1348. 0x3d, 0x69, 0xcc, 0x6d, 0x1f, 0x38, 0x4d, 0xe6,
  1349. 0xbb, 0x0c, 0x87, 0xdc, 0x5f, 0xa9, 0x24, 0x93,
  1350. 0x03, 0x46, 0xa2, 0x33, 0x6c, 0xf4, 0xd8, 0x5d,
  1351. 0x68, 0xf3, 0xd3, 0xe0, 0xf2, 0x30, 0xdb, 0xf5,
  1352. 0x4f, 0x0f, 0xad, 0xc7, 0xd0, 0xaa, 0x47, 0xd9,
  1353. 0x9f, 0x85, 0x1b, 0x2e, 0x6c, 0x3c, 0x57, 0x04,
  1354. 0x29, 0xf4, 0xf5, 0x66, 0x7d, 0x93, 0x4a, 0xaa,
  1355. 0x05, 0x52, 0x55, 0xc1, 0xc6, 0x06, 0x90, 0xab,
  1356. };
  1357. #ifndef OPENSSL_NO_EC
  1358. /* ECDSA key data */
  1359. static const char ecd_prime_curve_name[] = "secp224r1";
  1360. static const unsigned char ecd_prime_priv[] = {
  1361. 0x98, 0x1f, 0xb5, 0xf1, 0xfc, 0x87, 0x1d, 0x7d,
  1362. 0xde, 0x1e, 0x01, 0x64, 0x09, 0x9b, 0xe7, 0x1b,
  1363. 0x9f, 0xad, 0x63, 0xdd, 0x33, 0x01, 0xd1, 0x50,
  1364. 0x80, 0x93, 0x50, 0x30
  1365. };
  1366. static const unsigned char ecd_prime_pub[] = {
  1367. 0x04, 0x95, 0x47, 0x99, 0x44, 0x29, 0x8f, 0x51,
  1368. 0x39, 0xe2, 0x53, 0xec, 0x79, 0xb0, 0x4d, 0xde,
  1369. 0x87, 0x1a, 0x76, 0x54, 0xd5, 0x96, 0xb8, 0x7a,
  1370. 0x6d, 0xf4, 0x1c, 0x2c, 0x87, 0x91, 0x5f, 0xd5,
  1371. 0x31, 0xdd, 0x24, 0xe5, 0x78, 0xd9, 0x08, 0x24,
  1372. 0x8a, 0x49, 0x99, 0xec, 0x55, 0xf2, 0x82, 0xb3,
  1373. 0xc4, 0xb7, 0x33, 0x68, 0xe4, 0x24, 0xa9, 0x12,
  1374. 0x82
  1375. };
  1376. static const unsigned char ecdsa_prime_expected_sig[] = {
  1377. 0x30, 0x3d, 0x02, 0x1c, 0x48, 0x4f, 0x3c, 0x97,
  1378. 0x5b, 0xfa, 0x40, 0x6c, 0xdb, 0xd6, 0x70, 0xb5,
  1379. 0xbd, 0x2d, 0xd0, 0xc6, 0x22, 0x93, 0x5a, 0x88,
  1380. 0x56, 0xd0, 0xaf, 0x0a, 0x94, 0x92, 0x20, 0x01,
  1381. 0x02, 0x1d, 0x00, 0xa4, 0x80, 0xe0, 0x47, 0x88,
  1382. 0x8a, 0xef, 0x2a, 0x47, 0x9d, 0x81, 0x9a, 0xbf,
  1383. 0x45, 0xc3, 0x6f, 0x9e, 0x2e, 0xc1, 0x44, 0x9f,
  1384. 0xfd, 0x79, 0xdb, 0x90, 0x3e, 0xb9, 0xb2
  1385. };
  1386. static const ST_KAT_PARAM ecdsa_prime_key[] = {
  1387. ST_KAT_PARAM_UTF8STRING(OSSL_PKEY_PARAM_GROUP_NAME, ecd_prime_curve_name),
  1388. ST_KAT_PARAM_OCTET(OSSL_PKEY_PARAM_PUB_KEY, ecd_prime_pub),
  1389. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_PRIV_KEY, ecd_prime_priv),
  1390. ST_KAT_PARAM_END()
  1391. };
  1392. # ifndef OPENSSL_NO_EC2M
  1393. static const char ecd_bin_curve_name[] = "sect233r1";
  1394. static const unsigned char ecd_bin_priv[] = {
  1395. 0x00, 0x6d, 0xd6, 0x39, 0x9d, 0x2a, 0xa2, 0xc8,
  1396. 0x8c, 0xfc, 0x7b, 0x80, 0x66, 0xaa, 0xe1, 0xaa,
  1397. 0xba, 0xee, 0xcb, 0xfd, 0xc9, 0xe5, 0x36, 0x38,
  1398. 0x2e, 0xf7, 0x37, 0x6d, 0xd3, 0x20
  1399. };
  1400. static const unsigned char ecd_bin_pub[] = {
  1401. 0x04, 0x00, 0x06, 0xe2, 0x56, 0xf7, 0x37, 0xf9,
  1402. 0xea, 0xb6, 0xd1, 0x0f, 0x59, 0xfa, 0x23, 0xc3,
  1403. 0x93, 0xa8, 0xb2, 0x26, 0xe2, 0x5c, 0x08, 0xbe,
  1404. 0x63, 0x49, 0x26, 0xdc, 0xc7, 0x1e, 0x6f, 0x01,
  1405. 0x32, 0x3b, 0xe6, 0x54, 0x8d, 0xc1, 0x13, 0x3e,
  1406. 0x54, 0xb2, 0x66, 0x89, 0xb2, 0x82, 0x0a, 0x72,
  1407. 0x02, 0xa8, 0xe9, 0x6f, 0x54, 0xfd, 0x3a, 0x6b,
  1408. 0x99, 0xb6, 0x8f, 0x80, 0x46
  1409. };
  1410. static const unsigned char ecdsa_bin_expected_sig[] = {
  1411. 0x30, 0x3f, 0x02, 0x1d, 0x58, 0xe9, 0xd0, 0x84,
  1412. 0x5c, 0xad, 0x29, 0x03, 0xf6, 0xa6, 0xbc, 0xe0,
  1413. 0x24, 0x6d, 0x9e, 0x79, 0x5d, 0x1e, 0xe8, 0x5a,
  1414. 0xc3, 0x31, 0x0a, 0xa9, 0xfb, 0xe3, 0x99, 0x54,
  1415. 0x11, 0x02, 0x1e, 0x00, 0xa3, 0x44, 0x28, 0xa3,
  1416. 0x70, 0x97, 0x98, 0x17, 0xd7, 0xa6, 0xad, 0x91,
  1417. 0xaf, 0x41, 0x69, 0xb6, 0x06, 0x99, 0x39, 0xc7,
  1418. 0x63, 0xa4, 0x6a, 0x81, 0xe4, 0x9a, 0x9d, 0x15,
  1419. 0x8b
  1420. };
  1421. static const ST_KAT_PARAM ecdsa_bin_key[] = {
  1422. ST_KAT_PARAM_UTF8STRING(OSSL_PKEY_PARAM_GROUP_NAME, ecd_bin_curve_name),
  1423. ST_KAT_PARAM_OCTET(OSSL_PKEY_PARAM_PUB_KEY, ecd_bin_pub),
  1424. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_PRIV_KEY, ecd_bin_priv),
  1425. ST_KAT_PARAM_END()
  1426. };
  1427. # endif /* OPENSSL_NO_EC2M */
  1428. #endif /* OPENSSL_NO_EC */
  1429. #ifndef OPENSSL_NO_DSA
  1430. /* dsa 2048 */
  1431. static const unsigned char dsa_p[] = {
  1432. 0xa2, 0x9b, 0x88, 0x72, 0xce, 0x8b, 0x84, 0x23,
  1433. 0xb7, 0xd5, 0xd2, 0x1d, 0x4b, 0x02, 0xf5, 0x7e,
  1434. 0x03, 0xe9, 0xe6, 0xb8, 0xa2, 0x58, 0xdc, 0x16,
  1435. 0x61, 0x1b, 0xa0, 0x98, 0xab, 0x54, 0x34, 0x15,
  1436. 0xe4, 0x15, 0xf1, 0x56, 0x99, 0x7a, 0x3e, 0xe2,
  1437. 0x36, 0x65, 0x8f, 0xa0, 0x93, 0x26, 0x0d, 0xe3,
  1438. 0xad, 0x42, 0x2e, 0x05, 0xe0, 0x46, 0xf9, 0xec,
  1439. 0x29, 0x16, 0x1a, 0x37, 0x5f, 0x0e, 0xb4, 0xef,
  1440. 0xfc, 0xef, 0x58, 0x28, 0x5c, 0x5d, 0x39, 0xed,
  1441. 0x42, 0x5d, 0x7a, 0x62, 0xca, 0x12, 0x89, 0x6c,
  1442. 0x4a, 0x92, 0xcb, 0x19, 0x46, 0xf2, 0x95, 0x2a,
  1443. 0x48, 0x13, 0x3f, 0x07, 0xda, 0x36, 0x4d, 0x1b,
  1444. 0xdf, 0x6b, 0x0f, 0x71, 0x39, 0x98, 0x3e, 0x69,
  1445. 0x3c, 0x80, 0x05, 0x9b, 0x0e, 0xac, 0xd1, 0x47,
  1446. 0x9b, 0xa9, 0xf2, 0x85, 0x77, 0x54, 0xed, 0xe7,
  1447. 0x5f, 0x11, 0x2b, 0x07, 0xeb, 0xbf, 0x35, 0x34,
  1448. 0x8b, 0xbf, 0x3e, 0x01, 0xe0, 0x2f, 0x2d, 0x47,
  1449. 0x3d, 0xe3, 0x94, 0x53, 0xf9, 0x9d, 0xd2, 0x36,
  1450. 0x75, 0x41, 0xca, 0xca, 0x3b, 0xa0, 0x11, 0x66,
  1451. 0x34, 0x3d, 0x7b, 0x5b, 0x58, 0xa3, 0x7b, 0xd1,
  1452. 0xb7, 0x52, 0x1d, 0xb2, 0xf1, 0x3b, 0x86, 0x70,
  1453. 0x71, 0x32, 0xfe, 0x09, 0xf4, 0xcd, 0x09, 0xdc,
  1454. 0x16, 0x18, 0xfa, 0x34, 0x01, 0xeb, 0xf9, 0xcc,
  1455. 0x7b, 0x19, 0xfa, 0x94, 0xaa, 0x47, 0x20, 0x88,
  1456. 0x13, 0x3d, 0x6c, 0xb2, 0xd3, 0x5c, 0x11, 0x79,
  1457. 0xc8, 0xc8, 0xff, 0x36, 0x87, 0x58, 0xd5, 0x07,
  1458. 0xd9, 0xf9, 0xa1, 0x7d, 0x46, 0xc1, 0x10, 0xfe,
  1459. 0x31, 0x44, 0xce, 0x9b, 0x02, 0x2b, 0x42, 0xe4,
  1460. 0x19, 0xeb, 0x4f, 0x53, 0x88, 0x61, 0x3b, 0xfc,
  1461. 0x3e, 0x26, 0x24, 0x1a, 0x43, 0x2e, 0x87, 0x06,
  1462. 0xbc, 0x58, 0xef, 0x76, 0x11, 0x72, 0x78, 0xde,
  1463. 0xab, 0x6c, 0xf6, 0x92, 0x61, 0x82, 0x91, 0xb7
  1464. };
  1465. static const unsigned char dsa_q[] = {
  1466. 0xa3, 0xbf, 0xd9, 0xab, 0x78, 0x84, 0x79, 0x4e,
  1467. 0x38, 0x34, 0x50, 0xd5, 0x89, 0x1d, 0xc1, 0x8b,
  1468. 0x65, 0x15, 0x7b, 0xdc, 0xfc, 0xda, 0xc5, 0x15,
  1469. 0x18, 0x90, 0x28, 0x67
  1470. };
  1471. static const unsigned char dsa_g[] = {
  1472. 0x68, 0x19, 0x27, 0x88, 0x69, 0xc7, 0xfd, 0x3d,
  1473. 0x2d, 0x7b, 0x77, 0xf7, 0x7e, 0x81, 0x50, 0xd9,
  1474. 0xad, 0x43, 0x3b, 0xea, 0x3b, 0xa8, 0x5e, 0xfc,
  1475. 0x80, 0x41, 0x5a, 0xa3, 0x54, 0x5f, 0x78, 0xf7,
  1476. 0x22, 0x96, 0xf0, 0x6c, 0xb1, 0x9c, 0xed, 0xa0,
  1477. 0x6c, 0x94, 0xb0, 0x55, 0x1c, 0xfe, 0x6e, 0x6f,
  1478. 0x86, 0x3e, 0x31, 0xd1, 0xde, 0x6e, 0xed, 0x7d,
  1479. 0xab, 0x8b, 0x0c, 0x9d, 0xf2, 0x31, 0xe0, 0x84,
  1480. 0x34, 0xd1, 0x18, 0x4f, 0x91, 0xd0, 0x33, 0x69,
  1481. 0x6b, 0xb3, 0x82, 0xf8, 0x45, 0x5e, 0x98, 0x88,
  1482. 0xf5, 0xd3, 0x1d, 0x47, 0x84, 0xec, 0x40, 0x12,
  1483. 0x02, 0x46, 0xf4, 0xbe, 0xa6, 0x17, 0x94, 0xbb,
  1484. 0xa5, 0x86, 0x6f, 0x09, 0x74, 0x64, 0x63, 0xbd,
  1485. 0xf8, 0xe9, 0xe1, 0x08, 0xcd, 0x95, 0x29, 0xc3,
  1486. 0xd0, 0xf6, 0xdf, 0x80, 0x31, 0x6e, 0x2e, 0x70,
  1487. 0xaa, 0xeb, 0x1b, 0x26, 0xcd, 0xb8, 0xad, 0x97,
  1488. 0xbc, 0x3d, 0x28, 0x7e, 0x0b, 0x8d, 0x61, 0x6c,
  1489. 0x42, 0xe6, 0x5b, 0x87, 0xdb, 0x20, 0xde, 0xb7,
  1490. 0x00, 0x5b, 0xc4, 0x16, 0x74, 0x7a, 0x64, 0x70,
  1491. 0x14, 0x7a, 0x68, 0xa7, 0x82, 0x03, 0x88, 0xeb,
  1492. 0xf4, 0x4d, 0x52, 0xe0, 0x62, 0x8a, 0xf9, 0xcf,
  1493. 0x1b, 0x71, 0x66, 0xd0, 0x34, 0x65, 0xf3, 0x5a,
  1494. 0xcc, 0x31, 0xb6, 0x11, 0x0c, 0x43, 0xda, 0xbc,
  1495. 0x7c, 0x5d, 0x59, 0x1e, 0x67, 0x1e, 0xaf, 0x7c,
  1496. 0x25, 0x2c, 0x1c, 0x14, 0x53, 0x36, 0xa1, 0xa4,
  1497. 0xdd, 0xf1, 0x32, 0x44, 0xd5, 0x5e, 0x83, 0x56,
  1498. 0x80, 0xca, 0xb2, 0x53, 0x3b, 0x82, 0xdf, 0x2e,
  1499. 0xfe, 0x55, 0xec, 0x18, 0xc1, 0xe6, 0xcd, 0x00,
  1500. 0x7b, 0xb0, 0x89, 0x75, 0x8b, 0xb1, 0x7c, 0x2c,
  1501. 0xbe, 0x14, 0x44, 0x1b, 0xd0, 0x93, 0xae, 0x66,
  1502. 0xe5, 0x97, 0x6d, 0x53, 0x73, 0x3f, 0x4f, 0xa3,
  1503. 0x26, 0x97, 0x01, 0xd3, 0x1d, 0x23, 0xd4, 0x67
  1504. };
  1505. static const unsigned char dsa_pub[] = {
  1506. 0xa0, 0x12, 0xb3, 0xb1, 0x70, 0xb3, 0x07, 0x22,
  1507. 0x79, 0x57, 0xb7, 0xca, 0x20, 0x61, 0xa8, 0x16,
  1508. 0xac, 0x7a, 0x2b, 0x3d, 0x9a, 0xe9, 0x95, 0xa5,
  1509. 0x11, 0x9c, 0x38, 0x5b, 0x60, 0x3b, 0xf6, 0xf6,
  1510. 0xc5, 0xde, 0x4d, 0xc5, 0xec, 0xb5, 0xdf, 0xa4,
  1511. 0xa4, 0x1c, 0x68, 0x66, 0x2e, 0xb2, 0x5b, 0x63,
  1512. 0x8b, 0x7e, 0x26, 0x20, 0xba, 0x89, 0x8d, 0x07,
  1513. 0xda, 0x6c, 0x49, 0x91, 0xe7, 0x6c, 0xc0, 0xec,
  1514. 0xd1, 0xad, 0x34, 0x21, 0x07, 0x70, 0x67, 0xe4,
  1515. 0x7c, 0x18, 0xf5, 0x8a, 0x92, 0xa7, 0x2a, 0xd4,
  1516. 0x31, 0x99, 0xec, 0xb7, 0xbd, 0x84, 0xe7, 0xd3,
  1517. 0xaf, 0xb9, 0x01, 0x9f, 0x0e, 0x9d, 0xd0, 0xfb,
  1518. 0xaa, 0x48, 0x73, 0x00, 0xb1, 0x30, 0x81, 0xe3,
  1519. 0x3c, 0x90, 0x28, 0x76, 0x43, 0x6f, 0x7b, 0x03,
  1520. 0xc3, 0x45, 0x52, 0x84, 0x81, 0xd3, 0x62, 0x81,
  1521. 0x5e, 0x24, 0xfe, 0x59, 0xda, 0xc5, 0xac, 0x34,
  1522. 0x66, 0x0d, 0x4c, 0x8a, 0x76, 0xcb, 0x99, 0xa7,
  1523. 0xc7, 0xde, 0x93, 0xeb, 0x95, 0x6c, 0xd6, 0xbc,
  1524. 0x88, 0xe5, 0x8d, 0x90, 0x10, 0x34, 0x94, 0x4a,
  1525. 0x09, 0x4b, 0x01, 0x80, 0x3a, 0x43, 0xc6, 0x72,
  1526. 0xb9, 0x68, 0x8c, 0x0e, 0x01, 0xd8, 0xf4, 0xfc,
  1527. 0x91, 0xc6, 0x2a, 0x3f, 0x88, 0x02, 0x1f, 0x7b,
  1528. 0xd6, 0xa6, 0x51, 0xb1, 0xa8, 0x8f, 0x43, 0xaa,
  1529. 0x4e, 0xf2, 0x76, 0x53, 0xd1, 0x2b, 0xf8, 0xb7,
  1530. 0x09, 0x9f, 0xdf, 0x6b, 0x46, 0x10, 0x82, 0xf8,
  1531. 0xe9, 0x39, 0x10, 0x7b, 0xfd, 0x2f, 0x72, 0x10,
  1532. 0x08, 0x7d, 0x32, 0x6c, 0x37, 0x52, 0x00, 0xf1,
  1533. 0xf5, 0x1e, 0x7e, 0x74, 0xa3, 0x41, 0x31, 0x90,
  1534. 0x1b, 0xcd, 0x08, 0x63, 0x52, 0x1f, 0xf8, 0xd6,
  1535. 0x76, 0xc4, 0x85, 0x81, 0x86, 0x87, 0x36, 0xc5,
  1536. 0xe5, 0x1b, 0x16, 0xa4, 0xe3, 0x92, 0x15, 0xea,
  1537. 0x0b, 0x17, 0xc4, 0x73, 0x59, 0x74, 0xc5, 0x16
  1538. };
  1539. static const unsigned char dsa_priv[] = {
  1540. 0x6c, 0xca, 0xee, 0xf6, 0xd7, 0x3b, 0x4e, 0x80,
  1541. 0xf1, 0x1c, 0x17, 0xb8, 0xe9, 0x62, 0x7c, 0x03,
  1542. 0x66, 0x35, 0xba, 0xc3, 0x94, 0x23, 0x50, 0x5e,
  1543. 0x40, 0x7e, 0x5c, 0xb7
  1544. };
  1545. static const unsigned char dsa_expected_sig[] = {
  1546. 0x30, 0x3c, 0x02, 0x1c, 0x69, 0xc6, 0xd6, 0x9e,
  1547. 0x2b, 0x91, 0xea, 0x72, 0xb3, 0x8b, 0x7c, 0x57,
  1548. 0x48, 0x75, 0xb7, 0x65, 0xc0, 0xb4, 0xf7, 0xbb,
  1549. 0x08, 0xa4, 0x95, 0x77, 0xfc, 0xa7, 0xed, 0x31,
  1550. 0x02, 0x1c, 0x4c, 0x2c, 0xff, 0xc6, 0x55, 0xeb,
  1551. 0x8f, 0xa7, 0x4f, 0x27, 0xd8, 0xec, 0xfd, 0x62,
  1552. 0x73, 0xf2, 0xd1, 0x55, 0xa5, 0xf0, 0x41, 0x68,
  1553. 0x34, 0x8d, 0x9e, 0x88, 0x08, 0x06
  1554. };
  1555. static const ST_KAT_PARAM dsa_key[] = {
  1556. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_FFC_P, dsa_p),
  1557. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_FFC_Q, dsa_q),
  1558. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_FFC_G, dsa_g),
  1559. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_PUB_KEY, dsa_pub),
  1560. ST_KAT_PARAM_BIGNUM(OSSL_PKEY_PARAM_PRIV_KEY, dsa_priv),
  1561. ST_KAT_PARAM_END()
  1562. };
  1563. #endif /* OPENSSL_NO_DSA */
  1564. /* Hash DRBG inputs for signature KATs */
  1565. static const unsigned char sig_kat_entropyin[] = {
  1566. 0x06, 0x6d, 0xc8, 0xce, 0x75, 0xb2, 0x89, 0x66, 0xa6, 0x85, 0x16, 0x3f,
  1567. 0xe2, 0xa4, 0xd4, 0x27, 0xfb, 0xdb, 0x61, 0x66, 0x50, 0x61, 0x6b, 0xa2,
  1568. 0x82, 0xfc, 0x33, 0x2b, 0x4e, 0x6f, 0x12, 0x20
  1569. };
  1570. static const unsigned char sig_kat_nonce[] = {
  1571. 0x55, 0x9f, 0x7c, 0x64, 0x89, 0x70, 0x83, 0xec, 0x2d, 0x73, 0x70, 0xd9,
  1572. 0xf0, 0xe5, 0x07, 0x1f
  1573. };
  1574. static const unsigned char sig_kat_persstr[] = {
  1575. 0x88, 0x6f, 0x54, 0x9a, 0xad, 0x1a, 0xc6, 0x3d, 0x18, 0xcb, 0xcc, 0x66,
  1576. 0x85, 0xda, 0xa2, 0xc2, 0xf7, 0x9e, 0xb0, 0x89, 0x4c, 0xb4, 0xae, 0xf1,
  1577. 0xac, 0x54, 0x4f, 0xce, 0x57, 0xf1, 0x5e, 0x11
  1578. };
  1579. static const ST_KAT_SIGN st_kat_sign_tests[] = {
  1580. {
  1581. OSSL_SELF_TEST_DESC_SIGN_RSA,
  1582. "RSA",
  1583. "SHA-256",
  1584. rsa_crt_key,
  1585. ITM(sig_kat_entropyin),
  1586. ITM(sig_kat_nonce),
  1587. ITM(sig_kat_persstr),
  1588. ITM(rsa_expected_sig)
  1589. },
  1590. #ifndef OPENSSL_NO_EC
  1591. {
  1592. OSSL_SELF_TEST_DESC_SIGN_ECDSA,
  1593. "EC",
  1594. "SHA-256",
  1595. ecdsa_prime_key,
  1596. ITM(sig_kat_entropyin),
  1597. ITM(sig_kat_nonce),
  1598. ITM(sig_kat_persstr),
  1599. ITM(ecdsa_prime_expected_sig)
  1600. },
  1601. # ifndef OPENSSL_NO_EC2M
  1602. {
  1603. OSSL_SELF_TEST_DESC_SIGN_ECDSA,
  1604. "EC",
  1605. "SHA-256",
  1606. ecdsa_bin_key,
  1607. ITM(sig_kat_entropyin),
  1608. ITM(sig_kat_nonce),
  1609. ITM(sig_kat_persstr),
  1610. ITM(ecdsa_bin_expected_sig)
  1611. },
  1612. # endif
  1613. #endif /* OPENSSL_NO_EC */
  1614. #ifndef OPENSSL_NO_DSA
  1615. {
  1616. OSSL_SELF_TEST_DESC_SIGN_DSA,
  1617. "DSA",
  1618. "SHA-256",
  1619. dsa_key,
  1620. ITM(sig_kat_entropyin),
  1621. ITM(sig_kat_nonce),
  1622. ITM(sig_kat_persstr),
  1623. ITM(dsa_expected_sig)
  1624. },
  1625. #endif /* OPENSSL_NO_DSA */
  1626. };
  1627. static const ST_KAT_ASYM_CIPHER st_kat_asym_cipher_tests[] = {
  1628. {
  1629. OSSL_SELF_TEST_DESC_ASYM_RSA_ENC,
  1630. "RSA",
  1631. 1,
  1632. rsa_pub_key,
  1633. rsa_enc_params,
  1634. ITM(rsa_asym_plaintext_encrypt),
  1635. ITM(rsa_asym_expected_encrypt),
  1636. },
  1637. {
  1638. OSSL_SELF_TEST_DESC_ASYM_RSA_DEC,
  1639. "RSA",
  1640. 0,
  1641. rsa_priv_key,
  1642. rsa_enc_params,
  1643. ITM(rsa_asym_expected_encrypt),
  1644. ITM(rsa_asym_plaintext_encrypt),
  1645. },
  1646. {
  1647. OSSL_SELF_TEST_DESC_ASYM_RSA_DEC,
  1648. "RSA",
  1649. 0,
  1650. rsa_crt_key,
  1651. rsa_enc_params,
  1652. ITM(rsa_asym_expected_encrypt),
  1653. ITM(rsa_asym_plaintext_encrypt),
  1654. },
  1655. };