ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
common.h File Reference

Common declarations and data structures for cryptographic handshake. More...

Go to the source code of this file.

Data Structures

struct  crypto_handshake_context_t
 Cryptographic handshake context structure. More...

Macros

#define CRYPTO_HANDSHAKE_COMMON_EXPECTED_SERVER_KEY_BUFFER_SIZE   256
Authentication Requirement Flags

Flags sent in AUTH_CHALLENGE packet to indicate server requirements.

#define AUTH_REQUIRE_PASSWORD   0x01
 Server requires password authentication.
#define AUTH_REQUIRE_CLIENT_KEY   0x02
 Server requires client key authentication (whitelist).

Typedefs

typedef struct crypto_handshake_context_t crypto_handshake_context_t
 Cryptographic handshake context structure.

Enumerations

enum  crypto_handshake_state_t {
  CRYPTO_HANDSHAKE_DISABLED = 0 , CRYPTO_HANDSHAKE_INIT , CRYPTO_HANDSHAKE_KEY_EXCHANGE , CRYPTO_HANDSHAKE_AUTHENTICATING ,
  CRYPTO_HANDSHAKE_READY , CRYPTO_HANDSHAKE_FAILED
}
 Cryptographic handshake state enumeration. More...

Functions

Common Handshake Functions

This is the handoff point for crypto handshake context. Callers fill crypto_ctx, state, is_server, password_failure before passing it on; consumers read the values during the operation and return ownership only where the member contract explicitly says they do.

asciichat_error_t crypto_handshake_init (const char *name, crypto_handshake_context_t *ctx, bool is_server)
 Initialize named crypto handshake context.
asciichat_error_t crypto_handshake_set_parameters (crypto_handshake_context_t *ctx, const crypto_parameters_packet_t *params)
 Set crypto parameters from crypto_parameters_packet_t.
asciichat_error_t crypto_handshake_validate_packet_size (const crypto_handshake_context_t *ctx, uint16_t packet_type, size_t packet_size)
 Validate crypto packet size based on session parameters.
asciichat_error_t crypto_handshake_init_with_password (const char *name, crypto_handshake_context_t *ctx, bool is_server, const char *password)
 Initialize named crypto handshake context with password authentication.
void crypto_handshake_destroy (crypto_handshake_context_t *ctx)
 Cleanup crypto handshake context with secure memory wiping.
bool crypto_handshake_is_ready (const crypto_handshake_context_t *ctx)
 Check if handshake is complete and encryption is ready.
const crypto_context_t * crypto_handshake_get_context (const crypto_handshake_context_t *ctx)
 Get the crypto context for encryption/decryption.

Detailed Description

Common declarations and data structures for cryptographic handshake.

Definition in file crypto/handshake/common.h.

Macro Definition Documentation

◆ AUTH_REQUIRE_CLIENT_KEY

#define AUTH_REQUIRE_CLIENT_KEY   0x02

Server requires client key authentication (whitelist).

Definition at line 34 of file crypto/handshake/common.h.

Referenced by crypto_handshake_client_auth_response(), and crypto_handshake_server_auth_challenge().

◆ AUTH_REQUIRE_PASSWORD

#define AUTH_REQUIRE_PASSWORD   0x01

Server requires password authentication.

Definition at line 32 of file crypto/handshake/common.h.

Referenced by crypto_handshake_client_auth_response(), and crypto_handshake_server_auth_challenge().

◆ CRYPTO_HANDSHAKE_COMMON_EXPECTED_SERVER_KEY_BUFFER_SIZE

#define CRYPTO_HANDSHAKE_COMMON_EXPECTED_SERVER_KEY_BUFFER_SIZE   256

Definition at line 4 of file crypto/handshake/common.h.

Enumeration Type Documentation

◆ crypto_handshake_state_t

Cryptographic handshake state enumeration.

Represents the current state of the handshake protocol. Handshake follows a strict state machine - invalid transitions return errors.

Enumerator
CRYPTO_HANDSHAKE_DISABLED 

No encryption (handshake disabled)

CRYPTO_HANDSHAKE_INIT 

Initial state (ready to start handshake)

CRYPTO_HANDSHAKE_KEY_EXCHANGE 

DH key exchange in progress

CRYPTO_HANDSHAKE_AUTHENTICATING 

