mirror of https://github.com/ARMmbed/mbed-os.git
Refine AES alter. key endianness code
parent
77c53f8d06
commit
0a56b34d0e
|
@ -87,12 +87,9 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
|
|||
return( MBEDTLS_ERR_AES_INVALID_KEY_LENGTH );
|
||||
}
|
||||
|
||||
// key swap
|
||||
/* Fetch key byte data in big-endian */
|
||||
for( i = 0; i < ( keybits >> 5 ); i++ ) {
|
||||
ctx->keys[i] = (*(key+i*4) << 24) |
|
||||
(*(key+1+i*4) << 16) |
|
||||
(*(key+2+i*4) << 8) |
|
||||
(*(key+3+i*4) );
|
||||
ctx->keys[i] = nu_get32_be(key + i * 4);
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
|
|
|
@ -87,12 +87,9 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
|
|||
return( MBEDTLS_ERR_AES_INVALID_KEY_LENGTH );
|
||||
}
|
||||
|
||||
// key swap
|
||||
/* Fetch key byte data in big-endian */
|
||||
for( i = 0; i < ( keybits >> 5 ); i++ ) {
|
||||
ctx->keys[i] = (*(key+i*4) << 24) |
|
||||
(*(key+1+i*4) << 16) |
|
||||
(*(key+2+i*4) << 8) |
|
||||
(*(key+3+i*4) );
|
||||
ctx->keys[i] = nu_get32_be(key + i * 4);
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
|
|
Loading…
Reference in New Issue