blk_crypto_init_key(9)
π blk_crypto_init_key (kernel API manual, bestie edition) π
Okay so real talk β this one's blk_crypto_init_key from the kernel API manual, and it's literally the glow-up your key needs before blk-crypto will even look at it. Let's get into it β¨
πΈ NAME πΈ
blk_crypto_init_key β prepare a key for use with blk-crypto π
Like, it takes your key and gets it all dressed up and ready for the blk-crypto ball. No cap.
π SYNOPSIS π
int blk_crypto_init_key (struct blk_crypto_key *blk_key , const u8
*key_bytes , size_t key_size , enum blk_crypto_key_type key_type , enum
blk_crypto_mode_num crypto_mode , unsigned int dun_bytes , unsigned int
data_unit_size , int flags );
That's a lot of args, i know π but every single one is doing its job, ok? Let's meet them π
π¦ ARGUMENTS π¦
blk_keyβ pointer to theblk_crypto_keyyou're initializing. This is the main character here, the one getting set up πkey_bytesβ the actual bytes of the key. the raw material, the moment, the stuff πkey_sizeβ size of the key in bytes. yes, in bytes, specifically πkey_typeβ type of the key β either raw or hardware-wrapped. two vibes, you pick π«Άcrypto_modeβ identifier for the encryption algorithm to use. the algorithm's @ basically β¨dun_bytesβ number of bytes that will be used to specify the DUN when this key is used. yes it'sdun_bytesnot "done bytes", i know, i giggled too πdata_unit_sizeβ the data unit size to use for en/decryption. how big each unit is, lowkey important π₯flagsβBLK_CRYPTO_CFG_*flags. the little config sprinkles on top π
β RETURN β
0 on success, -errno on failure. that's it, that's the whole vibe check π
π¨ okay listen bestie, this part matters: the caller is responsible for zeroizing bothblk_keyandkey_byteswhen done with them. like, both of them. zeroize them. don't leave key material just lying around, that's genuinely not the move, fr fr π€
π SEE ALSO π
- Kernel file
./block/blk-crypto.cβ the source, go read it, it's giving lore π blk_crypto_config_supported_natively(9)blk_crypto_start_using_key(9)blk_crypto_evict_key(9)
the whole friend group, honestly π§
That's the whole page, bestie β slay, you now know how to prep a key for blk-crypto πβ¨ This one came out of ./block, dated October 2026, and it's page blk_crypto_init_key(9) of the kernel API manual. mwah, go zeroize your keys ππ¦π
π¦ 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