mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-07 00:46:17 +08:00
Update AEAD
This commit is contained in:
@@ -39,9 +39,10 @@ static int test_aead_sm4_cbc_sm3_hmac(void)
|
||||
|
||||
rand_bytes(key, sizeof(key));
|
||||
rand_bytes(iv, sizeof(iv));
|
||||
rand_bytes(aad, sizeof(aad));
|
||||
rand_bytes(plain, plainlen);
|
||||
|
||||
if (sm4_cbc_sm3_hmac_encrypt_init(&aead_ctx, key, iv, aad, sizeof(aad)) != 1) {
|
||||
if (sm4_cbc_sm3_hmac_encrypt_init(&aead_ctx, key, sizeof(key), iv, sizeof(iv), aad, sizeof(aad)) != 1) {
|
||||
error_print();
|
||||
return -1;
|
||||
}
|
||||
@@ -98,7 +99,7 @@ static int test_aead_sm4_cbc_sm3_hmac(void)
|
||||
in = cipher;
|
||||
out = buf;
|
||||
|
||||
if (sm4_cbc_sm3_hmac_decrypt_init(&aead_ctx, key, iv, aad, sizeof(aad)) != 1) {
|
||||
if (sm4_cbc_sm3_hmac_decrypt_init(&aead_ctx, key, sizeof(key), iv, sizeof(iv), aad, sizeof(aad)) != 1) {
|
||||
error_print();
|
||||
return -1;
|
||||
}
|
||||
@@ -157,9 +158,10 @@ static int test_aead_sm4_ctr_sm3_hmac(void)
|
||||
|
||||
rand_bytes(key, sizeof(key));
|
||||
rand_bytes(iv, sizeof(iv));
|
||||
rand_bytes(aad, sizeof(aad));
|
||||
rand_bytes(plain, plainlen);
|
||||
|
||||
if (sm4_ctr_sm3_hmac_encrypt_init(&aead_ctx, key, iv, aad, sizeof(aad)) != 1) {
|
||||
if (sm4_ctr_sm3_hmac_encrypt_init(&aead_ctx, key, sizeof(key), iv, sizeof(iv), aad, sizeof(aad)) != 1) {
|
||||
error_print();
|
||||
return -1;
|
||||
}
|
||||
@@ -218,7 +220,7 @@ static int test_aead_sm4_ctr_sm3_hmac(void)
|
||||
in = cipher;
|
||||
out = buf;
|
||||
|
||||
if (sm4_ctr_sm3_hmac_decrypt_init(&aead_ctx, key, iv, aad, sizeof(aad)) != 1) {
|
||||
if (sm4_ctr_sm3_hmac_decrypt_init(&aead_ctx, key, sizeof(key), iv, sizeof(iv), aad, sizeof(aad)) != 1) {
|
||||
error_print();
|
||||
return -1;
|
||||
}
|
||||
@@ -278,9 +280,10 @@ static int test_aead_sm4_gcm(void)
|
||||
|
||||
rand_bytes(key, sizeof(key));
|
||||
rand_bytes(iv, sizeof(iv));
|
||||
rand_bytes(aad, sizeof(aad));
|
||||
rand_bytes(plain, plainlen);
|
||||
|
||||
if (sm4_gcm_encrypt_init(&aead_ctx, key, iv, sizeof(iv), aad, sizeof(aad), GHASH_SIZE) != 1) {
|
||||
if (sm4_gcm_encrypt_init(&aead_ctx, key, sizeof(key), iv, sizeof(iv), aad, sizeof(aad), GHASH_SIZE) != 1) {
|
||||
error_print();
|
||||
return -1;
|
||||
}
|
||||
@@ -333,7 +336,7 @@ static int test_aead_sm4_gcm(void)
|
||||
in = cipher;
|
||||
out = buf;
|
||||
|
||||
if (sm4_gcm_decrypt_init(&aead_ctx, key, iv, sizeof(iv), aad, sizeof(aad), GHASH_SIZE) != 1) {
|
||||
if (sm4_gcm_decrypt_init(&aead_ctx, key, sizeof(key), iv, sizeof(iv), aad, sizeof(aad), GHASH_SIZE) != 1) {
|
||||
error_print();
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user