From 20cb29c2f8c5c87bc590896854a20b1473ceb358 Mon Sep 17 00:00:00 2001 From: "info@mode42.com" Date: Sat, 8 Aug 2026 03:54:55 +0000 Subject: #2 --- third_party/tinyaes/aes256gcm.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 third_party/tinyaes/aes256gcm.h (limited to 'third_party/tinyaes/aes256gcm.h') diff --git a/third_party/tinyaes/aes256gcm.h b/third_party/tinyaes/aes256gcm.h new file mode 100644 index 0000000..c7a349a --- /dev/null +++ b/third_party/tinyaes/aes256gcm.h @@ -0,0 +1,32 @@ +#ifndef HYBBX_AES256GCM_H +#define HYBBX_AES256GCM_H + +#include +#include + +#define HYBBX_AES256GCM_KEY_SIZE 32 +#define HYBBX_AES256GCM_NONCE_SIZE 12 +#define HYBBX_AES256GCM_TAG_SIZE 16 + +/** + * AES-256-GCM encrypt. @p ciphertext length equals @p plaintext_len. + * @p tag receives the 16-byte authentication tag. + */ +int hybbx_aes256gcm_encrypt(const uint8_t key[HYBBX_AES256GCM_KEY_SIZE], + const uint8_t nonce[HYBBX_AES256GCM_NONCE_SIZE], + const uint8_t *aad, size_t aad_len, + const uint8_t *plaintext, size_t plaintext_len, + uint8_t *ciphertext, + uint8_t tag[HYBBX_AES256GCM_TAG_SIZE]); + +/** + * AES-256-GCM decrypt. Returns 0 on success (tag valid), -1 on failure. + */ +int hybbx_aes256gcm_decrypt(const uint8_t key[HYBBX_AES256GCM_KEY_SIZE], + const uint8_t nonce[HYBBX_AES256GCM_NONCE_SIZE], + const uint8_t *aad, size_t aad_len, + const uint8_t *ciphertext, size_t ciphertext_len, + uint8_t *plaintext, + const uint8_t tag[HYBBX_AES256GCM_TAG_SIZE]); + +#endif -- cgit v1.3.1