STRUCT AKCIPHER_ALG(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct akcipher_alg(9) β€” the Kernel API Manual, bestie edition ✨

okay so this page is struct akcipher_alg(9) from the Kernel API Manual, and it's literally the blueprint for a generic public key cipher algorithm β€” like, the whole personality of an akcipher lives in this struct πŸŽ€


🌸 NAME 🌸

struct akcipher_alg β€” the generic public key cipher algorithm struct. that's it, that's the whole vibe πŸ’–


✨ SYNOPSIS ✨

here's the struct in all its glory, no cap, every member exactly where it belongs πŸ‘‘

struct akcipher_alg {
    int (*encrypt)(struct akcipher_request *req);
    int (*decrypt)(struct akcipher_request *req);
    int (*set_pub_key)(struct crypto_akcipher *tfm, const void *key,
                       unsigned int keylen);
    int (*set_priv_key)(struct crypto_akcipher *tfm, const void *key,
                        unsigned int keylen);
    unsigned int (*max_size)(struct crypto_akcipher *tfm);
    int (*init)(struct crypto_akcipher *tfm);
    void (*exit)(struct crypto_akcipher *tfm);
    struct crypto_alg base;
};

πŸ¦‹ Members πŸ¦‹

okay, member-by-member tour, bestie β€” grab a snack πŸ“

  • encrypt β€” this one does an encrypt operation, as defined by the public key algorithm. and lowkey important: if there's an error where dst_len was insufficient, then req->dst_len gets updated to the size required for the operation 😭 so like, it tells you how much room you actually needed.
  • decrypt β€” same energy, opposite direction: performs a decrypt operation as defined by the public key algorithm. and again, in case of error where dst_len was insufficient, req->dst_len will be updated to the size required for the operation πŸ’…
  • set_pub_key β€” this function invokes the algorithm-specific set public key function, which β€” and this is the iconic part β€” knows how to decode and interpret the BER encoded public key and parameters 🌈
  • set_priv_key β€” the sibling: invokes the algorithm-specific set private key function, which knows how to decode and interpret the BER encoded private key and parameters πŸ”
  • max_size β€” returns the dest buffer size required for a given key. like a little size-check bestie πŸ“
  • init β€” initializes the cryptographic transformation object. yes, that's the actual description, and yes it says it again: this function is used to initialize the cryptographic transformation object πŸ’€ and here's the when: it's called only once at the instantiation time, right after the transformation context was allocated. also, if the cryptographic hardware has some special requirements that need to be handled by software, this function shall check for the precise requirement of the transformation and put any software fallbacks in place 🧚✨
  • exit β€” deinitializes the cryptographic transformation object. it's the counterpart to init, used to remove the various changes set in init. the breakup arc, if you will 🫢
  • base β€” the common crypto API algorithm data structure. the main character foundation, fr fr πŸ‘‘

πŸ‘‘ SEE ALSO πŸ‘‘

go read these next, iykyk:


that's the whole page, no skips, no crumbs left behind πŸ’€

and finally, the cute little sign-off: this one lives at ./include/crypto, dated October 2026, and it's struct akcipher_alg(9) β€” go be a cipher icon bestie πŸ’œπŸŒΈβœ¨

πŸ“¦ where this page comes from