Skip to content

Instantly share code, notes, and snippets.

@jessicacarneiro
Last active October 12, 2017 16:05
Show Gist options
  • Select an option

  • Save jessicacarneiro/c57bd1196093b06a192a1356a3fb8ddd to your computer and use it in GitHub Desktop.

Select an option

Save jessicacarneiro/c57bd1196093b06a192a1356a3fb8ddd to your computer and use it in GitHub Desktop.
How to use HMAC with RELIC on Arduino
extern "C" {
#include "../include/relic.h"
}
void setup() {
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect
}
core_init();
pc_param_set_any();
}
void loop() {
uint8_t mac[MD_LEN];
uint8_t key[] = "key";
const uint8_t data[] = "The quick brown fox jumps over the lazy dog";
md_hmac(mac, data, sizeof(data)-1, key, sizeof(key)-1);
// answer should be f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8
for (int i = 0; i < MD_LEN; i++)
Serial.print(mac[i], HEX);
Serial.println("\n");
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment