ascii-chat
Binary v0.16.50-198-g78f51665f
Library lib/v0.3.2-2240-g78f51665f
Video chat in your terminal
Loading...
Searching...
No Matches
network/acip/security.c
Go to the documentation of this file.
2#include <recast/defer.h>
9#include <string.h>
10
12 if (!security)
13 return;
16}
17
19 if (!security || !transport || security->mode > ACIP_CRYPTO_FULL || security->handshake.state != CRYPTO_HANDSHAKE_INIT)
20 return SET_ERRNO(ERROR_INVALID_STATE, "Invalid peer security initialization");
21 security->handshake.addressless_transport = true;
22 transport->crypto_ctx = &security->handshake.crypto_ctx;
24 if (security->handshake.is_server)
25 return ASCIICHAT_OK;
27 protocol_version_packet_init(&version, security->mode);
28 return packet_send_via_transport(transport, PACKET_TYPE_PROTOCOL_VERSION, &version, sizeof(version), 0);
29}
30
31asciichat_error_t acip_security_receive(acip_security_t *security, acip_transport_t *transport, packet_type_t type, const void *payload, size_t length) {
32 if (!security || !transport || (!payload && length) || security->ready)
33 return SET_ERRNO(ERROR_INVALID_STATE, "Unexpected peer security packet");
34 crypto_handshake_context_t *ctx = &security->handshake;
36 if (!security->version_received) {
37 if (type != PACKET_TYPE_PROTOCOL_VERSION || length != sizeof(protocol_version_packet_t))
38 return SET_ERRNO(ERROR_NETWORK_PROTOCOL, "Expected peer security negotiation before media");
40 memcpy(&version, payload, sizeof(version));
41 uint8_t mode = version.supports_encryption;
44 return SET_ERRNO(ERROR_NETWORK_PROTOCOL, "Unsupported peer security protocol");
45 if (ctx->is_server) {
46 // Match secure WebSocket policy: defaults do not override a client's explicit no-encrypt.
47 if ((ctx->has_password || ctx->require_client_auth) && !ACIP_CRYPTO_HAS_AUTH(mode))
48 return SET_ERRNO(ERROR_CRYPTO_AUTH, "Peer omitted required authentication");
49 if (security->require_encryption && !ACIP_CRYPTO_HAS_ENCRYPT(mode))
50 return SET_ERRNO(ERROR_CRYPTO, "Peer omitted required encryption");
51 if (security->forbid_encryption && ACIP_CRYPTO_HAS_ENCRYPT(mode))
52 return SET_ERRNO(ERROR_CRYPTO, "Peer requires encryption but local policy disables it");
53 version.supports_encryption = mode;
54 result = packet_send_via_transport(transport, PACKET_TYPE_PROTOCOL_VERSION, &version, sizeof(version), 0);
55 if (result != ASCIICHAT_OK)
56 return result;
57 } else if ((mode & security->mode) != security->mode) {
58 return SET_ERRNO(ERROR_CRYPTO, "Peer attempted to downgrade requested security");
59 }
60 if (security->forbid_encryption && ACIP_CRYPTO_HAS_ENCRYPT(mode))
61 return SET_ERRNO(ERROR_CRYPTO, "Peer requires encryption but local policy disables it");
62 security->mode = mode;
63 security->version_received = true;
65 if (mode == ACIP_CRYPTO_NONE) {
67 security->ready = true;
68 return ASCIICHAT_OK;
69 }
70 if (!ctx->is_server)
71 return ASCIICHAT_OK;
72 result = crypto_handshake_server_send_parameters(ctx, transport);
73 if (result == ASCIICHAT_OK)
74 result = crypto_handshake_server_start(ctx, transport);
75 return result;
76 }
77 if (ctx->is_server) {
79 result = crypto_handshake_server_auth_challenge(ctx, transport, type, payload, length);
81 result = crypto_handshake_server_complete(ctx, transport, type, payload, length);
82 else
83 result = SET_ERRNO(ERROR_NETWORK_PROTOCOL, "Unexpected peer authentication state");
84 } else {
85 switch (type) {
87 if (security->parameters_received || ctx->state != CRYPTO_HANDSHAKE_INIT || length != sizeof(crypto_parameters_packet_t))
88 return SET_ERRNO(ERROR_NETWORK_PROTOCOL, "Invalid peer crypto parameters");
89 result = crypto_handshake_set_parameters(ctx, payload);
90 if (result == ASCIICHAT_OK && ctx->crypto_ctx.encrypt_data != !!ACIP_CRYPTO_HAS_ENCRYPT(security->mode))
91 return SET_ERRNO(ERROR_CRYPTO, "Peer cipher does not match negotiated policy");
92 security->parameters_received = result == ASCIICHAT_OK;
93 break;
95 if (!security->parameters_received)
96 return SET_ERRNO(ERROR_NETWORK_PROTOCOL, "Missing peer crypto parameters");
97 if (ctx->verify_server_key && length == ctx->crypto_ctx.public_key_size)
98 return SET_ERRNO(ERROR_CRYPTO_AUTH, "Peer omitted the required identity key");
99 result = crypto_handshake_client_key_exchange(ctx, transport, type, payload, length);
100 break;
102 result = crypto_handshake_client_auth_response(ctx, transport, type, payload, length);
103 break;
106 return SET_ERRNO(ERROR_CRYPTO_AUTH, "Peer skipped required mutual authentication");
107 result = crypto_handshake_client_complete(ctx, transport, type, payload, length);
108 break;
111 result = crypto_handshake_client_complete(ctx, transport, type, payload, length);
112 break;
113 default:
114 result = SET_ERRNO(ERROR_NETWORK_PROTOCOL, "Application packet before peer authentication");
115 }
116 }
117 if (result == ASCIICHAT_OK)
118 security->ready = ctx->state == CRYPTO_HANDSHAKE_READY;
119 else
121 if (result == ASCIICHAT_OK && security->ready)
122 result = acip_security_activate(transport);
123 return result;
124}
125
126static const packet_type_t rekey_types[] = {0,
133
134static crypto_rekey_message_t rekey_message(uint16_t type) {
135 for (unsigned i = 1; i < sizeof(rekey_types) / sizeof(rekey_types[0]); ++i)
136 if (rekey_types[i] == type)
137 return (crypto_rekey_message_t)i;
138 return CRYPTO_REKEY_NONE;
139}
140
142 return rekey_message(type) != CRYPTO_REKEY_NONE;
143}
144
145asciichat_error_t acip_security_rekey_encode(unsigned flow, crypto_rekey_message_t type, const void *payload, size_t length, void *packet, size_t capacity, size_t *written) {
146 if (type <= CRYPTO_REKEY_NONE || type > CRYPTO_REKEY_NEEDED || flow >= CRYPTO_RECORD_CHANNELS)
147 return SET_ERRNO(ERROR_INVALID_PARAM, "Invalid rekey message");
148 return packet_encode(rekey_types[type], payload, length, flow, packet, capacity, written);
149}
150
151asciichat_error_t acip_security_rekey_receive(crypto_rekey_session_t *session, acip_traffic_class_t flow, acip_delivery_t delivery, const void *packet, size_t length, uint64_t now, bool *consumed) {
152 packet_header_t header;
153 asciichat_error_t result = packet_validate(packet, length, 0, &header);
154 if (result != ASCIICHAT_OK)
155 return result;
156 return crypto_rekey_session_receive(session, flow, delivery, rekey_message(NET_TO_HOST_U16(header.type)), (const uint8_t *)packet + sizeof(header), length - sizeof(header), now, consumed);
157}
158
159asciichat_error_t acip_security_rekey_seal(crypto_record_t *records, unsigned flow, crypto_rekey_message_t message, const void *payload, size_t length, uint8_t **wire, size_t *written) {
161 size_t packet_length = 0;
162 asciichat_error_t result = acip_security_rekey_encode(flow, message, payload, length, packet, sizeof(packet), &packet_length);
163 return result == ASCIICHAT_OK ? acip_packet_seal(records, (acip_traffic_class_t)flow, ACIP_DELIVERY_RELIABLE, packet, packet_length, wire, written) : result;
164}
165
167 if (!transport)
168 return SET_ERRNO(ERROR_INVALID_PARAM, "Missing secure transport");
169 crypto_context_t *crypto = transport->crypto_ctx;
170 if (!crypto || !crypto->encrypt_data)
171 return ASCIICHAT_OK;
172 crypto_session_t *session = NULL;
173 asciichat_error_t result = crypto_session_lock(crypto, &session);
174 if (result == ASCIICHAT_OK) {
175 crypto_session_unlock(session);
176 atomic_store_bool(&transport->packet_security_active, true);
177 }
178 return result;
179}
180
181asciichat_error_t acip_security_decrypt(crypto_context_t *crypto, unsigned flow, unsigned delivery, const void *payload, size_t length, uint8_t **output, size_t *written, uint64_t *sequence,
182 bool *consumed) {
183 if (!output || !written || !consumed)
184 return SET_ERRNO(ERROR_INVALID_PARAM, "Missing security receive output");
185 *output = NULL;
186 *written = 0;
187 *consumed = false;
188 crypto_session_t *session = NULL;
189 asciichat_error_t result = crypto_session_lock(crypto, &session);
190 if (result != ASCIICHAT_OK)
191 return result;
192 result = acip_packet_decrypt_payload(&session->records, flow, delivery, payload, length, output, written, sequence);
193 if (result == ASCIICHAT_OK) {
194 packet_header_t header;
195 memcpy(&header, *output, sizeof(header));
196 result = crypto_session_receive(session, session->records.last_receive_channel, delivery, rekey_message(NET_TO_HOST_U16(header.type)), *output + sizeof(header), *written - sizeof(header),
197 time_get_ns(), consumed);
198 }
199 crypto_session_unlock(session);
200 if (result != ASCIICHAT_OK) {
201 buffer_release(*output);
202 *output = NULL;
203 *written = 0;
204 }
205 return result;
206}
207
209 if (!flow || !wire || !length)
210 return SET_ERRNO(ERROR_INVALID_PARAM, "Missing security output");
211 *wire = NULL;
212 *length = 0;
213 crypto_session_t *session = NULL;
214 asciichat_error_t result = crypto_session_lock(crypto, &session);
215 if (result != ASCIICHAT_OK)
216 return result;
217 defer(crypto_session_unlock(session));
218 result = crypto_session_tick(session, time_get_ns());
219 if (result == ASCIICHAT_OK && session->count) {
220 crypto_session_message_t *message = &session->messages[session->head];
221 *flow = (acip_traffic_class_t)message->channel;
222 result = acip_security_rekey_seal(&session->records, message->channel, message->type, message->payload, message->length, wire, length);
223 if (result == ASCIICHAT_OK) {
224 memset(message, 0, sizeof(*message));
225 session->head = (session->head + 1) % CRYPTO_SESSION_MESSAGES;
226 --session->count;
227 }
228 }
229 return result;
230}
231
233 if (!transport || !atomic_load_bool(&transport->packet_security_active))
234 return ASCIICHAT_OK;
235 for (unsigned i = 0; i < CRYPTO_SESSION_MESSAGES; ++i) {
236 uint8_t *wire = NULL;
237 size_t length = 0;
239 asciichat_error_t result = acip_security_next_control(transport->crypto_ctx, &channel, &wire, &length);
240 if (result != ASCIICHAT_OK || !wire)
241 return result;
242 defer(buffer_release(wire));
243 socket_buffer_t slice = {wire, length};
244 acip_send_options_t options = {.traffic_class = channel, .delivery = ACIP_DELIVERY_RELIABLE};
245 if (transport->methods->sendv_ex)
246 result = transport->methods->sendv_ex(transport, &slice, 1, &options);
247 else if (transport->methods->sendv)
248 result = transport->methods->sendv(transport, &slice, 1);
249 else
250 result = transport->methods->send(transport, wire, length);
251 if (result != ASCIICHAT_OK)
252 return result;
253 }
254 return ASCIICHAT_OK;
255}
256
258 if (!transport || !transport->crypto_ctx || !transport->crypto_ctx->encrypt_data)
259 return SET_ERRNO(ERROR_INVALID_STATE, "An encrypted authenticated session is required for rotation");
260 crypto_session_t *session = NULL;
261 asciichat_error_t result = crypto_session_lock(transport->crypto_ctx, &session);
262 if (result == ASCIICHAT_OK) {
263 result = crypto_rekey_session_request(&session->rotation, time_get_ns());
264 crypto_session_unlock(session);
265 }
266 return result;
267}
268
269asciichat_error_t acip_security_seal(crypto_context_t *crypto, acip_traffic_class_t flow, acip_delivery_t delivery, const void *packet, size_t length, uint8_t **output, size_t *written) {
270 crypto_session_t *session = NULL;
271 asciichat_error_t result = crypto_session_lock(crypto, &session);
272 if (result == ASCIICHAT_OK) {
273 result = acip_packet_seal(&session->records, flow, delivery, packet, length, output, written);
274 crypto_session_unlock(session);
275 }
276 return result;
277}
278
279asciichat_error_t acip_security_open(crypto_context_t *crypto, acip_traffic_class_t flow, acip_delivery_t delivery, const void *packet, size_t length, uint8_t **output, size_t *written,
280 uint64_t *sequence, bool *consumed) {
281 packet_header_t header;
282 asciichat_error_t result = packet_validate(packet, length, 0, &header);
283 if (result != ASCIICHAT_OK)
284 return result;
285 if (NET_TO_HOST_U16(header.type) != PACKET_TYPE_ENCRYPTED)
286 return SET_ERRNO(ERROR_CRYPTO, "Expected authenticated session record");
287 return acip_security_decrypt(crypto, flow, delivery, (const uint8_t *)packet + sizeof(header), length - sizeof(header), output, written, sequence, consumed);
288}
#define SET_ERRNO(code,...)
void atomic_store_bool(atomic_t *a, bool value)
Atomically store a boolean value.
bool atomic_load_bool(atomic_t *a)
Atomic pointer wrapper.
#define buffer_release(data)
Definition buffer.h:99
void crypto_handshake_destroy(crypto_handshake_context_t *ctx)
Cleanup crypto handshake context with secure memory wiping.
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.
🔄 Network byte order conversion helpers
#define NET_TO_HOST_U16(val)
Definition endian.h:115
unsigned short uint16_t
#define SAFE_FREE(ptr)
unsigned long long uint64_t
unsigned char uint8_t
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
@ ERROR_INVALID_STATE
@ ERROR_NETWORK_PROTOCOL
Definition error_codes.h:80
@ ASCIICHAT_OK
Definition error_codes.h:50
@ ERROR_CRYPTO_AUTH
Definition error_codes.h:99
@ ERROR_CRYPTO
Definition error_codes.h:97
@ ERROR_INVALID_PARAM
key_type_t type
Definition key_types.h:102
@ KEY_TYPE_ED25519
Definition key_types.h:58
asciichat_error_t packet_validate(const void *packet, size_t length, size_t limit, packet_header_t *output)
Definition packet.c:81
asciichat_error_t packet_encode(packet_type_t type, const void *payload, size_t length, uint32_t client_id, void *output, size_t capacity, size_t *written)
Definition packet.c:63
#define ACIP_CRYPTO_NONE
No encryption, no authentication (plaintext only).
Definition packet.h:1157
void protocol_version_packet_init(protocol_version_packet_t *version, uint8_t supports_encryption)
Initialize a protocol version packet with the current wire version.
Definition packet.c:37
#define ACIP_CRYPTO_HAS_AUTH(mode)
Check if crypto mode includes authentication.
Definition packet.h:1174
#define ACIP_CRYPTO_HAS_ENCRYPT(mode)
Check if crypto mode includes payload encryption.
Definition packet.h:1167
packet_type_t
Network protocol packet type enumeration.
Definition packet.h:315
#define ACIP_CRYPTO_FULL
Full crypto: encryption + authentication.
Definition packet.h:1160
@ PACKET_TYPE_CRYPTO_HANDSHAKE_COMPLETE
Server -> Client: "encryption ready" (UNENCRYPTED).
Definition packet.h:352
@ PACKET_TYPE_CRYPTO_KEY_EXCHANGE_INIT
Server -> Client: {server_pubkey[32]} (UNENCRYPTED).
Definition packet.h:340
@ PACKET_TYPE_CRYPTO_EPOCH_MARKER
Definition packet.h:359
@ PACKET_TYPE_CRYPTO_REKEY_COMPLETE
Initiator -> Responder: Empty (encrypted with NEW key, but still handshake).
Definition packet.h:375
@ PACKET_TYPE_CRYPTO_AUTH_FAILED
Server -> Client: "authentication failed" (UNENCRYPTED).
Definition packet.h:348
@ PACKET_TYPE_ENCRYPTED
Encrypted packet (after handshake completion).
Definition packet.h:369
@ PACKET_TYPE_CRYPTO_REKEY_REQUEST
Initiator -> Responder: {new_ephemeral_pk[32]} (UNENCRYPTED during rekey).
Definition packet.h:371
@ PACKET_TYPE_CRYPTO_SERVER_AUTH_RESP
Server -> Client: {HMAC[32]} server proves knowledge (UNENCRYPTED).
Definition packet.h:350
@ PACKET_TYPE_PROTOCOL_VERSION
Protocol version and capabilities negotiation.
Definition packet.h:317
@ PACKET_TYPE_CRYPTO_EPOCH_ACK
Definition packet.h:361
@ PACKET_TYPE_CRYPTO_AUTH_CHALLENGE
Server -> Client: {nonce[32]} (UNENCRYPTED).
Definition packet.h:344
@ PACKET_TYPE_CRYPTO_PARAMETERS
Server -> Client: Chosen algorithms + data sizes (UNENCRYPTED).
Definition packet.h:338
@ PACKET_TYPE_CRYPTO_REKEY_NEEDED
Definition packet.h:360
@ PACKET_TYPE_CRYPTO_REKEY_RESPONSE
Responder -> Initiator: {new_ephemeral_pk[32]} (UNENCRYPTED during rekey).
Definition packet.h:373
#define PROTOCOL_VERSION_MAJOR
Major protocol version number.
#define PROTOCOL_VERSION_MINOR
Minor protocol version number.
#define PROTOCOL_VERSION_PATCH
Patch protocol version number.
struct acip_transport acip_transport_t
Forward declaration of ACIP transport.
Definition host.h:508
Client-side handshake functions.
Server-side handshake functions.
struct crypto_session crypto_session_t
For crypto session, this is the live record that ties owner, mutex, records, rotation together....
#define CRYPTO_SESSION_MESSAGES
asciichat_error_t crypto_handshake_client_complete(crypto_handshake_context_t *ctx, acip_transport_t *transport, packet_type_t packet_type, const uint8_t *payload, size_t payload_len)
Client: Wait for handshake complete confirmation.
asciichat_error_t crypto_handshake_client_key_exchange(crypto_handshake_context_t *ctx, acip_transport_t *transport, packet_type_t packet_type, const uint8_t *payload, size_t payload_len)
Client: Process server's public key and send our public key.
asciichat_error_t crypto_handshake_client_auth_response(crypto_handshake_context_t *ctx, acip_transport_t *transport, packet_type_t packet_type, const uint8_t *payload, size_t payload_len)
Client: Process auth challenge and send response.
asciichat_error_t crypto_handshake_server_send_parameters(crypto_handshake_context_t *ctx, acip_transport_t *transport)
Server: Send CRYPTO_PARAMETERS and set handshake context sizes.
asciichat_error_t crypto_handshake_server_complete(crypto_handshake_context_t *ctx, acip_transport_t *transport, packet_type_t packet_type, const uint8_t *payload, size_t payload_len)
Server: Process auth response and complete handshake.
asciichat_error_t crypto_handshake_server_auth_challenge(crypto_handshake_context_t *ctx, acip_transport_t *transport, packet_type_t packet_type, const uint8_t *payload, size_t payload_len)
Server: Process client's public key and send auth challenge.
asciichat_error_t crypto_handshake_server_start(crypto_handshake_context_t *ctx, acip_transport_t *transport)
Server: Start crypto handshake by sending public key.
asciichat_error_t crypto_session_tick(crypto_session_t *session, uint64_t now)
asciichat_error_t crypto_session_receive(crypto_session_t *session, unsigned channel, unsigned delivery, crypto_rekey_message_t type, const void *payload, size_t length, uint64_t now, bool *consumed)
void crypto_session_unlock(crypto_session_t *session)
asciichat_error_t crypto_session_lock(crypto_context_t *crypto, crypto_session_t **output)
asciichat_error_t acip_security_rekey_encode(unsigned flow, crypto_rekey_message_t type, const void *payload, size_t length, void *packet, size_t capacity, size_t *written)
asciichat_error_t acip_security_start(acip_security_t *security, acip_transport_t *transport)
asciichat_error_t acip_security_next_control(crypto_context_t *crypto, acip_traffic_class_t *flow, uint8_t **wire, size_t *length)
asciichat_error_t acip_security_request_rekey(acip_transport_t *transport)
asciichat_error_t acip_security_rekey_seal(crypto_record_t *records, unsigned flow, crypto_rekey_message_t message, const void *payload, size_t length, uint8_t **wire, size_t *written)
void acip_security_cleanup(acip_security_t *security)
asciichat_error_t acip_security_seal(crypto_context_t *crypto, acip_traffic_class_t flow, acip_delivery_t delivery, const void *packet, size_t length, uint8_t **output, size_t *written)
asciichat_error_t acip_security_rekey_receive(crypto_rekey_session_t *session, acip_traffic_class_t flow, acip_delivery_t delivery, const void *packet, size_t length, uint64_t now, bool *consumed)
asciichat_error_t acip_security_open(crypto_context_t *crypto, acip_traffic_class_t flow, acip_delivery_t delivery, const void *packet, size_t length, uint8_t **output, size_t *written, uint64_t *sequence, bool *consumed)
asciichat_error_t acip_security_decrypt(crypto_context_t *crypto, unsigned flow, unsigned delivery, const void *payload, size_t length, uint8_t **output, size_t *written, uint64_t *sequence, bool *consumed)
bool acip_security_rekey_packet(uint16_t type)
asciichat_error_t acip_security_activate(acip_transport_t *transport)
asciichat_error_t acip_security_flush(acip_transport_t *transport)
asciichat_error_t acip_security_receive(acip_security_t *security, acip_transport_t *transport, packet_type_t type, const void *payload, size_t length)
asciichat_error_t acip_packet_decrypt_payload(crypto_record_t *records, unsigned flow, unsigned delivery, const void *payload, size_t length, uint8_t **output, size_t *written, uint64_t *sequence)
Definition prepare.c:164
asciichat_error_t acip_packet_seal(crypto_record_t *records, acip_traffic_class_t flow, acip_delivery_t delivery, const void *packet, size_t length, uint8_t **output, size_t *written)
Definition prepare.c:108
Protocol version, features, compression, and frame flag constants.
struct crypto_record crypto_record_t
When code needs to work with crypto record, it keeps crypto, key_epoch, last_receive_epoch,...
#define CRYPTO_RECORD_CHANNELS
Definition record.h:11
asciichat_error_t crypto_rekey_session_receive(crypto_rekey_session_t *s, unsigned flow, unsigned delivery, crypto_rekey_message_t type, const void *payload, size_t bytes, uint64_t now, bool *consumed)
Definition rekey.c:116
asciichat_error_t crypto_rekey_session_request(crypto_rekey_session_t *s, uint64_t now)
Definition rekey.c:107
crypto_rekey_message_t
Definition rekey.h:10
@ CRYPTO_REKEY_NONE
Definition rekey.h:11
@ CRYPTO_REKEY_NEEDED
Definition rekey.h:17
struct acip_security acip_security_t
acip security is intentionally a small, concrete record. Fields such as handshake,...
asciichat_error_t packet_send_via_transport(acip_transport_t *transport, packet_type_t type, const void *payload, size_t payload_len, uint32_t client_id)
Definition send.c:183
ACIP shared/bidirectional packet sending functions.
#define CRYPTO_PUBLIC_KEY_SIZE
Public key size (X25519).
Definition sizes.h:71
🔤 String Manipulation and Shell Escaping Utilities
bool parameters_received
Definition security.h:24
bool require_encryption
Definition security.h:22
uint8_t mode
Definition security.h:20
crypto_handshake_context_t handshake
Definition security.h:19
bool forbid_encryption
Definition security.h:21
bool version_received
Definition security.h:23
asciichat_error_t(* send)(acip_transport_t *transport, const void *data, size_t len)
Send data through this transport.
asciichat_error_t(* sendv)(acip_transport_t *transport, const socket_buffer_t *buffers, size_t count)
Custom destroy implementation (optional).
asciichat_error_t(* sendv_ex)(acip_transport_t *transport, const socket_buffer_t *buffers, size_t count, const acip_send_options_t *options)
atomic_t packet_security_active
Publishes the stable post-handshake crypto owner.
const acip_transport_methods_t * methods
Method table (virtual functions).
crypto_context_t * crypto_ctx
Optional encryption context.
Endpoint cryptographic state for handshake, packet protection, authentication, and rekeying.
Cryptographic handshake context structure.
Crypto parameters packet structure (Packet Type 15).
Definition packet.h:1056
unsigned last_receive_channel
Definition record.h:32
crypto rekey session is intentionally a small, concrete record. Fields such as security,...
Definition rekey.h:26
uint8_t payload[CRYPTO_PUBLIC_KEY_SIZE]
crypto_session_message_t messages[16]
crypto_rekey_session_t rotation
Fixed prefix shared by every ACIP packet on the wire.
Definition packet.h:641
Protocol version negotiation packet structure (Packet Type 1).
Definition packet.h:871
uint16_t protocol_patch
Patch protocol revision.
Definition packet.h:877
uint16_t protocol_revision
Minor protocol revision (server can be newer).
Definition packet.h:875
uint16_t protocol_version
Major protocol version (must match for compatibility).
Definition packet.h:873
uint8_t supports_encryption
Encryption & authentication mode bitmask (ACIP_CRYPTO_* constants: NONE, ENCRYPT, AUTH,...
Definition packet.h:879
acip_traffic_class_t
Definition traffic.h:9
@ ACIP_TRAFFIC_CONTROL
Definition traffic.h:10
acip_delivery_t
Definition traffic.h:15
@ ACIP_DELIVERY_RELIABLE
Definition traffic.h:16