hmac_drbg.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. /*
  2. * HMAC_DRBG implementation (NIST SP 800-90)
  3. *
  4. * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
  5. * SPDX-License-Identifier: Apache-2.0
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  8. * not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * This file is part of mbed TLS (https://tls.mbed.org)
  20. */
  21. /*
  22. * The NIST SP 800-90A DRBGs are described in the following publication.
  23. * http://csrc.nist.gov/publications/nistpubs/800-90A/SP800-90A.pdf
  24. * References below are based on rev. 1 (January 2012).
  25. */
  26. #if !defined(MBEDTLS_CONFIG_FILE)
  27. #include "mbedtls/config.h"
  28. #else
  29. #include MBEDTLS_CONFIG_FILE
  30. #endif
  31. #if defined(MBEDTLS_HMAC_DRBG_C)
  32. #include "mbedtls/hmac_drbg.h"
  33. #include "mbedtls/platform_util.h"
  34. #include <string.h>
  35. #if defined(MBEDTLS_FS_IO)
  36. #include <stdio.h>
  37. #endif
  38. #if defined(MBEDTLS_SELF_TEST)
  39. #if defined(MBEDTLS_PLATFORM_C)
  40. #include "mbedtls/platform.h"
  41. #else
  42. #include <stdio.h>
  43. #define mbedtls_printf printf
  44. #endif /* MBEDTLS_SELF_TEST */
  45. #endif /* MBEDTLS_PLATFORM_C */
  46. /*
  47. * HMAC_DRBG context initialization
  48. */
  49. void mbedtls_hmac_drbg_init( mbedtls_hmac_drbg_context *ctx )
  50. {
  51. memset( ctx, 0, sizeof( mbedtls_hmac_drbg_context ) );
  52. #if defined(MBEDTLS_THREADING_C)
  53. mbedtls_mutex_init( &ctx->mutex );
  54. #endif
  55. }
  56. /*
  57. * HMAC_DRBG update, using optional additional data (10.1.2.2)
  58. */
  59. void mbedtls_hmac_drbg_update( mbedtls_hmac_drbg_context *ctx,
  60. const unsigned char *additional, size_t add_len )
  61. {
  62. size_t md_len = mbedtls_md_get_size( ctx->md_ctx.md_info );
  63. unsigned char rounds = ( additional != NULL && add_len != 0 ) ? 2 : 1;
  64. unsigned char sep[1];
  65. unsigned char K[MBEDTLS_MD_MAX_SIZE];
  66. for( sep[0] = 0; sep[0] < rounds; sep[0]++ )
  67. {
  68. /* Step 1 or 4 */
  69. mbedtls_md_hmac_reset( &ctx->md_ctx );
  70. mbedtls_md_hmac_update( &ctx->md_ctx, ctx->V, md_len );
  71. mbedtls_md_hmac_update( &ctx->md_ctx, sep, 1 );
  72. if( rounds == 2 )
  73. mbedtls_md_hmac_update( &ctx->md_ctx, additional, add_len );
  74. mbedtls_md_hmac_finish( &ctx->md_ctx, K );
  75. /* Step 2 or 5 */
  76. mbedtls_md_hmac_starts( &ctx->md_ctx, K, md_len );
  77. mbedtls_md_hmac_update( &ctx->md_ctx, ctx->V, md_len );
  78. mbedtls_md_hmac_finish( &ctx->md_ctx, ctx->V );
  79. }
  80. }
  81. /*
  82. * Simplified HMAC_DRBG initialisation (for use with deterministic ECDSA)
  83. */
  84. int mbedtls_hmac_drbg_seed_buf( mbedtls_hmac_drbg_context *ctx,
  85. const mbedtls_md_info_t * md_info,
  86. const unsigned char *data, size_t data_len )
  87. {
  88. int ret;
  89. if( ( ret = mbedtls_md_setup( &ctx->md_ctx, md_info, 1 ) ) != 0 )
  90. return( ret );
  91. /*
  92. * Set initial working state.
  93. * Use the V memory location, which is currently all 0, to initialize the
  94. * MD context with an all-zero key. Then set V to its initial value.
  95. */
  96. mbedtls_md_hmac_starts( &ctx->md_ctx, ctx->V, mbedtls_md_get_size( md_info ) );
  97. memset( ctx->V, 0x01, mbedtls_md_get_size( md_info ) );
  98. mbedtls_hmac_drbg_update( ctx, data, data_len );
  99. return( 0 );
  100. }
  101. /*
  102. * HMAC_DRBG reseeding: 10.1.2.4 (arabic) + 9.2 (Roman)
  103. */
  104. int mbedtls_hmac_drbg_reseed( mbedtls_hmac_drbg_context *ctx,
  105. const unsigned char *additional, size_t len )
  106. {
  107. unsigned char seed[MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT];
  108. size_t seedlen;
  109. /* III. Check input length */
  110. if( len > MBEDTLS_HMAC_DRBG_MAX_INPUT ||
  111. ctx->entropy_len + len > MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT )
  112. {
  113. return( MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG );
  114. }
  115. memset( seed, 0, MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT );
  116. /* IV. Gather entropy_len bytes of entropy for the seed */
  117. if( ctx->f_entropy( ctx->p_entropy, seed, ctx->entropy_len ) != 0 )
  118. return( MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED );
  119. seedlen = ctx->entropy_len;
  120. /* 1. Concatenate entropy and additional data if any */
  121. if( additional != NULL && len != 0 )
  122. {
  123. memcpy( seed + seedlen, additional, len );
  124. seedlen += len;
  125. }
  126. /* 2. Update state */
  127. mbedtls_hmac_drbg_update( ctx, seed, seedlen );
  128. /* 3. Reset reseed_counter */
  129. ctx->reseed_counter = 1;
  130. /* 4. Done */
  131. return( 0 );
  132. }
  133. /*
  134. * HMAC_DRBG initialisation (10.1.2.3 + 9.1)
  135. */
  136. int mbedtls_hmac_drbg_seed( mbedtls_hmac_drbg_context *ctx,
  137. const mbedtls_md_info_t * md_info,
  138. int (*f_entropy)(void *, unsigned char *, size_t),
  139. void *p_entropy,
  140. const unsigned char *custom,
  141. size_t len )
  142. {
  143. int ret;
  144. size_t entropy_len, md_size;
  145. if( ( ret = mbedtls_md_setup( &ctx->md_ctx, md_info, 1 ) ) != 0 )
  146. return( ret );
  147. md_size = mbedtls_md_get_size( md_info );
  148. /*
  149. * Set initial working state.
  150. * Use the V memory location, which is currently all 0, to initialize the
  151. * MD context with an all-zero key. Then set V to its initial value.
  152. */
  153. mbedtls_md_hmac_starts( &ctx->md_ctx, ctx->V, md_size );
  154. memset( ctx->V, 0x01, md_size );
  155. ctx->f_entropy = f_entropy;
  156. ctx->p_entropy = p_entropy;
  157. ctx->reseed_interval = MBEDTLS_HMAC_DRBG_RESEED_INTERVAL;
  158. /*
  159. * See SP800-57 5.6.1 (p. 65-66) for the security strength provided by
  160. * each hash function, then according to SP800-90A rev1 10.1 table 2,
  161. * min_entropy_len (in bits) is security_strength.
  162. *
  163. * (This also matches the sizes used in the NIST test vectors.)
  164. */
  165. entropy_len = md_size <= 20 ? 16 : /* 160-bits hash -> 128 bits */
  166. md_size <= 28 ? 24 : /* 224-bits hash -> 192 bits */
  167. 32; /* better (256+) -> 256 bits */
  168. /*
  169. * For initialisation, use more entropy to emulate a nonce
  170. * (Again, matches test vectors.)
  171. */
  172. ctx->entropy_len = entropy_len * 3 / 2;
  173. if( ( ret = mbedtls_hmac_drbg_reseed( ctx, custom, len ) ) != 0 )
  174. return( ret );
  175. ctx->entropy_len = entropy_len;
  176. return( 0 );
  177. }
  178. /*
  179. * Set prediction resistance
  180. */
  181. void mbedtls_hmac_drbg_set_prediction_resistance( mbedtls_hmac_drbg_context *ctx,
  182. int resistance )
  183. {
  184. ctx->prediction_resistance = resistance;
  185. }
  186. /*
  187. * Set entropy length grabbed for reseeds
  188. */
  189. void mbedtls_hmac_drbg_set_entropy_len( mbedtls_hmac_drbg_context *ctx, size_t len )
  190. {
  191. ctx->entropy_len = len;
  192. }
  193. /*
  194. * Set reseed interval
  195. */
  196. void mbedtls_hmac_drbg_set_reseed_interval( mbedtls_hmac_drbg_context *ctx, int interval )
  197. {
  198. ctx->reseed_interval = interval;
  199. }
  200. /*
  201. * HMAC_DRBG random function with optional additional data:
  202. * 10.1.2.5 (arabic) + 9.3 (Roman)
  203. */
  204. int mbedtls_hmac_drbg_random_with_add( void *p_rng,
  205. unsigned char *output, size_t out_len,
  206. const unsigned char *additional, size_t add_len )
  207. {
  208. int ret;
  209. mbedtls_hmac_drbg_context *ctx = (mbedtls_hmac_drbg_context *) p_rng;
  210. size_t md_len = mbedtls_md_get_size( ctx->md_ctx.md_info );
  211. size_t left = out_len;
  212. unsigned char *out = output;
  213. /* II. Check request length */
  214. if( out_len > MBEDTLS_HMAC_DRBG_MAX_REQUEST )
  215. return( MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG );
  216. /* III. Check input length */
  217. if( add_len > MBEDTLS_HMAC_DRBG_MAX_INPUT )
  218. return( MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG );
  219. /* 1. (aka VII and IX) Check reseed counter and PR */
  220. if( ctx->f_entropy != NULL && /* For no-reseeding instances */
  221. ( ctx->prediction_resistance == MBEDTLS_HMAC_DRBG_PR_ON ||
  222. ctx->reseed_counter > ctx->reseed_interval ) )
  223. {
  224. if( ( ret = mbedtls_hmac_drbg_reseed( ctx, additional, add_len ) ) != 0 )
  225. return( ret );
  226. add_len = 0; /* VII.4 */
  227. }
  228. /* 2. Use additional data if any */
  229. if( additional != NULL && add_len != 0 )
  230. mbedtls_hmac_drbg_update( ctx, additional, add_len );
  231. /* 3, 4, 5. Generate bytes */
  232. while( left != 0 )
  233. {
  234. size_t use_len = left > md_len ? md_len : left;
  235. mbedtls_md_hmac_reset( &ctx->md_ctx );
  236. mbedtls_md_hmac_update( &ctx->md_ctx, ctx->V, md_len );
  237. mbedtls_md_hmac_finish( &ctx->md_ctx, ctx->V );
  238. memcpy( out, ctx->V, use_len );
  239. out += use_len;
  240. left -= use_len;
  241. }
  242. /* 6. Update */
  243. mbedtls_hmac_drbg_update( ctx, additional, add_len );
  244. /* 7. Update reseed counter */
  245. ctx->reseed_counter++;
  246. /* 8. Done */
  247. return( 0 );
  248. }
  249. /*
  250. * HMAC_DRBG random function
  251. */
  252. int mbedtls_hmac_drbg_random( void *p_rng, unsigned char *output, size_t out_len )
  253. {
  254. int ret;
  255. mbedtls_hmac_drbg_context *ctx = (mbedtls_hmac_drbg_context *) p_rng;
  256. #if defined(MBEDTLS_THREADING_C)
  257. if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 )
  258. return( ret );
  259. #endif
  260. ret = mbedtls_hmac_drbg_random_with_add( ctx, output, out_len, NULL, 0 );
  261. #if defined(MBEDTLS_THREADING_C)
  262. if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 )
  263. return( MBEDTLS_ERR_THREADING_MUTEX_ERROR );
  264. #endif
  265. return( ret );
  266. }
  267. /*
  268. * Free an HMAC_DRBG context
  269. */
  270. void mbedtls_hmac_drbg_free( mbedtls_hmac_drbg_context *ctx )
  271. {
  272. if( ctx == NULL )
  273. return;
  274. #if defined(MBEDTLS_THREADING_C)
  275. mbedtls_mutex_free( &ctx->mutex );
  276. #endif
  277. mbedtls_md_free( &ctx->md_ctx );
  278. mbedtls_platform_zeroize( ctx, sizeof( mbedtls_hmac_drbg_context ) );
  279. }
  280. #if defined(MBEDTLS_FS_IO)
  281. int mbedtls_hmac_drbg_write_seed_file( mbedtls_hmac_drbg_context *ctx, const char *path )
  282. {
  283. int ret;
  284. FILE *f;
  285. unsigned char buf[ MBEDTLS_HMAC_DRBG_MAX_INPUT ];
  286. if( ( f = fopen( path, "wb" ) ) == NULL )
  287. return( MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR );
  288. if( ( ret = mbedtls_hmac_drbg_random( ctx, buf, sizeof( buf ) ) ) != 0 )
  289. goto exit;
  290. if( fwrite( buf, 1, sizeof( buf ), f ) != sizeof( buf ) )
  291. {
  292. ret = MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR;
  293. goto exit;
  294. }
  295. ret = 0;
  296. exit:
  297. fclose( f );
  298. mbedtls_platform_zeroize( buf, sizeof( buf ) );
  299. return( ret );
  300. }
  301. int mbedtls_hmac_drbg_update_seed_file( mbedtls_hmac_drbg_context *ctx, const char *path )
  302. {
  303. int ret = 0;
  304. FILE *f;
  305. size_t n;
  306. unsigned char buf[ MBEDTLS_HMAC_DRBG_MAX_INPUT ];
  307. if( ( f = fopen( path, "rb" ) ) == NULL )
  308. return( MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR );
  309. fseek( f, 0, SEEK_END );
  310. n = (size_t) ftell( f );
  311. fseek( f, 0, SEEK_SET );
  312. if( n > MBEDTLS_HMAC_DRBG_MAX_INPUT )
  313. {
  314. fclose( f );
  315. return( MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG );
  316. }
  317. if( fread( buf, 1, n, f ) != n )
  318. ret = MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR;
  319. else
  320. mbedtls_hmac_drbg_update( ctx, buf, n );
  321. fclose( f );
  322. mbedtls_platform_zeroize( buf, sizeof( buf ) );
  323. if( ret != 0 )
  324. return( ret );
  325. return( mbedtls_hmac_drbg_write_seed_file( ctx, path ) );
  326. }
  327. #endif /* MBEDTLS_FS_IO */
  328. #if defined(MBEDTLS_SELF_TEST)
  329. #if !defined(MBEDTLS_SHA1_C)
  330. /* Dummy checkup routine */
  331. int mbedtls_hmac_drbg_self_test( int verbose )
  332. {
  333. (void) verbose;
  334. return( 0 );
  335. }
  336. #else
  337. #define OUTPUT_LEN 80
  338. /* From a NIST PR=true test vector */
  339. static const unsigned char entropy_pr[] = {
  340. 0xa0, 0xc9, 0xab, 0x58, 0xf1, 0xe2, 0xe5, 0xa4, 0xde, 0x3e, 0xbd, 0x4f,
  341. 0xf7, 0x3e, 0x9c, 0x5b, 0x64, 0xef, 0xd8, 0xca, 0x02, 0x8c, 0xf8, 0x11,
  342. 0x48, 0xa5, 0x84, 0xfe, 0x69, 0xab, 0x5a, 0xee, 0x42, 0xaa, 0x4d, 0x42,
  343. 0x17, 0x60, 0x99, 0xd4, 0x5e, 0x13, 0x97, 0xdc, 0x40, 0x4d, 0x86, 0xa3,
  344. 0x7b, 0xf5, 0x59, 0x54, 0x75, 0x69, 0x51, 0xe4 };
  345. static const unsigned char result_pr[OUTPUT_LEN] = {
  346. 0x9a, 0x00, 0xa2, 0xd0, 0x0e, 0xd5, 0x9b, 0xfe, 0x31, 0xec, 0xb1, 0x39,
  347. 0x9b, 0x60, 0x81, 0x48, 0xd1, 0x96, 0x9d, 0x25, 0x0d, 0x3c, 0x1e, 0x94,
  348. 0x10, 0x10, 0x98, 0x12, 0x93, 0x25, 0xca, 0xb8, 0xfc, 0xcc, 0x2d, 0x54,
  349. 0x73, 0x19, 0x70, 0xc0, 0x10, 0x7a, 0xa4, 0x89, 0x25, 0x19, 0x95, 0x5e,
  350. 0x4b, 0xc6, 0x00, 0x1d, 0x7f, 0x4e, 0x6a, 0x2b, 0xf8, 0xa3, 0x01, 0xab,
  351. 0x46, 0x05, 0x5c, 0x09, 0xa6, 0x71, 0x88, 0xf1, 0xa7, 0x40, 0xee, 0xf3,
  352. 0xe1, 0x5c, 0x02, 0x9b, 0x44, 0xaf, 0x03, 0x44 };
  353. /* From a NIST PR=false test vector */
  354. static const unsigned char entropy_nopr[] = {
  355. 0x79, 0x34, 0x9b, 0xbf, 0x7c, 0xdd, 0xa5, 0x79, 0x95, 0x57, 0x86, 0x66,
  356. 0x21, 0xc9, 0x13, 0x83, 0x11, 0x46, 0x73, 0x3a, 0xbf, 0x8c, 0x35, 0xc8,
  357. 0xc7, 0x21, 0x5b, 0x5b, 0x96, 0xc4, 0x8e, 0x9b, 0x33, 0x8c, 0x74, 0xe3,
  358. 0xe9, 0x9d, 0xfe, 0xdf };
  359. static const unsigned char result_nopr[OUTPUT_LEN] = {
  360. 0xc6, 0xa1, 0x6a, 0xb8, 0xd4, 0x20, 0x70, 0x6f, 0x0f, 0x34, 0xab, 0x7f,
  361. 0xec, 0x5a, 0xdc, 0xa9, 0xd8, 0xca, 0x3a, 0x13, 0x3e, 0x15, 0x9c, 0xa6,
  362. 0xac, 0x43, 0xc6, 0xf8, 0xa2, 0xbe, 0x22, 0x83, 0x4a, 0x4c, 0x0a, 0x0a,
  363. 0xff, 0xb1, 0x0d, 0x71, 0x94, 0xf1, 0xc1, 0xa5, 0xcf, 0x73, 0x22, 0xec,
  364. 0x1a, 0xe0, 0x96, 0x4e, 0xd4, 0xbf, 0x12, 0x27, 0x46, 0xe0, 0x87, 0xfd,
  365. 0xb5, 0xb3, 0xe9, 0x1b, 0x34, 0x93, 0xd5, 0xbb, 0x98, 0xfa, 0xed, 0x49,
  366. 0xe8, 0x5f, 0x13, 0x0f, 0xc8, 0xa4, 0x59, 0xb7 };
  367. /* "Entropy" from buffer */
  368. static size_t test_offset;
  369. static int hmac_drbg_self_test_entropy( void *data,
  370. unsigned char *buf, size_t len )
  371. {
  372. const unsigned char *p = data;
  373. memcpy( buf, p + test_offset, len );
  374. test_offset += len;
  375. return( 0 );
  376. }
  377. #define CHK( c ) if( (c) != 0 ) \
  378. { \
  379. if( verbose != 0 ) \
  380. mbedtls_printf( "failed\n" ); \
  381. return( 1 ); \
  382. }
  383. /*
  384. * Checkup routine for HMAC_DRBG with SHA-1
  385. */
  386. int mbedtls_hmac_drbg_self_test( int verbose )
  387. {
  388. mbedtls_hmac_drbg_context ctx;
  389. unsigned char buf[OUTPUT_LEN];
  390. const mbedtls_md_info_t *md_info = mbedtls_md_info_from_type( MBEDTLS_MD_SHA1 );
  391. mbedtls_hmac_drbg_init( &ctx );
  392. /*
  393. * PR = True
  394. */
  395. if( verbose != 0 )
  396. mbedtls_printf( " HMAC_DRBG (PR = True) : " );
  397. test_offset = 0;
  398. CHK( mbedtls_hmac_drbg_seed( &ctx, md_info,
  399. hmac_drbg_self_test_entropy, (void *) entropy_pr,
  400. NULL, 0 ) );
  401. mbedtls_hmac_drbg_set_prediction_resistance( &ctx, MBEDTLS_HMAC_DRBG_PR_ON );
  402. CHK( mbedtls_hmac_drbg_random( &ctx, buf, OUTPUT_LEN ) );
  403. CHK( mbedtls_hmac_drbg_random( &ctx, buf, OUTPUT_LEN ) );
  404. CHK( memcmp( buf, result_pr, OUTPUT_LEN ) );
  405. mbedtls_hmac_drbg_free( &ctx );
  406. mbedtls_hmac_drbg_free( &ctx );
  407. if( verbose != 0 )
  408. mbedtls_printf( "passed\n" );
  409. /*
  410. * PR = False
  411. */
  412. if( verbose != 0 )
  413. mbedtls_printf( " HMAC_DRBG (PR = False) : " );
  414. mbedtls_hmac_drbg_init( &ctx );
  415. test_offset = 0;
  416. CHK( mbedtls_hmac_drbg_seed( &ctx, md_info,
  417. hmac_drbg_self_test_entropy, (void *) entropy_nopr,
  418. NULL, 0 ) );
  419. CHK( mbedtls_hmac_drbg_reseed( &ctx, NULL, 0 ) );
  420. CHK( mbedtls_hmac_drbg_random( &ctx, buf, OUTPUT_LEN ) );
  421. CHK( mbedtls_hmac_drbg_random( &ctx, buf, OUTPUT_LEN ) );
  422. CHK( memcmp( buf, result_nopr, OUTPUT_LEN ) );
  423. mbedtls_hmac_drbg_free( &ctx );
  424. mbedtls_hmac_drbg_free( &ctx );
  425. if( verbose != 0 )
  426. mbedtls_printf( "passed\n" );
  427. if( verbose != 0 )
  428. mbedtls_printf( "\n" );
  429. return( 0 );
  430. }
  431. #endif /* MBEDTLS_SHA1_C */
  432. #endif /* MBEDTLS_SELF_TEST */
  433. #endif /* MBEDTLS_HMAC_DRBG_C */