mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-19 14:56:30 +08:00
Add more SM4 test vectors
SM4 pass openssl and other known test vectors. SM4-GCM and SM4-XTS only support the GB/T GF(2^128) encoding standard.
This commit is contained in:
@@ -356,7 +356,6 @@ err:
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SM2_PRIVATE_KEY_EXPORT
|
||||
int sm2_private_key_info_to_pem(const SM2_KEY *key, FILE *fp)
|
||||
{
|
||||
int ret = -1;
|
||||
@@ -405,7 +404,6 @@ int sm2_private_key_info_from_pem(SM2_KEY *sm2_key, FILE *fp)
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int sm2_public_key_info_to_der(const SM2_KEY *pub_key, uint8_t **out, size_t *outlen)
|
||||
{
|
||||
@@ -440,8 +438,6 @@ int sm2_public_key_info_from_der(SM2_KEY *pub_key, const uint8_t **in, size_t *i
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SM2_PRIVATE_KEY_EXPORT
|
||||
|
||||
// FIXME: side-channel of Base64
|
||||
int sm2_private_key_to_pem(const SM2_KEY *a, FILE *fp)
|
||||
{
|
||||
@@ -477,7 +473,6 @@ int sm2_private_key_from_pem(SM2_KEY *a, FILE *fp)
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int sm2_public_key_info_to_pem(const SM2_KEY *a, FILE *fp)
|
||||
{
|
||||
|
||||
@@ -92,7 +92,7 @@ int sm4_xts_decrypt(const SM4_KEY *key1, const SM4_KEY *key2, const uint8_t twea
|
||||
|
||||
for (i = 0; i < nblocks - 2; i++) {
|
||||
gmssl_memxor(block, in, T, 16);
|
||||
sm4_decrypt(key1, block, block);
|
||||
sm4_encrypt(key1, block, block);
|
||||
gmssl_memxor(out, block, T, 16);
|
||||
|
||||
gf128_from_bytes(a, T);
|
||||
@@ -106,7 +106,7 @@ int sm4_xts_decrypt(const SM4_KEY *key1, const SM4_KEY *key2, const uint8_t twea
|
||||
|
||||
if (inlen % 16 == 0) {
|
||||
gmssl_memxor(block, in, T, 16);
|
||||
sm4_decrypt(key1, block, block);
|
||||
sm4_encrypt(key1, block, block);
|
||||
gmssl_memxor(out, block, T, 16);
|
||||
|
||||
} else {
|
||||
@@ -117,7 +117,7 @@ int sm4_xts_decrypt(const SM4_KEY *key1, const SM4_KEY *key2, const uint8_t twea
|
||||
gf128_to_bytes(a, T1);
|
||||
|
||||
gmssl_memxor(block, in, T1, 16);
|
||||
sm4_decrypt(key1, block, block);
|
||||
sm4_encrypt(key1, block, block);
|
||||
gmssl_memxor(block, block, T1, 16);
|
||||
|
||||
in += 16;
|
||||
@@ -127,7 +127,7 @@ int sm4_xts_decrypt(const SM4_KEY *key1, const SM4_KEY *key2, const uint8_t twea
|
||||
memcpy(block, in, inlen);
|
||||
|
||||
gmssl_memxor(block, block, T, 16);
|
||||
sm4_decrypt(key1, block, block);
|
||||
sm4_encrypt(key1, block, block);
|
||||
gmssl_memxor(out, block, T, 16);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user