mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-29 19:56:16 +08:00
Add SM4 commands in gmssl CLI
This commit is contained in:
@@ -31,8 +31,8 @@ static int test_sm4_ccm(void)
|
||||
size_t len[] = { 4, 16, 36, 64 };
|
||||
uint8_t encrypted[sizeof(plaintext)];
|
||||
uint8_t decrypted[sizeof(plaintext)];
|
||||
uint8_t mac[SM4_CCM_MAX_MAC_SIZE];
|
||||
size_t maclen[] = { SM4_CCM_MIN_MAC_SIZE, SM4_CCM_MAX_MAC_SIZE };
|
||||
uint8_t mac[SM4_CCM_MAX_TAG_SIZE];
|
||||
size_t maclen[] = { SM4_CCM_MIN_TAG_SIZE, SM4_CCM_MAX_TAG_SIZE };
|
||||
size_t i;
|
||||
|
||||
rand_bytes(key, sizeof(key));
|
||||
|
||||
@@ -43,7 +43,7 @@ static int test_sm4_cbc_sm3_hmac(void)
|
||||
rand_bytes(aad, sizeof(aad));
|
||||
rand_bytes(plain, plainlen);
|
||||
|
||||
if (sm4_cbc_sm3_hmac_encrypt_init(&aead_ctx, key, sizeof(key), iv, sizeof(iv), aad, sizeof(aad)) != 1) {
|
||||
if (sm4_cbc_sm3_hmac_encrypt_init(&aead_ctx, key, iv, aad, sizeof(aad)) != 1) {
|
||||
error_print();
|
||||
return -1;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ static int test_sm4_cbc_sm3_hmac(void)
|
||||
in = cipher;
|
||||
out = buf;
|
||||
|
||||
if (sm4_cbc_sm3_hmac_decrypt_init(&aead_ctx, key, sizeof(key), iv, sizeof(iv), aad, sizeof(aad)) != 1) {
|
||||
if (sm4_cbc_sm3_hmac_decrypt_init(&aead_ctx, key, iv, aad, sizeof(aad)) != 1) {
|
||||
error_print();
|
||||
return -1;
|
||||
}
|
||||
@@ -162,7 +162,7 @@ static int test_sm4_ctr_sm3_hmac(void)
|
||||
rand_bytes(aad, sizeof(aad));
|
||||
rand_bytes(plain, plainlen);
|
||||
|
||||
if (sm4_ctr_sm3_hmac_encrypt_init(&aead_ctx, key, sizeof(key), iv, sizeof(iv), aad, sizeof(aad)) != 1) {
|
||||
if (sm4_ctr_sm3_hmac_encrypt_init(&aead_ctx, key, iv, aad, sizeof(aad)) != 1) {
|
||||
error_print();
|
||||
return -1;
|
||||
}
|
||||
@@ -221,7 +221,7 @@ static int test_sm4_ctr_sm3_hmac(void)
|
||||
in = cipher;
|
||||
out = buf;
|
||||
|
||||
if (sm4_ctr_sm3_hmac_decrypt_init(&aead_ctx, key, sizeof(key), iv, sizeof(iv), aad, sizeof(aad)) != 1) {
|
||||
if (sm4_ctr_sm3_hmac_decrypt_init(&aead_ctx, key, iv, aad, sizeof(aad)) != 1) {
|
||||
error_print();
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user