From d3e4244caf4bb4dc6892f7528247312cb28170a4 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 5 Nov 2018 16:54:40 +0000 Subject: [PATCH 1/2] Add explicit integer to enumeration casts to programs/pkey/gen_key.c Fixes #2170. --- programs/pkey/gen_key.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/programs/pkey/gen_key.c b/programs/pkey/gen_key.c index 48126948d..da7e0d072 100644 --- a/programs/pkey/gen_key.c +++ b/programs/pkey/gen_key.c @@ -313,7 +313,8 @@ int main( int argc, char *argv[] ) mbedtls_printf( "\n . Generating the private key ..." ); fflush( stdout ); - if( ( ret = mbedtls_pk_setup( &key, mbedtls_pk_info_from_type( opt.type ) ) ) != 0 ) + if( ( ret = mbedtls_pk_setup( &key, + mbedtls_pk_info_from_type( (mbedtls_pk_type_t) opt.type ) ) ) != 0 ) { mbedtls_printf( " failed\n ! mbedtls_pk_setup returned -0x%04x", -ret ); goto exit; @@ -335,8 +336,9 @@ int main( int argc, char *argv[] ) #if defined(MBEDTLS_ECP_C) if( opt.type == MBEDTLS_PK_ECKEY ) { - ret = mbedtls_ecp_gen_key( opt.ec_curve, mbedtls_pk_ec( key ), - mbedtls_ctr_drbg_random, &ctr_drbg ); + ret = mbedtls_ecp_gen_key( (mbedtls_ecp_group_id) opt.ec_curve, + mbedtls_pk_ec( key ), + mbedtls_ctr_drbg_random, &ctr_drbg ); if( ret != 0 ) { mbedtls_printf( " failed\n ! mbedtls_rsa_gen_key returned -0x%04x", -ret ); @@ -422,4 +424,3 @@ exit: } #endif /* MBEDTLS_PK_WRITE_C && MBEDTLS_PEM_WRITE_C && MBEDTLS_FS_IO && * MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C */ - From 02ea47603f6ab8e1e81ef2219aa793c26b7fcde3 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 6 Nov 2018 13:39:07 +0000 Subject: [PATCH 2/2] Adapt ChangeLog --- ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index 46b001c12..44ad09945 100644 --- a/ChangeLog +++ b/ChangeLog @@ -27,6 +27,9 @@ Bugfix * Zeroize memory used for reassembling handshake messages after use. * Use `mbedtls_zeroize()` instead of `memset()` for zeroization of sensitive data in the example programs aescrypt2 and crypt_and_hash. + * Add explicit integer to enumeration type casts to example program + programs/pkey/gen_key which previously led to compilation failure + on some toolchains. Reported by phoenixmcallister. Fixes #2170. Changes * "make apidoc" now generates the documentation for the current