ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
discovery_keys.h File Reference

Discovery Server Public Key Trust Management. More...

Go to the source code of this file.

Macros

#define ACDS_OFFICIAL_SERVER   ACDS_OFFICIAL_SERVER_HOSTNAME
 Official ACDS server hostname (automatic HTTPS key trust).
#define ACDS_OFFICIAL_KEY_SSH_URL   "https://discovery.ascii-chat.com/key.pub"
 Default HTTPS URLs for official ACDS keys.
#define ACDS_OFFICIAL_KEY_GPG_URL   "https://discovery.ascii-chat.com/key.gpg"
#define ACDS_KEYS_CACHE_DIR   "acds_keys"
 Key cache directory (relative to config dir).

Functions

asciichat_error_t discovery_keys_verify (const char *acds_server, const char *key_spec, uint8_t pubkey_out[32])
 Verify and load ACDS server public key.
asciichat_error_t discovery_keys_download_https (const char *url, uint8_t pubkey_out[32])
 Download key from HTTPS URL.
asciichat_error_t discovery_keys_load_file (const char *file_path, uint8_t pubkey_out[32])
 Load key from local file.
asciichat_error_t discovery_keys_get_cache_path (const char *acds_server, char *path_out, size_t path_size)
 Get cached key path for ACDS server.
asciichat_error_t discovery_keys_load_cached (const char *acds_server, uint8_t pubkey_out[32])
 Check if cached key exists and load it.
asciichat_error_t discovery_keys_save_cached (const char *acds_server, const uint8_t pubkey[32])
 Save key to cache.
asciichat_error_t discovery_keys_verify_change (const char *acds_server, const uint8_t old_pubkey[32], const uint8_t new_pubkey[32])
 Verify key change with user.
asciichat_error_t discovery_keys_clear_cache (const char *acds_server)
 Clear cached key for ACDS server.

Detailed Description

Discovery Server Public Key Trust Management.

This module handles verification and trust management for ACDS server public keys. It provides functionality to:

  • Download keys from HTTPS URLs using lib/crypto/http_client.h
  • Load keys from local files (SSH/GPG formats)
  • Special-case automatic trust for discovery-service.ascii-chat.com
  • Cache keys locally and detect changes (requires user verification)
  • Parse github:user and gitlab:user.gpg key specifications

Trust Model

Official ACDS Server (discovery-service.ascii-chat.com):

  • Automatically trusts keys downloaded from https://discovery-service.ascii-chat.com/key.pub or /key.gpg
  • First connection: downloads and caches key
  • Subsequent connections: uses cached key
  • Key changes: requires user verification (prevents MITM attacks)

Third-Party ACDS Servers:

  • Requires explicit –discovery-service-key configuration
  • Can be HTTPS URL, local file path, or github:user/gitlab:user specification
  • Keys are cached after first successful download/verification
  • Key changes require user verification

Usage

// Download and verify key from HTTPS URL
uint8_t pubkey[32];
asciichat_error_t result = discovery_keys_verify("acds.example.com",
"https://acds.example.com/key.pub",
pubkey);
// Automatic trust for official server
result = discovery_keys_verify("discovery-service.ascii-chat.com", NULL,
pubkey);
// Load from local file
result = discovery_keys_verify("acds.example.com", "/path/to/key.pub",
pubkey);
// GitHub key
result = discovery_keys_verify("acds.example.com", "github:zfogg", pubkey);
asciichat_error_t discovery_keys_verify(const char *acds_server, const char *key_spec, uint8_t pubkey_out[32])
Verify and load ACDS server public key.
unsigned char uint8_t
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
Author
Zachary Fogg me@zf.nosp@m.o.gg
Date
January 2026

Definition in file discovery_keys.h.

Macro Definition Documentation

◆ ACDS_KEYS_CACHE_DIR

#define ACDS_KEYS_CACHE_DIR   "acds_keys"

Key cache directory (relative to config dir).

Definition at line 83 of file discovery_keys.h.

