summaryrefslogtreecommitdiff
path: root/third_party/tinyaes/aes256gcm.h
diff options
context:
space:
mode:
authorinfo@mode42.com <info@mode42.com>2026-08-08 03:54:55 +0000
committerinfo@mode42.com <info@mode42.com>2026-08-08 03:54:55 +0000
commit20cb29c2f8c5c87bc590896854a20b1473ceb358 (patch)
tree2857f41513a56ad41af97b57362639298aa7f033 /third_party/tinyaes/aes256gcm.h
#2
Diffstat (limited to 'third_party/tinyaes/aes256gcm.h')
-rw-r--r--third_party/tinyaes/aes256gcm.h32
1 files changed, 32 insertions, 0 deletions
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 <stddef.h>
+#include <stdint.h>
+
+#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
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com