STRUCT AF_ALG_CTX(9)
π struct af_alg_ctx(9) π
okay so bestie, welcome to the kernel API manual β this one's a kernel API page about a little struct called af_alg_ctx, and honestly? it's giving backstage-pass energy. it's the definition of the crypto context. that's it, that's the whole vibe. π
β¨ NAME β¨
struct af_alg_ctx β literally just the definition of the crypto context, no cap π
β¨ SYNOPSIS β¨
okay here's the actual shape of it, copy it exactly bestie, don't freestyle:
struct af_alg_ctx {
struct list_head tsgl_list;
void *iv;
void *state;
size_t aead_assoclen;
struct crypto_wait wait;
size_t used;
atomic_t rcvused;
bool more:1, merge:1, enc:1, write:1, init:1;
unsigned int len;
unsigned int inflight;
};
look at those bitfields. more:1, merge:1, enc:1, write:1, init:1 β five whole booleans living in one byte, she's thriving on efficiency π§β¨
πΈ Members πΈ
tsgl_listβ the link to TX SGL. that's her whole job, she holds the link πivβ the IV for the cipher operation. yes, the IV. iconic πstateβ existing state, for when you're continuing an operation (picking up right where you left off, main character energy) π¦aead_assoclenβ length of the AAD for AEAD cipher operations πwaitβ for waiting for completion of async crypto ops. she waits. gracefully. patiently. π«Άusedβ TX bytes sent to kernel. and why do we care? because this variable is used to make sure user space cannot cause the kernel to allocate too much memory in asendmsgoperation. protective queen behavior honestly πrcvusedβ total RX bytes to be filled by kernel. and again, this variable is used to make sure user space cannot cause the kernel to allocate too much memory in arecvmsgoperation. same energy, receiving side πmoreβ more data to be expected from user space? (yes/no, that's the question) πmergeβ shall new data from user space be merged into the existing SG? πencβ the cryptographic operation to be performed whenrecvmsgis invoked πwriteβ true if we are in the middle of a write βinitβ true if metadata has been sent βlenβ length of memory allocated for this data structure πinflightβ non-zero when requests are in flight. for debugging only, bestie β don't go building your whole personality on it π
π Description π
so what does she do? the crypto context tracks the input data during the lifetime of an AF_ALG socket. that's the whole gig. she's there the entire time, keeping receipts on the input data, from start to finish. obsessed with her consistency fr fr π
π₯ SEE ALSO π₯
go read these next, iykyk:
- Kernel file
./include/crypto/if_alg.h struct af_alg_async_req(9)af_alg_sndbuf(9)af_alg_writable(9)af_alg_rcvbuf(9)af_alg_readable(9)
ok that's the whole page!! no notes, she ate π
and that's a wrap bestie π this one lives in ./include/crypto, and it's dated October 2026 β so yeah, very demure, very forward-looking. mwah ππ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms