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

Go to the source code of this file.

Data Structures

struct  crypto_record
 When code needs to work with crypto record, it keeps crypto, key_epoch, last_receive_epoch, previous_crypto here instead of scattering it across globals. Initialization establishes the handles and sizes; teardown must release any allocation, lock, thread, or callback context recorded in those fields. The caller serializes operations and keeps the borrowed crypto context alive. One previous receive epoch survives until each channel crosses its marker. More...

Macros

#define CRYPTO_RECORD_CHANNELS   3
#define CRYPTO_RECORD_CONTROL_CHANNEL   0
#define CRYPTO_RECORD_RELIABLE   0
#define CRYPTO_RECORD_DATAGRAM   1
#define CRYPTO_RECORD_ANY_CHANNEL   UINT_MAX

Typedefs

typedef struct crypto_record crypto_record_t
 When code needs to work with crypto record, it keeps Crypto Module, key_epoch, last_receive_epoch, previous_crypto here instead of scattering it across globals. Initialization establishes the handles and sizes; teardown must release any allocation, lock, thread, or callback context recorded in those fields. The caller serializes operations and keeps the borrowed crypto context alive. One previous receive epoch survives until each channel crosses its marker.
typedef asciichat_error_t(* crypto_record_validate_fn) (void *, unsigned, unsigned, const void *, size_t)

Functions

asciichat_error_t crypto_record_init (crypto_record_t *, crypto_context_t *, bool server)
asciichat_error_t crypto_record_seal_into (crypto_record_t *, unsigned channel, unsigned delivery, const void *, size_t, uint8_t *, size_t, size_t *)
asciichat_error_t crypto_record_seal_into_domain (crypto_record_t *, unsigned channel, unsigned delivery, const void *, size_t, uint8_t *, size_t, size_t *, buffer_domain_t *)
asciichat_error_t crypto_record_open_sequence (crypto_record_t *, unsigned channel, unsigned delivery, const void *, size_t, uint8_t **, size_t *, uint64_t *, crypto_record_validate_fn, void *)
asciichat_error_t crypto_record_prepare_epoch (crypto_record_t *)
asciichat_error_t crypto_record_commit_epoch (crypto_record_t *)
asciichat_error_t crypto_record_retire_epoch_flow (crypto_record_t *, unsigned channel, uint64_t epoch)
void crypto_record_cleanup (crypto_record_t *)

Macro Definition Documentation

◆ CRYPTO_RECORD_ANY_CHANNEL

#define CRYPTO_RECORD_ANY_CHANNEL   UINT_MAX

◆ CRYPTO_RECORD_CHANNELS

◆ CRYPTO_RECORD_CONTROL_CHANNEL

#define CRYPTO_RECORD_CONTROL_CHANNEL   0

Definition at line 12 of file record.h.

Referenced by crypto_record_seal_into_domain().

◆ CRYPTO_RECORD_DATAGRAM

#define CRYPTO_RECORD_DATAGRAM   1

Definition at line 14 of file record.h.

Referenced by crypto_record_open_sequence().

◆ CRYPTO_RECORD_RELIABLE

#define CRYPTO_RECORD_RELIABLE   0

Typedef Documentation

◆ crypto_record_t

When code needs to work with crypto record, it keeps Crypto Module, key_epoch, last_receive_epoch, previous_crypto here instead of scattering it across globals. Initialization establishes the handles and sizes; teardown must release any allocation, lock, thread, or callback context recorded in those fields. The caller serializes operations and keeps the borrowed crypto context alive. One previous receive epoch survives until each channel crosses its marker.

Authenticated records over independent ordered channels and unordered delivery.

◆ crypto_record_validate_fn

typedef asciichat_error_t(* crypto_record_validate_fn) (void *, unsigned, unsigned, const void *, size_t)

Definition at line 40 of file record.h.

Function Documentation

◆ crypto_record_cleanup()

void crypto_record_cleanup ( crypto_record_t * state)

Definition at line 293 of file record.c.

293 {
294 if (state)
295 sodium_memzero(state, sizeof(*state));
296}

Referenced by crypto_session_destroy().

◆ crypto_record_commit_epoch()

asciichat_error_t crypto_record_commit_epoch ( crypto_record_t * state)

Definition at line 251 of file record.c.