Referenced by discovery_keys_get_cache_path().

◆ ACDS_OFFICIAL_KEY_GPG_URL

#define ACDS_OFFICIAL_KEY_GPG_URL   "https://discovery.ascii-chat.com/key.gpg"

Definition at line 78 of file discovery_keys.h.

Referenced by discovery_keys_verify().

◆ ACDS_OFFICIAL_KEY_SSH_URL

#define ACDS_OFFICIAL_KEY_SSH_URL   "https://discovery.ascii-chat.com/key.pub"

Default HTTPS URLs for official ACDS keys.

Definition at line 77 of file discovery_keys.h.

Referenced by discovery_keys_verify().

◆ ACDS_OFFICIAL_SERVER

#define ACDS_OFFICIAL_SERVER   ACDS_OFFICIAL_SERVER_HOSTNAME

Official ACDS server hostname (automatic HTTPS key trust).

References the authoritative definition from network/acip/acds.h

Definition at line 72 of file discovery_keys.h.

Referenced by discovery_keys_verify().

Function Documentation

◆ discovery_keys_clear_cache()

asciichat_error_t discovery_keys_clear_cache ( const char * acds_server)

Clear cached key for ACDS server.

Removes the cached key for the given ACDS server. Useful for testing or forcing key re-download.

Parameters
acds_serverACDS server hostname
Returns
ASCIICHAT_OK on success, error code otherwise

Definition at line 250 of file discovery_keys.c.

250 {
251 if (!acds_server) {
252 return SET_ERRNO(ERROR_INVALID_PARAM, "NULL parameter");
253 }
254
255 char cache_path[PLATFORM_MAX_PATH_LENGTH];
257 acds_server, cache_path, sizeof(cache_path));
258 if (result != ASCIICHAT_OK) {
259 return result;
260 }
261
262 if (platform_is_regular_file(cache_path)) {
263 if (remove(cache_path) != 0) {
265 "Failed to delete cached key: %s", cache_path);
266 }
267 log_debug("Cleared cached ACDS key for server: %s", acds_server);
268 }
269
270 return ASCIICHAT_OK;
271}
#define SET_ERRNO(code,...)
#define SET_ERRNO_SYS(code,...)
asciichat_error_t discovery_keys_get_cache_path(const char *acds_server, char *path_out, size_t path_size)
Get cached key path for ACDS server.
@ ASCIICHAT_OK
Definition error_codes.h:50
@ ERROR_FILE_OPERATION
@ ERROR_INVALID_PARAM
#define log_debug(...)
Log a DEBUG message.
Definition log/log.h:565
int platform_is_regular_file(const char *path)
Definition util.c:136

References ASCIICHAT_OK, discovery_keys_get_cache_path(), ERROR_FILE_OPERATION, ERROR_INVALID_PARAM, log_debug, platform_is_regular_file(), SET_ERRNO, and SET_ERRNO_SYS.

◆ discovery_keys_download_https()

asciichat_error_t discovery_keys_download_https ( const char * url,
uint8_t pubkey_out[32] )

Download key from HTTPS URL.

Downloads a public key from an HTTPS URL using lib/crypto/http_client.h. Supports both SSH (OpenSSH format) and GPG (ASCII-armored or binary) keys.

Parameters
urlHTTPS URL to download from
pubkey_outEd25519 public key output (32 bytes)
Returns
ASCIICHAT_OK on success, error code otherwise

Definition at line 96 of file discovery_keys.c.

