diff --git a/programs/aes/aescrypt2 b/programs/aes/aescrypt2 new file mode 100755 index 000000000000..4aecec739193 Binary files /dev/null and b/programs/aes/aescrypt2 differ diff --git a/programs/aes/crypt_and_hash.c b/programs/aes/crypt_and_hash.c index 63a12480fdc8..0f97867faddb 100644 --- a/programs/aes/crypt_and_hash.c +++ b/programs/aes/crypt_and_hash.c @@ -128,7 +128,7 @@ int main( int argc, char *argv[] ) while( *list ) { cipher_info = mbedtls_cipher_info_from_type( *list ); - mbedtls_printf( " %s\n", cipher_info->name ); + mbedtls_printf( " %s\n", cipher_info->MBEDTLS_PRIVATE(name) ); list++; } @@ -313,7 +313,7 @@ int main( int argc, char *argv[] ) } - if( mbedtls_cipher_setkey( &cipher_ctx, digest, cipher_info->key_bitlen, + if( mbedtls_cipher_setkey( &cipher_ctx, digest, cipher_info->MBEDTLS_PRIVATE(key_bitlen), MBEDTLS_ENCRYPT ) != 0 ) { mbedtls_fprintf( stderr, "mbedtls_cipher_setkey() returned error\n"); @@ -412,7 +412,7 @@ int main( int argc, char *argv[] ) /* * Check the file size. */ - if( cipher_info->mode != MBEDTLS_MODE_GCM && + if( cipher_info->MBEDTLS_PRIVATE(mode) != MBEDTLS_MODE_GCM && ( ( filesize - mbedtls_md_get_size( md_info ) ) % mbedtls_cipher_get_block_size( &cipher_ctx ) ) != 0 ) { @@ -452,7 +452,7 @@ int main( int argc, char *argv[] ) mbedtls_md_finish( &md_ctx, digest ); } - if( mbedtls_cipher_setkey( &cipher_ctx, digest, cipher_info->key_bitlen, + if( mbedtls_cipher_setkey( &cipher_ctx, digest, cipher_info->MBEDTLS_PRIVATE(key_bitlen), MBEDTLS_DECRYPT ) != 0 ) { mbedtls_fprintf( stderr, "mbedtls_cipher_setkey() returned error\n" ); diff --git a/programs/pkey/dh_client.c b/programs/pkey/dh_client.c index d6e4990a9b13..f37df4a9f62d 100644 --- a/programs/pkey/dh_client.c +++ b/programs/pkey/dh_client.c @@ -127,15 +127,15 @@ int main( void ) mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 ); - if( ( ret = mbedtls_mpi_read_file( &rsa.N, 16, f ) ) != 0 || - ( ret = mbedtls_mpi_read_file( &rsa.E, 16, f ) ) != 0 ) + if( ( ret = mbedtls_mpi_read_file( &rsa.MBEDTLS_PRIVATE(N), 16, f ) ) != 0 || + ( ret = mbedtls_mpi_read_file( &rsa.MBEDTLS_PRIVATE(E), 16, f ) ) != 0 ) { mbedtls_printf( " failed\n ! mbedtls_mpi_read_file returned %d\n\n", ret ); fclose( f ); goto exit; } - rsa.len = ( mbedtls_mpi_bitlen( &rsa.N ) + 7 ) >> 3; + rsa.MBEDTLS_PRIVATE(len) = ( mbedtls_mpi_bitlen( &rsa.MBEDTLS_PRIVATE(N) ) + 7 ) >> 3; fclose( f ); @@ -193,7 +193,7 @@ int main( void ) goto exit; } - if( dhm.len < 64 || dhm.len > 512 ) + if( dhm.MBEDTLS_PRIVATE(len) < 64 || dhm.MBEDTLS_PRIVATE(len) > 512 ) { mbedtls_printf( " failed\n ! Invalid DHM modulus size\n\n" ); goto exit; @@ -208,7 +208,7 @@ int main( void ) p += 2; - if( ( n = (size_t) ( end - p ) ) != rsa.len ) + if( ( n = (size_t) ( end - p ) ) != rsa.MBEDTLS_PRIVATE(len) ) { mbedtls_printf( " failed\n ! Invalid RSA signature size\n\n" ); goto exit; @@ -233,8 +233,8 @@ int main( void ) mbedtls_printf( "\n . Sending own public value to server" ); fflush( stdout ); - n = dhm.len; - if( ( ret = mbedtls_dhm_make_public( &dhm, (int) dhm.len, buf, n, + n = dhm.MBEDTLS_PRIVATE(len); + if( ( ret = mbedtls_dhm_make_public( &dhm, (int) dhm.MBEDTLS_PRIVATE(len), buf, n, mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) { mbedtls_printf( " failed\n ! mbedtls_dhm_make_public returned %d\n\n", ret ); diff --git a/programs/pkey/dh_server.c b/programs/pkey/dh_server.c index dccf0951ca1e..d19ddad25abf 100644 --- a/programs/pkey/dh_server.c +++ b/programs/pkey/dh_server.c @@ -173,8 +173,8 @@ int main( void ) goto exit; } - if( mbedtls_mpi_read_file( &dhm.P, 16, f ) != 0 || - mbedtls_mpi_read_file( &dhm.G, 16, f ) != 0 ) + if( mbedtls_mpi_read_file( &dhm.MBEDTLS_PRIVATE(P), 16, f ) != 0 || + mbedtls_mpi_read_file( &dhm.MBEDTLS_PRIVATE(G), 16, f ) != 0 ) { mbedtls_printf( " failed\n ! Invalid DH parameter file\n\n" ); fclose( f ); @@ -210,7 +210,7 @@ int main( void ) memset( buf, 0, sizeof( buf ) ); - if( ( ret = mbedtls_dhm_make_params( &dhm, (int) mbedtls_mpi_size( &dhm.P ), buf, &n, + if( ( ret = mbedtls_dhm_make_params( &dhm, (int) mbedtls_mpi_size( &dhm.MBEDTLS_PRIVATE(P) ), buf, &n, mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) { mbedtls_printf( " failed\n ! mbedtls_dhm_make_params returned %d\n\n", ret ); @@ -226,8 +226,8 @@ int main( void ) goto exit; } - buf[n ] = (unsigned char)( rsa.len >> 8 ); - buf[n + 1] = (unsigned char)( rsa.len ); + buf[n ] = (unsigned char)( rsa.MBEDTLS_PRIVATE(len) >> 8 ); + buf[n + 1] = (unsigned char)( rsa.MBEDTLS_PRIVATE(len) ); if( ( ret = mbedtls_rsa_pkcs1_sign( &rsa, NULL, NULL, MBEDTLS_RSA_PRIVATE, MBEDTLS_MD_SHA256, 0, hash, buf + n + 2 ) ) != 0 ) @@ -236,7 +236,7 @@ int main( void ) goto exit; } - buflen = n + 2 + rsa.len; + buflen = n + 2 + rsa.MBEDTLS_PRIVATE(len); buf2[0] = (unsigned char)( buflen >> 8 ); buf2[1] = (unsigned char)( buflen ); @@ -255,14 +255,14 @@ int main( void ) memset( buf, 0, sizeof( buf ) ); - n = dhm.len; + n = dhm.MBEDTLS_PRIVATE(len); if( ( ret = mbedtls_net_recv( &client_fd, buf, n ) ) != (int) n ) { mbedtls_printf( " failed\n ! mbedtls_net_recv returned %d\n\n", ret ); goto exit; } - if( ( ret = mbedtls_dhm_read_public( &dhm, buf, dhm.len ) ) != 0 ) + if( ( ret = mbedtls_dhm_read_public( &dhm, buf, dhm.MBEDTLS_PRIVATE(len) ) ) != 0 ) { mbedtls_printf( " failed\n ! mbedtls_dhm_read_public returned %d\n\n", ret ); goto exit; diff --git a/programs/pkey/ecdh_curve25519.c b/programs/pkey/ecdh_curve25519.c index 67f136360c5e..1f4b8bc3f5d5 100644 --- a/programs/pkey/ecdh_curve25519.c +++ b/programs/pkey/ecdh_curve25519.c @@ -91,14 +91,14 @@ int main( int argc, char *argv[] ) mbedtls_printf( " . Setting up client context..." ); fflush( stdout ); - ret = mbedtls_ecp_group_load( &ctx_cli.grp, MBEDTLS_ECP_DP_CURVE25519 ); + ret = mbedtls_ecp_group_load( &ctx_cli.MBEDTLS_PRIVATE(grp), MBEDTLS_ECP_DP_CURVE25519 ); if( ret != 0 ) { mbedtls_printf( " failed\n ! mbedtls_ecp_group_load returned %d\n", ret ); goto exit; } - ret = mbedtls_ecdh_gen_public( &ctx_cli.grp, &ctx_cli.d, &ctx_cli.Q, + ret = mbedtls_ecdh_gen_public( &ctx_cli.MBEDTLS_PRIVATE(grp), &ctx_cli.MBEDTLS_PRIVATE(d), &ctx_cli.MBEDTLS_PRIVATE(Q), mbedtls_ctr_drbg_random, &ctr_drbg ); if( ret != 0 ) { @@ -106,7 +106,7 @@ int main( int argc, char *argv[] ) goto exit; } - ret = mbedtls_mpi_write_binary( &ctx_cli.Q.X, cli_to_srv, 32 ); + ret = mbedtls_mpi_write_binary( &ctx_cli.MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(X), cli_to_srv, 32 ); if( ret != 0 ) { mbedtls_printf( " failed\n ! mbedtls_mpi_write_binary returned %d\n", ret ); @@ -121,14 +121,14 @@ int main( int argc, char *argv[] ) mbedtls_printf( " . Setting up server context..." ); fflush( stdout ); - ret = mbedtls_ecp_group_load( &ctx_srv.grp, MBEDTLS_ECP_DP_CURVE25519 ); + ret = mbedtls_ecp_group_load( &ctx_srv.MBEDTLS_PRIVATE(grp), MBEDTLS_ECP_DP_CURVE25519 ); if( ret != 0 ) { mbedtls_printf( " failed\n ! mbedtls_ecp_group_load returned %d\n", ret ); goto exit; } - ret = mbedtls_ecdh_gen_public( &ctx_srv.grp, &ctx_srv.d, &ctx_srv.Q, + ret = mbedtls_ecdh_gen_public( &ctx_srv.MBEDTLS_PRIVATE(grp), &ctx_srv.MBEDTLS_PRIVATE(d), &ctx_srv.MBEDTLS_PRIVATE(Q), mbedtls_ctr_drbg_random, &ctr_drbg ); if( ret != 0 ) { @@ -136,7 +136,7 @@ int main( int argc, char *argv[] ) goto exit; } - ret = mbedtls_mpi_write_binary( &ctx_srv.Q.X, srv_to_cli, 32 ); + ret = mbedtls_mpi_write_binary( &ctx_srv.MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(X), srv_to_cli, 32 ); if( ret != 0 ) { mbedtls_printf( " failed\n ! mbedtls_mpi_write_binary returned %d\n", ret ); @@ -151,22 +151,22 @@ int main( int argc, char *argv[] ) mbedtls_printf( " . Server reading client key and computing secret..." ); fflush( stdout ); - ret = mbedtls_mpi_lset( &ctx_srv.Qp.Z, 1 ); + ret = mbedtls_mpi_lset( &ctx_srv.MBEDTLS_PRIVATE(Qp).MBEDTLS_PRIVATE(Z), 1 ); if( ret != 0 ) { mbedtls_printf( " failed\n ! mbedtls_mpi_lset returned %d\n", ret ); goto exit; } - ret = mbedtls_mpi_read_binary( &ctx_srv.Qp.X, cli_to_srv, 32 ); + ret = mbedtls_mpi_read_binary( &ctx_srv.MBEDTLS_PRIVATE(Qp).MBEDTLS_PRIVATE(X), cli_to_srv, 32 ); if( ret != 0 ) { mbedtls_printf( " failed\n ! mbedtls_mpi_read_binary returned %d\n", ret ); goto exit; } - ret = mbedtls_ecdh_compute_shared( &ctx_srv.grp, &ctx_srv.z, - &ctx_srv.Qp, &ctx_srv.d, + ret = mbedtls_ecdh_compute_shared( &ctx_srv.MBEDTLS_PRIVATE(grp), &ctx_srv.MBEDTLS_PRIVATE(z), + &ctx_srv.MBEDTLS_PRIVATE(Qp), &ctx_srv.MBEDTLS_PRIVATE(d), mbedtls_ctr_drbg_random, &ctr_drbg ); if( ret != 0 ) { @@ -182,22 +182,22 @@ int main( int argc, char *argv[] ) mbedtls_printf( " . Client reading server key and computing secret..." ); fflush( stdout ); - ret = mbedtls_mpi_lset( &ctx_cli.Qp.Z, 1 ); + ret = mbedtls_mpi_lset( &ctx_cli.MBEDTLS_PRIVATE(Qp).MBEDTLS_PRIVATE(Z), 1 ); if( ret != 0 ) { mbedtls_printf( " failed\n ! mbedtls_mpi_lset returned %d\n", ret ); goto exit; } - ret = mbedtls_mpi_read_binary( &ctx_cli.Qp.X, srv_to_cli, 32 ); + ret = mbedtls_mpi_read_binary( &ctx_cli.MBEDTLS_PRIVATE(Qp).MBEDTLS_PRIVATE(X), srv_to_cli, 32 ); if( ret != 0 ) { mbedtls_printf( " failed\n ! mbedtls_mpi_read_binary returned %d\n", ret ); goto exit; } - ret = mbedtls_ecdh_compute_shared( &ctx_cli.grp, &ctx_cli.z, - &ctx_cli.Qp, &ctx_cli.d, + ret = mbedtls_ecdh_compute_shared( &ctx_cli.MBEDTLS_PRIVATE(grp), &ctx_cli.MBEDTLS_PRIVATE(z), + &ctx_cli.MBEDTLS_PRIVATE(Qp), &ctx_cli.MBEDTLS_PRIVATE(d), mbedtls_ctr_drbg_random, &ctr_drbg ); if( ret != 0 ) { @@ -213,7 +213,7 @@ int main( int argc, char *argv[] ) mbedtls_printf( " . Checking if both computed secrets are equal..." ); fflush( stdout ); - ret = mbedtls_mpi_cmp_mpi( &ctx_cli.z, &ctx_srv.z ); + ret = mbedtls_mpi_cmp_mpi( &ctx_cli.MBEDTLS_PRIVATE(z), &ctx_srv.MBEDTLS_PRIVATE(z) ); if( ret != 0 ) { mbedtls_printf( " failed\n ! mbedtls_ecdh_compute_shared returned %d\n", ret ); diff --git a/programs/pkey/ecdsa.c b/programs/pkey/ecdsa.c index 1bbf8268c43f..3dacd75d3187 100644 --- a/programs/pkey/ecdsa.c +++ b/programs/pkey/ecdsa.c @@ -55,7 +55,7 @@ #define ECPARAMS MBEDTLS_ECP_DP_SECP192R1 #if !defined(ECPARAMS) -#define ECPARAMS mbedtls_ecp_curve_list()->grp_id +#define ECPARAMS mbedtls_ecp_curve_list()->MBEDTLS_PRIVATE(grp_id) #endif #if !defined(MBEDTLS_ECDSA_C) || !defined(MBEDTLS_SHA256_C) || \ @@ -84,7 +84,7 @@ static void dump_pubkey( const char *title, mbedtls_ecdsa_context *key ) unsigned char buf[300]; size_t len; - if( mbedtls_ecp_point_write_binary( &key->grp, &key->Q, + if( mbedtls_ecp_point_write_binary( &key->MBEDTLS_PRIVATE(grp), &key->MBEDTLS_PRIVATE(Q), MBEDTLS_ECP_PF_UNCOMPRESSED, &len, buf, sizeof buf ) != 0 ) { mbedtls_printf("internal error\n"); @@ -156,7 +156,7 @@ int main( int argc, char *argv[] ) goto exit; } - mbedtls_printf( " ok (key size: %d bits)\n", (int) ctx_sign.grp.pbits ); + mbedtls_printf( " ok (key size: %d bits)\n", (int) ctx_sign.MBEDTLS_PRIVATE(grp).MBEDTLS_PRIVATE(pbits) ); dump_pubkey( " + Public key: ", &ctx_sign ); @@ -204,13 +204,13 @@ int main( int argc, char *argv[] ) mbedtls_printf( " . Preparing verification context..." ); fflush( stdout ); - if( ( ret = mbedtls_ecp_group_copy( &ctx_verify.grp, &ctx_sign.grp ) ) != 0 ) + if( ( ret = mbedtls_ecp_group_copy( &ctx_verify.MBEDTLS_PRIVATE(grp), &ctx_sign.MBEDTLS_PRIVATE(grp) ) ) != 0 ) { mbedtls_printf( " failed\n ! mbedtls_ecp_group_copy returned %d\n", ret ); goto exit; } - if( ( ret = mbedtls_ecp_copy( &ctx_verify.Q, &ctx_sign.Q ) ) != 0 ) + if( ( ret = mbedtls_ecp_copy( &ctx_verify.MBEDTLS_PRIVATE(Q), &ctx_sign.MBEDTLS_PRIVATE(Q) ) ) != 0 ) { mbedtls_printf( " failed\n ! mbedtls_ecp_copy returned %d\n", ret ); goto exit; diff --git a/programs/pkey/gen_key.c b/programs/pkey/gen_key.c index 63cc11ed5b95..9ad1190fc7c9 100644 --- a/programs/pkey/gen_key.c +++ b/programs/pkey/gen_key.c @@ -90,7 +90,7 @@ int dev_random_entropy_poll( void *data, unsigned char *output, #endif #if defined(MBEDTLS_ECP_C) -#define DFL_EC_CURVE mbedtls_ecp_curve_list()->grp_id +#define DFL_EC_CURVE mbedtls_ecp_curve_list()->MBEDTLS_PRIVATE(grp_id) #else #define DFL_EC_CURVE 0 #endif @@ -223,9 +223,9 @@ int main( int argc, char *argv[] ) #if defined(MBEDTLS_ECP_C) mbedtls_printf( " available ec_curve values:\n" ); curve_info = mbedtls_ecp_curve_list(); - mbedtls_printf( " %s (default)\n", curve_info->name ); - while( ( ++curve_info )->name != NULL ) - mbedtls_printf( " %s\n", curve_info->name ); + mbedtls_printf( " %s (default)\n", curve_info->MBEDTLS_PRIVATE(name) ); + while( ( ++curve_info )->MBEDTLS_PRIVATE(name) != NULL ) + mbedtls_printf( " %s\n", curve_info->MBEDTLS_PRIVATE(name) ); #endif /* MBEDTLS_ECP_C */ goto exit; } @@ -274,7 +274,7 @@ int main( int argc, char *argv[] ) { if( ( curve_info = mbedtls_ecp_curve_info_from_name( q ) ) == NULL ) goto usage; - opt.ec_curve = curve_info->grp_id; + opt.ec_curve = curve_info->MBEDTLS_PRIVATE(grp_id); } #endif else if( strcmp( p, "filename" ) == 0 ) @@ -395,10 +395,10 @@ int main( int argc, char *argv[] ) { mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( key ); mbedtls_printf( "curve: %s\n", - mbedtls_ecp_curve_info_from_grp_id( ecp->grp.id )->name ); - mbedtls_mpi_write_file( "X_Q: ", &ecp->Q.X, 16, NULL ); - mbedtls_mpi_write_file( "Y_Q: ", &ecp->Q.Y, 16, NULL ); - mbedtls_mpi_write_file( "D: ", &ecp->d , 16, NULL ); + mbedtls_ecp_curve_info_from_grp_id( ecp->MBEDTLS_PRIVATE(grp).MBEDTLS_PRIVATE(id) )->MBEDTLS_PRIVATE(name) ); + mbedtls_mpi_write_file( "X_Q: ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(X), 16, NULL ); + mbedtls_mpi_write_file( "Y_Q: ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(Y), 16, NULL ); + mbedtls_mpi_write_file( "D: ", &ecp->MBEDTLS_PRIVATE(d) , 16, NULL ); } else #endif diff --git a/programs/pkey/key_app.c b/programs/pkey/key_app.c index 7f39e5ce37eb..7bd93c72b582 100644 --- a/programs/pkey/key_app.c +++ b/programs/pkey/key_app.c @@ -222,10 +222,10 @@ int main( int argc, char *argv[] ) if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_ECKEY ) { mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( pk ); - MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(X): ", &ecp->Q.X, 16, NULL ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(Y): ", &ecp->Q.Y, 16, NULL ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(Z): ", &ecp->Q.Z, 16, NULL ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "D : ", &ecp->d , 16, NULL ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(X): ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(X), 16, NULL ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(Y): ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(Y), 16, NULL ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(Z): ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(Z), 16, NULL ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "D : ", &ecp->MBEDTLS_PRIVATE(d) , 16, NULL ) ); } else #endif @@ -273,9 +273,9 @@ int main( int argc, char *argv[] ) if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_ECKEY ) { mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( pk ); - MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(X): ", &ecp->Q.X, 16, NULL ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(Y): ", &ecp->Q.Y, 16, NULL ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(Z): ", &ecp->Q.Z, 16, NULL ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(X): ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(X), 16, NULL ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(Y): ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(Y), 16, NULL ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(Z): ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(Z), 16, NULL ) ); } else #endif diff --git a/programs/pkey/key_app_writer.c b/programs/pkey/key_app_writer.c index 6a4d0e4ce630..4b65262d0d8b 100644 --- a/programs/pkey/key_app_writer.c +++ b/programs/pkey/key_app_writer.c @@ -335,10 +335,10 @@ int main( int argc, char *argv[] ) if( mbedtls_pk_get_type( &key ) == MBEDTLS_PK_ECKEY ) { mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( key ); - mbedtls_mpi_write_file( "Q(X): ", &ecp->Q.X, 16, NULL ); - mbedtls_mpi_write_file( "Q(Y): ", &ecp->Q.Y, 16, NULL ); - mbedtls_mpi_write_file( "Q(Z): ", &ecp->Q.Z, 16, NULL ); - mbedtls_mpi_write_file( "D : ", &ecp->d , 16, NULL ); + mbedtls_mpi_write_file( "Q(X): ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(X), 16, NULL ); + mbedtls_mpi_write_file( "Q(Y): ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(Y), 16, NULL ); + mbedtls_mpi_write_file( "Q(Z): ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(Z), 16, NULL ); + mbedtls_mpi_write_file( "D : ", &ecp->MBEDTLS_PRIVATE(d) , 16, NULL ); } else #endif @@ -389,9 +389,9 @@ int main( int argc, char *argv[] ) if( mbedtls_pk_get_type( &key ) == MBEDTLS_PK_ECKEY ) { mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( key ); - mbedtls_mpi_write_file( "Q(X): ", &ecp->Q.X, 16, NULL ); - mbedtls_mpi_write_file( "Q(Y): ", &ecp->Q.Y, 16, NULL ); - mbedtls_mpi_write_file( "Q(Z): ", &ecp->Q.Z, 16, NULL ); + mbedtls_mpi_write_file( "Q(X): ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(X), 16, NULL ); + mbedtls_mpi_write_file( "Q(Y): ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(Y), 16, NULL ); + mbedtls_mpi_write_file( "Q(Z): ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(Z), 16, NULL ); } else #endif diff --git a/programs/pkey/rsa_decrypt.c b/programs/pkey/rsa_decrypt.c index 01bf3a621ae1..4f15b92ecb97 100644 --- a/programs/pkey/rsa_decrypt.c +++ b/programs/pkey/rsa_decrypt.c @@ -164,7 +164,7 @@ int main( int argc, char *argv[] ) fclose( f ); - if( i != rsa.len ) + if( i != rsa.MBEDTLS_PRIVATE(len) ) { mbedtls_printf( "\n ! Invalid RSA signature format\n\n" ); goto exit; diff --git a/programs/pkey/rsa_encrypt.c b/programs/pkey/rsa_encrypt.c index ba0120172905..03a6e894f9c2 100644 --- a/programs/pkey/rsa_encrypt.c +++ b/programs/pkey/rsa_encrypt.c @@ -161,7 +161,7 @@ int main( int argc, char *argv[] ) goto exit; } - for( i = 0; i < rsa.len; i++ ) + for( i = 0; i < rsa.MBEDTLS_PRIVATE(len); i++ ) mbedtls_fprintf( f, "%02X%s", buf[i], ( i + 1 ) % 16 == 0 ? "\r\n" : " " ); diff --git a/programs/pkey/rsa_sign.c b/programs/pkey/rsa_sign.c index c9522c8c264b..8e657a79286f 100644 --- a/programs/pkey/rsa_sign.c +++ b/programs/pkey/rsa_sign.c @@ -164,7 +164,7 @@ int main( int argc, char *argv[] ) goto exit; } - for( i = 0; i < rsa.len; i++ ) + for( i = 0; i < rsa.MBEDTLS_PRIVATE(len); i++ ) mbedtls_fprintf( f, "%02X%s", buf[i], ( i + 1 ) % 16 == 0 ? "\r\n" : " " ); diff --git a/programs/pkey/rsa_verify.c b/programs/pkey/rsa_verify.c index fbc0779b2cd3..e7e347c70f18 100644 --- a/programs/pkey/rsa_verify.c +++ b/programs/pkey/rsa_verify.c @@ -89,15 +89,15 @@ int main( int argc, char *argv[] ) goto exit; } - if( ( ret = mbedtls_mpi_read_file( &rsa.N, 16, f ) ) != 0 || - ( ret = mbedtls_mpi_read_file( &rsa.E, 16, f ) ) != 0 ) + if( ( ret = mbedtls_mpi_read_file( &rsa.MBEDTLS_PRIVATE(N), 16, f ) ) != 0 || + ( ret = mbedtls_mpi_read_file( &rsa.MBEDTLS_PRIVATE(E), 16, f ) ) != 0 ) { mbedtls_printf( " failed\n ! mbedtls_mpi_read_file returned %d\n\n", ret ); fclose( f ); goto exit; } - rsa.len = ( mbedtls_mpi_bitlen( &rsa.N ) + 7 ) >> 3; + rsa.MBEDTLS_PRIVATE(len) = ( mbedtls_mpi_bitlen( &rsa.MBEDTLS_PRIVATE(N) ) + 7 ) >> 3; fclose( f ); @@ -119,7 +119,7 @@ int main( int argc, char *argv[] ) fclose( f ); - if( i != rsa.len ) + if( i != rsa.MBEDTLS_PRIVATE(len) ) { mbedtls_printf( "\n ! Invalid RSA signature format\n\n" ); goto exit; diff --git a/programs/ssl/dtls_client.c b/programs/ssl/dtls_client.c index 1e97795336bb..c3c73bb14cc8 100644 --- a/programs/ssl/dtls_client.c +++ b/programs/ssl/dtls_client.c @@ -17,6 +17,8 @@ * limitations under the License. */ +#define MBEDTLS_ALLOW_PRIVATE_ACCESS + #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else diff --git a/programs/ssl/dtls_server.c b/programs/ssl/dtls_server.c index bd2dc12de3eb..34419db7c61a 100644 --- a/programs/ssl/dtls_server.c +++ b/programs/ssl/dtls_server.c @@ -17,6 +17,8 @@ * limitations under the License. */ +#define MBEDTLS_ALLOW_PRIVATE_ACCESS + #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else diff --git a/programs/ssl/mini_client.c b/programs/ssl/mini_client.c index 0a9cc284dd3a..a067a8fd5ed5 100644 --- a/programs/ssl/mini_client.c +++ b/programs/ssl/mini_client.c @@ -18,6 +18,8 @@ * limitations under the License. */ +#define MBEDTLS_ALLOW_PRIVATE_ACCESS + #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else diff --git a/programs/ssl/ssl_client1.c b/programs/ssl/ssl_client1.c index 6624224af4ad..3e479d00af5b 100644 --- a/programs/ssl/ssl_client1.c +++ b/programs/ssl/ssl_client1.c @@ -17,6 +17,8 @@ * limitations under the License. */ +#define MBEDTLS_ALLOW_PRIVATE_ACCESS + #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else diff --git a/programs/ssl/ssl_fork_server.c b/programs/ssl/ssl_fork_server.c index d181c01dacc8..38a68831ec80 100644 --- a/programs/ssl/ssl_fork_server.c +++ b/programs/ssl/ssl_fork_server.c @@ -17,6 +17,8 @@ * limitations under the License. */ +#define MBEDTLS_ALLOW_PRIVATE_ACCESS + #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else diff --git a/programs/ssl/ssl_mail_client.c b/programs/ssl/ssl_mail_client.c index 428c6436262b..5d395c25fac8 100644 --- a/programs/ssl/ssl_mail_client.c +++ b/programs/ssl/ssl_mail_client.c @@ -20,6 +20,9 @@ /* Enable definition of gethostname() even when compiling with -std=c99. Must * be set before config.h, which pulls in glibc's features.h indirectly. * Harmless on other platforms. */ + +#define MBEDTLS_ALLOW_PRIVATE_ACCESS + #define _POSIX_C_SOURCE 200112L #define _XOPEN_SOURCE 600 diff --git a/programs/ssl/ssl_server.c b/programs/ssl/ssl_server.c index 11147b092bd9..8458a22b4317 100644 --- a/programs/ssl/ssl_server.c +++ b/programs/ssl/ssl_server.c @@ -17,6 +17,8 @@ * limitations under the License. */ +#define MBEDTLS_ALLOW_PRIVATE_ACCESS + #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 8b5017c3c797..88318bcda871 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -805,7 +805,7 @@ int sni_callback( void *p_info, mbedtls_ssl_context *ssl, return( mbedtls_ssl_set_hs_own_cert( ssl, cur->cert, cur->key ) ); } - cur = cur->next; + cur = cur->MBEDTLS_PRIVATE(next); } return( -1 ); @@ -921,7 +921,7 @@ int psk_callback( void *p_info, mbedtls_ssl_context *ssl, return( mbedtls_ssl_set_hs_psk( ssl, cur->key, cur->key_len ) ); } - cur = cur->next; + cur = cur->MBEDTLS_PRIVATE(next); } return( -1 ); diff --git a/programs/x509/cert_app.c b/programs/x509/cert_app.c index fb2484337c42..2adef3904b8b 100644 --- a/programs/x509/cert_app.c +++ b/programs/x509/cert_app.c @@ -335,7 +335,7 @@ int main( int argc, char *argv[] ) mbedtls_printf( "%s\n", buf ); - cur = cur->next; + cur = cur->MBEDTLS_PRIVATE(next); } /* diff --git a/programs/x509/cert_write.c b/programs/x509/cert_write.c index 18174d804981..ff7cf98074b5 100644 --- a/programs/x509/cert_write.c +++ b/programs/x509/cert_write.c @@ -518,7 +518,7 @@ int main( int argc, char *argv[] ) } ret = mbedtls_x509_dn_gets( issuer_name, sizeof(issuer_name), - &issuer_crt.subject ); + &issuer_crt.MBEDTLS_PRIVATE(subject) ); if( ret < 0 ) { mbedtls_strerror( ret, buf, 1024 ); @@ -552,7 +552,7 @@ int main( int argc, char *argv[] ) } ret = mbedtls_x509_dn_gets( subject_name, sizeof(subject_name), - &csr.subject ); + &csr.MBEDTLS_PRIVATE(subject) ); if( ret < 0 ) { mbedtls_strerror( ret, buf, 1024 ); @@ -562,7 +562,7 @@ int main( int argc, char *argv[] ) } opt.subject_name = subject_name; - subject_key = &csr.pk; + subject_key = &csr.MBEDTLS_PRIVATE(pk); mbedtls_printf( " ok\n" ); } @@ -606,7 +606,7 @@ int main( int argc, char *argv[] ) // if( strlen( opt.issuer_crt ) ) { - if( mbedtls_pk_check_pair( &issuer_crt.pk, issuer_key ) != 0 ) + if( mbedtls_pk_check_pair( &issuer_crt.MBEDTLS_PRIVATE(pk), issuer_key ) != 0 ) { mbedtls_printf( " failed\n ! issuer_key does not match " "issuer certificate\n\n" );