mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
Fix in evp_aes_xts init
This commit is contained in:
40
src/ssl.c
40
src/ssl.c
@ -17766,20 +17766,21 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md)
|
|||||||
ctx->cipherType = AES_128_XTS_TYPE;
|
ctx->cipherType = AES_128_XTS_TYPE;
|
||||||
ctx->flags &= ~WOLFSSL_EVP_CIPH_MODE;
|
ctx->flags &= ~WOLFSSL_EVP_CIPH_MODE;
|
||||||
ctx->flags |= WOLFSSL_EVP_CIPH_XTS_MODE;
|
ctx->flags |= WOLFSSL_EVP_CIPH_XTS_MODE;
|
||||||
ctx->keyLen = 16;
|
ctx->keyLen = 32;
|
||||||
ctx->block_size = 1;
|
ctx->block_size = 1;
|
||||||
if (enc == 0 || enc == 1)
|
if (enc == 0 || enc == 1)
|
||||||
ctx->enc = enc ? 1 : 0;
|
ctx->enc = enc ? 1 : 0;
|
||||||
if (key) {
|
if (iv) {
|
||||||
ret = AesSetKey_ex(&ctx->cipher.aes, key, ctx->keyLen, iv,
|
ctx->cipher.tweak = iv;
|
||||||
AES_ENCRYPTION, 0);
|
ctx->cipher.tweakSz = 16;
|
||||||
if (ret != 0)
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
if (iv && key == NULL) {
|
if (key) {
|
||||||
ret = wc_AesSetIV(&ctx->cipher.aes, iv);
|
ret = wc_AesXtsSetKey(&ctx->cipher.xts, key, ctx->keyLen,
|
||||||
if (ret != 0)
|
AES_ENCRYPTION, NULL, 0);
|
||||||
|
if (ret != 0) {
|
||||||
|
WOLFSSL_MSG("wc_AesXtsSetKey() failed");
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* WOLFSSL_AES_128 */
|
#endif /* WOLFSSL_AES_128 */
|
||||||
@ -17790,22 +17791,19 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md)
|
|||||||
ctx->cipherType = AES_256_XTS_TYPE;
|
ctx->cipherType = AES_256_XTS_TYPE;
|
||||||
ctx->flags &= ~WOLFSSL_EVP_CIPH_MODE;
|
ctx->flags &= ~WOLFSSL_EVP_CIPH_MODE;
|
||||||
ctx->flags |= WOLFSSL_EVP_CIPH_XTS_MODE;
|
ctx->flags |= WOLFSSL_EVP_CIPH_XTS_MODE;
|
||||||
ctx->keyLen = 32;
|
ctx->keyLen = 64;
|
||||||
ctx->block_size = 1;
|
ctx->block_size = 1;
|
||||||
if (enc == 0 || enc == 1)
|
if (enc == 0 || enc == 1)
|
||||||
ctx->enc = enc ? 1 : 0;
|
ctx->enc = enc ? 1 : 0;
|
||||||
if (key) {
|
if (iv) {
|
||||||
ret = AesSetKey_ex(&ctx->cipher.aes, key, ctx->keyLen, iv,
|
ctx->cipher.tweak = iv;
|
||||||
AES_ENCRYPTION, 0);
|
ctx->cipher.tweakSz = 16;
|
||||||
if (ret != 0){
|
|
||||||
WOLFSSL_MSG("AesSetKey() failed");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (iv && key == NULL) {
|
if (key) {
|
||||||
ret = wc_AesSetIV(&ctx->cipher.aes, iv);
|
ret = wc_AesXtsSetKey(&ctx->cipher.xts, key, ctx->keyLen,
|
||||||
if (ret != 0){
|
AES_ENCRYPTION, NULL, 0);
|
||||||
WOLFSSL_MSG("wc_AesSetIV() failed");
|
if (ret != 0) {
|
||||||
|
WOLFSSL_MSG("wc_AesXtsSetKey() failed");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ typedef union {
|
|||||||
Aes aes;
|
Aes aes;
|
||||||
#ifdef WOLFSSL_AES_XTS
|
#ifdef WOLFSSL_AES_XTS
|
||||||
XtsAes xts;
|
XtsAes xts;
|
||||||
byte* tweak;
|
const byte* tweak;
|
||||||
word32 tweakSz;
|
word32 tweakSz;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user