You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

63 lines
2.4 KiB

#include <tinycrypt/aes.h>
#include <tinycrypt/ccm_mode.h>
#include <tinycrypt/constants.h>
#include <string.h>
#include <stdio.h>
#define SC_NONCE_SIZE 8
#define SC_TAG_SIZE 8
#define SC_SESSION_KEY_SIZE 16
int main() {
printf("=== Zero-initialized Debug Test ===\n");
// Test AES key setup
struct tc_aes_key_sched_struct sched;
uint8_t test_key[SC_SESSION_KEY_SIZE] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10};
printf("Testing AES key setup...\n");
int aes_result = tc_aes128_set_encrypt_key(&sched, test_key);
printf("tc_aes128_set_encrypt_key returned: %d\n", aes_result);
if (aes_result == TC_CRYPTO_SUCCESS) {
printf("✓ AES key setup successful\n");
// Test CCM config with zero-initialized structure
struct tc_ccm_mode_struct ccm_state = {0}; // Zero initialize
TCCcmMode_t c = &ccm_state;
uint8_t nonce[SC_NONCE_SIZE] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
printf("\nCCM State before config:\n");
printf(" sched pointer: %p\n", (void*)ccm_state.sched);
printf(" nonce pointer: %p\n", (void*)ccm_state.nonce);
printf(" mlen: %u\n", ccm_state.mlen);
printf("\nTesting CCM config...\n");
printf("Nonce size: %d, Tag size: %d\n", SC_NONCE_SIZE, SC_TAG_SIZE);
printf("Using TCCcmMode_t pointer: %p\n", (void*)c);
int ccm_result = tc_ccm_config(c, &sched, nonce, SC_NONCE_SIZE, SC_TAG_SIZE);
printf("tc_ccm_config returned: %d\n", ccm_result);
printf("\nCCM State after config:\n");
printf(" sched pointer: %p\n", (void*)ccm_state.sched);
printf(" nonce pointer: %p\n", (void*)ccm_state.nonce);
printf(" mlen: %u\n", ccm_state.mlen);
if (ccm_result == TC_CRYPTO_SUCCESS) {
printf("✓ CCM config successful\n");
} else {
printf("❌ CCM config failed!\n");
printf("This suggests there might be an issue with:\n");
printf(" 1. Parameter validation\n");
printf(" 2. Missing dependencies\n");
printf(" 3. Structure alignment issues\n");
printf(" 4. Missing initialization routines\n");
}
} else {
printf("❌ AES key setup failed\n");
}
return 0;
}