251 {
252 if (!ready(state) || !state->pending_prepared || state->previous_valid ||
253 !state->crypto->rekey_in_progress || !state->crypto->has_temp_key)
255 "record key epoch is not ready to commit");
256 crypto_context_t previous = *state->crypto;
257 previous.session = NULL;
258 previous.rekey_in_progress = previous.has_temp_key = false;
259 sodium_memzero(previous.temp_private_key, sizeof(previous.temp_private_key));
260 sodium_memzero(previous.temp_public_key, sizeof(previous.temp_public_key));
261 sodium_memzero(previous.temp_shared_key, sizeof(previous.temp_shared_key));
262 if (crypto_rekey_commit(state->crypto) != CRYPTO_OK) {
263 sodium_memzero(&previous, sizeof(previous));
264 return SET_ERRNO(ERROR_CRYPTO, "Cannot commit record key epoch");
265 }
266 state->previous_crypto = previous;
267 sodium_memzero(&previous, sizeof(previous));
268 state->previous_epoch = state->key_epoch;
269 state->key_epoch = state->crypto->rekey_count;
270 state->previous_valid = true;
271 state->pending_prepared = false;
272 for (unsigned i = 0; i < CRYPTO_RECORD_CHANNELS; ++i)
273 state->previous_allowed[i] = true;
274 return ASCIICHAT_OK;
275}
#define SET_ERRNO(code,...)
crypto_result_t crypto_rekey_commit(crypto_context_t *ctx)
Commit to new keys after successful REKEY_COMPLETE.
@ ERROR_INVALID_STATE
@ ASCIICHAT_OK
Definition error_codes.h:50
@ ERROR_CRYPTO
#define CRYPTO_RECORD_CHANNELS
Definition record.h:11
Endpoint cryptographic state for handshake, packet protection, authentication, and rekeying.
struct crypto_session * session
Endpoint cryptographic state for handshake, packet protection, authentication, and rekeying.
bool previous_valid
Definition record.h:31
crypto_context_t previous_crypto
Definition record.h:29
bool pending_prepared
Definition record.h:31
crypto_context_t * crypto
Definition record.h:27
uint64_t key_epoch
Definition record.h:28
bool previous_allowed[3]
Definition record.h:32
uint64_t previous_epoch
Definition record.h:30

References ASCIICHAT_OK, crypto_record::crypto, CRYPTO_OK, CRYPTO_RECORD_CHANNELS, crypto_rekey_commit(), ERROR_CRYPTO, ERROR_INVALID_STATE, crypto_context_t::has_temp_key, crypto_record::key_epoch, crypto_record::pending_prepared, crypto_record::previous_allowed, crypto_record::previous_crypto, crypto_record::previous_epoch, crypto_record::previous_valid, crypto_context_t::rekey_count, crypto_context_t::rekey_in_progress, crypto_context_t::session, and SET_ERRNO.

Referenced by crypto_record_open_sequence(), and crypto_rekey_session_receive().

◆ crypto_record_init()

asciichat_error_t crypto_record_init ( crypto_record_t * state,
crypto_context_t * crypto,
bool server )

Definition at line 26 of file record.c.

27 {
28 if (!state || state->crypto || !crypto || !crypto->initialized ||
29 !crypto->encrypt_data || !crypto->key_exchange_complete ||
30 !crypto->handshake_complete || crypto->nonce_size != CRYPTO_NONCE_SIZE ||
31 crypto->mac_size != CRYPTO_MAC_SIZE || crypto->rekey_in_progress)
33 "Session handshake and encryption must be ready");
34 *state = (crypto_record_t){
35 .crypto = crypto, .key_epoch = crypto->rekey_count, .server = server};
36 return ASCIICHAT_OK;
37}
struct crypto_record crypto_record_t
When code needs to work with crypto record, it keeps crypto, key_epoch, last_receive_epoch,...
#define CRYPTO_NONCE_SIZE
Nonce size (XSalsa20).
Definition sizes.h:84
#define CRYPTO_MAC_SIZE
MAC size (Poly1305).
Definition sizes.h:90

References ASCIICHAT_OK, crypto_record::crypto, CRYPTO_MAC_SIZE, CRYPTO_NONCE_SIZE, crypto_context_t::encrypt_data, ERROR_INVALID_STATE, crypto_context_t::handshake_complete, crypto_context_t::initialized, crypto_context_t::key_exchange_complete, crypto_context_t::mac_size, crypto_context_t::nonce_size, crypto_context_t::rekey_count, crypto_context_t::rekey_in_progress, and SET_ERRNO.

Referenced by crypto_session_lock().

◆ crypto_record_open_sequence()

asciichat_error_t crypto_record_open_sequence ( crypto_record_t * state,
unsigned channel,
unsigned delivery,
const void * packet,
size_t length,
uint8_t ** out,
size_t * out_length,
uint64_t * sequence_out,
crypto_record_validate_fn validate,
void * context )

Definition at line 107 of file record.c.

110 {
111 if (!out || !out_length)
113 "Missing record decrypted packet output");
114 *out = NULL;
115 *out_length = 0;
116 if (sequence_out)
117 *sequence_out = 0;
118 if (!ready(state) || delivery > CRYPTO_RECORD_DATAGRAM ||
119 (traffic_class != CRYPTO_RECORD_ANY_CHANNEL &&
120 !valid_flow(traffic_class, delivery)))
122 "Record decryption is not ready for this flow");
123 const size_t record_overhead = CRYPTO_RECORD_EPOCH_SIZE +
124 (size_t)state->crypto->nonce_size +
125 (size_t)state->crypto->mac_size;
126 if (!packet || length < record_overhead ||
128 (size_t)state->crypto->nonce_size +
129 (size_t)state->crypto->mac_size)
131 "Invalid Record encrypted packet size");
132 const uint8_t *cipher = packet;
133 size_t cipher_length = length;
134 uint64_t network_epoch;
135 memcpy(&network_epoch, cipher, sizeof(network_epoch));
136 uint64_t epoch = NET_TO_HOST_U64(network_epoch);
137 crypto_context_t pending_crypto;
138 crypto_context_t *decrypt_crypto = state->crypto;
139 bool pending = false;
140 if (epoch != state->key_epoch) {
141 if (state->previous_valid && epoch == state->previous_epoch) {
142 decrypt_crypto = &state->previous_crypto;
143 } else if (state->key_epoch != UINT64_MAX &&
144 epoch == state->key_epoch + 1 && state->pending_prepared &&
145 state->crypto->rekey_in_progress &&
146 state->crypto->has_temp_key) {
147 pending_crypto = *state->crypto;
148 pending_crypto.session = NULL;
149 memcpy(pending_crypto.shared_key, state->crypto->temp_shared_key,
150 sizeof(pending_crypto.shared_key));
151 pending_crypto.rekey_in_progress = false;
152 pending_crypto.has_temp_key = false;
153 decrypt_crypto = &pending_crypto;
154 pending = true;
155 } else {
156 return SET_ERRNO(ERROR_CRYPTO, "Unknown or retired record key epoch");
157 }
158 }
159 cipher += CRYPTO_RECORD_EPOCH_SIZE;
160 cipher_length -= CRYPTO_RECORD_EPOCH_SIZE;
161 uint8_t *plain = buffer_alloc(NULL, cipher_length);
162 if (!plain) {
163 if (pending)
164 sodium_memzero(&pending_crypto, sizeof(pending_crypto));
165 return SET_ERRNO(ERROR_MEMORY, "Cannot allocate record decrypted packet");
166 }
167 defer(if (plain) buffer_release(plain));
168 size_t plain_length = 0;
169 crypto_result_t crypto_result =
170 crypto_decrypt(decrypt_crypto, cipher, cipher_length, plain,
171 cipher_length, &plain_length);
172 if (pending)
173 sodium_memzero(&pending_crypto, sizeof(pending_crypto));
174 if (crypto_result != CRYPTO_OK) {
175 return SET_ERRNO(ERROR_CRYPTO, "Cannot authenticate Record packet");
176 }
177 if (plain_length < CRYPTO_RECORD_PREFIX_SIZE || memcmp(plain, "ACR1", 4) ||
178 plain[4] != (state->server ? 0 : 1) ||
179 (traffic_class != CRYPTO_RECORD_ANY_CHANNEL &&
180 plain[5] != traffic_class) ||
181 plain[5] >= CRYPTO_RECORD_CHANNELS || plain[6] != (uint8_t)delivery ||
182 plain[7] || memcmp(plain + 16, &network_epoch, sizeof(network_epoch))) {
184 "Invalid authenticated record flow metadata");
185 }
186 traffic_class = plain[5];
187 if (epoch == state->previous_epoch && state->previous_valid &&
188 !state->previous_allowed[traffic_class]) {
189 return SET_ERRNO(ERROR_CRYPTO, "Retired record channel epoch");
190 }
191 uint64_t network_sequence;
192 memcpy(&network_sequence, plain + 8, sizeof(network_sequence));
193 uint64_t sequence = NET_TO_HOST_U64(network_sequence);
194 uint64_t high = state->receive_high[traffic_class][delivery];
195 uint64_t seen = state->datagram_seen[traffic_class];
196 if (!sequence || (delivery == CRYPTO_RECORD_RELIABLE && sequence <= high) ||
197 (delivery == CRYPTO_RECORD_DATAGRAM && sequence <= high &&
198 (high - sequence >= 64 ||
199 (seen & (UINT64_C(1) << (high - sequence)))))) {
200 return SET_ERRNO(ERROR_CRYPTO, "Replayed or stale Record packet");
201 }
202 size_t inner_length = plain_length - CRYPTO_RECORD_PREFIX_SIZE;
203 asciichat_error_t result =
204 validate ? validate(context, traffic_class, delivery,
205 plain + CRYPTO_RECORD_PREFIX_SIZE, inner_length)
206 : ASCIICHAT_OK;
207 if (result != ASCIICHAT_OK) {
208 return result;
209 }
210 if (pending) {
211 result = crypto_record_commit_epoch(state);
212 if (result != ASCIICHAT_OK) {
213 return result;
214 }
215 }
216 if (delivery == CRYPTO_RECORD_DATAGRAM) {
217 if (sequence > high) {
218 uint64_t advance = sequence - high;
219 seen = advance >= 64 ? UINT64_C(1) : (seen << advance) | UINT64_C(1);
220 high = sequence;
221 } else {
222 seen |= UINT64_C(1) << (high - sequence);
223 }
224 state->datagram_seen[traffic_class] = seen;
225 } else {
226 high = sequence;
227 }
228 state->receive_high[traffic_class][delivery] = high;
229 state->last_receive_epoch = epoch;
230 state->last_receive_channel = traffic_class;
231 state->last_receive_delivery = delivery;
232 memmove(plain, plain + CRYPTO_RECORD_PREFIX_SIZE, inner_length);
233 *out = plain;
234 plain = NULL;
235 *out_length = inner_length;
236 if (sequence_out)
237 *sequence_out = sequence;
238 return ASCIICHAT_OK;
239}
void * buffer_alloc(buffer_domain_t *domain, size_t size)
Definition buffer.c:294
#define buffer_release(data)
Definition buffer.h:108
#define NET_TO_HOST_U64(val)
Definition endian.h:224
unsigned long long uint64_t
unsigned char uint8_t
crypto_result_t
Cryptographic operation result codes.
crypto_result_t crypto_decrypt(crypto_context_t *ctx, const uint8_t *ciphertext, size_t ciphertext_len, uint8_t *plaintext_out, size_t plaintext_out_size, size_t *plaintext_len_out)
Decrypt data using XSalsa20-Poly1305.
#define CRYPTO_MAX_PLAINTEXT_SIZE
Maximum plaintext size (1MB).
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
@ ERROR_NETWORK_PROTOCOL
Definition error_codes.h:81
@ ERROR_MEMORY
Definition error_codes.h:55
@ ERROR_INVALID_PARAM
static bool size_t gotel_query_t * out
Definition queries.h:10
asciichat_error_t crypto_record_commit_epoch(crypto_record_t *state)
Definition record.c:251
#define CRYPTO_RECORD_PREFIX_SIZE
Definition record.c:9
#define CRYPTO_RECORD_EPOCH_SIZE
Definition record.c:10
#define CRYPTO_RECORD_RELIABLE
Definition record.h:13
#define CRYPTO_RECORD_DATAGRAM
Definition record.h:14
#define CRYPTO_RECORD_ANY_CHANNEL
Definition record.h:15
uint64_t last_receive_epoch
Definition record.h:28
unsigned last_receive_delivery
Definition record.h:36
uint64_t datagram_seen[3]
Definition record.h:35
uint64_t receive_high[3][2]
Definition record.h:34
bool server
Definition record.h:37
unsigned last_receive_channel
Definition record.h:36