Authentication challenge/response

CRYPTO_HANDSHAKE_READY 

Handshake complete, encryption ready

CRYPTO_HANDSHAKE_FAILED 

Handshake failed (cannot recover)

Definition at line 46 of file crypto/handshake/common.h.

Function Documentation

◆ crypto_handshake_destroy()

void crypto_handshake_destroy ( crypto_handshake_context_t * ctx)

Cleanup crypto handshake context with secure memory wiping.

Parameters
ctxHandshake context to cleanup

Definition at line 288 of file crypto/handshake/common.c.

288 {
289 if (!ctx)
290 return;
291
292 // Cleanup core crypto context
294
295 // Zero out sensitive data
296 sodium_memzero(ctx, sizeof(crypto_handshake_context_t));
297}
void crypto_destroy(crypto_context_t *ctx)
Cleanup crypto context with secure memory wiping.
Cryptographic handshake context structure.

References crypto_handshake_context_t::crypto_ctx, and crypto_destroy().

Referenced by acip_security_cleanup(), client_cleanup(), client_generate_keypair(), client_handle_crypto_parameters(), and client_handle_key_exchange_init().

◆ crypto_handshake_get_context()

const crypto_context_t * crypto_handshake_get_context ( const crypto_handshake_context_t * ctx)

Get the crypto context for encryption/decryption.

Parameters
ctxHandshake context
Returns
Pointer to crypto context, or NULL if ctx is NULL

Definition at line 307 of file crypto/handshake/common.c.

307 {
308 if (!ctx || !crypto_handshake_is_ready(ctx))
309 return NULL;
310 return &ctx->crypto_ctx;
311}
bool crypto_handshake_is_ready(const crypto_handshake_context_t *ctx)
Check if handshake is complete and encryption is ready.

References crypto_handshake_context_t::crypto_ctx, and crypto_handshake_is_ready().

◆ crypto_handshake_init()

asciichat_error_t crypto_handshake_init ( const char * name,
crypto_handshake_context_t * ctx,
bool is_server )

Initialize named crypto handshake context.

Parameters
nameDebug name for the crypto context (typically "crypto_client_<id>")
ctxHandshake context to initialize (must not be NULL)
is_serverTrue if this is the server side, false for client
Returns
ASCIICHAT_OK on success, error code on failure

The context is automatically registered with the debug naming system.

Definition at line 25 of file crypto/handshake/common.c.

25 {
26 if (!name) {
27 return SET_ERRNO(ERROR_INVALID_PARAM, "Crypto context name is required");
28 }
29
30 if (!ctx) {
31 return SET_ERRNO(ERROR_INVALID_PARAM, "Invalid parameters: ctx=%p", ctx);
32 }
33
34 // Register crypto context with debug naming system
35 NAMED_REGISTER_CRYPTO_CONTEXT(ctx, name, NULL);
36
37 // Zero out the context
38 memset(ctx, 0, sizeof(crypto_handshake_context_t));
39
40 // Initialize core crypto context
42 if (result != CRYPTO_OK) {
43 return SET_ERRNO(ERROR_CRYPTO, "Failed to initialize crypto context: %s", crypto_result_to_string(result));
44 }
45
47 ctx->is_server = is_server;
48 ctx->crypto_ctx.server_role = is_server;
49 ctx->crypto_ctx.server_role_known = true;
50 ctx->verify_server_key = false;
51 ctx->require_client_auth = false;
52 ctx->server_uses_client_auth = false; // Set to true only if authenticated packet received
53
54 // Load server keys if this is a server
55 if (is_server) {
56 log_dev("Server crypto handshake initialized (ephemeral keys)");
57 } else {
58 log_dev("Client crypto handshake initialized");
59 }
60
61 return ASCIICHAT_OK;
62}
#define SET_ERRNO(code,...)
crypto_result_t crypto_init(crypto_context_t *ctx)
Initialize libsodium and crypto context.
const char * crypto_result_to_string(crypto_result_t result)
Convert crypto result to human-readable string.
crypto_result_t
Cryptographic operation result codes.
#define NAMED_REGISTER_CRYPTO_CONTEXT(ctx, name, parent_ptr)
Register a crypto context with automatic format specifier.
@ ASCIICHAT_OK
Definition error_codes.h:46
@ ERROR_CRYPTO
Definition error_codes.h:93
@ ERROR_INVALID_PARAM
#define log_dev(...)
Log a DEV message (most verbose, development only).
Definition log/log.h:581
crypto_handshake_state_t state

