blob: 512eeb89cab7561a0767da53af7704a74da1cbeb [file] [log] [blame]
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +01001/* BEGIN_HEADER */
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +00002#include "mbedtls/hmac_drbg.h"
Mohammad Azim Khan67735d52017-04-06 11:55:43 +01003#include "string.h"
Rich Evans00ab4702015-02-06 13:43:58 +00004
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +01005typedef struct
6{
7 unsigned char *p;
8 size_t len;
9} entropy_ctx;
10
Reut Caspie278b362017-10-19 08:49:19 +010011static int mbedtls_test_entropy_func( void *data, unsigned char *buf, size_t len )
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +010012{
13 entropy_ctx *ctx = (entropy_ctx *) data;
14
15 if( len > ctx->len )
16 return( -1 );
17
18 memcpy( buf, ctx->p, len );
19
20 ctx->p += len;
21 ctx->len -= len;
22
23 return( 0 );
24}
25/* END_HEADER */
26
27/* BEGIN_DEPENDENCIES
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020028 * depends_on:MBEDTLS_HMAC_DRBG_C
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +010029 * END_DEPENDENCIES
30 */
31
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +010032/* BEGIN_CASE */
33void hmac_drbg_entropy_usage( int md_alg )
34{
35 unsigned char out[16];
36 unsigned char buf[1024];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020037 const mbedtls_md_info_t *md_info;
38 mbedtls_hmac_drbg_context ctx;
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +010039 entropy_ctx entropy;
Gilles Peskine4d2d4ff2019-10-22 19:10:33 +020040 size_t i, reps = 10;
41 size_t default_entropy_len;
42 size_t expected_consumed_entropy = 0;
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +010043
Manuel Pégourié-Gonnardf9e94812015-04-28 22:07:14 +020044 mbedtls_hmac_drbg_init( &ctx );
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +010045 memset( buf, 0, sizeof( buf ) );
46 memset( out, 0, sizeof( out ) );
47
48 entropy.len = sizeof( buf );
49 entropy.p = buf;
50
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020051 md_info = mbedtls_md_info_from_type( md_alg );
Paul Bakker94b916c2014-04-17 16:07:20 +020052 TEST_ASSERT( md_info != NULL );
Gilles Peskine4d2d4ff2019-10-22 19:10:33 +020053 if( mbedtls_md_get_size( md_info ) <= 20 )
54 default_entropy_len = 16;
55 else if( mbedtls_md_get_size( md_info ) <= 28 )
56 default_entropy_len = 24;
57 else
58 default_entropy_len = 32;
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +010059
60 /* Init must use entropy */
Reut Caspie278b362017-10-19 08:49:19 +010061 TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_test_entropy_func, &entropy,
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +010062 NULL, 0 ) == 0 );
Gilles Peskine4d2d4ff2019-10-22 19:10:33 +020063 /* default_entropy_len of entropy, plus half as much for the nonce */
64 expected_consumed_entropy += default_entropy_len * 3 / 2;
65 TEST_EQUAL( sizeof( buf ) - entropy.len, expected_consumed_entropy );
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +010066
67 /* By default, PR is off and reseed_interval is large,
68 * so the next few calls should not use entropy */
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +010069 for( i = 0; i < reps; i++ )
70 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020071 TEST_ASSERT( mbedtls_hmac_drbg_random( &ctx, out, sizeof( out ) - 4 ) == 0 );
72 TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, out, sizeof( out ) - 4,
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +010073 buf, 16 ) == 0 );
74 }
Gilles Peskine4d2d4ff2019-10-22 19:10:33 +020075 TEST_EQUAL( sizeof( buf ) - entropy.len, expected_consumed_entropy );
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +010076
77 /* While at it, make sure we didn't write past the requested length */
78 TEST_ASSERT( out[sizeof( out ) - 4] == 0 );
79 TEST_ASSERT( out[sizeof( out ) - 3] == 0 );
80 TEST_ASSERT( out[sizeof( out ) - 2] == 0 );
81 TEST_ASSERT( out[sizeof( out ) - 1] == 0 );
82
83 /* Set reseed_interval to the number of calls done,
84 * so the next call should reseed */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020085 mbedtls_hmac_drbg_set_reseed_interval( &ctx, 2 * reps );
86 TEST_ASSERT( mbedtls_hmac_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
Gilles Peskine4d2d4ff2019-10-22 19:10:33 +020087 expected_consumed_entropy += default_entropy_len;
88 TEST_EQUAL( sizeof( buf ) - entropy.len, expected_consumed_entropy );
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +010089
90 /* The new few calls should not reseed */
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +010091 for( i = 0; i < reps / 2; i++ )
92 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020093 TEST_ASSERT( mbedtls_hmac_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
94 TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, out, sizeof( out ) ,
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +010095 buf, 16 ) == 0 );
96 }
Gilles Peskine4d2d4ff2019-10-22 19:10:33 +020097 TEST_EQUAL( sizeof( buf ) - entropy.len, expected_consumed_entropy );
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +010098
99 /* Now enable PR, so the next few calls should all reseed */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200100 mbedtls_hmac_drbg_set_prediction_resistance( &ctx, MBEDTLS_HMAC_DRBG_PR_ON );
101 TEST_ASSERT( mbedtls_hmac_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
Gilles Peskine4d2d4ff2019-10-22 19:10:33 +0200102 expected_consumed_entropy += default_entropy_len;
103 TEST_EQUAL( sizeof( buf ) - entropy.len, expected_consumed_entropy );
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +0100104
105 /* Finally, check setting entropy_len */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200106 mbedtls_hmac_drbg_set_entropy_len( &ctx, 42 );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200107 TEST_ASSERT( mbedtls_hmac_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
Gilles Peskine4d2d4ff2019-10-22 19:10:33 +0200108 expected_consumed_entropy += 42;
109 TEST_EQUAL( sizeof( buf ) - entropy.len, expected_consumed_entropy );
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +0100110
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200111 mbedtls_hmac_drbg_set_entropy_len( &ctx, 13 );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200112 TEST_ASSERT( mbedtls_hmac_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
Gilles Peskine4d2d4ff2019-10-22 19:10:33 +0200113 expected_consumed_entropy += 13;
114 TEST_EQUAL( sizeof( buf ) - entropy.len, expected_consumed_entropy );
Paul Bakkerbd51b262014-07-10 15:26:12 +0200115
116exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200117 mbedtls_hmac_drbg_free( &ctx );
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +0100118}
119/* END_CASE */
120
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200121/* BEGIN_CASE depends_on:MBEDTLS_FS_IO */
Azim Khanf1aaec92017-05-30 14:23:15 +0100122void hmac_drbg_seed_file( int md_alg, char * path, int ret )
Manuel Pégourié-Gonnard48bc3e82014-01-30 21:11:16 +0100123{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200124 const mbedtls_md_info_t *md_info;
125 mbedtls_hmac_drbg_context ctx;
Manuel Pégourié-Gonnard48bc3e82014-01-30 21:11:16 +0100126
Manuel Pégourié-Gonnardf9e94812015-04-28 22:07:14 +0200127 mbedtls_hmac_drbg_init( &ctx );
128
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200129 md_info = mbedtls_md_info_from_type( md_alg );
Paul Bakker94b916c2014-04-17 16:07:20 +0200130 TEST_ASSERT( md_info != NULL );
131
Ronald Cron6c5bd7f2020-06-10 14:08:26 +0200132 TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info,
133 mbedtls_test_rnd_std_rand, NULL,
134 NULL, 0 ) == 0 );
Manuel Pégourié-Gonnard48bc3e82014-01-30 21:11:16 +0100135
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200136 TEST_ASSERT( mbedtls_hmac_drbg_write_seed_file( &ctx, path ) == ret );
137 TEST_ASSERT( mbedtls_hmac_drbg_update_seed_file( &ctx, path ) == ret );
Manuel Pégourié-Gonnard48bc3e82014-01-30 21:11:16 +0100138
Paul Bakkerbd51b262014-07-10 15:26:12 +0200139exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200140 mbedtls_hmac_drbg_free( &ctx );
Manuel Pégourié-Gonnard48bc3e82014-01-30 21:11:16 +0100141}
142/* END_CASE */
143
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +0100144/* BEGIN_CASE */
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +0100145void hmac_drbg_buf( int md_alg )
146{
147 unsigned char out[16];
148 unsigned char buf[100];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200149 const mbedtls_md_info_t *md_info;
150 mbedtls_hmac_drbg_context ctx;
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +0100151 size_t i;
152
Manuel Pégourié-Gonnardf9e94812015-04-28 22:07:14 +0200153 mbedtls_hmac_drbg_init( &ctx );
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +0100154 memset( buf, 0, sizeof( buf ) );
155 memset( out, 0, sizeof( out ) );
156
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200157 md_info = mbedtls_md_info_from_type( md_alg );
Paul Bakker94b916c2014-04-17 16:07:20 +0200158 TEST_ASSERT( md_info != NULL );
Manuel Pégourié-Gonnardf9e94812015-04-28 22:07:14 +0200159 TEST_ASSERT( mbedtls_hmac_drbg_seed_buf( &ctx, md_info, buf, sizeof( buf ) ) == 0 );
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +0100160
161 /* Make sure it never tries to reseed (would segfault otherwise) */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200162 mbedtls_hmac_drbg_set_reseed_interval( &ctx, 3 );
163 mbedtls_hmac_drbg_set_prediction_resistance( &ctx, MBEDTLS_HMAC_DRBG_PR_ON );
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +0100164
165 for( i = 0; i < 30; i++ )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200166 TEST_ASSERT( mbedtls_hmac_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +0100167
Paul Bakkerbd51b262014-07-10 15:26:12 +0200168exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200169 mbedtls_hmac_drbg_free( &ctx );
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +0100170}
171/* END_CASE */
172
173/* BEGIN_CASE */
Azim Khan5fcca462018-06-29 11:05:32 +0100174void hmac_drbg_no_reseed( int md_alg, data_t * entropy,
175 data_t * custom, data_t * add1,
176 data_t * add2, data_t * output )
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +0100177{
Manuel Pégourié-Gonnarde6cdbbd2014-02-01 11:30:03 +0100178 unsigned char data[1024];
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +0100179 unsigned char my_output[512];
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +0100180 entropy_ctx p_entropy;
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200181 const mbedtls_md_info_t *md_info;
182 mbedtls_hmac_drbg_context ctx;
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +0100183
Manuel Pégourié-Gonnardf9e94812015-04-28 22:07:14 +0200184 mbedtls_hmac_drbg_init( &ctx );
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +0100185
Azim Khand30ca132017-06-09 04:32:58 +0100186 p_entropy.p = entropy->x;
187 p_entropy.len = entropy->len;
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +0100188
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200189 md_info = mbedtls_md_info_from_type( md_alg );
Paul Bakker94b916c2014-04-17 16:07:20 +0200190 TEST_ASSERT( md_info != NULL );
Manuel Pégourié-Gonnarde6cdbbd2014-02-01 11:30:03 +0100191
192 /* Test the simplified buffer-based variant */
Azim Khand30ca132017-06-09 04:32:58 +0100193 memcpy( data, entropy->x, p_entropy.len );
194 memcpy( data + p_entropy.len, custom->x, custom->len );
Manuel Pégourié-Gonnardf9e94812015-04-28 22:07:14 +0200195 TEST_ASSERT( mbedtls_hmac_drbg_seed_buf( &ctx, md_info,
Azim Khand30ca132017-06-09 04:32:58 +0100196 data, p_entropy.len + custom->len ) == 0 );
197 TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len,
198 add1->x, add1->len ) == 0 );
199 TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len,
200 add2->x, add2->len ) == 0 );
Paul Bakkerbd51b262014-07-10 15:26:12 +0200201
202 /* clear for second run */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200203 mbedtls_hmac_drbg_free( &ctx );
Manuel Pégourié-Gonnarde6cdbbd2014-02-01 11:30:03 +0100204
Azim Khand30ca132017-06-09 04:32:58 +0100205 TEST_ASSERT( memcmp( my_output, output->x, output->len ) == 0 );
Manuel Pégourié-Gonnarde6cdbbd2014-02-01 11:30:03 +0100206
207 /* And now the normal entropy-based variant */
Reut Caspie278b362017-10-19 08:49:19 +0100208 TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_test_entropy_func, &p_entropy,
Azim Khand30ca132017-06-09 04:32:58 +0100209 custom->x, custom->len ) == 0 );
210 TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len,
211 add1->x, add1->len ) == 0 );
212 TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len,
213 add2->x, add2->len ) == 0 );
214 TEST_ASSERT( memcmp( my_output, output->x, output->len ) == 0 );
Manuel Pégourié-Gonnarde6cdbbd2014-02-01 11:30:03 +0100215
Paul Bakkerbd51b262014-07-10 15:26:12 +0200216exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200217 mbedtls_hmac_drbg_free( &ctx );
Manuel Pégourié-Gonnard24600b72014-01-31 09:54:14 +0100218}
219/* END_CASE */
220
221/* BEGIN_CASE */
Azim Khan5fcca462018-06-29 11:05:32 +0100222void hmac_drbg_nopr( int md_alg, data_t * entropy, data_t * custom,
223 data_t * add1, data_t * add2, data_t * add3,
224 data_t * output )
Manuel Pégourié-Gonnard24600b72014-01-31 09:54:14 +0100225{
Manuel Pégourié-Gonnard24600b72014-01-31 09:54:14 +0100226 unsigned char my_output[512];
Manuel Pégourié-Gonnard24600b72014-01-31 09:54:14 +0100227 entropy_ctx p_entropy;
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200228 const mbedtls_md_info_t *md_info;
229 mbedtls_hmac_drbg_context ctx;
Manuel Pégourié-Gonnard24600b72014-01-31 09:54:14 +0100230
Manuel Pégourié-Gonnardf9e94812015-04-28 22:07:14 +0200231 mbedtls_hmac_drbg_init( &ctx );
Manuel Pégourié-Gonnard24600b72014-01-31 09:54:14 +0100232
Azim Khand30ca132017-06-09 04:32:58 +0100233 p_entropy.p = entropy->x;
234 p_entropy.len = entropy->len;
Manuel Pégourié-Gonnard24600b72014-01-31 09:54:14 +0100235
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200236 md_info = mbedtls_md_info_from_type( md_alg );
Paul Bakker94b916c2014-04-17 16:07:20 +0200237 TEST_ASSERT( md_info != NULL );
238
Reut Caspie278b362017-10-19 08:49:19 +0100239 TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_test_entropy_func, &p_entropy,
Azim Khand30ca132017-06-09 04:32:58 +0100240 custom->x, custom->len ) == 0 );
241 TEST_ASSERT( mbedtls_hmac_drbg_reseed( &ctx, add1->x, add1->len ) == 0 );
242 TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len,
243 add2->x, add2->len ) == 0 );
244 TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len,
245 add3->x, add3->len ) == 0 );
Manuel Pégourié-Gonnard24600b72014-01-31 09:54:14 +0100246
Azim Khand30ca132017-06-09 04:32:58 +0100247 TEST_ASSERT( memcmp( my_output, output->x, output->len ) == 0 );
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +0100248
Paul Bakkerbd51b262014-07-10 15:26:12 +0200249exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200250 mbedtls_hmac_drbg_free( &ctx );
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +0100251}
252/* END_CASE */
253
Manuel Pégourié-Gonnard62273b82014-01-31 10:16:57 +0100254/* BEGIN_CASE */
Azim Khan5fcca462018-06-29 11:05:32 +0100255void hmac_drbg_pr( int md_alg, data_t * entropy, data_t * custom,
256 data_t * add1, data_t * add2, data_t * output )
Manuel Pégourié-Gonnard62273b82014-01-31 10:16:57 +0100257{
Manuel Pégourié-Gonnard62273b82014-01-31 10:16:57 +0100258 unsigned char my_output[512];
Manuel Pégourié-Gonnard62273b82014-01-31 10:16:57 +0100259 entropy_ctx p_entropy;
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200260 const mbedtls_md_info_t *md_info;
261 mbedtls_hmac_drbg_context ctx;
Manuel Pégourié-Gonnard62273b82014-01-31 10:16:57 +0100262
Manuel Pégourié-Gonnardf9e94812015-04-28 22:07:14 +0200263 mbedtls_hmac_drbg_init( &ctx );
Manuel Pégourié-Gonnard62273b82014-01-31 10:16:57 +0100264
Azim Khand30ca132017-06-09 04:32:58 +0100265 p_entropy.p = entropy->x;
266 p_entropy.len = entropy->len;
Manuel Pégourié-Gonnard62273b82014-01-31 10:16:57 +0100267
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200268 md_info = mbedtls_md_info_from_type( md_alg );
Paul Bakker94b916c2014-04-17 16:07:20 +0200269 TEST_ASSERT( md_info != NULL );
270
Reut Caspie278b362017-10-19 08:49:19 +0100271 TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_test_entropy_func, &p_entropy,
Azim Khand30ca132017-06-09 04:32:58 +0100272 custom->x, custom->len ) == 0 );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200273 mbedtls_hmac_drbg_set_prediction_resistance( &ctx, MBEDTLS_HMAC_DRBG_PR_ON );
Azim Khand30ca132017-06-09 04:32:58 +0100274 TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len,
275 add1->x, add1->len ) == 0 );
276 TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len,
277 add2->x, add2->len ) == 0 );
Manuel Pégourié-Gonnard62273b82014-01-31 10:16:57 +0100278
Azim Khand30ca132017-06-09 04:32:58 +0100279 TEST_ASSERT( memcmp( my_output, output->x, output->len ) == 0 );
Paul Bakkerbd51b262014-07-10 15:26:12 +0200280
281exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200282 mbedtls_hmac_drbg_free( &ctx );
Manuel Pégourié-Gonnard62273b82014-01-31 10:16:57 +0100283}
284/* END_CASE */
285
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200286/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
Azim Khanf1aaec92017-05-30 14:23:15 +0100287void hmac_drbg_selftest( )
Manuel Pégourié-Gonnard79afaa02014-01-31 11:12:09 +0100288{
Andres AG93012e82016-09-09 09:10:28 +0100289 TEST_ASSERT( mbedtls_hmac_drbg_self_test( 1 ) == 0 );
Manuel Pégourié-Gonnard79afaa02014-01-31 11:12:09 +0100290}
291/* END_CASE */