References ASCIICHAT_OK, buffer_alloc(), buffer_release, crypto_record::crypto, crypto_decrypt(), CRYPTO_MAX_PLAINTEXT_SIZE, CRYPTO_OK, CRYPTO_RECORD_ANY_CHANNEL, CRYPTO_RECORD_CHANNELS, crypto_record_commit_epoch(), CRYPTO_RECORD_DATAGRAM, CRYPTO_RECORD_EPOCH_SIZE, CRYPTO_RECORD_PREFIX_SIZE, CRYPTO_RECORD_RELIABLE, crypto_record::datagram_seen, ERROR_CRYPTO, ERROR_INVALID_PARAM, ERROR_INVALID_STATE, ERROR_MEMORY, ERROR_NETWORK_PROTOCOL, crypto_context_t::has_temp_key, crypto_record::key_epoch, crypto_record::last_receive_channel, crypto_record::last_receive_delivery, crypto_record::last_receive_epoch, crypto_context_t::mac_size, NET_TO_HOST_U64, crypto_context_t::nonce_size, out, crypto_record::pending_prepared, crypto_record::previous_allowed, crypto_record::previous_crypto, crypto_record::previous_epoch, crypto_record::previous_valid, crypto_record::receive_high, crypto_context_t::rekey_in_progress, crypto_record::server, crypto_context_t::session, SET_ERRNO, crypto_context_t::shared_key, and crypto_context_t::temp_shared_key.

