-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build with only montgomery curves (+ DJB configuration) #2013
Closed
gilles-peskine-arm
wants to merge
8
commits into
Mbed-TLS:development
from
gilles-peskine-arm:build_with_only_montgomery_curves
Closed
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b1b2d90
Add Curve25519 and Curve448 to check_config.h
gilles-peskine-arm ddc8032
Add missing #ifdef around Short Weierstrass-specific code
gilles-peskine-arm edff4df
Note that mbedtls_ecp_mul_add is only defined for Short Weierstrass
gilles-peskine-arm 168209c
Add missing #ifdef around Short Weierstrass-specific code
gilles-peskine-arm 6bbec3b
Add ChangeLog entry for no-short-Weierstrass build fix
gilles-peskine-arm d82a19e
Remove AES-only test from the cipher.chacha* test suites
gilles-peskine-arm 32e6ad8
Support HMAC_DRBG in the TLS test programs
gilles-peskine-arm 29efeea
New reference configuration with ChaCha/Poly and Curve25519
gilles-peskine-arm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,12 +39,22 @@ | |
|
||
#if !defined(MBEDTLS_ENTROPY_C) || \ | ||
!defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_CLI_C) || \ | ||
!defined(MBEDTLS_NET_C) || !defined(MBEDTLS_CTR_DRBG_C) | ||
!defined(MBEDTLS_NET_C) | ||
int main( void ) | ||
{ | ||
mbedtls_printf("MBEDTLS_ENTROPY_C and/or " | ||
"MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_CLI_C and/or " | ||
"MBEDTLS_NET_C and/or MBEDTLS_CTR_DRBG_C and/or not defined.\n"); | ||
"MBEDTLS_NET_C not defined.\n"); | ||
return( 0 ); | ||
} | ||
#elif !( defined(MBEDTLS_CTR_DRBG_C) || \ | ||
( defined(MBEDTLS_HMAC_DRBG_C) && ( defined(MBEDTLS_SHA256_C) || \ | ||
defined(MBEDTLS_SHA512_C) ) ) ) | ||
int main( void ) | ||
{ | ||
mbedtls_printf("MBEDTLS_CTR_DRBG_C and MBEDTLS_HMAC_DRBG_C not defined, " | ||
"or MBEDTLS_HMAC_DRBG_C defined without " | ||
"MBEDTLS_SHA256_C or MBEDTLS_512_C.\n"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: SHA512 |
||
return( 0 ); | ||
} | ||
#else | ||
|
@@ -53,6 +63,7 @@ int main( void ) | |
#include "mbedtls/ssl.h" | ||
#include "mbedtls/entropy.h" | ||
#include "mbedtls/ctr_drbg.h" | ||
#include "mbedtls/hmac_drbg.h" | ||
#include "mbedtls/certs.h" | ||
#include "mbedtls/x509.h" | ||
#include "mbedtls/error.h" | ||
|
@@ -530,7 +541,11 @@ int main( int argc, char *argv[] ) | |
mbedtls_x509_crt_profile crt_profile_for_test = mbedtls_x509_crt_profile_default; | ||
#endif | ||
mbedtls_entropy_context entropy; | ||
#if defined(MBEDTLS_CTR_DRBG_C) | ||
mbedtls_ctr_drbg_context ctr_drbg; | ||
#else | ||
mbedtls_hmac_drbg_context hmac_drbg; | ||
#endif | ||
mbedtls_ssl_context ssl; | ||
mbedtls_ssl_config conf; | ||
mbedtls_ssl_session saved_session; | ||
|
@@ -553,7 +568,11 @@ int main( int argc, char *argv[] ) | |
mbedtls_ssl_init( &ssl ); | ||
mbedtls_ssl_config_init( &conf ); | ||
memset( &saved_session, 0, sizeof( mbedtls_ssl_session ) ); | ||
#if defined(MBEDTLS_CTR_DRBG_C) | ||
mbedtls_ctr_drbg_init( &ctr_drbg ); | ||
#else | ||
mbedtls_hmac_drbg_init( &hmac_drbg ); | ||
#endif | ||
#if defined(MBEDTLS_X509_CRT_PARSE_C) | ||
mbedtls_x509_crt_init( &cacert ); | ||
mbedtls_x509_crt_init( &clicert ); | ||
|
@@ -1165,11 +1184,24 @@ int main( int argc, char *argv[] ) | |
fflush( stdout ); | ||
|
||
mbedtls_entropy_init( &entropy ); | ||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, | ||
&entropy, (const unsigned char *) pers, | ||
strlen( pers ) ) ) != 0 ) | ||
#if defined(MBEDTLS_CTR_DRBG_C) | ||
ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, | ||
&entropy, (const unsigned char *) pers, | ||
strlen( pers ) ); | ||
#else | ||
ret = mbedtls_hmac_drbg_seed( &hmac_drbg, | ||
#if defined(MBEDTLS_SHA256_C) | ||
mbedtls_md_info_from_type( MBEDTLS_MD_SHA256 ), | ||
#else | ||
mbedtls_md_info_from_type( MBEDTLS_MD_SHA512 ), | ||
#endif | ||
mbedtls_entropy_func, | ||
&entropy, (const unsigned char *) pers, | ||
strlen( pers ) ); | ||
#endif | ||
if( ret != 0 ) | ||
{ | ||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n", | ||
mbedtls_printf( " failed\n ! mbedtls_xxx_drbg_seed returned -0x%x\n", | ||
-ret ); | ||
goto exit; | ||
} | ||
|
@@ -1403,7 +1435,12 @@ int main( int argc, char *argv[] ) | |
} | ||
#endif | ||
|
||
#if defined(MBEDTLS_CTR_DRBG_C) | ||
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); | ||
#else | ||
mbedtls_ssl_conf_rng( &conf, mbedtls_hmac_drbg_random, &hmac_drbg ); | ||
#endif | ||
|
||
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); | ||
|
||
mbedtls_ssl_conf_read_timeout( &conf, opt.read_timeout ); | ||
|
@@ -2054,7 +2091,11 @@ int main( int argc, char *argv[] ) | |
mbedtls_ssl_session_free( &saved_session ); | ||
mbedtls_ssl_free( &ssl ); | ||
mbedtls_ssl_config_free( &conf ); | ||
#if defined(MBEDTLS_CTR_DRBG_C) | ||
mbedtls_ctr_drbg_free( &ctr_drbg ); | ||
#else | ||
mbedtls_hmac_drbg_free( &hmac_drbg ); | ||
#endif | ||
mbedtls_entropy_free( &entropy ); | ||
|
||
#if defined(_WIN32) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does
Support HMAC_DRBG in the TLS test programs
have to do withBuild with only montgomery curves
? Shouldn't this commit be in a different PR?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to enable the SSL test programs to at least build in the “DJB-only” configuration. DJB-only means no AES and therefore no CTR_DRBG.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK