You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I prepare a pair of Raspberry Pi Pico to do the RSA Encrypt and Decrypt between two boards.
And the program works, but it will freeze after encrypt a lot of data, I not very sure what the cause of the problem
To Reproduce
Steps to reproduce the behavior:
Flash the reciver and transmitter program at two Raspberry Pi Pico Board
Feed data to Transmitter board, and the Reciver recives the data and decrypt.
After a lot of data sent, the transmitter board Freezes when run the encrypt command
Expected behavior
It can transmit and recive a lot of data without any freeze
Screenshots
The ENCS will print before encrypt command, and the program freezes after prints this text
Additional context
The Loop section for the Transmitter at below, and the full program attached at the attatchment(But with some Chinese Comment).
Full program(Transmitter and Reciver in the same Source Code): main.zip
voidloop() {
// Wait for a client to connect
WiFiClient client = server.available();
if (client) {
// While the client is connectedwhile (client.connected()) {
// Check if the keys have been exchangedif (!keytrans) {
// Initialize the pk objectmbedtls_pk_init(&depk);
// Send the public keyint ret = transfer_sock(client, pkey_der, sizeof(pkey_der));
if (ret != 0) {
failblink();
}
// Receive the public key
ret = receive_sock(client, r_raw_der);
if (ret != 0) {
// Parse the public key
ret = mbedtls_pk_parse_public_key(&depk, r_raw_der, sizeof(r_raw_der));
} else {
failblink();
}
// Check the key formatif (mbedtls_pk_get_type(&depk) == MBEDTLS_PK_RSA && ret == 0) {
keytrans = true;
} else {
failblink();
}
} else {
// Start the actual data transfer// The buffer for the encrypted datauint8_t enc_data[128] = {};
// Empty the buffer// std::fill_n(enc_data, sizeof(enc_data), 0);// Receive the encrypted data
ret = receive_sock(client, enc_data);
if (ret == 0) {
failblink();
}
// The buffer for the signatureuint8_t sig_data[128] = {};
// Empty the buffer// std::fill_n(sig_data, sizeof(sig_data), 0);// Receive the signature
ret = receive_sock(client, sig_data);
if (ret == 0) {
failblink();
}
// Decrypt the datasize_t olen;
unsignedchar decrypted[85] = {0};
// Empty the buffer// std::fill_n(decrypted, sizeof(decrypted), 0);
ret = mbedtls_rsa_pkcs1_decrypt(
mbedtls_pk_rsa(keys),
mbedtls_ctr_drbg_random,
&drbg,
MBEDTLS_RSA_PRIVATE,
&olen,
enc_data,
decrypted,
sizeof(decrypted));
if (ret != 0) {
failblink();
}
// Get the hash of the received messageuint8_t rhash[32] = {0};
// Empty the buffer// std::fill_n(rhash, sizeof(rhash), 0);mbedtls_sha256(decrypted, olen, rhash, 0);
// Verify the signature
ret = mbedtls_rsa_pkcs1_verify(
mbedtls_pk_rsa(depk),
mbedtls_ctr_drbg_random,
&drbg,
MBEDTLS_RSA_PUBLIC,
MBEDTLS_MD_SHA256,
sizeof(rhash),
rhash,
sig_data);
if (ret == 0) {
// Write the decrypted data, using the correct receive length
Serial.write(decrypted, olen);
}
}
}
failblink();
} else {
// Wait and blinkdelay(100);
cyw43_arch_gpio_put(0, 1);
delay(200);
cyw43_arch_gpio_put(0, 0);
}
}
The text was updated successfully, but these errors were encountered:
Describe the bug
I prepare a pair of Raspberry Pi Pico to do the RSA Encrypt and Decrypt between two boards.
And the program works, but it will freeze after encrypt a lot of data, I not very sure what the cause of the problem
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Screenshots
![image](https://private-user-images.githubusercontent.com/46966555/280198395-9793e5af-f8bd-4928-930f-047d67b7429a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUxMTA1OTUsIm5iZiI6MTcyNTExMDI5NSwicGF0aCI6Ii80Njk2NjU1NS8yODAxOTgzOTUtOTc5M2U1YWYtZjhiZC00OTI4LTkzMGYtMDQ3ZDY3Yjc0MjlhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MzElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODMxVDEzMTgxNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTkwYjQzYzBjZTI1OTAzZDE0NTcxODA1ODVlMzFiM2Y2OWQwYzlkMmQ3ZjExMTIwY2FiY2Y4NGRkZTcyOWYxZTQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.zWlg5lbhYpmzlvnQ4fw53Z_xUxj-1TD9kVYWA_-V64k)
The
ENCS
will print before encrypt command, and the program freezes after prints this textBoard Info:
Additional context
The Loop section for the Transmitter at below, and the full program attached at the attatchment(But with some Chinese Comment).
Full program(Transmitter and Reciver in the same Source Code):
main.zip
The text was updated successfully, but these errors were encountered: