mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-06 16:36:16 +08:00
XTS use new GF(2^128) API
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user