Last active
March 2, 2018 22:40
-
-
Save jessicacarneiro/614bf64cf3be0abcf3c9ffe0730ae9b5 to your computer and use it in GitHub Desktop.
Revisions
-
jessicacarneiro revised this gist
Mar 2, 2018 . 1 changed file with 8 additions and 7 deletions.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 @@ -2,7 +2,8 @@ extern "C" { #include "../include/relic.h" } #define KEYSZ 16 #define CIPHER_TEXT_SZ(PLAINTEXT_SZ) (PLAINTEXT_SZ + BLOCK_SZ - (PLAINTEXT_SZ % BLOCK_SZ)) #include <string.h> @@ -21,8 +22,8 @@ void loop() uint8_t key[KEYSZ] = { 1 }; uint8_t iv[BC_LEN] = { 0 }; uint8_t input[5] = {'A','l','i','c','e'}; uint8_t output[CIPHER_TEXT_SZ(5)]; int output_sz = CIPHER_TEXT_SZ(5); Serial.print("1.Input: "); for (int i = 0; i < 5; i++) { @@ -31,20 +32,20 @@ void loop() } Serial.println("\n"); if (bc_aes_cbc_enc(output, &output_sz, input, 5, key, KEYSZ*8, iv) == STS_OK) Serial.print("2.Success enc\n"); else Serial.print("3.Error enc\n"); Serial.print("2.Output size in enc is "); Serial.println(output_sz); uint8_t dec[CIPHER_TEXT_SZ(5)]; memset(dec, 0, CIPHER_TEXT_SZ(5)); Serial.println(); int dec_sz = KEYSZ; if (bc_aes_cbc_dec(dec, &dec_sz, output, output_sz, key, KEYSZ*8, iv) == STS_OK) Serial.print("4.Success dec\n"); else Serial.print("4.Error dec\n"); -
jessicacarneiro revised this gist
Nov 1, 2017 . 1 changed file with 2 additions and 2 deletions.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 @@ -49,8 +49,8 @@ void loop() else Serial.print("4.Error dec\n"); Serial.print("5.Output size in dec is "); Serial.println(dec_sz); Serial.print("6.Output: "); for (int i = 0; i < dec_sz; i++) { -
jessicacarneiro revised this gist
Nov 1, 2017 . 1 changed file with 6 additions and 6 deletions.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 @@ -18,13 +18,13 @@ void setup() void loop() { 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; Serial.print("1.Input: "); for (int i = 0; i < 5; i++) { Serial.print(input[i], HEX); Serial.print(" "); @@ -40,8 +40,8 @@ void loop() Serial.println(output_sz); uint8_t dec[KEYSZ]; memset(dec, 0, KEYSZ); Serial.println(); int dec_sz = KEYSZ; if (bc_aes_cbc_dec(dec, &dec_sz, output, output_sz, key, KEYSZ, iv) == STS_OK) @@ -57,7 +57,7 @@ void loop() Serial.print(dec[i], HEX); Serial.print(" "); } Serial.println("\n"); delay(100); } -
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,63 @@ extern "C" { #include "../include/relic.h" } #define KEYSZ 128 #include <string.h> void setup() { Serial.begin(115200); while (!Serial) ; // wait for serial port to connect core_init(); pc_param_set_any(); } void loop() { 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; Serial.print("1.Input: "); for (int i = 0; i < 5; i++) { Serial.print(input[i], HEX); Serial.print(" "); } Serial.println("\n"); if (bc_aes_cbc_enc(output, &output_sz, input, 5, key, KEYSZ, iv) == STS_OK) Serial.print("2.Success enc\n"); else Serial.print("3.Error enc\n"); Serial.print("2.Output size in enc is "); Serial.println(output_sz); uint8_t dec[KEYSZ]; memset(dec, 0, KEYSZ); Serial.println(); int dec_sz = KEYSZ; if (bc_aes_cbc_dec(dec, &dec_sz, output, output_sz, key, KEYSZ, iv) == STS_OK) Serial.print("4.Success dec\n"); else Serial.print("4.Error dec\n"); Serial.print("5.Output size in dec is "); Serial.println(dec_sz); Serial.print("6.Output: "); for (int i = 0; i < dec_sz; i++) { Serial.print(dec[i], HEX); Serial.print(" "); } Serial.println("\n"); delay(100); }