97 {
98 if (!url || !pubkey_out) {
99 return SET_ERRNO(ERROR_INVALID_PARAM, "NULL parameter");
100 }
101
102 log_debug("Downloading ACDS key from %s", url);
103
104 // Use existing parse_public_key infrastructure which handles HTTPS URLs
105 public_key_t key;
106 asciichat_error_t result = parse_public_key(url, &key);
107 if (result != ASCIICHAT_OK) {
109 "Failed to download and parse ACDS key from %s", url);
110 }
111
112 memcpy(pubkey_out, key.key, ED25519_PUBLIC_KEY_SIZE);
113 log_debug("Successfully downloaded and parsed ACDS key from %s", url);
114 return ASCIICHAT_OK;
115}
@ ERROR_CRYPTO_KEY
uint8_t key[CRYPTO_PUBLIC_KEY_SIZE]
Definition key_types.h:85
asciichat_error_t parse_public_key(const char *input, public_key_t *key_out)
Parse SSH/GPG public key from any format (returns first key only).
Definition keys.c:37
#define ED25519_PUBLIC_KEY_SIZE
Ed25519 public key size in bytes.
Definition sizes.h:38
The normalized public identity used by ascii-chat's crypto and key-management code.
Definition key_types.h:83

References ASCIICHAT_OK, ED25519_PUBLIC_KEY_SIZE, ERROR_CRYPTO_KEY, ERROR_INVALID_PARAM, public_key_t::key, log_debug, parse_public_key(), and SET_ERRNO.

◆ discovery_keys_get_cache_path()

asciichat_error_t discovery_keys_get_cache_path ( const char * acds_server,
char * path_out,
size_t path_size )

Get cached key path for ACDS server.

Returns the local cache path for a given ACDS server's key. Path: ~/.config/ascii-chat/acds_keys/<hostname>/key.pub

Parameters
acds_serverACDS server hostname
path_outOutput buffer for cache path
path_sizeSize of output buffer
Returns
ASCIICHAT_OK on success, error code otherwise

Definition at line 143 of file discovery_keys.c.

145 {
146 if (!acds_server || !path_out || path_size == 0) {
147 return SET_ERRNO(ERROR_INVALID_PARAM, "NULL parameter");
148 }
149
150 char *config_dir = get_config_dir();
151 if (!config_dir) {
152 return SET_ERRNO(ERROR_CONFIG, "Failed to get config directory");
153 }
154
155 // Path: ~/.config/ascii-chat/acds_keys/<hostname>/key.pub
156 safe_snprintf(path_out, path_size,
157 "%s" ACDS_KEYS_CACHE_DIR PATH_SEPARATOR_STR
158 "%s" PATH_SEPARATOR_STR "key.pub",
159 config_dir, acds_server);
160 SAFE_FREE(config_dir);
161
162 return ASCIICHAT_OK;
163}
#define ACDS_KEYS_CACHE_DIR
Key cache directory (relative to config dir).
#define SAFE_FREE(ptr)
@ ERROR_CONFIG
Definition error_codes.h:56
char * get_config_dir(void)
Get configuration directory path with XDG_CONFIG_HOME support.
Definition path.c:293

References ACDS_KEYS_CACHE_DIR, ASCIICHAT_OK, ERROR_CONFIG, ERROR_INVALID_PARAM, get_config_dir(), SAFE_FREE, and SET_ERRNO.

Referenced by discovery_keys_clear_cache(), discovery_keys_load_cached(), and discovery_keys_save_cached().

◆ discovery_keys_load_cached()

asciichat_error_t discovery_keys_load_cached ( const char * acds_server,
uint8_t pubkey_out[32] )

Check if cached key exists and load it.

Attempts to load a cached key for the given ACDS server.

Parameters
acds_serverACDS server hostname
pubkey_outEd25519 public key output (32 bytes)
Returns
ASCIICHAT_OK if cached key exists and loaded successfully, error otherwise

Definition at line 166 of file discovery_keys.c.

167 {
168 if (!acds_server || !pubkey_out) {
169 return SET_ERRNO(ERROR_INVALID_PARAM, "NULL parameter");
170 }
171
172 char cache_path[PLATFORM_MAX_PATH_LENGTH];
174 acds_server, cache_path, sizeof(cache_path));
175 if (result != ASCIICHAT_OK) {
176 return result;
177 }
178
179 // Check if cached key exists
180 if (!platform_is_regular_file(cache_path)) {
181 return SET_ERRNO(ERROR_FILE_NOT_FOUND, "No cached key for ACDS server: %s",
182 acds_server);
183 }
184
185 // Load cached key using existing infrastructure
186 return discovery_keys_load_file(cache_path, pubkey_out);
187}
asciichat_error_t discovery_keys_load_file(const char *file_path, uint8_t pubkey_out[32])
Load key from local file.
@ ERROR_FILE_NOT_FOUND

