Skip to content

Commit

Permalink
main.cpp: Added auth_data and auth_tag for GCM
Browse files Browse the repository at this point in the history
  • Loading branch information
ogtomi committed May 18, 2023
1 parent 934ccf3 commit 6b873d3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "meta/cfb.h"
#include "meta/ofb.h"
#include "meta/ctr.h"
#include "meta/gcm.h"

int main()
{
Expand All @@ -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> aes_cbc(aes);

std::cout << "META" << std::endl;
GCM<AES> 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;
Expand Down

0 comments on commit 6b873d3

Please sign in to comment.