References ASCIICHAT_OK, crypto_handshake_context_t::crypto_ctx, CRYPTO_HANDSHAKE_INIT, crypto_init(), CRYPTO_OK, crypto_result_to_string(), ERROR_CRYPTO, ERROR_INVALID_PARAM, crypto_handshake_context_t::is_server, log_dev, NAMED_REGISTER_CRYPTO_CONTEXT, crypto_handshake_context_t::require_client_auth, crypto_context_t::server_role, crypto_context_t::server_role_known, crypto_handshake_context_t::server_uses_client_auth, SET_ERRNO, crypto_handshake_context_t::state, and crypto_handshake_context_t::verify_server_key.

Referenced by acip_security_init_options(), client_generate_keypair(), client_handle_crypto_parameters(), client_handle_key_exchange_init(), discovery_session_start(), and peer_crypto_create().

◆ crypto_handshake_init_with_password()

asciichat_error_t crypto_handshake_init_with_password ( const char * name,
crypto_handshake_context_t * ctx,
bool is_server,
const char * password )

Initialize named crypto handshake context with password authentication.

Parameters
nameDebug name for the crypto context (typically "crypto_client_<id>")
ctxHandshake context to initialize (must not be NULL)
is_serverTrue if this is the server side, false for client
passwordPassword for authentication (must meet length requirements)
Returns
ASCIICHAT_OK on success, error code on failure

The context is automatically registered with the debug naming system.

Definition at line 249 of file crypto/handshake/common.c.

