mirror of
				https://github.com/Mbed-TLS/mbedtls.git
				synced 2025-11-03 20:33:16 +03:00 
			
		
		
		
	PKCS#1v1.5 signature: better cleanup of temporary values
Zeroize temporary buffers used to sanity-check the signature. If there is an error, overwrite the tentative signature in the output buffer. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
		@@ -1942,9 +1942,13 @@ int mbedtls_rsa_rsassa_pkcs1_v15_sign( mbedtls_rsa_context *ctx,
 | 
				
			|||||||
    memcpy( sig, sig_try, ctx->len );
 | 
					    memcpy( sig, sig_try, ctx->len );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cleanup:
 | 
					cleanup:
 | 
				
			||||||
 | 
					    mbedtls_platform_zeroize( sig_try, ctx->len );
 | 
				
			||||||
 | 
					    mbedtls_platform_zeroize( verif, ctx->len );
 | 
				
			||||||
    mbedtls_free( sig_try );
 | 
					    mbedtls_free( sig_try );
 | 
				
			||||||
    mbedtls_free( verif );
 | 
					    mbedtls_free( verif );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if( ret != 0 )
 | 
				
			||||||
 | 
					        memset( sig, '!', ctx->len );
 | 
				
			||||||
    return( ret );
 | 
					    return( ret );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif /* MBEDTLS_PKCS1_V15 */
 | 
					#endif /* MBEDTLS_PKCS1_V15 */
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user