blob: b84826697deab9530ebda08cdf4992bd2b882be3 [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 Cron351f0ee2020-06-10 12:12:18 +0200132 TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_test_rnd_std_rand, NULL,
Manuel Pégourié-Gonnard48bc3e82014-01-30 21:11:16 +0100133 NULL, 0 ) == 0 );
134
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200135 TEST_ASSERT( mbedtls_hmac_drbg_write_seed_file( &ctx, path ) == ret );
136 TEST_ASSERT( mbedtls_hmac_drbg_update_seed_file( &ctx, path ) == ret );
Manuel Pégourié-Gonnard48bc3e82014-01-30 21:11:16 +0100137
Paul Bakkerbd51b262014-07-10 15:26:12 +0200138exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200139 mbedtls_hmac_drbg_free( &ctx );
Manuel Pégourié-Gonnard48bc3e82014-01-30 21:11:16 +0100140}
141/* END_CASE */
142
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +0100143/* BEGIN_CASE */
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +0100144void hmac_drbg_buf( int md_alg )
145{
146 unsigned char out[16];
147 unsigned char buf[100];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200148 const mbedtls_md_info_t *md_info;
149 mbedtls_hmac_drbg_context ctx;
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +0100150 size_t i;
151
Manuel Pégourié-Gonnardf9e94812015-04-28 22:07:14 +0200152 mbedtls_hmac_drbg_init( &ctx );
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +0100153 memset( buf, 0, sizeof( buf ) );
154 memset( out, 0, sizeof( out ) );
155
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200156 md_info = mbedtls_md_info_from_type( md_alg );
Paul Bakker94b916c2014-04-17 16:07:20 +0200157 TEST_ASSERT( md_info != NULL );
Manuel Pégourié-Gonnardf9e94812015-04-28 22:07:14 +0200158 TEST_ASSERT( mbedtls_hmac_drbg_seed_buf( &ctx, md_info, buf, sizeof( buf ) ) == 0 );
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +0100159
160 /* Make sure it never tries to reseed (would segfault otherwise) */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200161 mbedtls_hmac_drbg_set_reseed_interval( &ctx, 3 );
162 mbedtls_hmac_drbg_set_prediction_resistance( &ctx, MBEDTLS_HMAC_DRBG_PR_ON );
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +0100163
164 for( i = 0; i < 30; i++ )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200165 TEST_ASSERT( mbedtls_hmac_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +0100166
Paul Bakkerbd51b262014-07-10 15:26:12 +0200167exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200168 mbedtls_hmac_drbg_free( &ctx );
Manuel Pégourié-Gonnard4f880a52014-01-30 22:39:42 +0100169}
170/* END_CASE */
171
172/* BEGIN_CASE */
Azim Khan5fcca462018-06-29 11:05:32 +0100173void hmac_drbg_no_reseed( int md_alg, data_t * entropy,
174 data_t * custom, data_t * add1,
175 data_t * add2, data_t * output )
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +0100176{
Manuel Pégourié-Gonnarde6cdbbd2014-02-01 11:30:03 +0100177 unsigned char data[1024];
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +0100178 unsigned char my_output[512];
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +0100179 entropy_ctx p_entropy;
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200180 const mbedtls_md_info_t *md_info;
181 mbedtls_hmac_drbg_context ctx;
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +0100182
Manuel Pégourié-Gonnardf9e94812015-04-28 22:07:14 +0200183 mbedtls_hmac_drbg_init( &ctx );
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +0100184
Azim Khand30ca132017-06-09 04:32:58 +0100185 p_entropy.p = entropy->x;
186 p_entropy.len = entropy->len;
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +0100187
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200188 md_info = mbedtls_md_info_from_type( md_alg );
Paul Bakker94b916c2014-04-17 16:07:20 +0200189 TEST_ASSERT( md_info != NULL );
Manuel Pégourié-Gonnarde6cdbbd2014-02-01 11:30:03 +0100190
191 /* Test the simplified buffer-based variant */
Azim Khand30ca132017-06-09 04:32:58 +0100192 memcpy( data, entropy->x, p_entropy.len );
193 memcpy( data + p_entropy.len, custom->x, custom->len );
Manuel Pégourié-Gonnardf9e94812015-04-28 22:07:14 +0200194 TEST_ASSERT( mbedtls_hmac_drbg_seed_buf( &ctx, md_info,
Azim Khand30ca132017-06-09 04:32:58 +0100195 data, p_entropy.len + custom->len ) == 0 );
196 TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len,
197 add1->x, add1->len ) == 0 );
198 TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len,
199 add2->x, add2->len ) == 0 );
Paul Bakkerbd51b262014-07-10 15:26:12 +0200200
201 /* clear for second run */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200202 mbedtls_hmac_drbg_free( &ctx );
Manuel Pégourié-Gonnarde6cdbbd2014-02-01 11:30:03 +0100203
Azim Khand30ca132017-06-09 04:32:58 +0100204 TEST_ASSERT( memcmp( my_output, output->x, output->len ) == 0 );
Manuel Pégourié-Gonnarde6cdbbd2014-02-01 11:30:03 +0100205
206 /* And now the normal entropy-based variant */
Reut Caspie278b362017-10-19 08:49:19 +0100207 TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_test_entropy_func, &p_entropy,
Azim Khand30ca132017-06-09 04:32:58 +0100208 custom->x, custom->len ) == 0 );
209 TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len,
210 add1->x, add1->len ) == 0 );
211 TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len,
212 add2->x, add2->len ) == 0 );
213 TEST_ASSERT( memcmp( my_output, output->x, output->len ) == 0 );
Manuel Pégourié-Gonnarde6cdbbd2014-02-01 11:30:03 +0100214
Paul Bakkerbd51b262014-07-10 15:26:12 +0200215exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200216 mbedtls_hmac_drbg_free( &ctx );
Manuel Pégourié-Gonnard24600b72014-01-31 09:54:14 +0100217}
218/* END_CASE */
219
220/* BEGIN_CASE */
Azim Khan5fcca462018-06-29 11:05:32 +0100221void hmac_drbg_nopr( int md_alg, data_t * entropy, data_t * custom,
222 data_t * add1, data_t * add2, data_t * add3,
223 data_t * output )
Manuel Pégourié-Gonnard24600b72014-01-31 09:54:14 +0100224{
Manuel Pégourié-Gonnard24600b72014-01-31 09:54:14 +0100225 unsigned char my_output[512];
Manuel Pégourié-Gonnard24600b72014-01-31 09:54:14 +0100226 entropy_ctx p_entropy;
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200227 const mbedtls_md_info_t *md_info;
228 mbedtls_hmac_drbg_context ctx;
Manuel Pégourié-Gonnard24600b72014-01-31 09:54:14 +0100229
Manuel Pégourié-Gonnardf9e94812015-04-28 22:07:14 +0200230 mbedtls_hmac_drbg_init( &ctx );
Manuel Pégourié-Gonnard24600b72014-01-31 09:54:14 +0100231
Azim Khand30ca132017-06-09 04:32:58 +0100232 p_entropy.p = entropy->x;
233 p_entropy.len = entropy->len;
Manuel Pégourié-Gonnard24600b72014-01-31 09:54:14 +0100234
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200235 md_info = mbedtls_md_info_from_type( md_alg );
Paul Bakker94b916c2014-04-17 16:07:20 +0200236 TEST_ASSERT( md_info != NULL );
237
Reut Caspie278b362017-10-19 08:49:19 +0100238 TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_test_entropy_func, &p_entropy,
Azim Khand30ca132017-06-09 04:32:58 +0100239 custom->x, custom->len ) == 0 );
240 TEST_ASSERT( mbedtls_hmac_drbg_reseed( &ctx, add1->x, add1->len ) == 0 );
241 TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len,
242 add2->x, add2->len ) == 0 );
243 TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len,
244 add3->x, add3->len ) == 0 );
Manuel Pégourié-Gonnard24600b72014-01-31 09:54:14 +0100245
Azim Khand30ca132017-06-09 04:32:58 +0100246 TEST_ASSERT( memcmp( my_output, output->x, output->len ) == 0 );
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +0100247
Paul Bakkerbd51b262014-07-10 15:26:12 +0200248exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200249 mbedtls_hmac_drbg_free( &ctx );
Manuel Pégourié-Gonnard6801f392014-01-30 17:22:14 +0100250}
251/* END_CASE */
252
Manuel Pégourié-Gonnard62273b82014-01-31 10:16:57 +0100253/* BEGIN_CASE */
Azim Khan5fcca462018-06-29 11:05:32 +0100254void hmac_drbg_pr( int md_alg, data_t * entropy, data_t * custom,
255 data_t * add1, data_t * add2, data_t * output )
Manuel Pégourié-Gonnard62273b82014-01-31 10:16:57 +0100256{
Manuel Pégourié-Gonnard62273b82014-01-31 10:16:57 +0100257 unsigned char my_output[512];
Manuel Pégourié-Gonnard62273b82014-01-31 10:16:57 +0100258 entropy_ctx p_entropy;
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200259 const mbedtls_md_info_t *md_info;
260 mbedtls_hmac_drbg_context ctx;
Manuel Pégourié-Gonnard62273b82014-01-31 10:16:57 +0100261
Manuel Pégourié-Gonnardf9e94812015-04-28 22:07:14 +0200262 mbedtls_hmac_drbg_init( &ctx );
Manuel Pégourié-Gonnard62273b82014-01-31 10:16:57 +0100263
Azim Khand30ca132017-06-09 04:32:58 +0100264 p_entropy.p = entropy->x;
265 p_entropy.len = entropy->len;
Manuel Pégourié-Gonnard62273b82014-01-31 10:16:57 +0100266
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200267 md_info = mbedtls_md_info_from_type( md_alg );
Paul Bakker94b916c2014-04-17 16:07:20 +0200268 TEST_ASSERT( md_info != NULL );
269
Reut Caspie278b362017-10-19 08:49:19 +0100270 TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_test_entropy_func, &p_entropy,
Azim Khand30ca132017-06-09 04:32:58 +0100271 custom->x, custom->len ) == 0 );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200272 mbedtls_hmac_drbg_set_prediction_resistance( &ctx, MBEDTLS_HMAC_DRBG_PR_ON );
Azim Khand30ca132017-06-09 04:32:58 +0100273 TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len,
274 add1->x, add1->len ) == 0 );
275 TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len,
276 add2->x, add2->len ) == 0 );
Manuel Pégourié-Gonnard62273b82014-01-31 10:16:57 +0100277
Azim Khand30ca132017-06-09 04:32:58 +0100278 TEST_ASSERT( memcmp( my_output, output->x, output->len ) == 0 );
Paul Bakkerbd51b262014-07-10 15:26:12 +0200279
280exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200281 mbedtls_hmac_drbg_free( &ctx );
Manuel Pégourié-Gonnard62273b82014-01-31 10:16:57 +0100282}
283/* END_CASE */
284
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200285/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
Azim Khanf1aaec92017-05-30 14:23:15 +0100286void hmac_drbg_selftest( )
Manuel Pégourié-Gonnard79afaa02014-01-31 11:12:09 +0100287{
Andres AG93012e82016-09-09 09:10:28 +0100288 TEST_ASSERT( mbedtls_hmac_drbg_self_test( 1 ) == 0 );
Manuel Pégourié-Gonnard79afaa02014-01-31 11:12:09 +0100289}
290/* END_CASE */