Referenced by acip_packet_decrypt_payload().

◆ crypto_record_prepare_epoch()

asciichat_error_t crypto_record_prepare_epoch ( crypto_record_t * state)

Definition at line 241 of file record.c.

241 {
242 if (!ready(state) || state->previous_valid || state->pending_prepared ||
243 state->key_epoch == UINT64_MAX || !state->crypto->rekey_in_progress ||
244 !state->crypto->has_temp_key)
246 "record key epoch is not ready to prepare");
247 state->pending_prepared = true;
248 return ASCIICHAT_OK;
249}

References ASCIICHAT_OK, crypto_record::crypto, ERROR_INVALID_STATE, crypto_context_t::has_temp_key, crypto_record::key_epoch, crypto_record::pending_prepared, crypto_record::previous_valid, crypto_context_t::rekey_in_progress, and SET_ERRNO.

Referenced by crypto_rekey_session_receive(), and crypto_rekey_session_tick().

◆ crypto_record_retire_epoch_flow()

asciichat_error_t crypto_record_retire_epoch_flow ( crypto_record_t * state,
unsigned channel,
uint64_t epoch )

Definition at line 277 of file record.c.

279 {
280 if (!ready(state) || (unsigned)traffic_class > (CRYPTO_RECORD_CHANNELS - 1) ||
281 epoch != state->key_epoch || !state->previous_valid)
283 "Invalid record epoch retirement marker");
284 state->previous_allowed[traffic_class] = false;
285 if (!state->previous_allowed[0] && !state->previous_allowed[1] &&
286 !state->previous_allowed[2]) {
287 sodium_memzero(&state->previous_crypto, sizeof(state->previous_crypto));
288 state->previous_valid = false;
289 }
290 return ASCIICHAT_OK;
291}

References ASCIICHAT_OK, CRYPTO_RECORD_CHANNELS, ERROR_INVALID_STATE, crypto_record::key_epoch, crypto_record::previous_allowed, crypto_record::previous_crypto, crypto_record::previous_valid, and SET_ERRNO.

Referenced by crypto_rekey_session_receive().

◆ crypto_record_seal_into()

asciichat_error_t crypto_record_seal_into ( crypto_record_t * state,
unsigned channel,
unsigned delivery,
const void * packet,
size_t length,
uint8_t * wire,
size_t capacity,
size_t * out_length )

Output buffers belong to the buffer library. No packet headers or CRCs are added here.

Definition at line 39 of file record.c.

43 {
44 return crypto_record_seal_into_domain(state, traffic_class, delivery, packet,
45 length, wire, capacity, out_length,
46 NULL);
47}
asciichat_error_t crypto_record_seal_into_domain(crypto_record_t *state, unsigned traffic_class, unsigned delivery, const void *packet, size_t length, uint8_t *wire, size_t capacity, size_t *out_length, buffer_domain_t *requested_domain)
Definition record.c:49

References crypto_record_seal_into_domain().

◆ crypto_record_seal_into_domain()

asciichat_error_t crypto_record_seal_into_domain ( crypto_record_t * state,
unsigned channel,
unsigned delivery,
const void * packet,
size_t length,
uint8_t * wire,
size_t capacity,
size_t * out_length,
buffer_domain_t * requested_domain )

