STRUCT AF_ALG_CTX(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 a sendmsg operation. 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 a recvmsg operation. 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 when recvmsg is 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:


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