Created
May 6, 2020 07:40
-
-
Save kazuho/02c0d512ea9e10c6f45e0d0fad5de091 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(int argc, char **argv) | |
{ | |
static const uint8_t key[16] = {}, iv[12] = {}, aad[13] = {}, text[16384] = {}; | |
ptls_fusion_aesgcm_context_t ctx; | |
uint8_t encrypted[sizeof(text) + 16]; | |
size_t textlen = 16384; | |
// 以下のifを追加すると0.7秒遅くなる | |
if (sscanf(argv[1], "%zu", &textlen) != 1) { | |
fprintf(stderr, "failed to obtain text length from argument\n"); | |
return 1; | |
} | |
ptls_fusion_aesgcm_init(&ctx, key); | |
for (int i = 0; i < 1000000; ++i) | |
ptls_fusion_aesgcm_encrypt(&ctx, iv, aad, sizeof(aad), encrypted, text, textlen); | |
// このprintfにはバグがあり、sizeof(text)をtextlenに変えると、上掲の速度低下はなくなる | |
for (int i = 0; i < 16; ++i) | |
printf("%02x", encrypted[sizeof(text) + i]); | |
printf("\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment