mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
mbedtls tests: Add optional debug log output to AES stream tests
This commit is contained in:
parent
e6b8bc6ecb
commit
9c4c377f2d
@ -8,6 +8,7 @@
|
||||
#include "mbedtls/gcm.h"
|
||||
#include "unity.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "test_utils.h"
|
||||
@ -356,7 +357,7 @@ TEST_CASE("mbedtls CTR stream test", "[aes]")
|
||||
no matter how many bytes we encrypt each call
|
||||
*/
|
||||
for (int bytes_to_process = 1; bytes_to_process < SZ; bytes_to_process++) {
|
||||
|
||||
ESP_LOGD("test", "bytes_to_process %d", bytes_to_process);
|
||||
memset(nonce, 0xEE, 16);
|
||||
memset(chipertext, 0x0, SZ);
|
||||
memset(decryptedtext, 0x0, SZ);
|
||||
@ -370,10 +371,14 @@ TEST_CASE("mbedtls CTR stream test", "[aes]")
|
||||
mbedtls_aes_crypt_ctr(&ctx, length, &offset, nonce,
|
||||
stream_block, plaintext + idx, chipertext + idx );
|
||||
}
|
||||
ESP_LOG_BUFFER_HEXDUMP("expected", expected_cipher, SZ, ESP_LOG_DEBUG);
|
||||
ESP_LOG_BUFFER_HEXDUMP("actual ", chipertext, SZ, ESP_LOG_DEBUG);
|
||||
|
||||
TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher, chipertext, SZ);
|
||||
|
||||
// Decrypt
|
||||
memset(nonce, 0xEE, 16);
|
||||
memset(decryptedtext, 0x22, SZ);
|
||||
offset = 0;
|
||||
for (int idx = 0; idx < SZ; idx = idx + bytes_to_process) {
|
||||
// Limit length of last call to avoid exceeding buffer size
|
||||
@ -381,6 +386,7 @@ TEST_CASE("mbedtls CTR stream test", "[aes]")
|
||||
mbedtls_aes_crypt_ctr(&ctx, length, &offset, nonce,
|
||||
stream_block, chipertext + idx, decryptedtext + idx );
|
||||
}
|
||||
ESP_LOG_BUFFER_HEXDUMP("decrypted", decryptedtext, SZ, ESP_LOG_DEBUG);
|
||||
TEST_ASSERT_EQUAL_HEX8_ARRAY(plaintext, decryptedtext, SZ);
|
||||
}
|
||||
|
||||
@ -451,6 +457,7 @@ TEST_CASE("mbedtls OFB stream test", "[aes]")
|
||||
*/
|
||||
|
||||
for (int bytes_to_process = 1; bytes_to_process < SZ; bytes_to_process++) {
|
||||
ESP_LOGD("test", "bytes_to_process %d", bytes_to_process);
|
||||
// Encrypt
|
||||
memset(iv, 0xEE, 16);
|
||||
size_t offset = 0;
|
||||
@ -464,6 +471,7 @@ TEST_CASE("mbedtls OFB stream test", "[aes]")
|
||||
|
||||
// Decrypt
|
||||
memset(iv, 0xEE, 16);
|
||||
memset(decryptedtext, 0x22, SZ);
|
||||
offset = 0;
|
||||
for (int idx = 0; idx < SZ; idx = idx + bytes_to_process) {
|
||||
// Limit length of last call to avoid exceeding buffer size
|
||||
|
Loading…
x
Reference in New Issue
Block a user