Skip to content

Commit 6c2f139

Browse files
committed
Merge remote-tracking branch 'restricted/pr/514' into mbedtls-2.1
2 parents b5bbb95 + 43c1964 commit 6c2f139

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

ChangeLog

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Security
1616
plaintexts and forge RSA signatures. Other asymmetric algorithms may
1717
have been similarly vulnerable. Reported by Eyal Ronen, Robert Gillham,
1818
Daniel Genkin, Adi Shamir, David Wong and Yuval Yarom.
19+
* Wipe sensitive buffers on the stack in the CTR_DRBG and HMAC_DRBG
20+
modules.
1921

2022
= mbed TLS 2.1.16 branch released 2018-11-19
2123

library/ctr_drbg.c

+9
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ static int block_cipher_df( unsigned char *output,
226226

227227
mbedtls_aes_free( &aes_ctx );
228228

229+
mbedtls_zeroize( buf, sizeof( buf ) );
230+
mbedtls_zeroize( tmp, sizeof( tmp ) );
231+
mbedtls_zeroize( key, sizeof( key ) );
232+
mbedtls_zeroize( chain, sizeof( chain ) );
229233
return( 0 );
230234
}
231235

@@ -264,6 +268,7 @@ static int ctr_drbg_update_internal( mbedtls_ctr_drbg_context *ctx,
264268
mbedtls_aes_setkey_enc( &ctx->aes_ctx, tmp, MBEDTLS_CTR_DRBG_KEYBITS );
265269
memcpy( ctx->counter, tmp + MBEDTLS_CTR_DRBG_KEYSIZE, MBEDTLS_CTR_DRBG_BLOCKSIZE );
266270

271+
mbedtls_zeroize( tmp, sizeof( tmp ) );
267272
return( 0 );
268273
}
269274

@@ -281,6 +286,7 @@ void mbedtls_ctr_drbg_update( mbedtls_ctr_drbg_context *ctx,
281286

282287
block_cipher_df( add_input, additional, add_len );
283288
ctr_drbg_update_internal( ctx, add_input );
289+
mbedtls_zeroize( add_input, sizeof( add_input ) );
284290
}
285291
}
286292

@@ -327,6 +333,7 @@ int mbedtls_ctr_drbg_reseed( mbedtls_ctr_drbg_context *ctx,
327333
ctr_drbg_update_internal( ctx, seed );
328334
ctx->reseed_counter = 1;
329335

336+
mbedtls_zeroize( seed, sizeof( seed ) );
330337
return( 0 );
331338
}
332339

@@ -393,6 +400,8 @@ int mbedtls_ctr_drbg_random_with_add( void *p_rng,
393400

394401
ctx->reseed_counter++;
395402

403+
mbedtls_zeroize( add_input, sizeof( add_input ) );
404+
mbedtls_zeroize( tmp, sizeof( tmp ) );
396405
return( 0 );
397406
}
398407

library/hmac_drbg.c

+3
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ void mbedtls_hmac_drbg_update( mbedtls_hmac_drbg_context *ctx,
9393
mbedtls_md_hmac_update( &ctx->md_ctx, ctx->V, md_len );
9494
mbedtls_md_hmac_finish( &ctx->md_ctx, ctx->V );
9595
}
96+
97+
mbedtls_zeroize( K, sizeof( K ) );
9698
}
9799

98100
/*
@@ -158,6 +160,7 @@ int mbedtls_hmac_drbg_reseed( mbedtls_hmac_drbg_context *ctx,
158160
ctx->reseed_counter = 1;
159161

160162
/* 4. Done */
163+
mbedtls_zeroize( seed, seedlen );
161164
return( 0 );
162165
}
163166

0 commit comments

Comments
 (0)