Created
November 1, 2017 15:44
-
-
Save jessicacarneiro/01d24ba27fd943836056dfa02a1c3a27 to your computer and use it in GitHub Desktop.
Revisions
-
jessicacarneiro created this gist
Nov 1, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ #include <stdio.h> #include "relic.h" #define KEYSZ 128 int main() { if (core_init() != STS_OK) { core_clean(); return EXIT_FAILURE; } if (pc_param_set_any() != STS_OK) { THROW(ERR_NO_CURVE); core_clean(); return EXIT_FAILURE; } uint8_t key[KEYSZ] = { 1 }; uint8_t iv[BC_LEN] = { 0 }; uint8_t input[5] = {'A','l','i','c','e'}; uint8_t output[KEYSZ]; int output_sz = KEYSZ; if (bc_aes_cbc_enc(output, &output_sz, input, 5, key, KEYSZ, iv) == STS_OK) printf("1.Success enc\n"); else printf("1.Error enc\n"); printf("2.Output size in enc is %d\n", output_sz); printf("3.Input: "); for (int i = 0; i < 5; i++) { printf("%c", input[i]); } printf("\n"); uint8_t dec[KEYSZ]; memset(dec, 0, KEYSZ); printf("\n"); int dec_sz = KEYSZ; if (bc_aes_cbc_dec(dec, &dec_sz, output, output_sz, key, KEYSZ, iv) == STS_OK) printf("4.Success dec\n"); else printf("4.Error dec\n"); printf("5.Output size in dec is %d\n", dec_sz); printf("6.Output: "); for (int i = 0; i < dec_sz; i++) { printf("%c", dec[i]); } printf("\n"); }