2022-03-25 16:59:58 +03:00
|
|
|
#include "aes-gcm.h"
|
|
|
|
|
2022-03-26 21:00:58 +03:00
|
|
|
int aes_gcm_crypt(int mode, uint8_t *output, const uint8_t *input, size_t input_length, const uint8_t *key, const size_t key_len, const uint8_t *iv, const size_t iv_len, const uint8_t *adata, size_t adata_len, uint8_t *atag, size_t atag_len)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
gcm_context ctx;
|
2022-03-25 16:59:58 +03:00
|
|
|
|
|
|
|
gcm_setkey(&ctx, key, (const uint)key_len);
|
2022-03-26 21:00:58 +03:00
|
|
|
ret = gcm_crypt_and_tag(&ctx, mode, iv, iv_len, adata, adata_len, input, output, input_length, atag, atag_len);
|
2022-03-25 16:59:58 +03:00
|
|
|
gcm_zero_ctx(&ctx);
|
|
|
|
|
2022-03-26 21:00:58 +03:00
|
|
|
return ret;
|
2022-03-25 16:59:58 +03:00
|
|
|
}
|