XTS use new GF(2^128) API

This commit is contained in:
Zhi Guan
2024-04-11 18:02:46 +08:00
parent f9e9b20fa7
commit e4502ddd24
2 changed files with 10 additions and 10 deletions

View File

@@ -36,8 +36,8 @@ int sm4_xts_encrypt(const SM4_KEY *key1, const SM4_KEY *key2, const uint8_t twea
sm4_encrypt(key1, block, block);
gmssl_memxor(out, block, T, 16);
a = gf128_from_bytes(T);
a = gf128_mul2(a);
gf128_from_bytes(a, T);
gf128_mul_by_2(a, a);
gf128_to_bytes(a, T);
in += 16;
@@ -55,8 +55,8 @@ int sm4_xts_encrypt(const SM4_KEY *key1, const SM4_KEY *key2, const uint8_t twea
sm4_encrypt(key1, block, block);
gmssl_memxor(block, block, T, 16);
a = gf128_from_bytes(T);
a = gf128_mul2(a);
gf128_from_bytes(a, T);
gf128_mul_by_2(a, a);
gf128_to_bytes(a, T);
in += 16;
@@ -95,8 +95,8 @@ int sm4_xts_decrypt(const SM4_KEY *key1, const SM4_KEY *key2, const uint8_t twea
sm4_decrypt(key1, block, block);
gmssl_memxor(out, block, T, 16);
a = gf128_from_bytes(T);
a = gf128_mul2(a);
gf128_from_bytes(a, T);
gf128_mul_by_2(a, a);
gf128_to_bytes(a, T);
in += 16;
@@ -112,8 +112,8 @@ int sm4_xts_decrypt(const SM4_KEY *key1, const SM4_KEY *key2, const uint8_t twea
} else {
uint8_t T1[16];
a = gf128_from_bytes(T);
a = gf128_mul2(a);
gf128_from_bytes(a, T);
gf128_mul_by_2(a, a);
gf128_to_bytes(a, T1);
gmssl_memxor(block, in, T1, 16);

View File

@@ -559,8 +559,8 @@ bad:
goto end;
}
#ifdef ENABLE_SM4_XTS
if (mode == SM4_MODE_XTS) {
#ifdef ENABLE_SM4_CCM
if (mode == SM4_MODE_CCM) {
if (sm4_ccm_crypt(key, keylen, iv, ivlen, aad, aadlen, taglen, infp, outfp, enc, prog) != 1) {
goto end;
}