1KCAPI_CIPHER_ENC_SM4(3) Programming Interface KCAPI_CIPHER_ENC_SM4(3)
2
3
4
6 kcapi_cipher_enc_sm4_cbc - Convenience function for SM4 CBC encryption
7
9 ssize_t kcapi_cipher_enc_sm4_cbc(const uint8_t * key, uint32_t keylen,
10 const uint8_t * in, size_t inlen,
11 const uint8_t * iv, uint8_t * out,
12 size_t outlen);
13
15 key
16 [in] key buffer
17
18 keylen
19 [in] length of key buffer
20
21 in
22 [in] plaintext data buffer
23
24 inlen
25 [in] length of in buffer
26
27 iv
28 [in] IV to be used for cipher operation
29
30 out
31 [out] ciphertext data buffer
32
33 outlen
34 [in] length of out buffer
35
37 The convenience function performs an SM4 CBC encryption operation using
38 the provided key, the given input buffer and the given IV. The output
39 is stored in the out buffer.
40
41 Note, SM4 CBC requires an input data that is a multiple of 16 bytes. If
42 you have data that is not guaranteed to be multiples of 16 bytes,
43 either add zero bytes at the end of the buffer to pad it up to a
44 multiple of 16 bytes. Otherwise, the CTR mode encryption operation may
45 be usable.
46
47 The output buffer must be at least as large as the input buffer.
48
49 The IV must be exactly 16 bytes in size.
50
51 The SM4 key is fixed 16 bytes long.
52
53 return number of bytes generated upon success; a negative errno-style
54 error code if an error occurred
55
57 Stephan Mueller <smueller@chronox.de>
58 Author.
59
61libkcapi Manual 1.4.0 July 2023 KCAPI_CIPHER_ENC_SM4(3)