aes_gcm_decrypt(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… aes_gcm_decrypt β€” bestie edition

okay so this is aes_gcm_decrypt(9) from the Kernel API Manual, and it is literally the function that decrypts a message with AES-GCM. she's an icon, she's a legend, and she's about to hand you back your plaintext πŸŽ€


✨ SYNOPSIS ✨

int aes_gcm_decrypt (u8 *dst , const u8 *src , size_t data_len ,
                     const u8 *authtag , const u8 *ad , size_t ad_len ,
                     const u8 nonce[static 12] ,
                     const struct aes_gcm_key *key );

🌸 ARGUMENTS 🌸

  • dst β€” where the decrypted plaintext goes, queen. it can be in-place or out-of-place, we love flexibility πŸ’– but for any other overlap, the behavior is unspecified β€” so don't get cute with it, bestie, that's an unhinged vibe check you will fail.
  • src β€” the source ciphertext data. the scrambled-up little mystery we're solving πŸ•΅οΈβ€β™€οΈ
  • data_len β€” length of the plaintext in bytes (and also the length of the ciphertext excluding the tag). max is at most 2^36 - 32. memorise it. it's giving strict but fair.
  • authtag β€” the stored authentication tag 🏷️ its length is the authtag_len that was passed to aes_gcm_preparekey. usually, protocols using AES-GCM put the tag at the end of the ciphertext β€” in which case this should be set to src + data_len, and src must have room for the tag. iykyk ✨
  • ad β€” the associated data (yes, the data that travels alongside, no, it doesn't get encrypted, don't ask).
  • ad_len β€” length of associated data in bytes: at most 2^61 - 1. huge. iconic. periodt.
  • nonce β€” the 12-byte nonce. twelve. exactly twelve. not eleven, not thirteen. πŸ’…
  • key β€” the key, already prepared using aes_gcm_preparekey. like, already prepared. do not show up here with a raw key, that's embarrassing for everyone.

πŸ¦‹ DESCRIPTION πŸ¦‹

For AES-GMAC (i.e., AES-GCM without any data en/decrypted β€” a vibe-only run, no payload), use dst=NULL, src=NULL, and data_len=0 to verify the AES-GMAC value. yes bestie, that's the whole trick. no data, just trust ✨


🌈 CONTEXT 🌈

Any context. she does not gatekeep, she does not discriminate, any context is welcome in this house 🫢


πŸ‘‘ RETURN πŸ‘‘

  • 0 on success πŸŽ‰ this is the only case where any decrypted or associated data can be used. like, the only one. if you're not seeing a 0, hands off the data, fr fr.
  • -EBADMSG if the message is inauthentic πŸ’€ that's a fake friend, do not trust that message, do not read that message, do not let it into the group chat.
🚨 real talk: anything that isn't 0 means the output is not usable. the whole point of GCM is that the tag check is the gate, and this gate does not accept vibes as authentication.

🧚 SEE ALSO 🧚

Kernel file ./include/crypto/aes-gcm.h, plus her whole friend group:


and that's the page, bestie πŸ’œ this queen lives over in ./include/crypto, she's dated October 2026, and she ships as part of the Kernel API Manual β€” go decrypt something responsibly, mwah πŸŽ€βœ¨

πŸ“¦ where this page comes from