Definition at line 49 of file record.c.

52 {
53 if (!wire || !out_length)
55 "Missing Record encrypted packet output");
56 *out_length = 0;
57 if (!ready(state) || !valid_flow(traffic_class, delivery))
59 "Record encryption is not ready for this flow");
60 if (!packet || !length)
61 return SET_ERRNO(ERROR_INVALID_PARAM, "Missing record plaintext");
63 state->send_sequence[traffic_class][delivery] == UINT64_MAX)
65 "Record packet or sequence limit exceeded");
66 size_t plain_length = CRYPTO_RECORD_PREFIX_SIZE + length;
67 size_t cipher_capacity =
68 plain_length + state->crypto->nonce_size + state->crypto->mac_size;
69 if (capacity < CRYPTO_RECORD_EPOCH_SIZE + cipher_capacity)
71 "Record ciphertext output is too small");
72 buffer_domain_t *record_buffer_domain =
73 requested_domain ? requested_domain
74 : (traffic_class == CRYPTO_RECORD_CONTROL_CHANNEL
76 : NULL);
77 uint8_t *plain = buffer_alloc(record_buffer_domain, plain_length);
78 if (!plain) {
79 return SET_ERRNO(ERROR_MEMORY, "Cannot allocate Record packet");
80 }
81 memcpy(plain, "ACR1", 4);
82 plain[4] = state->server ? 1 : 0;
83 plain[5] = (uint8_t)traffic_class;
84 plain[6] = (uint8_t)delivery;
85 plain[7] = 0;
86 uint64_t sequence = state->send_sequence[traffic_class][delivery] + 1;
87 uint64_t network_sequence = HOST_TO_NET_U64(sequence);
88 memcpy(plain + 8, &network_sequence, sizeof(network_sequence));
89 uint64_t network_epoch = HOST_TO_NET_U64(state->key_epoch);
90 memcpy(plain + 16, &network_epoch, sizeof(network_epoch));
91 memcpy(plain + CRYPTO_RECORD_PREFIX_SIZE, packet, length);
92 size_t cipher_length = 0;
93 crypto_result_t crypto_result = crypto_encrypt(
94 state->crypto, plain, plain_length, wire + CRYPTO_RECORD_EPOCH_SIZE,
95 cipher_capacity, &cipher_length);
96 buffer_release(plain);
97 if (crypto_result != CRYPTO_OK) {
98 return SET_ERRNO(ERROR_CRYPTO, "Cannot encrypt Record packet");
99 }
100 memcpy(wire, &network_epoch, sizeof(network_epoch));
101 cipher_length += CRYPTO_RECORD_EPOCH_SIZE;
102 state->send_sequence[traffic_class][delivery] = sequence;
103 *out_length = cipher_length;
104 return ASCIICHAT_OK;
105}
buffer_domain_t * buffer_control_domain(void)
Definition buffer.c:465
struct buffer_domain buffer_domain_t
Definition buffer.h:28
#define HOST_TO_NET_U64(val)
Definition endian.h:209
crypto_result_t crypto_encrypt(crypto_context_t *ctx, const uint8_t *plaintext, size_t plaintext_len, uint8_t *ciphertext_out, size_t ciphertext_out_size, size_t *ciphertext_len_out)
Encrypt data using XSalsa20-Poly1305.
@ ERROR_NETWORK_SIZE
Definition error_codes.h:83
#define CRYPTO_RECORD_CONTROL_CHANNEL
Definition record.h:12
uint64_t send_sequence[3][2]
Definition record.h:33

References ASCIICHAT_OK, buffer_alloc(), buffer_control_domain(), buffer_release, crypto_record::crypto, crypto_encrypt(), CRYPTO_MAX_PLAINTEXT_SIZE, CRYPTO_OK, CRYPTO_RECORD_CONTROL_CHANNEL, CRYPTO_RECORD_EPOCH_SIZE, CRYPTO_RECORD_PREFIX_SIZE, ERROR_CRYPTO, ERROR_INVALID_PARAM, ERROR_INVALID_STATE, ERROR_MEMORY, ERROR_NETWORK_SIZE, HOST_TO_NET_U64, crypto_record::key_epoch, crypto_context_t::mac_size, crypto_context_t::nonce_size, crypto_record::send_sequence, crypto_record::server, and SET_ERRNO.

Referenced by acip_packet_encrypt(), and crypto_record_seal_into().