Deleted 13 obsolete ETCP and connection test files: - test_etcp.c, test_etcp_2instance.c, test_etcp_connection_init.c - test_etcp_connections_send.c, test_etcp_link_crypto_working.c - test_etcp_link_simple.c, test_etcp_simple.c, test_etcp_stress.c - test_etcp_connection_full.c, test_etcp_connection_real.c - test_etcp_full_lifecycle.c, test_etcp_new.c, test_etcp_simple_real.c Updated Makefile.am to include only: - test_etcp_two_instances_fixed (working handshake test) - Essential module tests (routing, secure_channel, lib, etc.) Result: Clean test suite with only functional ETCP handshake demonstration
59 lines
2.1 KiB
C
59 lines
2.1 KiB
C
#include "../src/secure_channel.h"
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
|
|
int main() {
|
|
printf("=== Debug Test ===\n");
|
|
|
|
struct SC_MYKEYS keys;
|
|
for (int i = 0; i < SC_PRIVKEY_SIZE; i++) {
|
|
keys.private_key[i] = i;
|
|
keys.public_key[i] = i + 64;
|
|
}
|
|
|
|
sc_context_t ctx;
|
|
int result = sc_init_ctx(&ctx, &keys);
|
|
printf("sc_init_ctx returned: %d\n", result);
|
|
|
|
if (result == SC_OK) {
|
|
printf("Context initialized successfully\n");
|
|
printf("initialized: %d, peer_key_set: %d, session_ready: %d\n",
|
|
ctx.initialized, ctx.peer_key_set, ctx.session_ready);
|
|
|
|
// Manually set peer key and session ready
|
|
memcpy(ctx.peer_public_key, keys.public_key, SC_PUBKEY_SIZE);
|
|
ctx.peer_key_set = 1;
|
|
ctx.session_ready = 1; // This is the key!
|
|
printf("Manually set peer key and session ready\n");
|
|
printf("initialized: %d, peer_key_set: %d, session_ready: %d\n",
|
|
ctx.initialized, ctx.peer_key_set, ctx.session_ready);
|
|
|
|
// Try to encrypt
|
|
uint8_t plaintext[] = "Hello";
|
|
uint8_t ciphertext[256];
|
|
size_t ciphertext_len;
|
|
|
|
printf("Trying to encrypt...\n");
|
|
int enc_result = sc_encrypt(&ctx, plaintext, 5, ciphertext, &ciphertext_len);
|
|
printf("sc_encrypt returned: %d\n", enc_result);
|
|
|
|
if (enc_result == SC_OK) {
|
|
printf("Encryption successful! Ciphertext length: %zu\n", ciphertext_len);
|
|
|
|
// Try to decrypt
|
|
uint8_t decrypted[256];
|
|
size_t decrypted_len;
|
|
printf("Trying to decrypt...\n");
|
|
int dec_result = sc_decrypt(&ctx, ciphertext, ciphertext_len, decrypted, &decrypted_len);
|
|
printf("sc_decrypt returned: %d\n", dec_result);
|
|
|
|
if (dec_result == SC_OK) {
|
|
printf("Decryption successful! Decrypted length: %zu\n", decrypted_len);
|
|
printf("Original: '%.*s', Decrypted: '%.*s'\n", 5, plaintext, (int)decrypted_len, decrypted);
|
|
}
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|