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.
 
 
 
 
 
 

56 lines
1.8 KiB

#include <tinycrypt/ecc.h>
#include <tinycrypt/ecc_dh.h>
#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("=== ECC-initialized Debug Test ===\n");
// Try to initialize ECC
printf("Initializing ECC...\n");
uECC_Curve curve = uECC_secp256r1();
if (curve) {
printf("✓ ECC curve initialized: %p\n", (void*)curve);
} else {
printf("❌ ECC curve initialization failed\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("\nTesting 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
struct tc_ccm_mode_struct ccm_state = {0};
TCCcmMode_t c = &ccm_state;
uint8_t nonce[SC_NONCE_SIZE] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
printf("\nTesting CCM config...\n");
int ccm_result = tc_ccm_config(c, &sched, nonce, SC_NONCE_SIZE, SC_TAG_SIZE);
printf("tc_ccm_config returned: %d\n", ccm_result);
if (ccm_result == TC_CRYPTO_SUCCESS) {
printf("✓ CCM config successful\n");
} else {
printf("❌ CCM config failed even with ECC initialization\n");
}
} else {
printf("❌ AES key setup failed\n");
}
return 0;
}