mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-02-24 15:56:46 +00:00
Prefixed macros with MBEDTLS
As per tests/scripts/check-names.sh, macros in library/ header files should be prefixed with MBEDTLS_ The macro functions in common.h where also indented to comply with the same test Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
This commit is contained in:
parent
888a141e70
commit
2bbafda1f8
|
@ -567,7 +567,7 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
|
|||
|
||||
for( i = 0; i < ( keybits >> 5 ); i++ )
|
||||
{
|
||||
GET_UINT32_LE( RK[i], key, i << 2 );
|
||||
MBEDTLS_GET_UINT32_LE( RK[i], key, i << 2 );
|
||||
}
|
||||
|
||||
switch( ctx->nr )
|
||||
|
@ -850,10 +850,10 @@ int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx,
|
|||
uint32_t Y[4];
|
||||
} t;
|
||||
|
||||
GET_UINT32_LE( t.X[0], input, 0 ); t.X[0] ^= *RK++;
|
||||
GET_UINT32_LE( t.X[1], input, 4 ); t.X[1] ^= *RK++;
|
||||
GET_UINT32_LE( t.X[2], input, 8 ); t.X[2] ^= *RK++;
|
||||
GET_UINT32_LE( t.X[3], input, 12 ); t.X[3] ^= *RK++;
|
||||
MBEDTLS_GET_UINT32_LE( t.X[0], input, 0 ); t.X[0] ^= *RK++;
|
||||
MBEDTLS_GET_UINT32_LE( t.X[1], input, 4 ); t.X[1] ^= *RK++;
|
||||
MBEDTLS_GET_UINT32_LE( t.X[2], input, 8 ); t.X[2] ^= *RK++;
|
||||
MBEDTLS_GET_UINT32_LE( t.X[3], input, 12 ); t.X[3] ^= *RK++;
|
||||
|
||||
for( i = ( ctx->nr >> 1 ) - 1; i > 0; i-- )
|
||||
{
|
||||
|
@ -887,10 +887,10 @@ int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx,
|
|||
( (uint32_t) FSb[ ( t.Y[1] >> 16 ) & 0xFF ] << 16 ) ^
|
||||
( (uint32_t) FSb[ ( t.Y[2] >> 24 ) & 0xFF ] << 24 );
|
||||
|
||||
PUT_UINT32_LE( t.X[0], output, 0 );
|
||||
PUT_UINT32_LE( t.X[1], output, 4 );
|
||||
PUT_UINT32_LE( t.X[2], output, 8 );
|
||||
PUT_UINT32_LE( t.X[3], output, 12 );
|
||||
MBEDTLS_PUT_UINT32_LE( t.X[0], output, 0 );
|
||||
MBEDTLS_PUT_UINT32_LE( t.X[1], output, 4 );
|
||||
MBEDTLS_PUT_UINT32_LE( t.X[2], output, 8 );
|
||||
MBEDTLS_PUT_UINT32_LE( t.X[3], output, 12 );
|
||||
|
||||
mbedtls_platform_zeroize( &t, sizeof( t ) );
|
||||
|
||||
|
@ -923,10 +923,10 @@ int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx,
|
|||
uint32_t Y[4];
|
||||
} t;
|
||||
|
||||
GET_UINT32_LE( t.X[0], input, 0 ); t.X[0] ^= *RK++;
|
||||
GET_UINT32_LE( t.X[1], input, 4 ); t.X[1] ^= *RK++;
|
||||
GET_UINT32_LE( t.X[2], input, 8 ); t.X[2] ^= *RK++;
|
||||
GET_UINT32_LE( t.X[3], input, 12 ); t.X[3] ^= *RK++;
|
||||
MBEDTLS_GET_UINT32_LE( t.X[0], input, 0 ); t.X[0] ^= *RK++;
|
||||
MBEDTLS_GET_UINT32_LE( t.X[1], input, 4 ); t.X[1] ^= *RK++;
|
||||
MBEDTLS_GET_UINT32_LE( t.X[2], input, 8 ); t.X[2] ^= *RK++;
|
||||
MBEDTLS_GET_UINT32_LE( t.X[3], input, 12 ); t.X[3] ^= *RK++;
|
||||
|
||||
for( i = ( ctx->nr >> 1 ) - 1; i > 0; i-- )
|
||||
{
|
||||
|
@ -960,10 +960,10 @@ int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx,
|
|||
( (uint32_t) RSb[ ( t.Y[1] >> 16 ) & 0xFF ] << 16 ) ^
|
||||
( (uint32_t) RSb[ ( t.Y[0] >> 24 ) & 0xFF ] << 24 );
|
||||
|
||||
PUT_UINT32_LE( t.X[0], output, 0 );
|
||||
PUT_UINT32_LE( t.X[1], output, 4 );
|
||||
PUT_UINT32_LE( t.X[2], output, 8 );
|
||||
PUT_UINT32_LE( t.X[3], output, 12 );
|
||||
MBEDTLS_PUT_UINT32_LE( t.X[0], output, 0 );
|
||||
MBEDTLS_PUT_UINT32_LE( t.X[1], output, 4 );
|
||||
MBEDTLS_PUT_UINT32_LE( t.X[2], output, 8 );
|
||||
MBEDTLS_PUT_UINT32_LE( t.X[3], output, 12 );
|
||||
|
||||
mbedtls_platform_zeroize( &t, sizeof( t ) );
|
||||
|
||||
|
|
|
@ -385,7 +385,7 @@ static void aria_fe_xor( uint32_t r[4], const uint32_t p[4],
|
|||
* Big endian 128-bit rotation: r = a ^ (b <<< n), used only in key setup.
|
||||
*
|
||||
* We chose to store bytes into 32-bit words in little-endian format (see
|
||||
* GET/PUT_UINT32_LE) so we need to reverse bytes here.
|
||||
* GET/MBEDTLS_PUT_UINT32_LE) so we need to reverse bytes here.
|
||||
*/
|
||||
static void aria_rot128( uint32_t r[4], const uint32_t a[4],
|
||||
const uint32_t b[4], uint8_t n )
|
||||
|
@ -433,21 +433,21 @@ int mbedtls_aria_setkey_enc( mbedtls_aria_context *ctx,
|
|||
return( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA );
|
||||
|
||||
/* Copy key to W0 (and potential remainder to W1) */
|
||||
GET_UINT32_LE( w[0][0], key, 0 );
|
||||
GET_UINT32_LE( w[0][1], key, 4 );
|
||||
GET_UINT32_LE( w[0][2], key, 8 );
|
||||
GET_UINT32_LE( w[0][3], key, 12 );
|
||||
MBEDTLS_GET_UINT32_LE( w[0][0], key, 0 );
|
||||
MBEDTLS_GET_UINT32_LE( w[0][1], key, 4 );
|
||||
MBEDTLS_GET_UINT32_LE( w[0][2], key, 8 );
|
||||
MBEDTLS_GET_UINT32_LE( w[0][3], key, 12 );
|
||||
|
||||
memset( w[1], 0, 16 );
|
||||
if( keybits >= 192 )
|
||||
{
|
||||
GET_UINT32_LE( w[1][0], key, 16 ); // 192 bit key
|
||||
GET_UINT32_LE( w[1][1], key, 20 );
|
||||
MBEDTLS_GET_UINT32_LE( w[1][0], key, 16 ); // 192 bit key
|
||||
MBEDTLS_GET_UINT32_LE( w[1][1], key, 20 );
|
||||
}
|
||||
if( keybits == 256 )
|
||||
{
|
||||
GET_UINT32_LE( w[1][2], key, 24 ); // 256 bit key
|
||||
GET_UINT32_LE( w[1][3], key, 28 );
|
||||
MBEDTLS_GET_UINT32_LE( w[1][2], key, 24 ); // 256 bit key
|
||||
MBEDTLS_GET_UINT32_LE( w[1][3], key, 28 );
|
||||
}
|
||||
|
||||
i = ( keybits - 128 ) >> 6; // index: 0, 1, 2
|
||||
|
@ -524,10 +524,10 @@ int mbedtls_aria_crypt_ecb( mbedtls_aria_context *ctx,
|
|||
ARIA_VALIDATE_RET( input != NULL );
|
||||
ARIA_VALIDATE_RET( output != NULL );
|
||||
|
||||
GET_UINT32_LE( a, input, 0 );
|
||||
GET_UINT32_LE( b, input, 4 );
|
||||
GET_UINT32_LE( c, input, 8 );
|
||||
GET_UINT32_LE( d, input, 12 );
|
||||
MBEDTLS_GET_UINT32_LE( a, input, 0 );
|
||||
MBEDTLS_GET_UINT32_LE( b, input, 4 );
|
||||
MBEDTLS_GET_UINT32_LE( c, input, 8 );
|
||||
MBEDTLS_GET_UINT32_LE( d, input, 12 );
|
||||
|
||||
i = 0;
|
||||
while( 1 )
|
||||
|
@ -559,10 +559,10 @@ int mbedtls_aria_crypt_ecb( mbedtls_aria_context *ctx,
|
|||
c ^= ctx->rk[i][2];
|
||||
d ^= ctx->rk[i][3];
|
||||
|
||||
PUT_UINT32_LE( a, output, 0 );
|
||||
PUT_UINT32_LE( b, output, 4 );
|
||||
PUT_UINT32_LE( c, output, 8 );
|
||||
PUT_UINT32_LE( d, output, 12 );
|
||||
MBEDTLS_PUT_UINT32_LE( a, output, 0 );
|
||||
MBEDTLS_PUT_UINT32_LE( b, output, 4 );
|
||||
MBEDTLS_PUT_UINT32_LE( c, output, 8 );
|
||||
MBEDTLS_PUT_UINT32_LE( d, output, 12 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
|
|
@ -353,8 +353,8 @@ int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx,
|
|||
* Prepare SIGMA values
|
||||
*/
|
||||
for( i = 0; i < 6; i++ ) {
|
||||
GET_UINT32_BE( SIGMA[i][0], SIGMA_CHARS[i], 0 );
|
||||
GET_UINT32_BE( SIGMA[i][1], SIGMA_CHARS[i], 4 );
|
||||
MBEDTLS_GET_UINT32_BE( SIGMA[i][0], SIGMA_CHARS[i], 0 );
|
||||
MBEDTLS_GET_UINT32_BE( SIGMA[i][1], SIGMA_CHARS[i], 4 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -365,7 +365,7 @@ int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx,
|
|||
|
||||
/* Store KL, KR */
|
||||
for( i = 0; i < 8; i++ )
|
||||
GET_UINT32_BE( KC[i], t, i * 4 );
|
||||
MBEDTLS_GET_UINT32_BE( KC[i], t, i * 4 );
|
||||
|
||||
/* Generate KA */
|
||||
for( i = 0; i < 4; ++i )
|
||||
|
@ -491,10 +491,10 @@ int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx,
|
|||
NR = ctx->nr;
|
||||
RK = ctx->rk;
|
||||
|
||||
GET_UINT32_BE( X[0], input, 0 );
|
||||
GET_UINT32_BE( X[1], input, 4 );
|
||||
GET_UINT32_BE( X[2], input, 8 );
|
||||
GET_UINT32_BE( X[3], input, 12 );
|
||||
MBEDTLS_GET_UINT32_BE( X[0], input, 0 );
|
||||
MBEDTLS_GET_UINT32_BE( X[1], input, 4 );
|
||||
MBEDTLS_GET_UINT32_BE( X[2], input, 8 );
|
||||
MBEDTLS_GET_UINT32_BE( X[3], input, 12 );
|
||||
|
||||
X[0] ^= *RK++;
|
||||
X[1] ^= *RK++;
|
||||
|
@ -529,10 +529,10 @@ int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx,
|
|||
X[0] ^= *RK++;
|
||||
X[1] ^= *RK++;
|
||||
|
||||
PUT_UINT32_BE( X[2], output, 0 );
|
||||
PUT_UINT32_BE( X[3], output, 4 );
|
||||
PUT_UINT32_BE( X[0], output, 8 );
|
||||
PUT_UINT32_BE( X[1], output, 12 );
|
||||
MBEDTLS_PUT_UINT32_BE( X[2], output, 0 );
|
||||
MBEDTLS_PUT_UINT32_BE( X[3], output, 4 );
|
||||
MBEDTLS_PUT_UINT32_BE( X[0], output, 8 );
|
||||
MBEDTLS_PUT_UINT32_BE( X[1], output, 12 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
|
|
@ -205,14 +205,14 @@ int mbedtls_chacha20_setkey( mbedtls_chacha20_context *ctx,
|
|||
ctx->state[3] = 0x6b206574;
|
||||
|
||||
/* Set key */
|
||||
ctx->state[4] = BYTES_TO_U32_LE( key, 0 );
|
||||
ctx->state[5] = BYTES_TO_U32_LE( key, 4 );
|
||||
ctx->state[6] = BYTES_TO_U32_LE( key, 8 );
|
||||
ctx->state[7] = BYTES_TO_U32_LE( key, 12 );
|
||||
ctx->state[8] = BYTES_TO_U32_LE( key, 16 );
|
||||
ctx->state[9] = BYTES_TO_U32_LE( key, 20 );
|
||||
ctx->state[10] = BYTES_TO_U32_LE( key, 24 );
|
||||
ctx->state[11] = BYTES_TO_U32_LE( key, 28 );
|
||||
ctx->state[4] = MBEDTLS_BYTES_TO_U32_LE( key, 0 );
|
||||
ctx->state[5] = MBEDTLS_BYTES_TO_U32_LE( key, 4 );
|
||||
ctx->state[6] = MBEDTLS_BYTES_TO_U32_LE( key, 8 );
|
||||
ctx->state[7] = MBEDTLS_BYTES_TO_U32_LE( key, 12 );
|
||||
ctx->state[8] = MBEDTLS_BYTES_TO_U32_LE( key, 16 );
|
||||
ctx->state[9] = MBEDTLS_BYTES_TO_U32_LE( key, 20 );
|
||||
ctx->state[10] = MBEDTLS_BYTES_TO_U32_LE( key, 24 );
|
||||
ctx->state[11] = MBEDTLS_BYTES_TO_U32_LE( key, 28 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
@ -228,9 +228,9 @@ int mbedtls_chacha20_starts( mbedtls_chacha20_context* ctx,
|
|||
ctx->state[12] = counter;
|
||||
|
||||
/* Nonce */
|
||||
ctx->state[13] = BYTES_TO_U32_LE( nonce, 0 );
|
||||
ctx->state[14] = BYTES_TO_U32_LE( nonce, 4 );
|
||||
ctx->state[15] = BYTES_TO_U32_LE( nonce, 8 );
|
||||
ctx->state[13] = MBEDTLS_BYTES_TO_U32_LE( nonce, 0 );
|
||||
ctx->state[14] = MBEDTLS_BYTES_TO_U32_LE( nonce, 4 );
|
||||
ctx->state[15] = MBEDTLS_BYTES_TO_U32_LE( nonce, 8 );
|
||||
|
||||
mbedtls_platform_zeroize( ctx->keystream8, sizeof( ctx->keystream8 ) );
|
||||
|
||||
|
|
|
@ -62,61 +62,61 @@
|
|||
* To tidy up code and save horizontal and vertical space, use byte
|
||||
* reading macros to cast
|
||||
*/
|
||||
#define BYTE_0( x ) ( (uint8_t) ( ( x ) & 0xff ) )
|
||||
#define BYTE_1( x ) ( (uint8_t) ( ( ( x ) >> 8 ) & 0xff ) )
|
||||
#define BYTE_2( x ) ( (uint8_t) ( ( ( x ) >> 16 ) & 0xff ) )
|
||||
#define BYTE_3( x ) ( (uint8_t) ( ( ( x ) >> 24 ) & 0xff ) )
|
||||
#define MBEDTLS_BYTE_0( x ) ( (uint8_t) ( ( x ) & 0xff ) )
|
||||
#define MBEDTLS_BYTE_1( x ) ( (uint8_t) ( ( ( x ) >> 8 ) & 0xff ) )
|
||||
#define MBEDTLS_BYTE_2( x ) ( (uint8_t) ( ( ( x ) >> 16 ) & 0xff ) )
|
||||
#define MBEDTLS_BYTE_3( x ) ( (uint8_t) ( ( ( x ) >> 24 ) & 0xff ) )
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (big endian)
|
||||
*/
|
||||
#ifndef GET_UINT32_BE
|
||||
#define GET_UINT32_BE(n,b,i) \
|
||||
do { \
|
||||
(n) = ( (uint32_t) (b)[(i) ] << 24 ) \
|
||||
| ( (uint32_t) (b)[(i) + 1] << 16 ) \
|
||||
| ( (uint32_t) (b)[(i) + 2] << 8 ) \
|
||||
| ( (uint32_t) (b)[(i) + 3] ); \
|
||||
} while( 0 )
|
||||
#ifndef MBEDTLS_GET_UINT32_BE
|
||||
#define MBEDTLS_GET_UINT32_BE(n,b,i) \
|
||||
do { \
|
||||
(n) = ( (uint32_t) (b)[(i) ] << 24 ) \
|
||||
| ( (uint32_t) (b)[(i) + 1] << 16 ) \
|
||||
| ( (uint32_t) (b)[(i) + 2] << 8 ) \
|
||||
| ( (uint32_t) (b)[(i) + 3] ); \
|
||||
} while( 0 )
|
||||
#endif
|
||||
|
||||
#ifndef PUT_UINT32_BE
|
||||
#define PUT_UINT32_BE(n,b,i) \
|
||||
do { \
|
||||
(b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
|
||||
(b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
|
||||
(b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
|
||||
(b)[(i) + 3] = (unsigned char) ( (n) ); \
|
||||
} while( 0 )
|
||||
#ifndef MBEDTLS_PUT_UINT32_BE
|
||||
#define MBEDTLS_PUT_UINT32_BE(n,b,i) \
|
||||
do { \
|
||||
(b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
|
||||
(b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
|
||||
(b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
|
||||
(b)[(i) + 3] = (unsigned char) ( (n) ); \
|
||||
} while( 0 )
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (little endian)
|
||||
*/
|
||||
#ifndef GET_UINT32_LE
|
||||
#define GET_UINT32_LE(n,b,i) \
|
||||
do { \
|
||||
(n) = ( (uint32_t) (b)[(i) ] ) \
|
||||
| ( (uint32_t) (b)[(i) + 1] << 8 ) \
|
||||
| ( (uint32_t) (b)[(i) + 2] << 16 ) \
|
||||
| ( (uint32_t) (b)[(i) + 3] << 24 ); \
|
||||
} while( 0 )
|
||||
#ifndef MBEDTLS_GET_UINT32_LE
|
||||
#define MBEDTLS_GET_UINT32_LE(n,b,i) \
|
||||
do { \
|
||||
(n) = ( (uint32_t) (b)[(i) ] ) \
|
||||
| ( (uint32_t) (b)[(i) + 1] << 8 ) \
|
||||
| ( (uint32_t) (b)[(i) + 2] << 16 ) \
|
||||
| ( (uint32_t) (b)[(i) + 3] << 24 ); \
|
||||
} while( 0 )
|
||||
#endif
|
||||
|
||||
#ifndef PUT_UINT32_LE
|
||||
#define PUT_UINT32_LE(n,b,i) \
|
||||
do { \
|
||||
(b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \
|
||||
(b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \
|
||||
(b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \
|
||||
(b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \
|
||||
} while( 0 )
|
||||
#ifndef MBEDTLS_PUT_UINT32_LE
|
||||
#define MBEDTLS_PUT_UINT32_LE(n,b,i) \
|
||||
do { \
|
||||
(b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \
|
||||
(b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \
|
||||
(b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \
|
||||
(b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \
|
||||
} while( 0 )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* 32-bit integer conversion from bytes (little endian)
|
||||
*/
|
||||
#define BYTES_TO_U32_LE( data, offset ) \
|
||||
#define MBEDTLS_BYTES_TO_U32_LE( data, offset ) \
|
||||
( (uint32_t) (data)[offset] \
|
||||
| (uint32_t) ( (uint32_t) (data)[( offset ) + 1] << 8 ) \
|
||||
| (uint32_t) ( (uint32_t) (data)[( offset ) + 2] << 16 ) \
|
||||
|
|
|
@ -152,10 +152,10 @@ static int block_cipher_df( unsigned char *output,
|
|||
* (Total is padded to a multiple of 16-bytes with zeroes)
|
||||
*/
|
||||
p = buf + MBEDTLS_CTR_DRBG_BLOCKSIZE;
|
||||
*p++ = BYTE_3( data_len );
|
||||
*p++ = BYTE_2( data_len );
|
||||
*p++ = BYTE_1( data_len );
|
||||
*p++ = BYTE_0( data_len );
|
||||
*p++ = MBEDTLS_BYTE_3( data_len );
|
||||
*p++ = MBEDTLS_BYTE_2( data_len );
|
||||
*p++ = MBEDTLS_BYTE_1( data_len );
|
||||
*p++ = MBEDTLS_BYTE_0( data_len );
|
||||
p += 3;
|
||||
*p++ = MBEDTLS_CTR_DRBG_SEEDLEN;
|
||||
memcpy( p, data, data_len );
|
||||
|
|
|
@ -400,8 +400,8 @@ void mbedtls_des_setkey( uint32_t SK[32], const unsigned char key[MBEDTLS_DES_KE
|
|||
int i;
|
||||
uint32_t X, Y, T;
|
||||
|
||||
GET_UINT32_BE( X, key, 0 );
|
||||
GET_UINT32_BE( Y, key, 4 );
|
||||
MBEDTLS_GET_UINT32_BE( X, key, 0 );
|
||||
MBEDTLS_GET_UINT32_BE( Y, key, 4 );
|
||||
|
||||
/*
|
||||
* Permuted Choice 1
|
||||
|
@ -610,8 +610,8 @@ int mbedtls_des_crypt_ecb( mbedtls_des_context *ctx,
|
|||
|
||||
SK = ctx->sk;
|
||||
|
||||
GET_UINT32_BE( X, input, 0 );
|
||||
GET_UINT32_BE( Y, input, 4 );
|
||||
MBEDTLS_GET_UINT32_BE( X, input, 0 );
|
||||
MBEDTLS_GET_UINT32_BE( Y, input, 4 );
|
||||
|
||||
DES_IP( X, Y );
|
||||
|
||||
|
@ -623,8 +623,8 @@ int mbedtls_des_crypt_ecb( mbedtls_des_context *ctx,
|
|||
|
||||
DES_FP( Y, X );
|
||||
|
||||
PUT_UINT32_BE( Y, output, 0 );
|
||||
PUT_UINT32_BE( X, output, 4 );
|
||||
MBEDTLS_PUT_UINT32_BE( Y, output, 0 );
|
||||
MBEDTLS_PUT_UINT32_BE( X, output, 4 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
@ -697,8 +697,8 @@ int mbedtls_des3_crypt_ecb( mbedtls_des3_context *ctx,
|
|||
|
||||
SK = ctx->sk;
|
||||
|
||||
GET_UINT32_BE( X, input, 0 );
|
||||
GET_UINT32_BE( Y, input, 4 );
|
||||
MBEDTLS_GET_UINT32_BE( X, input, 0 );
|
||||
MBEDTLS_GET_UINT32_BE( Y, input, 4 );
|
||||
|
||||
DES_IP( X, Y );
|
||||
|
||||
|
@ -722,8 +722,8 @@ int mbedtls_des3_crypt_ecb( mbedtls_des3_context *ctx,
|
|||
|
||||
DES_FP( Y, X );
|
||||
|
||||
PUT_UINT32_BE( Y, output, 0 );
|
||||
PUT_UINT32_BE( X, output, 4 );
|
||||
MBEDTLS_PUT_UINT32_BE( Y, output, 0 );
|
||||
MBEDTLS_PUT_UINT32_BE( X, output, 4 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
|
|
@ -88,12 +88,12 @@ static int gcm_gen_table( mbedtls_gcm_context *ctx )
|
|||
return( ret );
|
||||
|
||||
/* pack h as two 64-bits ints, big-endian */
|
||||
GET_UINT32_BE( hi, h, 0 );
|
||||
GET_UINT32_BE( lo, h, 4 );
|
||||
MBEDTLS_GET_UINT32_BE( hi, h, 0 );
|
||||
MBEDTLS_GET_UINT32_BE( lo, h, 4 );
|
||||
vh = (uint64_t) hi << 32 | lo;
|
||||
|
||||
GET_UINT32_BE( hi, h, 8 );
|
||||
GET_UINT32_BE( lo, h, 12 );
|
||||
MBEDTLS_GET_UINT32_BE( hi, h, 8 );
|
||||
MBEDTLS_GET_UINT32_BE( lo, h, 12 );
|
||||
vl = (uint64_t) hi << 32 | lo;
|
||||
|
||||
/* 8 = 1000 corresponds to 1 in GF(2^128) */
|
||||
|
@ -200,10 +200,10 @@ static void gcm_mult( mbedtls_gcm_context *ctx, const unsigned char x[16],
|
|||
if( mbedtls_aesni_has_support( MBEDTLS_AESNI_CLMUL ) ) {
|
||||
unsigned char h[16];
|
||||
|
||||
PUT_UINT32_BE( ctx->HH[8] >> 32, h, 0 );
|
||||
PUT_UINT32_BE( ctx->HH[8], h, 4 );
|
||||
PUT_UINT32_BE( ctx->HL[8] >> 32, h, 8 );
|
||||
PUT_UINT32_BE( ctx->HL[8], h, 12 );
|
||||
MBEDTLS_PUT_UINT32_BE( ctx->HH[8] >> 32, h, 0 );
|
||||
MBEDTLS_PUT_UINT32_BE( ctx->HH[8], h, 4 );
|
||||
MBEDTLS_PUT_UINT32_BE( ctx->HL[8] >> 32, h, 8 );
|
||||
MBEDTLS_PUT_UINT32_BE( ctx->HL[8], h, 12 );
|
||||
|
||||
mbedtls_aesni_gcm_mult( output, x, h );
|
||||
return;
|
||||
|
@ -239,10 +239,10 @@ static void gcm_mult( mbedtls_gcm_context *ctx, const unsigned char x[16],
|
|||
zl ^= ctx->HL[hi];
|
||||
}
|
||||
|
||||
PUT_UINT32_BE( zh >> 32, output, 0 );
|
||||
PUT_UINT32_BE( zh, output, 4 );
|
||||
PUT_UINT32_BE( zl >> 32, output, 8 );
|
||||
PUT_UINT32_BE( zl, output, 12 );
|
||||
MBEDTLS_PUT_UINT32_BE( zh >> 32, output, 0 );
|
||||
MBEDTLS_PUT_UINT32_BE( zh, output, 4 );
|
||||
MBEDTLS_PUT_UINT32_BE( zl >> 32, output, 8 );
|
||||
MBEDTLS_PUT_UINT32_BE( zl, output, 12 );
|
||||
}
|
||||
|
||||
int mbedtls_gcm_starts( mbedtls_gcm_context *ctx,
|
||||
|
@ -286,7 +286,7 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx,
|
|||
else
|
||||
{
|
||||
memset( work_buf, 0x00, 16 );
|
||||
PUT_UINT32_BE( iv_len * 8, work_buf, 12 );
|
||||
MBEDTLS_PUT_UINT32_BE( iv_len * 8, work_buf, 12 );
|
||||
|
||||
p = iv;
|
||||
while( iv_len > 0 )
|
||||
|
@ -419,10 +419,10 @@ int mbedtls_gcm_finish( mbedtls_gcm_context *ctx,
|
|||
{
|
||||
memset( work_buf, 0x00, 16 );
|
||||
|
||||
PUT_UINT32_BE( ( orig_add_len >> 32 ), work_buf, 0 );
|
||||
PUT_UINT32_BE( ( orig_add_len ), work_buf, 4 );
|
||||
PUT_UINT32_BE( ( orig_len >> 32 ), work_buf, 8 );
|
||||
PUT_UINT32_BE( ( orig_len ), work_buf, 12 );
|
||||
MBEDTLS_PUT_UINT32_BE( ( orig_add_len >> 32 ), work_buf, 0 );
|
||||
MBEDTLS_PUT_UINT32_BE( ( orig_add_len ), work_buf, 4 );
|
||||
MBEDTLS_PUT_UINT32_BE( ( orig_len >> 32 ), work_buf, 8 );
|
||||
MBEDTLS_PUT_UINT32_BE( ( orig_len ), work_buf, 12 );
|
||||
|
||||
for( i = 0; i < 16; i++ )
|
||||
ctx->buf[i] ^= work_buf[i];
|
||||
|
|
|
@ -94,22 +94,22 @@ int mbedtls_internal_md5_process( mbedtls_md5_context *ctx,
|
|||
uint32_t X[16], A, B, C, D;
|
||||
} local;
|
||||
|
||||
GET_UINT32_LE( local.X[ 0], data, 0 );
|
||||
GET_UINT32_LE( local.X[ 1], data, 4 );
|
||||
GET_UINT32_LE( local.X[ 2], data, 8 );
|
||||
GET_UINT32_LE( local.X[ 3], data, 12 );
|
||||
GET_UINT32_LE( local.X[ 4], data, 16 );
|
||||
GET_UINT32_LE( local.X[ 5], data, 20 );
|
||||
GET_UINT32_LE( local.X[ 6], data, 24 );
|
||||
GET_UINT32_LE( local.X[ 7], data, 28 );
|
||||
GET_UINT32_LE( local.X[ 8], data, 32 );
|
||||
GET_UINT32_LE( local.X[ 9], data, 36 );
|
||||
GET_UINT32_LE( local.X[10], data, 40 );
|
||||
GET_UINT32_LE( local.X[11], data, 44 );
|
||||
GET_UINT32_LE( local.X[12], data, 48 );
|
||||
GET_UINT32_LE( local.X[13], data, 52 );
|
||||
GET_UINT32_LE( local.X[14], data, 56 );
|
||||
GET_UINT32_LE( local.X[15], data, 60 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 0], data, 0 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 1], data, 4 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 2], data, 8 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 3], data, 12 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 4], data, 16 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 5], data, 20 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 6], data, 24 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 7], data, 28 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 8], data, 32 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 9], data, 36 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[10], data, 40 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[11], data, 44 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[12], data, 48 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[13], data, 52 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[14], data, 56 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[15], data, 60 );
|
||||
|
||||
#define S(x,n) \
|
||||
( ( (x) << (n) ) | ( ( (x) & 0xFFFFFFFF) >> ( 32 - (n) ) ) )
|
||||
|
@ -330,8 +330,8 @@ int mbedtls_md5_finish_ret( mbedtls_md5_context *ctx,
|
|||
| ( ctx->total[1] << 3 );
|
||||
low = ( ctx->total[0] << 3 );
|
||||
|
||||
PUT_UINT32_LE( low, ctx->buffer, 56 );
|
||||
PUT_UINT32_LE( high, ctx->buffer, 60 );
|
||||
MBEDTLS_PUT_UINT32_LE( low, ctx->buffer, 56 );
|
||||
MBEDTLS_PUT_UINT32_LE( high, ctx->buffer, 60 );
|
||||
|
||||
if( ( ret = mbedtls_internal_md5_process( ctx, ctx->buffer ) ) != 0 )
|
||||
return( ret );
|
||||
|
@ -339,10 +339,10 @@ int mbedtls_md5_finish_ret( mbedtls_md5_context *ctx,
|
|||
/*
|
||||
* Output final state
|
||||
*/
|
||||
PUT_UINT32_LE( ctx->state[0], output, 0 );
|
||||
PUT_UINT32_LE( ctx->state[1], output, 4 );
|
||||
PUT_UINT32_LE( ctx->state[2], output, 8 );
|
||||
PUT_UINT32_LE( ctx->state[3], output, 12 );
|
||||
MBEDTLS_PUT_UINT32_LE( ctx->state[0], output, 0 );
|
||||
MBEDTLS_PUT_UINT32_LE( ctx->state[1], output, 4 );
|
||||
MBEDTLS_PUT_UINT32_LE( ctx->state[2], output, 8 );
|
||||
MBEDTLS_PUT_UINT32_LE( ctx->state[3], output, 12 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
|
|
@ -223,7 +223,7 @@ int mbedtls_nist_kw_wrap( mbedtls_nist_kw_context *ctx,
|
|||
}
|
||||
|
||||
memcpy( output, NIST_KW_ICV2, KW_SEMIBLOCK_LENGTH / 2 );
|
||||
PUT_UINT32_BE( ( in_len & 0xffffffff ), output,
|
||||
MBEDTLS_PUT_UINT32_BE( ( in_len & 0xffffffff ), output,
|
||||
KW_SEMIBLOCK_LENGTH / 2 );
|
||||
|
||||
memcpy( output + KW_SEMIBLOCK_LENGTH, input, in_len );
|
||||
|
@ -454,7 +454,7 @@ int mbedtls_nist_kw_unwrap( mbedtls_nist_kw_context *ctx,
|
|||
ret = MBEDTLS_ERR_CIPHER_AUTH_FAILED;
|
||||
}
|
||||
|
||||
GET_UINT32_BE( Plen, A, KW_SEMIBLOCK_LENGTH / 2 );
|
||||
MBEDTLS_GET_UINT32_BE( Plen, A, KW_SEMIBLOCK_LENGTH / 2 );
|
||||
|
||||
/*
|
||||
* Plen is the length of the plaintext, when the input is valid.
|
||||
|
|
|
@ -122,10 +122,10 @@ static void poly1305_process( mbedtls_poly1305_context *ctx,
|
|||
for( i = 0U; i < nblocks; i++ )
|
||||
{
|
||||
/* The input block is treated as a 128-bit little-endian integer */
|
||||
d0 = BYTES_TO_U32_LE( input, offset + 0 );
|
||||
d1 = BYTES_TO_U32_LE( input, offset + 4 );
|
||||
d2 = BYTES_TO_U32_LE( input, offset + 8 );
|
||||
d3 = BYTES_TO_U32_LE( input, offset + 12 );
|
||||
d0 = MBEDTLS_BYTES_TO_U32_LE( input, offset + 0 );
|
||||
d1 = MBEDTLS_BYTES_TO_U32_LE( input, offset + 4 );
|
||||
d2 = MBEDTLS_BYTES_TO_U32_LE( input, offset + 8 );
|
||||
d3 = MBEDTLS_BYTES_TO_U32_LE( input, offset + 12 );
|
||||
|
||||
/* Compute: acc += (padded) block as a 130-bit integer */
|
||||
d0 += (uint64_t) acc0;
|
||||
|
@ -290,15 +290,15 @@ int mbedtls_poly1305_starts( mbedtls_poly1305_context *ctx,
|
|||
POLY1305_VALIDATE_RET( key != NULL );
|
||||
|
||||
/* r &= 0x0ffffffc0ffffffc0ffffffc0fffffff */
|
||||
ctx->r[0] = BYTES_TO_U32_LE( key, 0 ) & 0x0FFFFFFFU;
|
||||
ctx->r[1] = BYTES_TO_U32_LE( key, 4 ) & 0x0FFFFFFCU;
|
||||
ctx->r[2] = BYTES_TO_U32_LE( key, 8 ) & 0x0FFFFFFCU;
|
||||
ctx->r[3] = BYTES_TO_U32_LE( key, 12 ) & 0x0FFFFFFCU;
|
||||
ctx->r[0] = MBEDTLS_BYTES_TO_U32_LE( key, 0 ) & 0x0FFFFFFFU;
|
||||
ctx->r[1] = MBEDTLS_BYTES_TO_U32_LE( key, 4 ) & 0x0FFFFFFCU;
|
||||
ctx->r[2] = MBEDTLS_BYTES_TO_U32_LE( key, 8 ) & 0x0FFFFFFCU;
|
||||
ctx->r[3] = MBEDTLS_BYTES_TO_U32_LE( key, 12 ) & 0x0FFFFFFCU;
|
||||
|
||||
ctx->s[0] = BYTES_TO_U32_LE( key, 16 );
|
||||
ctx->s[1] = BYTES_TO_U32_LE( key, 20 );
|
||||
ctx->s[2] = BYTES_TO_U32_LE( key, 24 );
|
||||
ctx->s[3] = BYTES_TO_U32_LE( key, 28 );
|
||||
ctx->s[0] = MBEDTLS_BYTES_TO_U32_LE( key, 16 );
|
||||
ctx->s[1] = MBEDTLS_BYTES_TO_U32_LE( key, 20 );
|
||||
ctx->s[2] = MBEDTLS_BYTES_TO_U32_LE( key, 24 );
|
||||
ctx->s[3] = MBEDTLS_BYTES_TO_U32_LE( key, 28 );
|
||||
|
||||
/* Initial accumulator state */
|
||||
ctx->acc[0] = 0U;
|
||||
|
|
|
@ -4570,8 +4570,8 @@ static psa_status_t psa_tls12_prf_psk_to_ms_set_key(
|
|||
* uint16 with the value N, and the PSK itself.
|
||||
*/
|
||||
|
||||
*cur++ = BYTE_1( data_length );
|
||||
*cur++ = BYTE_0( data_length );
|
||||
*cur++ = MBEDTLS_BYTE_1( data_length );
|
||||
*cur++ = MBEDTLS_BYTE_0( data_length );
|
||||
memset( cur, 0, data_length );
|
||||
cur += data_length;
|
||||
*cur++ = pms[0];
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#define mbedtls_free free
|
||||
#endif
|
||||
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/****************************************************************/
|
||||
/* Key storage */
|
||||
|
@ -279,14 +279,14 @@ void psa_format_key_data_for_storage( const uint8_t *data,
|
|||
(psa_persistent_key_storage_format *) storage_data;
|
||||
|
||||
memcpy( storage_format->magic, PSA_KEY_STORAGE_MAGIC_HEADER, PSA_KEY_STORAGE_MAGIC_HEADER_LENGTH );
|
||||
PUT_UINT32_LE( 0, storage_format->version, 0 );
|
||||
PUT_UINT32_LE( attr->lifetime, storage_format->lifetime, 0 );
|
||||
MBEDTLS_PUT_UINT32_LE( 0, storage_format->version, 0 );
|
||||
MBEDTLS_PUT_UINT32_LE( attr->lifetime, storage_format->lifetime, 0 );
|
||||
PUT_UINT16_LE( (uint16_t) attr->type, storage_format->type, 0 );
|
||||
PUT_UINT16_LE( (uint16_t) attr->bits, storage_format->bits, 0 );
|
||||
PUT_UINT32_LE( attr->policy.usage, storage_format->policy, 0 );
|
||||
PUT_UINT32_LE( attr->policy.alg, storage_format->policy, sizeof( uint32_t ) );
|
||||
PUT_UINT32_LE( attr->policy.alg2, storage_format->policy, 2 * sizeof( uint32_t ) );
|
||||
PUT_UINT32_LE( data_length, storage_format->data_len, 0 );
|
||||
MBEDTLS_PUT_UINT32_LE( attr->policy.usage, storage_format->policy, 0 );
|
||||
MBEDTLS_PUT_UINT32_LE( attr->policy.alg, storage_format->policy, sizeof( uint32_t ) );
|
||||
MBEDTLS_PUT_UINT32_LE( attr->policy.alg2, storage_format->policy, 2 * sizeof( uint32_t ) );
|
||||
MBEDTLS_PUT_UINT32_LE( data_length, storage_format->data_len, 0 );
|
||||
memcpy( storage_format->key_data, data, data_length );
|
||||
}
|
||||
|
||||
|
@ -316,11 +316,11 @@ psa_status_t psa_parse_key_data_from_storage( const uint8_t *storage_data,
|
|||
if( status != PSA_SUCCESS )
|
||||
return( status );
|
||||
|
||||
GET_UINT32_LE( version, storage_format->version, 0 );
|
||||
MBEDTLS_GET_UINT32_LE( version, storage_format->version, 0 );
|
||||
if( version != 0 )
|
||||
return( PSA_ERROR_DATA_INVALID );
|
||||
|
||||
GET_UINT32_LE( *key_data_length, storage_format->data_len, 0 );
|
||||
MBEDTLS_GET_UINT32_LE( *key_data_length, storage_format->data_len, 0 );
|
||||
if( *key_data_length > ( storage_data_length - sizeof(*storage_format) ) ||
|
||||
*key_data_length > PSA_CRYPTO_MAX_STORAGE_SIZE )
|
||||
return( PSA_ERROR_DATA_INVALID );
|
||||
|
@ -337,12 +337,12 @@ psa_status_t psa_parse_key_data_from_storage( const uint8_t *storage_data,
|
|||
memcpy( *key_data, storage_format->key_data, *key_data_length );
|
||||
}
|
||||
|
||||
GET_UINT32_LE( attr->lifetime, storage_format->lifetime, 0 );
|
||||
MBEDTLS_GET_UINT32_LE( attr->lifetime, storage_format->lifetime, 0 );
|
||||
GET_UINT16_LE( attr->type, storage_format->type, 0 );
|
||||
GET_UINT16_LE( attr->bits, storage_format->bits, 0 );
|
||||
GET_UINT32_LE( attr->policy.usage, storage_format->policy, 0 );
|
||||
GET_UINT32_LE( attr->policy.alg, storage_format->policy, sizeof( uint32_t ) );
|
||||
GET_UINT32_LE( attr->policy.alg2, storage_format->policy, 2 * sizeof( uint32_t ) );
|
||||
MBEDTLS_GET_UINT32_LE( attr->policy.usage, storage_format->policy, 0 );
|
||||
MBEDTLS_GET_UINT32_LE( attr->policy.alg, storage_format->policy, sizeof( uint32_t ) );
|
||||
MBEDTLS_GET_UINT32_LE( attr->policy.alg2, storage_format->policy, 2 * sizeof( uint32_t ) );
|
||||
|
||||
return( PSA_SUCCESS );
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
|
||||
#include "psa_crypto_its.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
@ -195,14 +197,14 @@ psa_status_t psa_its_set( psa_storage_uid_t uid,
|
|||
size_t n;
|
||||
|
||||
memcpy( header.magic, PSA_ITS_MAGIC_STRING, PSA_ITS_MAGIC_LENGTH );
|
||||
header.size[0] = BYTE_0( data_length );
|
||||
header.size[1] = BYTE_1( data_length );
|
||||
header.size[2] = BYTE_2( data_length );
|
||||
header.size[3] = BYTE_3( data_length );
|
||||
header.flags[0] = BYTE_0( create_flags );
|
||||
header.flags[1] = BYTE_1( create_flags );
|
||||
header.flags[2] = BYTE_2( create_flags );
|
||||
header.flags[3] = BYTE_3( create_flags );
|
||||
header.size[0] = MBEDTLS_BYTE_0( data_length );
|
||||
header.size[1] = MBEDTLS_BYTE_1( data_length );
|
||||
header.size[2] = MBEDTLS_BYTE_2( data_length );
|
||||
header.size[3] = MBEDTLS_BYTE_3( data_length );
|
||||
header.flags[0] = MBEDTLS_BYTE_0( create_flags );
|
||||
header.flags[1] = MBEDTLS_BYTE_1( create_flags );
|
||||
header.flags[2] = MBEDTLS_BYTE_2( create_flags );
|
||||
header.flags[3] = MBEDTLS_BYTE_3( create_flags );
|
||||
|
||||
psa_its_fill_filename( uid, filename );
|
||||
stream = fopen( PSA_ITS_STORAGE_TEMP, "wb" );
|
||||
|
|
|
@ -99,22 +99,22 @@ int mbedtls_internal_ripemd160_process( mbedtls_ripemd160_context *ctx,
|
|||
uint32_t A, B, C, D, E, Ap, Bp, Cp, Dp, Ep, X[16];
|
||||
} local;
|
||||
|
||||
GET_UINT32_LE( local.X[ 0], data, 0 );
|
||||
GET_UINT32_LE( local.X[ 1], data, 4 );
|
||||
GET_UINT32_LE( local.X[ 2], data, 8 );
|
||||
GET_UINT32_LE( local.X[ 3], data, 12 );
|
||||
GET_UINT32_LE( local.X[ 4], data, 16 );
|
||||
GET_UINT32_LE( local.X[ 5], data, 20 );
|
||||
GET_UINT32_LE( local.X[ 6], data, 24 );
|
||||
GET_UINT32_LE( local.X[ 7], data, 28 );
|
||||
GET_UINT32_LE( local.X[ 8], data, 32 );
|
||||
GET_UINT32_LE( local.X[ 9], data, 36 );
|
||||
GET_UINT32_LE( local.X[10], data, 40 );
|
||||
GET_UINT32_LE( local.X[11], data, 44 );
|
||||
GET_UINT32_LE( local.X[12], data, 48 );
|
||||
GET_UINT32_LE( local.X[13], data, 52 );
|
||||
GET_UINT32_LE( local.X[14], data, 56 );
|
||||
GET_UINT32_LE( local.X[15], data, 60 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 0], data, 0 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 1], data, 4 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 2], data, 8 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 3], data, 12 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 4], data, 16 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 5], data, 20 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 6], data, 24 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 7], data, 28 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 8], data, 32 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[ 9], data, 36 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[10], data, 40 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[11], data, 44 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[12], data, 48 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[13], data, 52 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[14], data, 56 );
|
||||
MBEDTLS_GET_UINT32_LE( local.X[15], data, 60 );
|
||||
|
||||
local.A = local.Ap = ctx->state[0];
|
||||
local.B = local.Bp = ctx->state[1];
|
||||
|
@ -377,8 +377,8 @@ int mbedtls_ripemd160_finish_ret( mbedtls_ripemd160_context *ctx,
|
|||
| ( ctx->total[1] << 3 );
|
||||
low = ( ctx->total[0] << 3 );
|
||||
|
||||
PUT_UINT32_LE( low, msglen, 0 );
|
||||
PUT_UINT32_LE( high, msglen, 4 );
|
||||
MBEDTLS_PUT_UINT32_LE( low, msglen, 0 );
|
||||
MBEDTLS_PUT_UINT32_LE( high, msglen, 4 );
|
||||
|
||||
last = ctx->total[0] & 0x3F;
|
||||
padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
|
||||
|
@ -391,11 +391,11 @@ int mbedtls_ripemd160_finish_ret( mbedtls_ripemd160_context *ctx,
|
|||
if( ret != 0 )
|
||||
return( ret );
|
||||
|
||||
PUT_UINT32_LE( ctx->state[0], output, 0 );
|
||||
PUT_UINT32_LE( ctx->state[1], output, 4 );
|
||||
PUT_UINT32_LE( ctx->state[2], output, 8 );
|
||||
PUT_UINT32_LE( ctx->state[3], output, 12 );
|
||||
PUT_UINT32_LE( ctx->state[4], output, 16 );
|
||||
MBEDTLS_PUT_UINT32_LE( ctx->state[0], output, 0 );
|
||||
MBEDTLS_PUT_UINT32_LE( ctx->state[1], output, 4 );
|
||||
MBEDTLS_PUT_UINT32_LE( ctx->state[2], output, 8 );
|
||||
MBEDTLS_PUT_UINT32_LE( ctx->state[3], output, 12 );
|
||||
MBEDTLS_PUT_UINT32_LE( ctx->state[4], output, 16 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
|
|
@ -110,22 +110,22 @@ int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx,
|
|||
SHA1_VALIDATE_RET( ctx != NULL );
|
||||
SHA1_VALIDATE_RET( (const unsigned char *)data != NULL );
|
||||
|
||||
GET_UINT32_BE( local.W[ 0], data, 0 );
|
||||
GET_UINT32_BE( local.W[ 1], data, 4 );
|
||||
GET_UINT32_BE( local.W[ 2], data, 8 );
|
||||
GET_UINT32_BE( local.W[ 3], data, 12 );
|
||||
GET_UINT32_BE( local.W[ 4], data, 16 );
|
||||
GET_UINT32_BE( local.W[ 5], data, 20 );
|
||||
GET_UINT32_BE( local.W[ 6], data, 24 );
|
||||
GET_UINT32_BE( local.W[ 7], data, 28 );
|
||||
GET_UINT32_BE( local.W[ 8], data, 32 );
|
||||
GET_UINT32_BE( local.W[ 9], data, 36 );
|
||||
GET_UINT32_BE( local.W[10], data, 40 );
|
||||
GET_UINT32_BE( local.W[11], data, 44 );
|
||||
GET_UINT32_BE( local.W[12], data, 48 );
|
||||
GET_UINT32_BE( local.W[13], data, 52 );
|
||||
GET_UINT32_BE( local.W[14], data, 56 );
|
||||
GET_UINT32_BE( local.W[15], data, 60 );
|
||||
MBEDTLS_GET_UINT32_BE( local.W[ 0], data, 0 );
|
||||
MBEDTLS_GET_UINT32_BE( local.W[ 1], data, 4 );
|
||||
MBEDTLS_GET_UINT32_BE( local.W[ 2], data, 8 );
|
||||
MBEDTLS_GET_UINT32_BE( local.W[ 3], data, 12 );
|
||||
MBEDTLS_GET_UINT32_BE( local.W[ 4], data, 16 );
|
||||
MBEDTLS_GET_UINT32_BE( local.W[ 5], data, 20 );
|
||||
MBEDTLS_GET_UINT32_BE( local.W[ 6], data, 24 );
|
||||
MBEDTLS_GET_UINT32_BE( local.W[ 7], data, 28 );
|
||||
MBEDTLS_GET_UINT32_BE( local.W[ 8], data, 32 );
|
||||
MBEDTLS_GET_UINT32_BE( local.W[ 9], data, 36 );
|
||||
MBEDTLS_GET_UINT32_BE( local.W[10], data, 40 );
|
||||
MBEDTLS_GET_UINT32_BE( local.W[11], data, 44 );
|
||||
MBEDTLS_GET_UINT32_BE( local.W[12], data, 48 );
|
||||
MBEDTLS_GET_UINT32_BE( local.W[13], data, 52 );
|
||||
MBEDTLS_GET_UINT32_BE( local.W[14], data, 56 );
|
||||
MBEDTLS_GET_UINT32_BE( local.W[15], data, 60 );
|
||||
|
||||
#define S(x,n) (((x) << (n)) | (((x) & 0xFFFFFFFF) >> (32 - (n))))
|
||||
|
||||
|
@ -385,8 +385,8 @@ int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx,
|
|||
| ( ctx->total[1] << 3 );
|
||||
low = ( ctx->total[0] << 3 );
|
||||
|
||||
PUT_UINT32_BE( high, ctx->buffer, 56 );
|
||||
PUT_UINT32_BE( low, ctx->buffer, 60 );
|
||||
MBEDTLS_PUT_UINT32_BE( high, ctx->buffer, 56 );
|
||||
MBEDTLS_PUT_UINT32_BE( low, ctx->buffer, 60 );
|
||||
|
||||
if( ( ret = mbedtls_internal_sha1_process( ctx, ctx->buffer ) ) != 0 )
|
||||
return( ret );
|
||||
|
@ -394,11 +394,11 @@ int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx,
|
|||
/*
|
||||
* Output final state
|
||||
*/
|
||||
PUT_UINT32_BE( ctx->state[0], output, 0 );
|
||||
PUT_UINT32_BE( ctx->state[1], output, 4 );
|
||||
PUT_UINT32_BE( ctx->state[2], output, 8 );
|
||||
PUT_UINT32_BE( ctx->state[3], output, 12 );
|
||||
PUT_UINT32_BE( ctx->state[4], output, 16 );
|
||||
MBEDTLS_PUT_UINT32_BE( ctx->state[0], output, 0 );
|
||||
MBEDTLS_PUT_UINT32_BE( ctx->state[1], output, 4 );
|
||||
MBEDTLS_PUT_UINT32_BE( ctx->state[2], output, 8 );
|
||||
MBEDTLS_PUT_UINT32_BE( ctx->state[3], output, 12 );
|
||||
MBEDTLS_PUT_UINT32_BE( ctx->state[4], output, 16 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx,
|
|||
for( i = 0; i < 64; i++ )
|
||||
{
|
||||
if( i < 16 )
|
||||
GET_UINT32_BE( local.W[i], data, 4 * i );
|
||||
MBEDTLS_GET_UINT32_BE( local.W[i], data, 4 * i );
|
||||
else
|
||||
R( i );
|
||||
|
||||
|
@ -206,7 +206,7 @@ int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx,
|
|||
}
|
||||
#else /* MBEDTLS_SHA256_SMALLER */
|
||||
for( i = 0; i < 16; i++ )
|
||||
GET_UINT32_BE( local.W[i], data, 4 * i );
|
||||
MBEDTLS_GET_UINT32_BE( local.W[i], data, 4 * i );
|
||||
|
||||
for( i = 0; i < 16; i += 8 )
|
||||
{
|
||||
|
@ -372,8 +372,8 @@ int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx,
|
|||
| ( ctx->total[1] << 3 );
|
||||
low = ( ctx->total[0] << 3 );
|
||||
|
||||
PUT_UINT32_BE( high, ctx->buffer, 56 );
|
||||
PUT_UINT32_BE( low, ctx->buffer, 60 );
|
||||
MBEDTLS_PUT_UINT32_BE( high, ctx->buffer, 56 );
|
||||
MBEDTLS_PUT_UINT32_BE( low, ctx->buffer, 60 );
|
||||
|
||||
if( ( ret = mbedtls_internal_sha256_process( ctx, ctx->buffer ) ) != 0 )
|
||||
return( ret );
|
||||
|
@ -381,16 +381,16 @@ int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx,
|
|||
/*
|
||||
* Output final state
|
||||
*/
|
||||
PUT_UINT32_BE( ctx->state[0], output, 0 );
|
||||
PUT_UINT32_BE( ctx->state[1], output, 4 );
|
||||
PUT_UINT32_BE( ctx->state[2], output, 8 );
|
||||
PUT_UINT32_BE( ctx->state[3], output, 12 );
|
||||
PUT_UINT32_BE( ctx->state[4], output, 16 );
|
||||
PUT_UINT32_BE( ctx->state[5], output, 20 );
|
||||
PUT_UINT32_BE( ctx->state[6], output, 24 );
|
||||
MBEDTLS_PUT_UINT32_BE( ctx->state[0], output, 0 );
|
||||
MBEDTLS_PUT_UINT32_BE( ctx->state[1], output, 4 );
|
||||
MBEDTLS_PUT_UINT32_BE( ctx->state[2], output, 8 );
|
||||
MBEDTLS_PUT_UINT32_BE( ctx->state[3], output, 12 );
|
||||
MBEDTLS_PUT_UINT32_BE( ctx->state[4], output, 16 );
|
||||
MBEDTLS_PUT_UINT32_BE( ctx->state[5], output, 20 );
|
||||
MBEDTLS_PUT_UINT32_BE( ctx->state[6], output, 24 );
|
||||
|
||||
if( ctx->is224 == 0 )
|
||||
PUT_UINT32_BE( ctx->state[7], output, 28 );
|
||||
MBEDTLS_PUT_UINT32_BE( ctx->state[7], output, 28 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
|
|
@ -2526,13 +2526,13 @@ int mbedtls_ssl_flight_transmit( mbedtls_ssl_context *ssl )
|
|||
* Handshake headers: type(1) len(3) seq(2) f_off(3) f_len(3) */
|
||||
memcpy( ssl->out_msg, cur->p, 6 );
|
||||
|
||||
ssl->out_msg[6] = BYTE_2( frag_off );
|
||||
ssl->out_msg[7] = BYTE_1( frag_off );
|
||||
ssl->out_msg[8] = BYTE_0( frag_off );
|
||||
ssl->out_msg[6] = MBEDTLS_BYTE_2( frag_off );
|
||||
ssl->out_msg[7] = MBEDTLS_BYTE_1( frag_off );
|
||||
ssl->out_msg[8] = MBEDTLS_BYTE_0( frag_off );
|
||||
|
||||
ssl->out_msg[ 9] = BYTE_2( cur_hs_frag_len );
|
||||
ssl->out_msg[10] = BYTE_1( cur_hs_frag_len );
|
||||
ssl->out_msg[11] = BYTE_0( cur_hs_frag_len );
|
||||
ssl->out_msg[ 9] = MBEDTLS_BYTE_2( cur_hs_frag_len );
|
||||
ssl->out_msg[10] = MBEDTLS_BYTE_1( cur_hs_frag_len );
|
||||
ssl->out_msg[11] = MBEDTLS_BYTE_0( cur_hs_frag_len );
|
||||
|
||||
MBEDTLS_SSL_DEBUG_BUF( 3, "handshake header", ssl->out_msg, 12 );
|
||||
|
||||
|
|
|
@ -245,8 +245,8 @@ int mbedtls_ssl_ticket_write( void *p_ticket,
|
|||
{
|
||||
goto cleanup;
|
||||
}
|
||||
state_len_bytes[0] = BYTE_1( clear_len );
|
||||
state_len_bytes[1] = BYTE_0( clear_len );
|
||||
state_len_bytes[0] = MBEDTLS_BYTE_1( clear_len );
|
||||
state_len_bytes[1] = MBEDTLS_BYTE_0( clear_len );
|
||||
|
||||
/* Encrypt and authenticate */
|
||||
if( ( ret = mbedtls_cipher_auth_encrypt_ext( &key->ctx,
|
||||
|
|
Loading…
Reference in a new issue