self_test_data.inc 64 KB

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