KCAPI_CIPHER_DEC_SM4(3)
π NAME π
kcapi_cipher_dec_sm4_cbc β the convenience function that does SM4 CBC decryption for you, no cap, and it's literally called KCAPI_CIPHER_DEC_SM4 in the manual pages bestie β¨
π SYNOPSIS π
ssize_t kcapi_cipher_dec_sm4_cbc(const uint8_t * key, uint32_t keylen,
const uint8_t * in, size_t inlen,
const uint8_t * iv, uint8_t * out,
size_t outlen);
π¦ ARGUMENTS π¦
Okay so here's the whole cast, and every single one of them matters:
keyβ [in] the key buffer, your little secret πkeylenβ [in] how long that key buffer isinβ [in] the ciphertext data buffer (the locked-up version, the mystery)inlenβ [in] how long theinbuffer isivβ [in] the IV that's getting used for this cipher operationoutβ [out] the plaintext data buffer, where the decoded truth lands π«Άoutlenβ [in] how long theoutbuffer is
β¨ DESCRIPTION β¨
So this convenience function performs an SM4 CBC decryption operation using the provided key, the given input buffer, and the given iv. The output gets stored in the out buffer. Iconic behaviour, honestly.
Real talk though, bestie: SM4 CBC requires input data that is a multiple of 16 bytes. If your data is not guaranteed to be a multiple of 16 bytes, either add zero bytes at the end of the buffer to pad it up to a multiple of 16 bytes β or, alternatively, the CTR mode encryption operation may be usable. Just saying, you have options. π
The out buffer must be at least as large as the in buffer. No shrinking, no skimping, the output needs room to breathe.
The iv must be exactly 16 bytes in size. Exactly. Not 15, not 17. Periodt. πΈ
The SM4 key is fixed 16 bytes long. That's the vibe, that's the law.
And the return value: it hands you the number of bytes generated upon success, or a negative errno-style error code if an error occurred. So if it's negative, something went wrong and you should go read the errno, fr fr π
π AUTHOR π
- Stephan Mueller
<smueller@chronox.de>- Author. The main character who wrote all this. Respect. π«Ά
π COPYRIGHT π
This whole thing is the libkcapi Manual, version 1.5.0, dated July 2025 β and that's a wrap, bestie πβ¨ Go forth and decrypt your SM4 CBC data responsibly, and remember: multiple of 16 bytes, IV of 16 bytes, key of 16 bytes. Slay. ππ¦π
π¦ where this page comes from
- fedora 43: libkcapi-devel 1.5.0-6.fc43 Β· BSD-3-Clause OR GPL-2.0-only
- fedora 43: libkcapi-devel 1.5.0-6.fc43 Β· BSD-3-Clause OR GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms