ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
lib/wasm/stubs/crypto.c
Go to the documentation of this file.
1
5
8#include <ascii-chat/common.h>
15#include <stdint.h>
16#include <stdbool.h>
17#include <string.h>
18
19// Public-key list parsing and TOFU prompts are unavailable in browser builds;
20// browser-configured key material uses the shared SSH parser and raw-key pinning.
21asciichat_error_t parse_public_keys(const char *input, public_key_t *keys_out, size_t *num_keys, size_t max_keys) {
22 // Key file parsing not supported in WASM
23 return SET_ERRNO(ERROR_NOT_SUPPORTED, "Public key file parsing not supported in WASM");
24}
25
26// Known hosts stubs (no filesystem in WASM)
27asciichat_error_t check_known_host(const char *server_ip, uint16_t port, const uint8_t server_key[ED25519_PUBLIC_KEY_SIZE]) {
28 // Known hosts checking not supported in WASM
29 return ASCIICHAT_OK;
30}
31
33 // Known hosts checking not supported in WASM
34 return ASCIICHAT_OK;
35}
36
37bool display_mitm_warning(const char *server_ip, uint16_t port, const uint8_t expected_key[ED25519_PUBLIC_KEY_SIZE], const uint8_t received_key[ED25519_PUBLIC_KEY_SIZE]) {
38 // MITM warnings not displayed in WASM (browser console log instead)
39 return false;
40}
41
42bool prompt_unknown_host(const char *server_ip, uint16_t port, const uint8_t server_key[ED25519_PUBLIC_KEY_SIZE]) {
43 // No interactive prompts in WASM - auto-accept
44 return true;
45}
46
47bool prompt_unknown_host_no_identity(const char *server_ip, uint16_t port) {
48 // No interactive prompts in WASM - auto-accept
49 return true;
50}
51
52asciichat_error_t add_known_host(const char *server_ip, uint16_t port, const uint8_t server_key[ED25519_PUBLIC_KEY_SIZE]) {
53 // Known hosts file updates not supported in WASM
54 return ASCIICHAT_OK;
55}
56
57const char *get_known_hosts_path(void) {
58 // No filesystem in WASM
59 return NULL;
60}
61
62// Password prompt stub
63asciichat_error_t prompt_password(const char *prompt_text, char *password_out, size_t password_max_len) {
64 // Password prompts not supported in WASM
65 return SET_ERRNO(ERROR_NOT_SUPPORTED, "Password prompts not supported in WASM");
66}
67
68// Preserve the browser's existing raw-key pinning path; there is no native
69// known_hosts file or terminal identity card in the browser.
71 bool *has_stored_key) {
72 if (has_stored_key)
73 *has_stored_key = false;
74 if (stored_key)
75 memset(stored_key, 0, sizeof(stored_key));
76 return check_known_host(server_ip, port, server_key);
77}
78
79void key_identity_announce(const char *label, const public_key_t *key) {
80 (void)label;
81 (void)key;
82}
83
#define SET_ERRNO(code,...)
unsigned short uint16_t
unsigned char uint8_t
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).
void known_hosts_destroy(void)
Cleanup function to free cached known_hosts path.
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
@ ASCIICHAT_OK
Definition error_codes.h:50
@ ERROR_NOT_SUPPORTED
Definition error_codes.h:74
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 prompt_password(const char *prompt_text, char *password_out, size_t password_max_len)
Prompt the user for a password with secure input.
⚙️ Common definitions, error codes, macros, and types shared throughout the application
Transport abstraction layer for ACIP protocol.
Known hosts management for MITM attack prevention.
const char * get_known_hosts_path(void)
bool prompt_unknown_host(const char *server_ip, uint16_t port, const uint8_t server_key[ED25519_PUBLIC_KEY_SIZE])
bool display_mitm_warning(const char *server_ip, uint16_t port, const uint8_t expected_key[ED25519_PUBLIC_KEY_SIZE], const uint8_t received_key[ED25519_PUBLIC_KEY_SIZE])
asciichat_error_t check_known_host_with_key(const char *server_ip, uint16_t port, const uint8_t server_key[ED25519_PUBLIC_KEY_SIZE], uint8_t stored_key[ED25519_PUBLIC_KEY_SIZE], bool *has_stored_key)
void key_identity_announce(const char *label, const public_key_t *key)
asciichat_error_t add_known_host(const char *server_ip, uint16_t port, const uint8_t server_key[ED25519_PUBLIC_KEY_SIZE])
asciichat_error_t check_known_host(const char *server_ip, uint16_t port, const uint8_t server_key[ED25519_PUBLIC_KEY_SIZE])
#define ED25519_PUBLIC_KEY_SIZE
Ed25519 public key size in bytes.
Definition sizes.h:38
🔤 String Manipulation and Shell Escaping Utilities
The normalized public identity used by ascii-chat's crypto and key-management code.
Definition key_types.h:83