From 6b873d3a496faf998ae8116f18019da649345f02 Mon Sep 17 00:00:00 2001 From: ogtomi Date: Thu, 18 May 2023 13:22:07 +0200 Subject: [PATCH] main.cpp: Added auth_data and auth_tag for GCM --- main.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index 1fa6ce8..19d200c 100644 --- a/main.cpp +++ b/main.cpp @@ -11,6 +11,7 @@ #include "meta/cfb.h" #include "meta/ofb.h" #include "meta/ctr.h" +#include "meta/gcm.h" int main() { @@ -20,15 +21,17 @@ int main() std::string message = "00112233445566778899aabbccddeeff"; std::string message_ll = "00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff"; + std::string auth_data = "00000000000000000000000000000000"; + std::string auth_tag{}; + AES aes(AES_key_length::AES_128); aes.generate_keys(key_128); - CBC aes_cbc(aes); - - std::cout << "META" << std::endl; + GCM aes_gcm(aes); + std::cout << message_ll << std::endl; - aes_cbc.encrypt(message_ll); + aes_gcm.encrypt(message_ll, auth_data, auth_tag); std::cout << message_ll << std::endl; - aes_cbc.decrypt(message_ll); + aes_gcm.decrypt(message_ll, auth_data, auth_tag); std::cout << message_ll << std::endl; return 0;