References ASCIICHAT_OK, discovery_keys_get_cache_path(), discovery_keys_load_file(), ED25519_PUBLIC_KEY_SIZE, ERROR_FILE_NOT_FOUND, ERROR_INVALID_PARAM, platform_is_regular_file(), and SET_ERRNO.

Referenced by discovery_keys_verify().

◆ discovery_keys_load_file()

asciichat_error_t discovery_keys_load_file ( const char * file_path,
uint8_t pubkey_out[32] )

Load key from local file.

Loads a public key from a local file. Supports:

  • OpenSSH format (.pub files)
  • GPG ASCII-armored format (.asc, .gpg)
  • GPG binary format
Parameters
file_pathPath to key file
pubkey_outEd25519 public key output (32 bytes)
Returns
ASCIICHAT_OK on success, error code otherwise

Definition at line 118 of file discovery_keys.c.

119 {
120 if (!file_path || !pubkey_out) {
121 return SET_ERRNO(ERROR_INVALID_PARAM, "NULL parameter");
122 }
123
124 log_debug("Loading ACDS key from file: %s", file_path);
125
126 // Use existing parse_public_key infrastructure which handles file paths
127 public_key_t key;
129 if (result != ASCIICHAT_OK) {
130 return SET_ERRNO(ERROR_CRYPTO_KEY, "Failed to load ACDS key from file: %s",
131 file_path);
132 }
133
134 memcpy(pubkey_out, key.key, ED25519_PUBLIC_KEY_SIZE);
135 log_debug("Successfully loaded ACDS key from file: %s", file_path);
136 return ASCIICHAT_OK;
137}
char file_path[PLATFORM_MAX_PATH_LENGTH]
Definition mmap.c:44

References ASCIICHAT_OK, ED25519_PUBLIC_KEY_SIZE, ERROR_CRYPTO_KEY, ERROR_INVALID_PARAM, file_path, public_key_t::key, log_debug, parse_public_key(), and SET_ERRNO.

Referenced by discovery_keys_load_cached().

◆ discovery_keys_save_cached()

asciichat_error_t discovery_keys_save_cached ( const char * acds_server,
const uint8_t pubkey[32] )

Save key to cache.

Caches a public key for the given ACDS server.

Parameters
acds_serverACDS server hostname
pubkeyPublic key to cache (32 bytes)
Returns
ASCIICHAT_OK on success, error code otherwise

Definition at line 190 of file discovery_keys.c.

191 {
192 if (!acds_server || !pubkey) {
193 return SET_ERRNO(ERROR_INVALID_PARAM, "NULL parameter");
194 }
195
196 char cache_path[PLATFORM_MAX_PATH_LENGTH];
198 acds_server, cache_path, sizeof(cache_path));
199 if (result != ASCIICHAT_OK) {
200 return result;
201 }
202
203 // Create cache directory if it doesn't exist
204 char dir_path[PLATFORM_MAX_PATH_LENGTH];
205 safe_snprintf(dir_path, sizeof(dir_path), "%s", cache_path);
206
207 // Find the last path separator (handle both / and \ for cross-platform
208 // compatibility)
209 char *last_sep = strrchr(dir_path, '\\');
210 if (!last_sep) {
211 last_sep = strrchr(dir_path, '/');
212 }
213
214 if (last_sep) {
215 *last_sep = '\0';
216 if (!platform_is_directory(dir_path)) {
217 result = platform_mkdir_recursive(dir_path, 0700);
218 if (result != ASCIICHAT_OK) {
220 "Failed to create ACDS key cache directory: %s",
221 dir_path);
222 }
223 }
224 }
225
226 // Save key in OpenSSH public key format
227 FILE *f = platform_fopen("file_stream", cache_path, "w");
228 if (!f) {
230 "Failed to create cache file: %s", cache_path);
231 }
232
233 // OpenSSH encodes a length-prefixed algorithm name followed by the key
234 // string.
236 0, 0, 0, 11, 's', 's', 'h', '-', 'e', 'd',
237 '2', '5', '5', '1', '9', 0, 0, 0, 32};
238 memcpy(wire_key + 19, pubkey, ED25519_PUBLIC_KEY_SIZE);
240 sodium_bin2base64(base64_key, sizeof(base64_key), wire_key, sizeof(wire_key),
241 sodium_base64_VARIANT_ORIGINAL);
242
243 fprintf(f, "ssh-ed25519 %s acds-cached-key\n", base64_key);
244 fclose(f);
245
246 log_debug("Cached ACDS key for server: %s", acds_server);
247 return ASCIICHAT_OK;
248}
#define CRYPTO_DISCOVERY_KEYS_BASE64_KEY_BUFFER_SIZE
#define SSH_ED25519_WIRE_KEY_SIZE
int platform_mkdir_recursive(const char *path, int mode)
Definition filesystem.c:36
FILE * platform_fopen(const char *name, const char *filename, const char *mode)
Definition filesystem.c:18

References ASCIICHAT_OK, CRYPTO_DISCOVERY_KEYS_BASE64_KEY_BUFFER_SIZE, discovery_keys_get_cache_path(), ED25519_PUBLIC_KEY_SIZE, ERROR_FILE_OPERATION, ERROR_INVALID_PARAM, log_debug, platform_fopen(), platform_mkdir_recursive(), SET_ERRNO, SET_ERRNO_SYS, and SSH_ED25519_WIRE_KEY_SIZE.

Referenced by discovery_keys_verify().

◆ discovery_keys_verify()

asciichat_error_t discovery_keys_verify ( const char * acds_server,
const char * key_spec,
uint8_t pubkey_out[32] )

Verify and load ACDS server public key.

This function handles all ACDS key verification scenarios:

Automatic Trust (discovery-service.ascii-chat.com only):

  • If acds_server == "discovery-service.ascii-chat.com" and key_spec == NULL:
    • Downloads from ACDS_OFFICIAL_KEY_SSH_URL or ACDS_OFFICIAL_KEY_GPG_URL
    • Caches key locally
    • Trusts without user verification (first time)
    • Requires user verification if key changes

Explicit Key Specification:

  • HTTPS URL: Downloads key from URL, caches it
  • Local file: Loads key from file path
  • github:user: Fetches SSH or GPG key from GitHub
  • gitlab:user.gpg: Fetches GPG key from GitLab

Caching Behavior:

  • Keys are cached in ~/.config/ascii-chat/acds_keys/<hostname>/
  • Cache invalidation requires user confirmation (prevents MITM attacks)
Parameters
acds_serverACDS server hostname (e.g., "acds.example.com")
key_specKey specification:
  • NULL: automatic trust for discovery-service.ascii-chat.com only
  • HTTPS URL: https://example.com/key.pub
  • File path: /path/to/key.pub or ~/.ssh/server.pub
  • GitHub: github:username
  • GitLab: gitlab:username.gpg
pubkey_outEd25519 public key output (32 bytes)
Returns
ASCIICHAT_OK on success, error code otherwise

Definition at line 315 of file discovery_keys.c.

