ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
lib/platform/wasm/stubs/crypto.c
Go to the documentation of this file.
1
6#include <ascii-chat/common.h>
11#include <stdint.h>
12#include <stdbool.h>
13#include <string.h>
14
15// Ed25519 signature stubs (not needed for basic handshake)
16asciichat_error_t ed25519_verify_signature(const uint8_t public_key[32], const uint8_t *message, size_t message_len,
17 const uint8_t signature[64], const char *gpg_key_id) {
18 // Server identity verification not supported in WASM (no known_hosts file)
19 return ASCIICHAT_OK;
20}
21
22asciichat_error_t ed25519_sign_message(const private_key_t *key, const uint8_t *message, size_t message_len,
23 uint8_t signature[64]) {
24 // Client authentication not supported in WASM (no client keys)
25 return SET_ERRNO(ERROR_NOT_SUPPORTED, "Ed25519 signing not supported in WASM");
26}
27
28// Public key parsing stubs
29asciichat_error_t parse_public_keys(const char *input, public_key_t *keys_out, size_t *num_keys, size_t max_keys) {
30 // Key file parsing not supported in WASM
31 return SET_ERRNO(ERROR_NOT_SUPPORTED, "Public key file parsing not supported in WASM");
32}
33
34// Known hosts stubs (no filesystem in WASM)
35asciichat_error_t check_known_host(const char *server_ip, uint16_t port, const uint8_t server_key[32]) {
36 // Known hosts checking not supported in WASM
37 return ASCIICHAT_OK;
38}
39
41 // Known hosts checking not supported in WASM
42 return ASCIICHAT_OK;
43}
44
45bool display_mitm_warning(const char *server_ip, uint16_t port, const uint8_t expected_key[32],
46 const uint8_t received_key[32]) {
47 // MITM warnings not displayed in WASM (browser console log instead)
48 return false;
49}
50
51bool prompt_unknown_host(const char *server_ip, uint16_t port, const uint8_t server_key[32]) {
52 // No interactive prompts in WASM - auto-accept
53 return true;
54}
55
56bool prompt_unknown_host_no_identity(const char *server_ip, uint16_t port) {
57 // No interactive prompts in WASM - auto-accept
58 return true;
59}
60
61asciichat_error_t add_known_host(const char *server_ip, uint16_t port, const uint8_t server_key[32]) {
62 // Known hosts file updates not supported in WASM
63 return ASCIICHAT_OK;
64}
65
66const char *get_known_hosts_path(void) {
67 // No filesystem in WASM
68 return NULL;
69}
70
71// Password prompt stub
72asciichat_error_t prompt_password(const char *prompt_text, char *password_out, size_t password_max_len) {
73 // Password prompts not supported in WASM
74 return SET_ERRNO(ERROR_NOT_SUPPORTED, "Password prompts not supported in WASM");
75}
⚙️ Common definitions, error codes, macros, and types shared throughout the application
unsigned short uint16_t
Definition common.h:57
unsigned char uint8_t
Definition common.h:56
bool prompt_unknown_host(const char *server_ip, uint16_t port, const uint8_t server_key[32])
Interactive prompt for unknown host - returns true if user wants to add, false to abort.
bool prompt_unknown_host_no_identity(const char *server_ip, uint16_t port)
Interactive prompt for unknown host without identity key - returns true if user wants to continue,...
asciichat_error_t check_known_host_no_identity(const char *server_ip, uint16_t port)
Check known_hosts for servers without identity key (no-identity entries)
asciichat_error_t add_known_host(const char *server_ip, uint16_t port, const uint8_t server_key[32])
Add server to known_hosts.
bool display_mitm_warning(const char *server_ip, uint16_t port, const uint8_t expected_key[32], const uint8_t received_key[32])
Display MITM warning with key comparison and prompt user for confirmation.
asciichat_error_t check_known_host(const char *server_ip, uint16_t port, const uint8_t server_key[32])
Check if server key is in known_hosts.
#define SET_ERRNO(code, context_msg,...)
Set error code with custom context message and log it, returning the error code.
asciichat_error_t
Error and exit codes - unified status values (0-255)
Definition error_codes.h:49
@ ASCIICHAT_OK
Definition error_codes.h:51
@ ERROR_NOT_SUPPORTED
Definition error_codes.h:74
asciichat_error_t ed25519_verify_signature(const uint8_t public_key[32], const uint8_t *message, size_t message_len, const uint8_t signature[64], const char *gpg_key_id)
Verify an Ed25519 signature.
asciichat_error_t parse_public_keys(const char *input, public_key_t *keys_out, size_t *num_keys, size_t max_keys)
Parse all SSH/GPG public keys from any format (returns all keys)
asciichat_error_t ed25519_sign_message(const private_key_t *key, const uint8_t *message, size_t message_len, uint8_t signature[64])
Sign a message with Ed25519 (uses SSH agent if available, otherwise in-memory key)
asciichat_error_t prompt_password(const char *prompt_text, char *password_out, size_t password_max_len)
Prompt the user for a password with secure input.
const char * get_known_hosts_path(void)
ClangTool/LibTooling compatibility shim for stdbool.h.
Private key structure (for server –ssh-key)
Definition key_types.h:91
Public key structure.
Definition key_types.h:69
Transport abstraction layer for ACIP protocol.