aes_xts_preparekey(9)
β¨ aes_xts_preparekey β¨ (section 9, from the Kernel API Manual, bestie π )
okay so listen β this is aes_xts_preparekey, and it's literally the glow-up your raw key needs before it can do AES-XTS encryption and decryption. π
πΈ NAME πΈ
aes_xts_preparekey β prepare a key for AES-XTS encryption and decryption. that's it, that's the job, and it ate. π
β¨ SYNOPSIS β¨
int aes_xts_preparekey (struct aes_xts_key *key , const u8 *in_key ,
size_t key_len , int flags );
π¦ ARGUMENTS π¦
keyβ (output) the key structure to initialize. this is your main character struct, the one getting all dressed up. πin_keyβ the raw AES-XTS key. the before picture. πkey_lenβ length of the raw key, in bytes. sizes matter, ikyk. πflagsβ optional flagXTS_FORBID_WEAK_KEYS, which does exactly what it says on the tin: it forbids keys whose two halves are the same. no identical-twin keys on its watch, no cap. π«
π DESCRIPTION π
okay so here's the self-care routine: users should use memzero_explicit to zeroize the key struct at the end of its lifetime. wipe it down, cleanse it, keep it out of memory's camera roll. π§ββοΈ
but β and this is the plot twist β if this function fails, zeroization is unnecessary. nothing to scrub if nothing ever got set up, periodt. π
π CONTEXT π
Any context. any. it's giving low-maintenance icon, fr fr. β¨
π₯ RETURN π₯
0on success. slay, we love a clean win. π-EINVALif the key is rejected, and there are two whole reasons that can happen:- because its length isn't
32,64, or (when FIPS mode isn't enabled)48; or - because its two halves are the same and either
XTS_FORBID_WEAK_KEYSis given or FIPS mode is enabled. π΄
- because its length isn't
ngl, get the length or the halves wrong and it's an instant -EINVAL, no second chances. read the requirements before you slide into the function call. π
π SEE ALSO π
Kernel file ./include/crypto/aes-xts.h, struct aes_xts_key(9), aes_xts_encrypt(9), aes_xts_decrypt(9) β go read the whole friend group, they're all iconic. π«Ά
and that's the page, bestie! π signed off by ./include/crypto, dated October 2026 β mwah, catch you in section 9. π
βπΈ
π¦ 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