aes: Remove AES-XEX
AES-XEX is a building block for other cryptographic standards and not yet a standard in and of itself. We'll just provide the standardized AES-XTS algorithm, and not AES-XEX. The AES-XTS algorithm and interface provided can be used to perform the AES-XEX algorithm when the length of the input is a multiple of the AES block size.
This commit is contained in:
parent
010c2cb456
commit
e9ecf00007
8 changed files with 2 additions and 3794 deletions
|
@ -983,64 +983,6 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
|
|||
}
|
||||
#endif /* MBEDTLS_CIPHER_MODE_CBC */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_XEX)
|
||||
/*
|
||||
* AES-XEX buffer encryption/decryption
|
||||
*/
|
||||
int mbedtls_aes_crypt_xex( mbedtls_aes_context *crypt_ctx,
|
||||
mbedtls_aes_context *tweak_ctx,
|
||||
int mode,
|
||||
size_t length,
|
||||
unsigned char iv[16],
|
||||
const unsigned char *input,
|
||||
unsigned char *output )
|
||||
{
|
||||
union xex_buf128 {
|
||||
uint8_t u8[16];
|
||||
uint64_t u64[2];
|
||||
};
|
||||
|
||||
union xex_buf128 scratch;
|
||||
union xex_buf128 t_buf;
|
||||
union xex_buf128 *inbuf;
|
||||
union xex_buf128 *outbuf;
|
||||
|
||||
inbuf = (union xex_buf128*)input;
|
||||
outbuf = (union xex_buf128*)output;
|
||||
|
||||
if( length % 16 )
|
||||
return( MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH );
|
||||
|
||||
|
||||
mbedtls_aes_crypt_ecb( tweak_ctx, MBEDTLS_AES_ENCRYPT, iv, t_buf.u8 );
|
||||
|
||||
goto first;
|
||||
|
||||
do
|
||||
{
|
||||
mbedtls_gf128mul_x_ble( t_buf.u8, t_buf.u8 );
|
||||
|
||||
first:
|
||||
/* PP <- T xor P */
|
||||
scratch.u64[0] = (uint64_t)( inbuf->u64[0] ^ t_buf.u64[0] );
|
||||
scratch.u64[1] = (uint64_t)( inbuf->u64[1] ^ t_buf.u64[1] );
|
||||
|
||||
/* CC <- E(Key2,PP) */
|
||||
mbedtls_aes_crypt_ecb( crypt_ctx, mode, scratch.u8, outbuf->u8 );
|
||||
|
||||
/* C <- T xor CC */
|
||||
outbuf->u64[0] = (uint64_t)( outbuf->u64[0] ^ t_buf.u64[0] );
|
||||
outbuf->u64[1] = (uint64_t)( outbuf->u64[1] ^ t_buf.u64[1] );
|
||||
|
||||
inbuf += 1;
|
||||
outbuf += 1;
|
||||
length -= 16;
|
||||
} while( length > 0 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_CIPHER_MODE_XEX */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_MODE_XTS)
|
||||
|
||||
/* Endianess with 64 bits values */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue