Remove MBEDTLS_ from internal macros
This commit is contained in:
parent
a687baf195
commit
8408a94969
7 changed files with 86 additions and 86 deletions
|
@ -100,14 +100,14 @@ static unsigned long add_count, dbl_count, mul_count;
|
|||
defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) || \
|
||||
defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) || \
|
||||
defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
|
||||
#define MBEDTLS_ECP_SHORT_WEIERSTRASS
|
||||
#define ECP_SHORTWEIERSTRASS
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECP_DP_M221_ENABLED) || \
|
||||
defined(MBEDTLS_ECP_DP_M255_ENABLED) || \
|
||||
defined(MBEDTLS_ECP_DP_M383_ENABLED) || \
|
||||
defined(MBEDTLS_ECP_DP_M511_ENABLED)
|
||||
#define MBEDTLS_ECP_MONTGOMERY
|
||||
#define ECP_MONTGOMERY
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -115,9 +115,9 @@ static unsigned long add_count, dbl_count, mul_count;
|
|||
*/
|
||||
typedef enum
|
||||
{
|
||||
MBEDTLS_ECP_TYPE_NONE = 0,
|
||||
MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS, /* y^2 = x^3 + a x + b */
|
||||
MBEDTLS_ECP_TYPE_MONTGOMERY, /* y^2 = x^3 + a x^2 + x */
|
||||
ECP_TYPE_NONE = 0,
|
||||
ECP_TYPE_SHORT_WEIERSTRASS, /* y^2 = x^3 + a x + b */
|
||||
ECP_TYPE_MONTGOMERY, /* y^2 = x^3 + a x^2 + x */
|
||||
} ecp_curve_type;
|
||||
|
||||
/*
|
||||
|
@ -267,12 +267,12 @@ const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_name( const char *name
|
|||
static inline ecp_curve_type ecp_get_type( const mbedtls_ecp_group *grp )
|
||||
{
|
||||
if( grp->G.X.p == NULL )
|
||||
return( MBEDTLS_ECP_TYPE_NONE );
|
||||
return( ECP_TYPE_NONE );
|
||||
|
||||
if( grp->G.Y.p == NULL )
|
||||
return( MBEDTLS_ECP_TYPE_MONTGOMERY );
|
||||
return( ECP_TYPE_MONTGOMERY );
|
||||
else
|
||||
return( MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS );
|
||||
return( ECP_TYPE_SHORT_WEIERSTRASS );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -745,7 +745,7 @@ cleanup:
|
|||
while( mbedtls_mpi_cmp_mpi( &N, &grp->P ) >= 0 ) \
|
||||
MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( &N, &N, &grp->P ) )
|
||||
|
||||
#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS)
|
||||
#if defined(ECP_SHORTWEIERSTRASS)
|
||||
/*
|
||||
* For curves in short Weierstrass form, we do all the internal operations in
|
||||
* Jacobian coordinates.
|
||||
|
@ -1080,7 +1080,7 @@ int mbedtls_ecp_add( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
|||
{
|
||||
int ret;
|
||||
|
||||
if( ecp_get_type( grp ) != MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS )
|
||||
if( ecp_get_type( grp ) != ECP_TYPE_SHORT_WEIERSTRASS )
|
||||
return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE );
|
||||
|
||||
MBEDTLS_MPI_CHK( ecp_add_mixed( grp, R, P, Q ) );
|
||||
|
@ -1101,7 +1101,7 @@ int mbedtls_ecp_sub( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
|||
|
||||
mbedtls_ecp_point_init( &mQ );
|
||||
|
||||
if( ecp_get_type( grp ) != MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS )
|
||||
if( ecp_get_type( grp ) != ECP_TYPE_SHORT_WEIERSTRASS )
|
||||
return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE );
|
||||
|
||||
/* mQ = - Q */
|
||||
|
@ -1475,9 +1475,9 @@ cleanup:
|
|||
return( ret );
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS */
|
||||
#endif /* ECP_SHORTWEIERSTRASS */
|
||||
|
||||
#if defined(MBEDTLS_ECP_MONTGOMERY)
|
||||
#if defined(ECP_MONTGOMERY)
|
||||
/*
|
||||
* For Montgomery curves, we do all the internal arithmetic in projective
|
||||
* coordinates. Import/export of points uses only the x coordinates, which is
|
||||
|
@ -1656,7 +1656,7 @@ cleanup:
|
|||
return( ret );
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_ECP_MONTGOMERY */
|
||||
#endif /* ECP_MONTGOMERY */
|
||||
|
||||
/*
|
||||
* Multiplication R = m * P
|
||||
|
@ -1675,18 +1675,18 @@ int mbedtls_ecp_mul( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
|||
( ret = mbedtls_ecp_check_pubkey( grp, P ) ) != 0 )
|
||||
return( ret );
|
||||
|
||||
#if defined(MBEDTLS_ECP_MONTGOMERY)
|
||||
if( ecp_get_type( grp ) == MBEDTLS_ECP_TYPE_MONTGOMERY )
|
||||
#if defined(ECP_MONTGOMERY)
|
||||
if( ecp_get_type( grp ) == ECP_TYPE_MONTGOMERY )
|
||||
return( ecp_mul_mxz( grp, R, m, P, f_rng, p_rng ) );
|
||||
#endif
|
||||
#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS)
|
||||
if( ecp_get_type( grp ) == MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS )
|
||||
#if defined(ECP_SHORTWEIERSTRASS)
|
||||
if( ecp_get_type( grp ) == ECP_TYPE_SHORT_WEIERSTRASS )
|
||||
return( ecp_mul_comb( grp, R, m, P, f_rng, p_rng ) );
|
||||
#endif
|
||||
return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA );
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS)
|
||||
#if defined(ECP_SHORTWEIERSTRASS)
|
||||
/*
|
||||
* Check that an affine point is valid as a public key,
|
||||
* short weierstrass curves (SEC1 3.2.3.1)
|
||||
|
@ -1734,10 +1734,10 @@ cleanup:
|
|||
|
||||
return( ret );
|
||||
}
|
||||
#endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS */
|
||||
#endif /* ECP_SHORTWEIERSTRASS */
|
||||
|
||||
|
||||
#if defined(MBEDTLS_ECP_MONTGOMERY)
|
||||
#if defined(ECP_MONTGOMERY)
|
||||
/*
|
||||
* Check validity of a public key for Montgomery curves with x-only schemes
|
||||
*/
|
||||
|
@ -1749,7 +1749,7 @@ static int ecp_check_pubkey_mx( const mbedtls_ecp_group *grp, const mbedtls_ecp_
|
|||
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_ECP_MONTGOMERY */
|
||||
#endif /* ECP_MONTGOMERY */
|
||||
|
||||
/*
|
||||
* Check that a point is valid as a public key
|
||||
|
@ -1760,12 +1760,12 @@ int mbedtls_ecp_check_pubkey( const mbedtls_ecp_group *grp, const mbedtls_ecp_po
|
|||
if( mbedtls_mpi_cmp_int( &pt->Z, 1 ) != 0 )
|
||||
return( MBEDTLS_ERR_ECP_INVALID_KEY );
|
||||
|
||||
#if defined(MBEDTLS_ECP_MONTGOMERY)
|
||||
if( ecp_get_type( grp ) == MBEDTLS_ECP_TYPE_MONTGOMERY )
|
||||
#if defined(ECP_MONTGOMERY)
|
||||
if( ecp_get_type( grp ) == ECP_TYPE_MONTGOMERY )
|
||||
return( ecp_check_pubkey_mx( grp, pt ) );
|
||||
#endif
|
||||
#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS)
|
||||
if( ecp_get_type( grp ) == MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS )
|
||||
#if defined(ECP_SHORTWEIERSTRASS)
|
||||
if( ecp_get_type( grp ) == ECP_TYPE_SHORT_WEIERSTRASS )
|
||||
return( ecp_check_pubkey_sw( grp, pt ) );
|
||||
#endif
|
||||
return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA );
|
||||
|
@ -1776,8 +1776,8 @@ int mbedtls_ecp_check_pubkey( const mbedtls_ecp_group *grp, const mbedtls_ecp_po
|
|||
*/
|
||||
int mbedtls_ecp_check_privkey( const mbedtls_ecp_group *grp, const mbedtls_mpi *d )
|
||||
{
|
||||
#if defined(MBEDTLS_ECP_MONTGOMERY)
|
||||
if( ecp_get_type( grp ) == MBEDTLS_ECP_TYPE_MONTGOMERY )
|
||||
#if defined(ECP_MONTGOMERY)
|
||||
if( ecp_get_type( grp ) == ECP_TYPE_MONTGOMERY )
|
||||
{
|
||||
/* see [M255] page 5 */
|
||||
if( mbedtls_mpi_get_bit( d, 0 ) != 0 ||
|
||||
|
@ -1788,9 +1788,9 @@ int mbedtls_ecp_check_privkey( const mbedtls_ecp_group *grp, const mbedtls_mpi *
|
|||
else
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_ECP_MONTGOMERY */
|
||||
#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS)
|
||||
if( ecp_get_type( grp ) == MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS )
|
||||
#endif /* ECP_MONTGOMERY */
|
||||
#if defined(ECP_SHORTWEIERSTRASS)
|
||||
if( ecp_get_type( grp ) == ECP_TYPE_SHORT_WEIERSTRASS )
|
||||
{
|
||||
/* see SEC1 3.2 */
|
||||
if( mbedtls_mpi_cmp_int( d, 1 ) < 0 ||
|
||||
|
@ -1799,7 +1799,7 @@ int mbedtls_ecp_check_privkey( const mbedtls_ecp_group *grp, const mbedtls_mpi *
|
|||
else
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS */
|
||||
#endif /* ECP_SHORTWEIERSTRASS */
|
||||
|
||||
return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA );
|
||||
}
|
||||
|
@ -1814,8 +1814,8 @@ int mbedtls_ecp_gen_keypair( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp
|
|||
int ret;
|
||||
size_t n_size = ( grp->nbits + 7 ) / 8;
|
||||
|
||||
#if defined(MBEDTLS_ECP_MONTGOMERY)
|
||||
if( ecp_get_type( grp ) == MBEDTLS_ECP_TYPE_MONTGOMERY )
|
||||
#if defined(ECP_MONTGOMERY)
|
||||
if( ecp_get_type( grp ) == ECP_TYPE_MONTGOMERY )
|
||||
{
|
||||
/* [M225] page 5 */
|
||||
size_t b;
|
||||
|
@ -1835,9 +1835,9 @@ int mbedtls_ecp_gen_keypair( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp
|
|||
MBEDTLS_MPI_CHK( mbedtls_mpi_set_bit( d, 2, 0 ) );
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_ECP_MONTGOMERY */
|
||||
#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS)
|
||||
if( ecp_get_type( grp ) == MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS )
|
||||
#endif /* ECP_MONTGOMERY */
|
||||
#if defined(ECP_SHORTWEIERSTRASS)
|
||||
if( ecp_get_type( grp ) == ECP_TYPE_SHORT_WEIERSTRASS )
|
||||
{
|
||||
/* SEC1 3.2.1: Generate d such that 1 <= n < N */
|
||||
int count = 0;
|
||||
|
@ -1872,7 +1872,7 @@ int mbedtls_ecp_gen_keypair( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp
|
|||
mbedtls_mpi_cmp_mpi( d, &grp->N ) >= 0 );
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS */
|
||||
#endif /* ECP_SHORTWEIERSTRASS */
|
||||
return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA );
|
||||
|
||||
cleanup:
|
||||
|
|
|
@ -1208,7 +1208,7 @@ static void ssl_mac( mbedtls_md_context_t *md_ctx, unsigned char *secret,
|
|||
#if defined(MBEDTLS_ARC4_C) || defined(MBEDTLS_CIPHER_NULL_CIPHER) || \
|
||||
( defined(MBEDTLS_CIPHER_MODE_CBC) && \
|
||||
( defined(MBEDTLS_AES_C) || defined(MBEDTLS_CAMELLIA_C) ) )
|
||||
#define MBEDTLS_SOME_MODES_USE_MAC
|
||||
#define SSL_SOME_MODES_USE_MAC
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -1235,7 +1235,7 @@ static int ssl_encrypt_buf( mbedtls_ssl_context *ssl )
|
|||
/*
|
||||
* Add MAC before if needed
|
||||
*/
|
||||
#if defined(MBEDTLS_SOME_MODES_USE_MAC)
|
||||
#if defined(SSL_SOME_MODES_USE_MAC)
|
||||
if( mode == MBEDTLS_MODE_STREAM ||
|
||||
( mode == MBEDTLS_MODE_CBC
|
||||
#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
|
||||
|
@ -1538,14 +1538,14 @@ static int ssl_encrypt_buf( mbedtls_ssl_context *ssl )
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
#define MBEDTLS_SSL_MAX_MAC_SIZE 48
|
||||
#define SSL_MAX_MAC_SIZE 48
|
||||
|
||||
static int ssl_decrypt_buf( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
size_t i;
|
||||
mbedtls_cipher_mode_t mode;
|
||||
int auth_done = 0;
|
||||
#if defined(MBEDTLS_SOME_MODES_USE_MAC)
|
||||
#if defined(SSL_SOME_MODES_USE_MAC)
|
||||
size_t padlen = 0, correct = 1;
|
||||
#endif
|
||||
|
||||
|
@ -1707,7 +1707,7 @@ static int ssl_decrypt_buf( mbedtls_ssl_context *ssl )
|
|||
#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
|
||||
if( ssl->session_in->encrypt_then_mac == MBEDTLS_SSL_ETM_ENABLED )
|
||||
{
|
||||
unsigned char computed_mac[MBEDTLS_SSL_MAX_MAC_SIZE];
|
||||
unsigned char computed_mac[SSL_MAX_MAC_SIZE];
|
||||
unsigned char pseudo_hdr[13];
|
||||
|
||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "using encrypt then mac" ) );
|
||||
|
@ -1891,10 +1891,10 @@ static int ssl_decrypt_buf( mbedtls_ssl_context *ssl )
|
|||
* Authenticate if not done yet.
|
||||
* Compute the MAC regardless of the padding result (RFC4346, CBCTIME).
|
||||
*/
|
||||
#if defined(MBEDTLS_SOME_MODES_USE_MAC)
|
||||
#if defined(SSL_SOME_MODES_USE_MAC)
|
||||
if( auth_done == 0 )
|
||||
{
|
||||
unsigned char tmp[MBEDTLS_SSL_MAX_MAC_SIZE];
|
||||
unsigned char tmp[SSL_MAX_MAC_SIZE];
|
||||
|
||||
ssl->in_msglen -= ssl->transform_in->maclen;
|
||||
|
||||
|
@ -1976,7 +1976,7 @@ static int ssl_decrypt_buf( mbedtls_ssl_context *ssl )
|
|||
if( correct == 0 )
|
||||
return( MBEDTLS_ERR_SSL_INVALID_MAC );
|
||||
}
|
||||
#endif /* MBEDTLS_SOME_MODES_USE_MAC */
|
||||
#endif /* SSL_SOME_MODES_USE_MAC */
|
||||
|
||||
/* Make extra sure authentication was performed, exactly once */
|
||||
if( auth_done != 1 )
|
||||
|
|
|
@ -62,10 +62,10 @@ struct _hr_time
|
|||
|
||||
#endif /* _WIN32 && !EFIX64 && !EFI32 */
|
||||
|
||||
#if !defined(MBEDTLS_HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \
|
||||
#if !defined(HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \
|
||||
( defined(_MSC_VER) && defined(_M_IX86) ) || defined(__WATCOMC__)
|
||||
|
||||
#define MBEDTLS_HAVE_HARDCLOCK
|
||||
#define HAVE_HARDCLOCK
|
||||
|
||||
unsigned long mbedtls_timing_hardclock( void )
|
||||
{
|
||||
|
@ -74,15 +74,15 @@ unsigned long mbedtls_timing_hardclock( void )
|
|||
__asm mov [tsc], eax
|
||||
return( tsc );
|
||||
}
|
||||
#endif /* !MBEDTLS_HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
|
||||
#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
|
||||
( _MSC_VER && _M_IX86 ) || __WATCOMC__ */
|
||||
|
||||
/* some versions of mingw-64 have 32-bit longs even on x84_64 */
|
||||
#if !defined(MBEDTLS_HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \
|
||||
#if !defined(HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \
|
||||
defined(__GNUC__) && ( defined(__i386__) || ( \
|
||||
( defined(__amd64__) || defined( __x86_64__) ) && __SIZEOF_LONG__ == 4 ) )
|
||||
|
||||
#define MBEDTLS_HAVE_HARDCLOCK
|
||||
#define HAVE_HARDCLOCK
|
||||
|
||||
unsigned long mbedtls_timing_hardclock( void )
|
||||
{
|
||||
|
@ -90,13 +90,13 @@ unsigned long mbedtls_timing_hardclock( void )
|
|||
asm volatile( "rdtsc" : "=a" (lo), "=d" (hi) );
|
||||
return( lo );
|
||||
}
|
||||
#endif /* !MBEDTLS_HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
|
||||
#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
|
||||
__GNUC__ && __i386__ */
|
||||
|
||||
#if !defined(MBEDTLS_HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \
|
||||
#if !defined(HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \
|
||||
defined(__GNUC__) && ( defined(__amd64__) || defined(__x86_64__) )
|
||||
|
||||
#define MBEDTLS_HAVE_HARDCLOCK
|
||||
#define HAVE_HARDCLOCK
|
||||
|
||||
unsigned long mbedtls_timing_hardclock( void )
|
||||
{
|
||||
|
@ -104,13 +104,13 @@ unsigned long mbedtls_timing_hardclock( void )
|
|||
asm volatile( "rdtsc" : "=a" (lo), "=d" (hi) );
|
||||
return( lo | ( hi << 32 ) );
|
||||
}
|
||||
#endif /* !MBEDTLS_HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
|
||||
#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
|
||||
__GNUC__ && ( __amd64__ || __x86_64__ ) */
|
||||
|
||||
#if !defined(MBEDTLS_HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \
|
||||
#if !defined(HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \
|
||||
defined(__GNUC__) && ( defined(__powerpc__) || defined(__ppc__) )
|
||||
|
||||
#define MBEDTLS_HAVE_HARDCLOCK
|
||||
#define HAVE_HARDCLOCK
|
||||
|
||||
unsigned long mbedtls_timing_hardclock( void )
|
||||
{
|
||||
|
@ -126,16 +126,16 @@ unsigned long mbedtls_timing_hardclock( void )
|
|||
|
||||
return( tbl );
|
||||
}
|
||||
#endif /* !MBEDTLS_HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
|
||||
#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
|
||||
__GNUC__ && ( __powerpc__ || __ppc__ ) */
|
||||
|
||||
#if !defined(MBEDTLS_HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \
|
||||
#if !defined(HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \
|
||||
defined(__GNUC__) && defined(__sparc64__)
|
||||
|
||||
#if defined(__OpenBSD__)
|
||||
#warning OpenBSD does not allow access to tick register using software version instead
|
||||
#else
|
||||
#define MBEDTLS_HAVE_HARDCLOCK
|
||||
#define HAVE_HARDCLOCK
|
||||
|
||||
unsigned long mbedtls_timing_hardclock( void )
|
||||
{
|
||||
|
@ -144,13 +144,13 @@ unsigned long mbedtls_timing_hardclock( void )
|
|||
return( tick );
|
||||
}
|
||||
#endif /* __OpenBSD__ */
|
||||
#endif /* !MBEDTLS_HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
|
||||
#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
|
||||
__GNUC__ && __sparc64__ */
|
||||
|
||||
#if !defined(MBEDTLS_HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \
|
||||
#if !defined(HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \
|
||||
defined(__GNUC__) && defined(__sparc__) && !defined(__sparc64__)
|
||||
|
||||
#define MBEDTLS_HAVE_HARDCLOCK
|
||||
#define HAVE_HARDCLOCK
|
||||
|
||||
unsigned long mbedtls_timing_hardclock( void )
|
||||
{
|
||||
|
@ -159,13 +159,13 @@ unsigned long mbedtls_timing_hardclock( void )
|
|||
asm volatile( "mov %%g1, %0" : "=r" (tick) );
|
||||
return( tick );
|
||||
}
|
||||
#endif /* !MBEDTLS_HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
|
||||
#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
|
||||
__GNUC__ && __sparc__ && !__sparc64__ */
|
||||
|
||||
#if !defined(MBEDTLS_HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \
|
||||
#if !defined(HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \
|
||||
defined(__GNUC__) && defined(__alpha__)
|
||||
|
||||
#define MBEDTLS_HAVE_HARDCLOCK
|
||||
#define HAVE_HARDCLOCK
|
||||
|
||||
unsigned long mbedtls_timing_hardclock( void )
|
||||
{
|
||||
|
@ -173,13 +173,13 @@ unsigned long mbedtls_timing_hardclock( void )
|
|||
asm volatile( "rpcc %0" : "=r" (cc) );
|
||||
return( cc & 0xFFFFFFFF );
|
||||
}
|
||||
#endif /* !MBEDTLS_HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
|
||||
#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
|
||||
__GNUC__ && __alpha__ */
|
||||
|
||||
#if !defined(MBEDTLS_HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \
|
||||
#if !defined(HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \
|
||||
defined(__GNUC__) && defined(__ia64__)
|
||||
|
||||
#define MBEDTLS_HAVE_HARDCLOCK
|
||||
#define HAVE_HARDCLOCK
|
||||
|
||||
unsigned long mbedtls_timing_hardclock( void )
|
||||
{
|
||||
|
@ -187,13 +187,13 @@ unsigned long mbedtls_timing_hardclock( void )
|
|||
asm volatile( "mov %0 = ar.itc" : "=r" (itc) );
|
||||
return( itc );
|
||||
}
|
||||
#endif /* !MBEDTLS_HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
|
||||
#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
|
||||
__GNUC__ && __ia64__ */
|
||||
|
||||
#if !defined(MBEDTLS_HAVE_HARDCLOCK) && defined(_MSC_VER) && \
|
||||
#if !defined(HAVE_HARDCLOCK) && defined(_MSC_VER) && \
|
||||
!defined(EFIX64) && !defined(EFI32)
|
||||
|
||||
#define MBEDTLS_HAVE_HARDCLOCK
|
||||
#define HAVE_HARDCLOCK
|
||||
|
||||
unsigned long mbedtls_timing_hardclock( void )
|
||||
{
|
||||
|
@ -203,11 +203,11 @@ unsigned long mbedtls_timing_hardclock( void )
|
|||
|
||||
return( (unsigned long)( offset.QuadPart ) );
|
||||
}
|
||||
#endif /* !MBEDTLS_HAVE_HARDCLOCK && _MSC_VER && !EFIX64 && !EFI32 */
|
||||
#endif /* !HAVE_HARDCLOCK && _MSC_VER && !EFIX64 && !EFI32 */
|
||||
|
||||
#if !defined(MBEDTLS_HAVE_HARDCLOCK)
|
||||
#if !defined(HAVE_HARDCLOCK)
|
||||
|
||||
#define MBEDTLS_HAVE_HARDCLOCK
|
||||
#define HAVE_HARDCLOCK
|
||||
|
||||
static int hardclock_init = 0;
|
||||
static struct timeval tv_init;
|
||||
|
@ -226,7 +226,7 @@ unsigned long mbedtls_timing_hardclock( void )
|
|||
return( ( tv_cur.tv_sec - tv_init.tv_sec ) * 1000000
|
||||
+ ( tv_cur.tv_usec - tv_init.tv_usec ) );
|
||||
}
|
||||
#endif /* !MBEDTLS_HAVE_HARDCLOCK */
|
||||
#endif /* !HAVE_HARDCLOCK */
|
||||
|
||||
volatile int mbedtls_timing_alarmed = 0;
|
||||
|
||||
|
|
|
@ -702,7 +702,7 @@ static int compat_snprintf( char *str, size_t size, const char *format, ... )
|
|||
#define snprintf compat_snprintf
|
||||
#endif /* _MSC_VER && !snprintf && !EFIX64 && !EFI32 */
|
||||
|
||||
#define MBEDTLS_ERR_DEBUG_BUF_TOO_SMALL -2
|
||||
#define ERR_BUF_TOO_SMALL -2
|
||||
|
||||
#define SAFE_SNPRINTF() \
|
||||
{ \
|
||||
|
@ -711,7 +711,7 @@ static int compat_snprintf( char *str, size_t size, const char *format, ... )
|
|||
\
|
||||
if( (unsigned int) ret > n ) { \
|
||||
p[n - 1] = '\0'; \
|
||||
return( MBEDTLS_ERR_DEBUG_BUF_TOO_SMALL ); \
|
||||
return( ERR_BUF_TOO_SMALL ); \
|
||||
} \
|
||||
\
|
||||
n -= (unsigned int) ret; \
|
||||
|
@ -870,7 +870,7 @@ int mbedtls_x509_key_size_helper( char *buf, size_t size, const char *name )
|
|||
int ret;
|
||||
|
||||
if( strlen( name ) + sizeof( " key size" ) > size )
|
||||
return( MBEDTLS_ERR_DEBUG_BUF_TOO_SMALL );
|
||||
return( ERR_BUF_TOO_SMALL );
|
||||
|
||||
ret = mbedtls_snprintf( p, n, "%s key size", name );
|
||||
SAFE_SNPRINTF();
|
||||
|
|
|
@ -598,7 +598,7 @@ static int compat_snprintf( char *str, size_t size, const char *format, ... )
|
|||
#define snprintf compat_snprintf
|
||||
#endif /* _MSC_VER && !snprintf && !EFIX64 && !EFI32 */
|
||||
|
||||
#define MBEDTLS_ERR_DEBUG_BUF_TOO_SMALL -2
|
||||
#define ERR_BUF_TOO_SMALL -2
|
||||
|
||||
#define SAFE_SNPRINTF() \
|
||||
{ \
|
||||
|
@ -607,7 +607,7 @@ static int compat_snprintf( char *str, size_t size, const char *format, ... )
|
|||
\
|
||||
if( (unsigned int) ret > n ) { \
|
||||
p[n - 1] = '\0'; \
|
||||
return( MBEDTLS_ERR_DEBUG_BUF_TOO_SMALL ); \
|
||||
return( ERR_BUF_TOO_SMALL ); \
|
||||
} \
|
||||
\
|
||||
n -= (unsigned int) ret; \
|
||||
|
|
|
@ -1108,7 +1108,7 @@ static int compat_snprintf( char *str, size_t size, const char *format, ... )
|
|||
#define snprintf compat_snprintf
|
||||
#endif /* _MSC_VER && !snprintf && !EFIX64 && !EFI32 */
|
||||
|
||||
#define MBEDTLS_ERR_DEBUG_BUF_TOO_SMALL -2
|
||||
#define ERR_BUF_TOO_SMALL -2
|
||||
|
||||
#define SAFE_SNPRINTF() \
|
||||
{ \
|
||||
|
@ -1117,7 +1117,7 @@ static int compat_snprintf( char *str, size_t size, const char *format, ... )
|
|||
\
|
||||
if( (unsigned int) ret > n ) { \
|
||||
p[n - 1] = '\0'; \
|
||||
return( MBEDTLS_ERR_DEBUG_BUF_TOO_SMALL ); \
|
||||
return( ERR_BUF_TOO_SMALL ); \
|
||||
} \
|
||||
\
|
||||
n -= (unsigned int) ret; \
|
||||
|
@ -1139,7 +1139,7 @@ static int x509_info_subject_alt_name( char **buf, size_t *size,
|
|||
if( cur->buf.len + sep_len >= n )
|
||||
{
|
||||
*p = '\0';
|
||||
return( MBEDTLS_ERR_DEBUG_BUF_TOO_SMALL );
|
||||
return( ERR_BUF_TOO_SMALL );
|
||||
}
|
||||
|
||||
n -= cur->buf.len + sep_len;
|
||||
|
|
|
@ -358,7 +358,7 @@ static int compat_snprintf( char *str, size_t size, const char *format, ... )
|
|||
#define snprintf compat_snprintf
|
||||
#endif /* _MSC_VER && !snprintf && !EFIX64 && !EFI32 */
|
||||
|
||||
#define MBEDTLS_ERR_DEBUG_BUF_TOO_SMALL -2
|
||||
#define ERR_BUF_TOO_SMALL -2
|
||||
|
||||
#define SAFE_SNPRINTF() \
|
||||
{ \
|
||||
|
@ -367,7 +367,7 @@ static int compat_snprintf( char *str, size_t size, const char *format, ... )
|
|||
\
|
||||
if( (unsigned int) ret > n ) { \
|
||||
p[n - 1] = '\0'; \
|
||||
return( MBEDTLS_ERR_DEBUG_BUF_TOO_SMALL ); \
|
||||
return( ERR_BUF_TOO_SMALL ); \
|
||||
} \
|
||||
\
|
||||
n -= (unsigned int) ret; \
|
||||
|
|
Loading…
Reference in a new issue