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.
41 lines
1.2 KiB
41 lines
1.2 KiB
#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; |
|
}
|
|
|