pkcs5.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. /**
  2. * \file pkcs5.c
  3. *
  4. * \brief PKCS#5 functions
  5. *
  6. * \author Mathias Olsson <mathias@kompetensum.com>
  7. *
  8. * Copyright The Mbed TLS Contributors
  9. * SPDX-License-Identifier: Apache-2.0
  10. *
  11. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  12. * not use this file except in compliance with the License.
  13. * You may obtain a copy of the License at
  14. *
  15. * http://www.apache.org/licenses/LICENSE-2.0
  16. *
  17. * Unless required by applicable law or agreed to in writing, software
  18. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  19. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  20. * See the License for the specific language governing permissions and
  21. * limitations under the License.
  22. */
  23. /*
  24. * PKCS#5 includes PBKDF2 and more
  25. *
  26. * http://tools.ietf.org/html/rfc2898 (Specification)
  27. * http://tools.ietf.org/html/rfc6070 (Test vectors)
  28. */
  29. #include "common.h"
  30. #if defined(MBEDTLS_PKCS5_C)
  31. #include "mbedtls/pkcs5.h"
  32. #include "mbedtls/error.h"
  33. #if defined(MBEDTLS_ASN1_PARSE_C)
  34. #include "mbedtls/asn1.h"
  35. #include "mbedtls/cipher.h"
  36. #include "mbedtls/oid.h"
  37. #endif /* MBEDTLS_ASN1_PARSE_C */
  38. #include <string.h>
  39. #include "mbedtls/platform.h"
  40. #include "hash_info.h"
  41. #include "mbedtls/psa_util.h"
  42. #if !defined(MBEDTLS_MD_C)
  43. #define PSA_TO_MBEDTLS_ERR(status) PSA_TO_MBEDTLS_ERR_LIST(status, \
  44. psa_to_md_errors, \
  45. psa_generic_status_to_mbedtls)
  46. #endif
  47. #if defined(MBEDTLS_ASN1_PARSE_C)
  48. static int pkcs5_parse_pbkdf2_params(const mbedtls_asn1_buf *params,
  49. mbedtls_asn1_buf *salt, int *iterations,
  50. int *keylen, mbedtls_md_type_t *md_type)
  51. {
  52. int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
  53. mbedtls_asn1_buf prf_alg_oid;
  54. unsigned char *p = params->p;
  55. const unsigned char *end = params->p + params->len;
  56. if (params->tag != (MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE)) {
  57. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_PKCS5_INVALID_FORMAT,
  58. MBEDTLS_ERR_ASN1_UNEXPECTED_TAG);
  59. }
  60. /*
  61. * PBKDF2-params ::= SEQUENCE {
  62. * salt OCTET STRING,
  63. * iterationCount INTEGER,
  64. * keyLength INTEGER OPTIONAL
  65. * prf AlgorithmIdentifier DEFAULT algid-hmacWithSHA1
  66. * }
  67. *
  68. */
  69. if ((ret = mbedtls_asn1_get_tag(&p, end, &salt->len,
  70. MBEDTLS_ASN1_OCTET_STRING)) != 0) {
  71. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_PKCS5_INVALID_FORMAT, ret);
  72. }
  73. salt->p = p;
  74. p += salt->len;
  75. if ((ret = mbedtls_asn1_get_int(&p, end, iterations)) != 0) {
  76. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_PKCS5_INVALID_FORMAT, ret);
  77. }
  78. if (p == end) {
  79. return 0;
  80. }
  81. if ((ret = mbedtls_asn1_get_int(&p, end, keylen)) != 0) {
  82. if (ret != MBEDTLS_ERR_ASN1_UNEXPECTED_TAG) {
  83. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_PKCS5_INVALID_FORMAT, ret);
  84. }
  85. }
  86. if (p == end) {
  87. return 0;
  88. }
  89. if ((ret = mbedtls_asn1_get_alg_null(&p, end, &prf_alg_oid)) != 0) {
  90. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_PKCS5_INVALID_FORMAT, ret);
  91. }
  92. if (mbedtls_oid_get_md_hmac(&prf_alg_oid, md_type) != 0) {
  93. return MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE;
  94. }
  95. if (p != end) {
  96. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_PKCS5_INVALID_FORMAT,
  97. MBEDTLS_ERR_ASN1_LENGTH_MISMATCH);
  98. }
  99. return 0;
  100. }
  101. int mbedtls_pkcs5_pbes2(const mbedtls_asn1_buf *pbe_params, int mode,
  102. const unsigned char *pwd, size_t pwdlen,
  103. const unsigned char *data, size_t datalen,
  104. unsigned char *output)
  105. {
  106. int ret, iterations = 0, keylen = 0;
  107. unsigned char *p, *end;
  108. mbedtls_asn1_buf kdf_alg_oid, enc_scheme_oid, kdf_alg_params, enc_scheme_params;
  109. mbedtls_asn1_buf salt;
  110. mbedtls_md_type_t md_type = MBEDTLS_MD_SHA1;
  111. unsigned char key[32], iv[32];
  112. size_t olen = 0;
  113. const mbedtls_cipher_info_t *cipher_info;
  114. mbedtls_cipher_type_t cipher_alg;
  115. mbedtls_cipher_context_t cipher_ctx;
  116. p = pbe_params->p;
  117. end = p + pbe_params->len;
  118. /*
  119. * PBES2-params ::= SEQUENCE {
  120. * keyDerivationFunc AlgorithmIdentifier {{PBES2-KDFs}},
  121. * encryptionScheme AlgorithmIdentifier {{PBES2-Encs}}
  122. * }
  123. */
  124. if (pbe_params->tag != (MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE)) {
  125. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_PKCS5_INVALID_FORMAT,
  126. MBEDTLS_ERR_ASN1_UNEXPECTED_TAG);
  127. }
  128. if ((ret = mbedtls_asn1_get_alg(&p, end, &kdf_alg_oid,
  129. &kdf_alg_params)) != 0) {
  130. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_PKCS5_INVALID_FORMAT, ret);
  131. }
  132. // Only PBKDF2 supported at the moment
  133. //
  134. if (MBEDTLS_OID_CMP(MBEDTLS_OID_PKCS5_PBKDF2, &kdf_alg_oid) != 0) {
  135. return MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE;
  136. }
  137. if ((ret = pkcs5_parse_pbkdf2_params(&kdf_alg_params,
  138. &salt, &iterations, &keylen,
  139. &md_type)) != 0) {
  140. return ret;
  141. }
  142. if ((ret = mbedtls_asn1_get_alg(&p, end, &enc_scheme_oid,
  143. &enc_scheme_params)) != 0) {
  144. return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_PKCS5_INVALID_FORMAT, ret);
  145. }
  146. if (mbedtls_oid_get_cipher_alg(&enc_scheme_oid, &cipher_alg) != 0) {
  147. return MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE;
  148. }
  149. cipher_info = mbedtls_cipher_info_from_type(cipher_alg);
  150. if (cipher_info == NULL) {
  151. return MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE;
  152. }
  153. /*
  154. * The value of keylen from pkcs5_parse_pbkdf2_params() is ignored
  155. * since it is optional and we don't know if it was set or not
  156. */
  157. keylen = cipher_info->key_bitlen / 8;
  158. if (enc_scheme_params.tag != MBEDTLS_ASN1_OCTET_STRING ||
  159. enc_scheme_params.len != cipher_info->iv_size) {
  160. return MBEDTLS_ERR_PKCS5_INVALID_FORMAT;
  161. }
  162. mbedtls_cipher_init(&cipher_ctx);
  163. memcpy(iv, enc_scheme_params.p, enc_scheme_params.len);
  164. if ((ret = mbedtls_pkcs5_pbkdf2_hmac_ext(md_type, pwd, pwdlen, salt.p,
  165. salt.len, iterations, keylen,
  166. key)) != 0) {
  167. goto exit;
  168. }
  169. if ((ret = mbedtls_cipher_setup(&cipher_ctx, cipher_info)) != 0) {
  170. goto exit;
  171. }
  172. if ((ret = mbedtls_cipher_setkey(&cipher_ctx, key, 8 * keylen,
  173. (mbedtls_operation_t) mode)) != 0) {
  174. goto exit;
  175. }
  176. if ((ret = mbedtls_cipher_crypt(&cipher_ctx, iv, enc_scheme_params.len,
  177. data, datalen, output, &olen)) != 0) {
  178. ret = MBEDTLS_ERR_PKCS5_PASSWORD_MISMATCH;
  179. }
  180. exit:
  181. mbedtls_cipher_free(&cipher_ctx);
  182. return ret;
  183. }
  184. #endif /* MBEDTLS_ASN1_PARSE_C */
  185. #if defined(MBEDTLS_MD_C)
  186. static int pkcs5_pbkdf2_hmac(mbedtls_md_context_t *ctx,
  187. const unsigned char *password,
  188. size_t plen, const unsigned char *salt, size_t slen,
  189. unsigned int iteration_count,
  190. uint32_t key_length, unsigned char *output)
  191. {
  192. int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
  193. unsigned int i;
  194. unsigned char md1[MBEDTLS_MD_MAX_SIZE];
  195. unsigned char work[MBEDTLS_MD_MAX_SIZE];
  196. unsigned char md_size = mbedtls_md_get_size(ctx->md_info);
  197. size_t use_len;
  198. unsigned char *out_p = output;
  199. unsigned char counter[4];
  200. memset(counter, 0, 4);
  201. counter[3] = 1;
  202. #if UINT_MAX > 0xFFFFFFFF
  203. if (iteration_count > 0xFFFFFFFF) {
  204. return MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA;
  205. }
  206. #endif
  207. if ((ret = mbedtls_md_hmac_starts(ctx, password, plen)) != 0) {
  208. return ret;
  209. }
  210. while (key_length) {
  211. // U1 ends up in work
  212. //
  213. if ((ret = mbedtls_md_hmac_update(ctx, salt, slen)) != 0) {
  214. goto cleanup;
  215. }
  216. if ((ret = mbedtls_md_hmac_update(ctx, counter, 4)) != 0) {
  217. goto cleanup;
  218. }
  219. if ((ret = mbedtls_md_hmac_finish(ctx, work)) != 0) {
  220. goto cleanup;
  221. }
  222. if ((ret = mbedtls_md_hmac_reset(ctx)) != 0) {
  223. goto cleanup;
  224. }
  225. memcpy(md1, work, md_size);
  226. for (i = 1; i < iteration_count; i++) {
  227. // U2 ends up in md1
  228. //
  229. if ((ret = mbedtls_md_hmac_update(ctx, md1, md_size)) != 0) {
  230. goto cleanup;
  231. }
  232. if ((ret = mbedtls_md_hmac_finish(ctx, md1)) != 0) {
  233. goto cleanup;
  234. }
  235. if ((ret = mbedtls_md_hmac_reset(ctx)) != 0) {
  236. goto cleanup;
  237. }
  238. // U1 xor U2
  239. //
  240. mbedtls_xor(work, work, md1, md_size);
  241. }
  242. use_len = (key_length < md_size) ? key_length : md_size;
  243. memcpy(out_p, work, use_len);
  244. key_length -= (uint32_t) use_len;
  245. out_p += use_len;
  246. for (i = 4; i > 0; i--) {
  247. if (++counter[i - 1] != 0) {
  248. break;
  249. }
  250. }
  251. }
  252. cleanup:
  253. /* Zeroise buffers to clear sensitive data from memory. */
  254. mbedtls_platform_zeroize(work, MBEDTLS_MD_MAX_SIZE);
  255. mbedtls_platform_zeroize(md1, MBEDTLS_MD_MAX_SIZE);
  256. return ret;
  257. }
  258. #if !defined(MBEDTLS_DEPRECATED_REMOVED)
  259. int mbedtls_pkcs5_pbkdf2_hmac(mbedtls_md_context_t *ctx,
  260. const unsigned char *password,
  261. size_t plen, const unsigned char *salt, size_t slen,
  262. unsigned int iteration_count,
  263. uint32_t key_length, unsigned char *output)
  264. {
  265. return pkcs5_pbkdf2_hmac(ctx, password, plen, salt, slen, iteration_count,
  266. key_length, output);
  267. }
  268. #endif
  269. #endif /* MBEDTLS_MD_C */
  270. int mbedtls_pkcs5_pbkdf2_hmac_ext(mbedtls_md_type_t md_alg,
  271. const unsigned char *password,
  272. size_t plen, const unsigned char *salt, size_t slen,
  273. unsigned int iteration_count,
  274. uint32_t key_length, unsigned char *output)
  275. {
  276. #if defined(MBEDTLS_MD_C)
  277. mbedtls_md_context_t md_ctx;
  278. const mbedtls_md_info_t *md_info = NULL;
  279. int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
  280. md_info = mbedtls_md_info_from_type(md_alg);
  281. if (md_info == NULL) {
  282. return MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE;
  283. }
  284. mbedtls_md_init(&md_ctx);
  285. if ((ret = mbedtls_md_setup(&md_ctx, md_info, 1)) != 0) {
  286. goto exit;
  287. }
  288. ret = pkcs5_pbkdf2_hmac(&md_ctx, password, plen, salt, slen,
  289. iteration_count, key_length, output);
  290. exit:
  291. mbedtls_md_free(&md_ctx);
  292. return ret;
  293. #else
  294. unsigned int i;
  295. unsigned char md1[PSA_HASH_MAX_SIZE];
  296. unsigned char work[PSA_HASH_MAX_SIZE];
  297. const unsigned char md_size = mbedtls_hash_info_get_size(md_alg);
  298. psa_mac_operation_t operation = PSA_MAC_OPERATION_INIT;
  299. psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
  300. psa_status_t status_destruction = PSA_ERROR_CORRUPTION_DETECTED;
  301. size_t use_len, out_len;
  302. unsigned char *out_p = output;
  303. unsigned char counter[4];
  304. mbedtls_svc_key_id_t psa_hmac_key = MBEDTLS_SVC_KEY_ID_INIT;
  305. psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
  306. const psa_algorithm_t alg = PSA_ALG_HMAC(mbedtls_hash_info_psa_from_md(md_alg));
  307. const size_t out_size = PSA_MAC_LENGTH(PSA_KEY_TYPE_HMAC, 0, alg);
  308. memset(counter, 0, sizeof(counter));
  309. counter[3] = 1;
  310. psa_set_key_usage_flags(&attributes, PSA_KEY_USAGE_SIGN_MESSAGE);
  311. psa_set_key_algorithm(&attributes, alg);
  312. psa_set_key_type(&attributes, PSA_KEY_TYPE_HMAC);
  313. if (key_length == 0) {
  314. return 0;
  315. }
  316. if ((status = psa_import_key(&attributes,
  317. password, plen,
  318. &psa_hmac_key)) != PSA_SUCCESS) {
  319. return MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA;
  320. }
  321. #if UINT_MAX > 0xFFFFFFFF
  322. if (iteration_count > 0xFFFFFFFF) {
  323. return MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA;
  324. }
  325. #endif
  326. while (key_length) {
  327. status = psa_mac_sign_setup(&operation, psa_hmac_key,
  328. PSA_ALG_HMAC(alg));
  329. if (status != PSA_SUCCESS) {
  330. goto cleanup;
  331. }
  332. // U1 ends up in work
  333. if ((status = psa_mac_update(&operation, salt, slen)) != PSA_SUCCESS) {
  334. goto cleanup;
  335. }
  336. if ((status = psa_mac_update(&operation, counter, sizeof(counter))) != PSA_SUCCESS) {
  337. goto cleanup;
  338. }
  339. if ((status = psa_mac_sign_finish(&operation, work, out_size, &out_len))
  340. != PSA_SUCCESS) {
  341. goto cleanup;
  342. }
  343. memcpy(md1, work, out_len);
  344. for (i = 1; i < iteration_count; i++) {
  345. // U2 ends up in md1
  346. //
  347. status = psa_mac_sign_setup(&operation, psa_hmac_key,
  348. PSA_ALG_HMAC(alg));
  349. if (status != PSA_SUCCESS) {
  350. goto cleanup;
  351. }
  352. if ((status = psa_mac_update(&operation, md1, md_size)) != PSA_SUCCESS) {
  353. goto cleanup;
  354. }
  355. if ((status =
  356. psa_mac_sign_finish(&operation, md1, out_size, &out_len)) != PSA_SUCCESS) {
  357. goto cleanup;
  358. }
  359. // U1 xor U2
  360. //
  361. mbedtls_xor(work, work, md1, md_size);
  362. }
  363. use_len = (key_length < md_size) ? key_length : md_size;
  364. memcpy(out_p, work, use_len);
  365. key_length -= (uint32_t) use_len;
  366. out_p += use_len;
  367. for (i = 4; i > 0; i--) {
  368. if (++counter[i - 1] != 0) {
  369. break;
  370. }
  371. }
  372. }
  373. cleanup:
  374. /* Zeroise buffers to clear sensitive data from memory. */
  375. mbedtls_platform_zeroize(work, PSA_HASH_MAX_SIZE);
  376. mbedtls_platform_zeroize(md1, PSA_HASH_MAX_SIZE);
  377. status_destruction = psa_destroy_key(psa_hmac_key);
  378. if (status == PSA_SUCCESS && status_destruction != PSA_SUCCESS) {
  379. status = status_destruction;
  380. }
  381. status_destruction = psa_mac_abort(&operation);
  382. if (status == PSA_SUCCESS && status_destruction != PSA_SUCCESS) {
  383. status = status_destruction;
  384. }
  385. return PSA_TO_MBEDTLS_ERR(status);
  386. #endif /* !MBEDTLS_MD_C */
  387. }
  388. #if defined(MBEDTLS_SELF_TEST)
  389. #if !defined(MBEDTLS_HAS_ALG_SHA_1_VIA_MD_OR_PSA)
  390. int mbedtls_pkcs5_self_test(int verbose)
  391. {
  392. if (verbose != 0) {
  393. mbedtls_printf(" PBKDF2 (SHA1): skipped\n\n");
  394. }
  395. return 0;
  396. }
  397. #else
  398. #define MAX_TESTS 6
  399. static const size_t plen_test_data[MAX_TESTS] =
  400. { 8, 8, 8, 24, 9 };
  401. static const unsigned char password_test_data[MAX_TESTS][32] =
  402. {
  403. "password",
  404. "password",
  405. "password",
  406. "passwordPASSWORDpassword",
  407. "pass\0word",
  408. };
  409. static const size_t slen_test_data[MAX_TESTS] =
  410. { 4, 4, 4, 36, 5 };
  411. static const unsigned char salt_test_data[MAX_TESTS][40] =
  412. {
  413. "salt",
  414. "salt",
  415. "salt",
  416. "saltSALTsaltSALTsaltSALTsaltSALTsalt",
  417. "sa\0lt",
  418. };
  419. static const uint32_t it_cnt_test_data[MAX_TESTS] =
  420. { 1, 2, 4096, 4096, 4096 };
  421. static const uint32_t key_len_test_data[MAX_TESTS] =
  422. { 20, 20, 20, 25, 16 };
  423. static const unsigned char result_key_test_data[MAX_TESTS][32] =
  424. {
  425. { 0x0c, 0x60, 0xc8, 0x0f, 0x96, 0x1f, 0x0e, 0x71,
  426. 0xf3, 0xa9, 0xb5, 0x24, 0xaf, 0x60, 0x12, 0x06,
  427. 0x2f, 0xe0, 0x37, 0xa6 },
  428. { 0xea, 0x6c, 0x01, 0x4d, 0xc7, 0x2d, 0x6f, 0x8c,
  429. 0xcd, 0x1e, 0xd9, 0x2a, 0xce, 0x1d, 0x41, 0xf0,
  430. 0xd8, 0xde, 0x89, 0x57 },
  431. { 0x4b, 0x00, 0x79, 0x01, 0xb7, 0x65, 0x48, 0x9a,
  432. 0xbe, 0xad, 0x49, 0xd9, 0x26, 0xf7, 0x21, 0xd0,
  433. 0x65, 0xa4, 0x29, 0xc1 },
  434. { 0x3d, 0x2e, 0xec, 0x4f, 0xe4, 0x1c, 0x84, 0x9b,
  435. 0x80, 0xc8, 0xd8, 0x36, 0x62, 0xc0, 0xe4, 0x4a,
  436. 0x8b, 0x29, 0x1a, 0x96, 0x4c, 0xf2, 0xf0, 0x70,
  437. 0x38 },
  438. { 0x56, 0xfa, 0x6a, 0xa7, 0x55, 0x48, 0x09, 0x9d,
  439. 0xcc, 0x37, 0xd7, 0xf0, 0x34, 0x25, 0xe0, 0xc3 },
  440. };
  441. int mbedtls_pkcs5_self_test(int verbose)
  442. {
  443. int ret, i;
  444. unsigned char key[64];
  445. for (i = 0; i < MAX_TESTS; i++) {
  446. if (verbose != 0) {
  447. mbedtls_printf(" PBKDF2 (SHA1) #%d: ", i);
  448. }
  449. ret = mbedtls_pkcs5_pbkdf2_hmac_ext(MBEDTLS_MD_SHA1, password_test_data[i],
  450. plen_test_data[i], salt_test_data[i],
  451. slen_test_data[i], it_cnt_test_data[i],
  452. key_len_test_data[i], key);
  453. if (ret != 0 ||
  454. memcmp(result_key_test_data[i], key, key_len_test_data[i]) != 0) {
  455. if (verbose != 0) {
  456. mbedtls_printf("failed\n");
  457. }
  458. ret = 1;
  459. goto exit;
  460. }
  461. if (verbose != 0) {
  462. mbedtls_printf("passed\n");
  463. }
  464. }
  465. if (verbose != 0) {
  466. mbedtls_printf("\n");
  467. }
  468. exit:
  469. return ret;
  470. }
  471. #endif /* MBEDTLS_HAS_ALG_SHA_1_VIA_MD_OR_PSA */
  472. #endif /* MBEDTLS_SELF_TEST */
  473. #endif /* MBEDTLS_PKCS5_C */