Commit 9408cff6 by Enrico Pozzobon

corrected esp32 interrupts

parent 33472d31
......@@ -61,11 +61,16 @@ void setup() {
memset(ad, 0, MAX_BYTES);
memset(m, 0, MAX_BYTES);
memset(c, 0, MAX_BYTES);
mlen = 8;
adlen = 0;
crypto_aead_encrypt(c, &clen, m, mlen, ad, adlen, nsec, npub, k);
crypto_aead_decrypt(m, &mlen, nsec, c, clen, ad, adlen, npub, k);
SerialOut.print("Hello, World!");
}
void loop() {
int res;
portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED;
uint16_t len = uartp_recv(cmdbuf, CMDBUF_LEN - 1);
uint8_t action = cmdbuf[0];
if (len == 0 || len > CMDBUF_LEN - 1)
......@@ -82,22 +87,18 @@ void loop() {
case 'p': my_assert(l == CRYPTO_NPUBBYTES); memcpy(npub, var, l); break;
case 's': my_assert(l == CRYPTO_NSECBYTES); memcpy(nsec, var, l); break;
case 'e':
noInterrupts();
asm("nop");
portENTER_CRITICAL(&mux);
digitalWrite(CRYPTO_BUSY, LOW);
res = crypto_aead_encrypt(c, &clen, m, mlen, ad, adlen, nsec, npub, k);
digitalWrite(CRYPTO_BUSY, HIGH);
asm("nop");
interrupts();
portEXIT_CRITICAL(&mux);
break;
case 'd':
noInterrupts();
asm("nop");
portENTER_CRITICAL(&mux);
digitalWrite(CRYPTO_BUSY, LOW);
res = crypto_aead_decrypt(m, &mlen, nsec, c, clen, ad, adlen, npub, k);
digitalWrite(CRYPTO_BUSY, HIGH);
asm("nop");
interrupts();
portEXIT_CRITICAL(&mux);
break;
case'M': var = m; rl = mlen; break;
case'C': var = c; rl = clen; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment