Skip to content

Instantly share code, notes, and snippets.

@kazuho
Created May 7, 2020 04:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazuho/59c0a9c49654dd9aed96e136e7e2b066 to your computer and use it in GitHub Desktop.
Save kazuho/59c0a9c49654dd9aed96e136e7e2b066 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "picotls/fusion.h"
int main(int argc, char **argv)
{
static const uint8_t key[16] = {}, iv[12] = {}, aad[13] = {};
ptls_fusion_aesgcm_context_t ctx;
size_t textlen = 16384;
if (sscanf(argv[1], "%zu", &textlen) != 1) {
fprintf(stderr, "failed to obtain text length from argument\n");
return 1;
}
uint8_t *text = malloc(textlen + 16);
memset(text, 0, textlen + 16);
ptls_fusion_aesgcm_init(&ctx, key);
for (int i = 0; i < 1000000; ++i)
ptls_fusion_aesgcm_encrypt(&ctx, iv, aad, sizeof(aad), text, text, textlen);
for (int i = 0; i < 16; ++i)
printf("%02x", text[textlen + i]);
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment