Files
utun2/tests/debug_test.c
T
Evgeny 1d4741e69e Clean: Remove all obsolete ETCP tests, keep only working handshake test
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
2026-01-21 08:00:54 +03:00

42 lines
1.2 KiB
C

#include "../src/secure_channel.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\n", ctx.initialized, ctx.peer_key_set);
// Manually set peer key
memcpy(ctx.peer_public_key, keys.public_key, SC_PUBKEY_SIZE);
ctx.peer_key_set = 1;
printf("Manually set peer key\n");
// 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);
}
}
return 0;
}