316 {
317 if (!acds_server || !pubkey_out) {
318 return SET_ERRNO(ERROR_INVALID_PARAM, "NULL parameter");
319 }
320
322 asciichat_error_t result;
323 bool is_official = is_official_server(acds_server);
324
325 // ===========================================================================
326 // Step 1: Obtain the public key
327 // ===========================================================================
328
329 if (!key_spec && is_official) {
330 // Automatic trust for official server: try SSH key first, then GPG
331 log_info("Attempting automatic HTTPS key trust for official ACDS server");
332
333 public_key_t key;
335 if (result != ASCIICHAT_OK) {
336 log_debug("SSH key download failed, trying GPG key");
338 }
339
340 if (result != ASCIICHAT_OK) {
342 "Failed to download key from official ACDS server");
343 }
344
345 memcpy(new_pubkey, key.key, ED25519_PUBLIC_KEY_SIZE);
346
347 } else if (!key_spec) {
348 // No key_spec and not official server = error
350 "Third-party ACDS servers require explicit "
351 "--discovery-service-key configuration."
352 "Only %s has automatic trust.",
354
355 } else {
356 // Use parse_public_key for all other cases (handles HTTPS, files, github:,
357 // gitlab:, etc.)
358 public_key_t key;
359 result = parse_public_key(key_spec, &key);
360 if (result != ASCIICHAT_OK) {
362 "Failed to load/download ACDS key from: %s", key_spec);
363 }
364
365 memcpy(new_pubkey, key.key, ED25519_PUBLIC_KEY_SIZE);
366 }
367
368 // ===========================================================================
369 // Step 2: Check cache and handle key changes
370 // ===========================================================================
371
372 uint8_t cached_pubkey[ED25519_PUBLIC_KEY_SIZE];
373 result = discovery_keys_load_cached(acds_server, cached_pubkey);
374
375 if (result == ASCIICHAT_OK) {
376 // Cached key exists - compare
377 if (memcmp(cached_pubkey, new_pubkey, ED25519_PUBLIC_KEY_SIZE) != 0) {
378 // Key changed - require user verification
379 result =
380 discovery_keys_verify_change(acds_server, cached_pubkey, new_pubkey);
381 if (result != ASCIICHAT_OK) {
382 return result; // User rejected or error
383 }
384
385 // User accepted - update cache
386 result = discovery_keys_save_cached(acds_server, new_pubkey);
387 if (result != ASCIICHAT_OK) {
388 log_warn("Failed to update cached key, continuing anyway");
389 }
390 } else {
391 log_debug("ACDS key matches cached key for: %s", acds_server);
392 }
393
394 } else {
395 // No cached key - save it for next time
396 log_info("First connection to ACDS server: %s, caching key", acds_server);
397 result = discovery_keys_save_cached(acds_server, new_pubkey);
398 if (result != ASCIICHAT_OK) {
399 log_warn("Failed to cache key, continuing anyway");
400 }
401 }
402
403 // ===========================================================================
404 // Step 3: Return verified key
405 // ===========================================================================
406
407 memcpy(pubkey_out, new_pubkey, ED25519_PUBLIC_KEY_SIZE);
408 log_debug("ACDS key verification successful for: %s", acds_server);
409 return ASCIICHAT_OK;
410}
asciichat_error_t discovery_keys_load_cached(const char *acds_server, uint8_t pubkey_out[32])
Check if cached key exists and load it.
asciichat_error_t discovery_keys_verify_change(const char *acds_server, const uint8_t old_pubkey[32], const uint8_t new_pubkey[32])
Verify key change with user.
asciichat_error_t discovery_keys_save_cached(const char *acds_server, const uint8_t pubkey[32])
Save key to cache.
#define ACDS_OFFICIAL_SERVER
Official ACDS server hostname (automatic HTTPS key trust).
#define ACDS_OFFICIAL_KEY_SSH_URL
Default HTTPS URLs for official ACDS keys.
#define ACDS_OFFICIAL_KEY_GPG_URL
@ ERROR_NETWORK
Definition error_codes.h:77
#define log_warn(...)
Log a WARN message.
Definition log/log.h:591
#define log_info(...)
Log an INFO message.
Definition log/log.h:578