250 {
251 if (!name) {
252 return SET_ERRNO(ERROR_INVALID_PARAM, "Crypto context name is required");
253 }
254
255 if (!ctx || !password) {
256 return SET_ERRNO(ERROR_INVALID_PARAM, "Invalid parameters: ctx=%p, password=%p", ctx, password);
257 }
258
259 // Register crypto context with debug naming system
260 NAMED_REGISTER_CRYPTO_CONTEXT(ctx, name, NULL);
261
262 // Zero out the context
263 memset(ctx, 0, sizeof(crypto_handshake_context_t));
264
265 // Initialize core crypto context with password
266 crypto_result_t result = crypto_init_with_password(&ctx->crypto_ctx, password);
267 if (result != CRYPTO_OK) {
268 return SET_ERRNO(ERROR_CRYPTO, "Failed to initialize crypto context with password: %s",
270 }
271
273 ctx->is_server = is_server;
274 ctx->crypto_ctx.server_role = is_server;
275 ctx->crypto_ctx.server_role_known = true;
276 ctx->verify_server_key = false;
277 ctx->require_client_auth = false;
278 ctx->server_uses_client_auth = false; // Set to true only if authenticated packet received
279 ctx->has_password = true;
280
281 // Store password temporarily (will be cleared after key derivation)
282 SAFE_STRNCPY(ctx->password, password, sizeof(ctx->password) - 1);
283
284 return ASCIICHAT_OK;
285}
#define SAFE_STRNCPY(dst, src, size)
Definition common.h:423
crypto_result_t crypto_init_with_password(crypto_context_t *ctx, const char *password)
Initialize with password-based encryption.

References ASCIICHAT_OK, crypto_handshake_context_t::crypto_ctx, CRYPTO_HANDSHAKE_INIT, crypto_init_with_password(), CRYPTO_OK, crypto_result_to_string(), ERROR_CRYPTO, ERROR_INVALID_PARAM, crypto_handshake_context_t::has_password, crypto_handshake_context_t::is_server, NAMED_REGISTER_CRYPTO_CONTEXT, crypto_handshake_context_t::password, crypto_handshake_context_t::require_client_auth, SAFE_STRNCPY, crypto_context_t::server_role, crypto_context_t::server_role_known, crypto_handshake_context_t::server_uses_client_auth, SET_ERRNO, crypto_handshake_context_t::state, and crypto_handshake_context_t::verify_server_key.

Referenced by acip_security_init_options(), and peer_crypto_create().

◆ crypto_handshake_is_ready()

bool crypto_handshake_is_ready ( const crypto_handshake_context_t * ctx)

Check if handshake is complete and encryption is ready.

Parameters
ctxHandshake context
Returns
true if handshake is complete and encryption is ready, false otherwise

Definition at line 300 of file crypto/handshake/common.c.

300 {
301 if (!ctx)
302 return false;
304}
bool crypto_is_ready(const crypto_context_t *ctx)
Check if key exchange is complete and ready for encryption.

References crypto_handshake_context_t::crypto_ctx, CRYPTO_HANDSHAKE_READY, crypto_is_ready(), and crypto_handshake_context_t::state.

Referenced by crypto_handshake_get_context().

◆ crypto_handshake_set_parameters()

asciichat_error_t crypto_handshake_set_parameters ( crypto_handshake_context_t * ctx,
const crypto_parameters_packet_t * params )

Set crypto parameters from crypto_parameters_packet_t.

Parameters
ctxHandshake context
paramsNegotiated crypto parameters (from capabilities negotiation)
Returns
ASCIICHAT_OK on success, error code on failure

Definition at line 65 of file crypto/handshake/common.c.

66 {
67 if (!ctx || !params) {
68 return SET_ERRNO(ERROR_INVALID_PARAM, "Invalid parameters: ctx=%p, params=%p", ctx, params);
69 }
70
72
73 // Client receives network byte order and must convert
74 // Server uses host byte order and must NOT convert
75 if (ctx->is_server) {
76 // Server: values are already in host byte order
77 // Update crypto context with negotiated parameters directly
82 } else {
83 ctx->require_client_auth = params->verification_enabled != 0;
84 // Client: convert from network byte order
85 // Update crypto context with negotiated parameters directly
90 }
91 // Update crypto context with negotiated parameters directly
92 ctx->crypto_ctx.nonce_size = params->nonce_size;
93 ctx->crypto_ctx.mac_size = params->mac_size;
94 ctx->crypto_ctx.hmac_size = params->hmac_size;
96 AUTH_CHALLENGE_SIZE; // Auth challenge size is fixed for now, could be negotiated later
98 (uint8_t)ctx->crypto_ctx.shared_key_size; // Use shared key size as encryption key size
99 ctx->crypto_ctx.private_key_size = ctx->crypto_ctx.public_key_size; // Same as public key for X25519
100 ctx->crypto_ctx.salt_size = ARGON2ID_SALT_SIZE; // Salt size doesn't change
101
102 log_debug("Crypto parameters set: kex_key=%u, auth_key=%u, sig=%u, "
103 "secret=%u, nonce=%u, mac=%u, hmac=%u",
106 ctx->crypto_ctx.hmac_size);
107
108 return ASCIICHAT_OK;
109}
#define NET_TO_HOST_U16(val)
Definition endian.h:111
unsigned char uint8_t
Definition common.h:60
#define log_debug(...)
Log a DEBUG message.
Definition log/log.h:595
#define CIPHER_ALGO_NONE
No encryption (plaintext mode).
Definition packet.h:1124
#define AUTH_CHALLENGE_SIZE
Challenge nonce size (32 bytes).
Definition sizes.h:99
#define ARGON2ID_SALT_SIZE
Argon2id salt size in bytes.
Definition sizes.h:47
uint8_t hmac_size
HMAC size in bytes (e.g., 32 for HMAC-SHA256).
Definition packet.h:1059
uint8_t selected_cipher
Selected cipher algorithm (CIPHER_ALGO_*).
Definition packet.h:1043
uint16_t auth_public_key_size
Authentication public key size in bytes (e.g., 32 for Ed25519, 1952 for Dilithium3).
Definition packet.h:1049
uint8_t verification_enabled
Server verification enabled flag (1=enabled, 0=disabled).
Definition packet.h:1045
uint16_t signature_size
Signature size in bytes (e.g., 64 for Ed25519, 3309 for Dilithium3).
Definition packet.h:1051
uint8_t nonce_size
Nonce size in bytes (e.g., 24 for XSalsa20).
Definition packet.h:1055
uint8_t mac_size
MAC size in bytes (e.g., 16 for Poly1305).
Definition packet.h:1057
uint16_t shared_secret_size
Shared secret size in bytes (e.g., 32 for X25519).
Definition packet.h:1053
uint16_t kex_public_key_size
Key exchange public key size in bytes (e.g., 32 for X25519, 1568 for Kyber1024).
Definition packet.h:1047

References ARGON2ID_SALT_SIZE, ASCIICHAT_OK, AUTH_CHALLENGE_SIZE, crypto_context_t::auth_challenge_size, crypto_context_t::auth_public_key_size, crypto_parameters_packet_t::auth_public_key_size, CIPHER_ALGO_NONE, crypto_handshake_context_t::crypto_ctx, crypto_context_t::encrypt_data, crypto_context_t::encryption_key_size, ERROR_INVALID_PARAM, crypto_context_t::hmac_size, crypto_parameters_packet_t::hmac_size, crypto_handshake_context_t::is_server, crypto_parameters_packet_t::kex_public_key_size, log_debug, crypto_context_t::mac_size, crypto_parameters_packet_t::mac_size, NET_TO_HOST_U16, crypto_context_t::nonce_size, crypto_parameters_packet_t::nonce_size, crypto_context_t::private_key_size, crypto_context_t::public_key_size, crypto_handshake_context_t::require_client_auth, crypto_context_t::salt_size, crypto_parameters_packet_t::selected_cipher, SET_ERRNO, crypto_context_t::shared_key_size, crypto_parameters_packet_t::shared_secret_size, crypto_context_t::signature_size, crypto_parameters_packet_t::signature_size, and crypto_parameters_packet_t::verification_enabled.

Referenced by acds_handshake_receive(), acip_security_receive(), client_handle_crypto_parameters(), and crypto_handshake_server_send_parameters().

◆ crypto_handshake_validate_packet_size()

asciichat_error_t crypto_handshake_validate_packet_size ( const crypto_handshake_context_t * ctx,
uint16_t packet_type,
size_t packet_size )

Validate crypto packet size based on session parameters.

Parameters
ctxHandshake context (must have parameters set)
packet_typePacket type to validate
packet_sizeActual packet size received
Returns
ASCIICHAT_OK if valid, error code on failure

Definition at line 112 of file crypto/handshake/common.c.

113 {
114 if (!ctx) {
115 return SET_ERRNO(ERROR_INVALID_PARAM, "Invalid parameters: ctx=%p", ctx);
116 }
117
118 switch (packet_type) {
120 if (packet_size != sizeof(crypto_capabilities_packet_t)) {
121 // Don't return an error code, just set the errno and return the error code
122 return SET_ERRNO(ERROR_NETWORK_PROTOCOL, "Invalid crypto capabilities packet size: %zu (expected %zu)",
123 packet_size, sizeof(crypto_capabilities_packet_t));
124 }
125 break;
126
128 if (packet_size != sizeof(crypto_parameters_packet_t)) {
129 return SET_ERRNO(ERROR_NETWORK_PROTOCOL, "Invalid crypto parameters packet size: %zu (expected %zu)", packet_size,
131 }
132 break;
133
135 // Server can send either:
136 // 1. Simple format: kex_public_key_size (when server has no identity key)
137 // 2. Authenticated format: kex_public_key_size + auth_public_key_size + signature_size
138 {
139 size_t simple_size = ctx->crypto_ctx.public_key_size;
140 size_t authenticated_size =
142
143 if (packet_size != simple_size && packet_size != authenticated_size) {
145 "Invalid KEY_EXCHANGE_INIT size: %zu (expected %zu for simple or %zu for authenticated: "
146 "kex=%u + auth=%u + sig=%u)",
147 packet_size, simple_size, authenticated_size, ctx->crypto_ctx.public_key_size,
149 }
150 }
151 break;
152
154 // Client can send either:
155 // 1. Simple format: kex_public_key_size (when server has no identity key)
156 // 2. Authenticated format: kex_public_key_size + client_auth_key_size + client_sig_size + [gpg_key_id_len:1] +
157 // [gpg_key_id:0-16]
158 {
159 size_t simple_size = ctx->crypto_ctx.public_key_size;
160 // For authenticated format, use Ed25519 sizes since client has Ed25519 key
161 size_t ed25519_auth_size = ED25519_PUBLIC_KEY_SIZE; // Ed25519 public key is always 32 bytes
162 size_t ed25519_sig_size = ED25519_SIGNATURE_SIZE; // Ed25519 signature is always 64 bytes
163 size_t authenticated_min_size = ctx->crypto_ctx.public_key_size + ed25519_auth_size + ed25519_sig_size;
164 size_t authenticated_max_size = authenticated_min_size + 1 + 40; // +1 for length, +40 for max GPG key ID
165
166 if (packet_size != simple_size &&
167 (packet_size < authenticated_min_size || packet_size > authenticated_max_size)) {
169 "Invalid KEY_EXCHANGE_RESP size: %zu (expected %zu for simple or %zu-%zu for authenticated: "
170 "kex=%u + auth=%u + sig=%u + optional GPG key ID)",
171 packet_size, simple_size, authenticated_min_size, authenticated_max_size,
172 ctx->crypto_ctx.public_key_size, ed25519_auth_size, ed25519_sig_size);
173 }
174 }
175 break;
176
178 // Server sends: 1 byte auth_flags + auth_challenge_size byte nonce
179 {
180 size_t expected_size = AUTH_CHALLENGE_FLAGS_SIZE + ctx->crypto_ctx.auth_challenge_size;
181 if (packet_size != expected_size) {
182 return SET_ERRNO(ERROR_NETWORK_PROTOCOL, "Invalid AUTH_CHALLENGE size: %zu (expected %zu: flags=%d + nonce=%u)",
183 packet_size, expected_size, AUTH_CHALLENGE_FLAGS_SIZE, ctx->crypto_ctx.auth_challenge_size);
184 }
185 }
186 break;
187
189 // Client sends: hmac_size + auth_challenge_size bytes client_nonce + [gpg_key_id_len:1] + [gpg_key_id:0-40]
190 {
191 size_t min_size = ctx->crypto_ctx.hmac_size + ctx->crypto_ctx.auth_challenge_size;
192 size_t max_size = min_size + 1 + 40; // +1 for length, +40 for max GPG key ID
193 if (packet_size < min_size || packet_size > max_size) {
195 "Invalid AUTH_RESPONSE size: %zu (expected %zu-%zu: hmac=%u + "
196 "nonce=%u + optional GPG key ID)",
197 packet_size, min_size, max_size, ctx->crypto_ctx.hmac_size,
199 }
200 }
201 break;
202
204 // Variable size - just check reasonable limits
205 if (packet_size > MAX_AUTH_FAILED_PACKET_SIZE) {
206 return SET_ERRNO(ERROR_NETWORK_PROTOCOL, "Invalid AUTH_FAILED size: %zu (max %d)", packet_size,
208 }
209 break;
210
212 // Server sends: hmac_size bytes
213 if (packet_size != ctx->crypto_ctx.hmac_size) {
214 return SET_ERRNO(ERROR_NETWORK_PROTOCOL, "Invalid SERVER_AUTH_RESP size: %zu (expected %u)", packet_size,
215 ctx->crypto_ctx.hmac_size);
216 }
217 break;
218
220 // Empty packet
221 if (packet_size != 0) {
222 return SET_ERRNO(ERROR_NETWORK_PROTOCOL, "Invalid HANDSHAKE_COMPLETE size: %zu (expected 0)", packet_size);
223 }
224 break;
225
227 // Empty packet
228 if (packet_size != 0) {
229 return SET_ERRNO(ERROR_NETWORK_PROTOCOL, "Invalid NO_ENCRYPTION size: %zu (expected 0)", packet_size);
230 }
231 break;
232
234 // Variable size - check reasonable limits
235 if (packet_size > MAX_ENCRYPTED_PACKET_SIZE) { // 64KB max for encrypted packets
236 return SET_ERRNO(ERROR_NETWORK_PROTOCOL, "Invalid ENCRYPTED size: %zu (max %d)", packet_size,
238 }
239 break;
240
241 default:
242 return SET_ERRNO(ERROR_NETWORK_PROTOCOL, "Unknown crypto packet type: %u", packet_type);
243 }
244
245 return ASCIICHAT_OK;
246}
@ ERROR_NETWORK_PROTOCOL
Definition error_codes.h:76
@ PACKET_TYPE_CRYPTO_AUTH_RESPONSE
Client -> Server: {HMAC[32]} (UNENCRYPTED).
Definition packet.h:332
@ PACKET_TYPE_CRYPTO_HANDSHAKE_COMPLETE
Server -> Client: "encryption ready" (UNENCRYPTED).
Definition packet.h:338
@ PACKET_TYPE_CRYPTO_KEY_EXCHANGE_INIT
Server -> Client: {server_pubkey[32]} (UNENCRYPTED).
Definition packet.h:326
@ PACKET_TYPE_CRYPTO_KEY_EXCHANGE_RESP
Client -> Server: {client_pubkey[32]} (UNENCRYPTED).
Definition packet.h:328
@ PACKET_TYPE_CRYPTO_AUTH_FAILED
Server -> Client: "authentication failed" (UNENCRYPTED).
Definition packet.h:334
@ PACKET_TYPE_ENCRYPTED
Encrypted packet (after handshake completion).
Definition packet.h:355
@ PACKET_TYPE_CRYPTO_SERVER_AUTH_RESP
Server -> Client: {HMAC[32]} server proves knowledge (UNENCRYPTED).
Definition packet.h:336
@ PACKET_TYPE_CRYPTO_NO_ENCRYPTION
Client -> Server: "I want to proceed without encryption" (UNENCRYPTED).
Definition packet.h:340
@ PACKET_TYPE_CRYPTO_AUTH_CHALLENGE
Server -> Client: {nonce[32]} (UNENCRYPTED).
Definition packet.h:330
@ PACKET_TYPE_CRYPTO_PARAMETERS
Server -> Client: Chosen algorithms + data sizes (UNENCRYPTED).
Definition packet.h:324
@ PACKET_TYPE_CRYPTO_CAPABILITIES
Client -> Server: Supported crypto algorithms (UNENCRYPTED).
Definition packet.h:322
#define ED25519_SIGNATURE_SIZE
Ed25519 signature size in bytes.
Definition sizes.h:37
#define MAX_AUTH_FAILED_PACKET_SIZE
Maximum AUTH_FAILED packet size (256 bytes).
Definition sizes.h:142
#define MAX_ENCRYPTED_PACKET_SIZE
Maximum encrypted packet size (64KB).
Definition sizes.h:144
#define ED25519_PUBLIC_KEY_SIZE
Ed25519 public key size in bytes.
Definition sizes.h:33
#define AUTH_CHALLENGE_FLAGS_SIZE
Authentication flags size (1 byte).
Definition sizes.h:115
Crypto capabilities packet structure (Packet Type 14).
Definition packet.h:1008
Crypto parameters packet structure (Packet Type 15).
Definition packet.h:1037

References ASCIICHAT_OK, AUTH_CHALLENGE_FLAGS_SIZE, crypto_context_t::auth_challenge_size, crypto_context_t::auth_public_key_size, crypto_handshake_context_t::crypto_ctx, ED25519_PUBLIC_KEY_SIZE, ED25519_SIGNATURE_SIZE, ERROR_INVALID_PARAM, ERROR_NETWORK_PROTOCOL, crypto_context_t::hmac_size, MAX_AUTH_FAILED_PACKET_SIZE, MAX_ENCRYPTED_PACKET_SIZE, PACKET_TYPE_CRYPTO_AUTH_CHALLENGE, PACKET_TYPE_CRYPTO_AUTH_FAILED, PACKET_TYPE_CRYPTO_AUTH_RESPONSE, PACKET_TYPE_CRYPTO_CAPABILITIES, PACKET_TYPE_CRYPTO_HANDSHAKE_COMPLETE, PACKET_TYPE_CRYPTO_KEY_EXCHANGE_INIT, PACKET_TYPE_CRYPTO_KEY_EXCHANGE_RESP, PACKET_TYPE_CRYPTO_NO_ENCRYPTION, PACKET_TYPE_CRYPTO_PARAMETERS, PACKET_TYPE_CRYPTO_SERVER_AUTH_RESP, PACKET_TYPE_ENCRYPTED, crypto_context_t::public_key_size, SET_ERRNO, and crypto_context_t::signature_size.

Referenced by crypto_handshake_client_auth_response(), crypto_handshake_client_key_exchange(), crypto_handshake_server_auth_challenge(), and crypto_handshake_server_complete().