mirror of
https://github.com/bol-van/zapret.git
synced 2026-03-15 09:41:51 +00:00
nfqws: QUIC initial dissection support
This commit is contained in:
38
nfq/crypto/aes-gcm.c
Normal file
38
nfq/crypto/aes-gcm.c
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "aes-gcm.h"
|
||||
|
||||
int aes_gcm_encrypt(unsigned char* output, const unsigned char* input, size_t input_length, const unsigned char* key, const size_t key_len, const unsigned char * iv, const size_t iv_len) {
|
||||
|
||||
int ret = 0; // our return value
|
||||
gcm_context ctx; // includes the AES context structure
|
||||
|
||||
size_t tag_len = 0;
|
||||
unsigned char * tag_buf = NULL;
|
||||
|
||||
gcm_setkey(&ctx, key, (const uint)key_len);
|
||||
|
||||
ret = gcm_crypt_and_tag(&ctx, ENCRYPT, iv, iv_len, NULL, 0,
|
||||
input, output, input_length, tag_buf, tag_len);
|
||||
|
||||
gcm_zero_ctx(&ctx);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
int aes_gcm_decrypt(unsigned char* output, const unsigned char* input, size_t input_length, const unsigned char* key, const size_t key_len, const unsigned char * iv, const size_t iv_len) {
|
||||
|
||||
int ret = 0; // our return value
|
||||
gcm_context ctx; // includes the AES context structure
|
||||
|
||||
size_t tag_len = 0;
|
||||
unsigned char * tag_buf = NULL;
|
||||
|
||||
gcm_setkey(&ctx, key, (const uint)key_len);
|
||||
|
||||
ret = gcm_crypt_and_tag(&ctx, DECRYPT, iv, iv_len, NULL, 0,
|
||||
input, output, input_length, tag_buf, tag_len);
|
||||
|
||||
gcm_zero_ctx(&ctx);
|
||||
|
||||
return(ret);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user