hmac_drbg.c 16 KB

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