References ACDS_OFFICIAL_KEY_GPG_URL, ACDS_OFFICIAL_KEY_SSH_URL, ACDS_OFFICIAL_SERVER, ASCIICHAT_OK, discovery_keys_load_cached(), discovery_keys_save_cached(), discovery_keys_verify_change(), ED25519_PUBLIC_KEY_SIZE, ERROR_CRYPTO_KEY, ERROR_INVALID_PARAM, ERROR_NETWORK, public_key_t::key, log_debug, log_info, log_warn, parse_public_key(), and SET_ERRNO.

Referenced by client_crypto_init().

◆ discovery_keys_verify_change()

asciichat_error_t discovery_keys_verify_change ( const char * acds_server,
const uint8_t old_pubkey[32],
const uint8_t new_pubkey[32] )

Verify key change with user.

When a cached key doesn't match the newly downloaded/loaded key, prompts the user to verify the change.

Displays:

  • Old key fingerprint (SHA256)
  • New key fingerprint (SHA256)
  • Warning about potential MITM attack
  • Prompt: "Accept new key? (y/N): "
Parameters
acds_serverACDS server hostname
old_pubkeyPrevious cached key (32 bytes)
new_pubkeyNew downloaded key (32 bytes)
Returns
ASCIICHAT_OK if user accepts, ERROR_USER_REJECTED if declined

Definition at line 277 of file discovery_keys.c.

279 {
280 if (!acds_server || !old_pubkey || !new_pubkey) {
281 return SET_ERRNO(ERROR_INVALID_PARAM, "NULL parameter");
282 }
283
284 char old_fingerprint[HEX_STRING_SIZE_32],
286 compute_key_fingerprint(old_pubkey, old_fingerprint);
287 compute_key_fingerprint(new_pubkey, new_fingerprint);
288
289 // Ask user to confirm
291 safe_snprintf(
292 question, sizeof(question),
293 "ACDS SERVER KEY HAS CHANGED\nServer: %s\n\nOld SHA256: %s\nNew SHA256: "
294 "%s\n\n"
295 "This may indicate key rotation or a man-in-the-middle attack.\n"
296 "Verify the new fingerprint with the operator before "
297 "accepting.\n\nAccept new ACDS server key",
298 acds_server, old_fingerprint, new_fingerprint);
299 bool accepted = ui_notice_confirm_kind(UI_PROMPT_DISCOVERY_KEY_CHANGE,
300 UI_NOTICE_DANGER, question, 120);
301 if (!accepted) {
303 "User rejected ACDS key change for: %s", acds_server);
304 }
305
306 log_info("User accepted ACDS key change for: %s", acds_server);
307 return ASCIICHAT_OK;
308}
#define CRYPTO_DISCOVERY_KEYS_QUESTION_BUFFER_SIZE
#define CRYPTO_DISCOVERY_KEYS_NEW_FINGERPRINT_BUFFER_SIZE
@ ERROR_CRYPTO_VERIFICATION
void compute_key_fingerprint(const uint8_t key[ED25519_PUBLIC_KEY_SIZE], char fingerprint[CRYPTO_HEX_KEY_SIZE_NULL])
bool ui_notice_confirm_kind(ui_prompt_kind_t kind, ui_notice_severity_t severity, const char *text, unsigned timeout_seconds)
Definition notice.c:548
@ UI_NOTICE_DANGER
Definition notice.h:16
#define HEX_STRING_SIZE_32
Hex string size for 32-byte values (64 hex chars + null terminator).
Definition sizes.h:163

References ASCIICHAT_OK, compute_key_fingerprint(), CRYPTO_DISCOVERY_KEYS_NEW_FINGERPRINT_BUFFER_SIZE, CRYPTO_DISCOVERY_KEYS_QUESTION_BUFFER_SIZE, ED25519_PUBLIC_KEY_SIZE, ERROR_CRYPTO_VERIFICATION, ERROR_INVALID_PARAM, HEX_STRING_SIZE_32, log_info, SET_ERRNO, ui_notice_confirm_kind(), and UI_NOTICE_DANGER.

Referenced by discovery_keys_verify().