quic_aead_ctx (quic v1.10.0)
View SourceSummary
Functions
Open: takes Ciphertext||Tag; returns Plaintext | error. The whole thing is passed in so the length check lives in one place: both the NIF and the OTP path need the tag split off, and neither may be handed input too short to hold one.
Seal: returns Ciphertext||Tag.
One ECB block for AES header protection (mask source).
Fused short-header receive: header unprotection, PN reconstruction and AEAD open in one NIF call. Returns {ok, PN, UnprotectedFirstByte, Plaintext}, error on authentication failure, or fallback (NIF missing, ChaCha, or the packet's key phase differs from ExpectedPhase - the caller then runs the generic path with key selection).
Batched open_packet over a train of short-header datagrams (FirstByte + DCID + PN + ciphertext + tag each). Returns the opened prefix; a shorter list than Datagrams means the remainder must be run through the generic per-packet path. fallback when the NIF is unavailable or the cipher is ChaCha.
Seal a run of short-header packets with consecutive PNs in one NIF call (header build + nonce + AEAD + header protection fused). Returns {ok, [WirePacket]} or fallback when the NIF is not loaded, the cipher is ChaCha (its HP is not ECB) or the NIF rejects the input - callers then take the per-packet path.
Functions
Open: takes Ciphertext||Tag; returns Plaintext | error. The whole thing is passed in so the length check lives in one place: both the NIF and the OTP path need the tag split off, and neither may be handed input too short to hold one.
Seal: returns Ciphertext||Tag.
One ECB block for AES header protection (mask source).
-spec open_packet(atom(), binary(), binary(), binary(), non_neg_integer() | undefined, 0 | 1, binary(), binary()) -> {ok, non_neg_integer(), byte(), binary()} | error | fallback.
Fused short-header receive: header unprotection, PN reconstruction and AEAD open in one NIF call. Returns {ok, PN, UnprotectedFirstByte, Plaintext}, error on authentication failure, or fallback (NIF missing, ChaCha, or the packet's key phase differs from ExpectedPhase - the caller then runs the generic path with key selection).
-spec open_run(atom(), binary(), binary(), binary(), non_neg_integer() | undefined, 0 | 1, non_neg_integer(), [binary()]) -> {ok, [{non_neg_integer(), byte(), [term()] | {raw, binary()}}]} | fallback.
Batched open_packet over a train of short-header datagrams (FirstByte + DCID + PN + ciphertext + tag each). Returns the opened prefix; a shorter list than Datagrams means the remainder must be run through the generic per-packet path. fallback when the NIF is unavailable or the cipher is ChaCha.
-spec protect_run(atom(), binary(), binary(), binary(), non_neg_integer(), byte(), binary(), [iodata()]) -> {ok, [binary()]} | fallback.
Seal a run of short-header packets with consecutive PNs in one NIF call (header build + nonce + AEAD + header protection fused). Returns {ok, [WirePacket]} or fallback when the NIF is not loaded, the cipher is ChaCha (its HP is not ECB) or the NIF rejects the input - callers then take the per-packet path.