'\" t .\" Title: kcapi_cipher_enc_sm4_cbc .\" Author: .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: April 2024 .\" Manual: Programming Interface .\" Source: libkcapi Manual 1.4.0 .\" Language: English .\" .TH "KCAPI_CIPHER_ENC_SM4" "3" "April 2024" "libkcapi Manual 1\&.4\&.0" "Programming Interface" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" kcapi_cipher_enc_sm4_cbc \- Convenience function for SM4 CBC encryption .SH "SYNOPSIS" .HP \w'ssize_t\ kcapi_cipher_enc_sm4_cbc('u .BI "ssize_t kcapi_cipher_enc_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" ");" .SH "ARGUMENTS" .PP \fIkey\fR .RS 4 [in] key buffer .RE .PP \fIkeylen\fR .RS 4 [in] length of key buffer .RE .PP \fIin\fR .RS 4 [in] plaintext data buffer .RE .PP \fIinlen\fR .RS 4 [in] length of in buffer .RE .PP \fIiv\fR .RS 4 [in] IV to be used for cipher operation .RE .PP \fIout\fR .RS 4 [out] ciphertext data buffer .RE .PP \fIoutlen\fR .RS 4 [in] length of out buffer .RE .SH "DESCRIPTION" .PP The convenience function performs an SM4 CBC encryption operation using the provided key, the given input buffer and the given IV\&. The output is stored in the out buffer\&. .PP Note, SM4 CBC requires an input data that is a multiple of 16 bytes\&. If you have data that is not guaranteed to be multiples of 16 bytes, either add zero bytes at the end of the buffer to pad it up to a multiple of 16 bytes\&. Otherwise, the CTR mode encryption operation may be usable\&. .PP The output buffer must be at least as large as the input buffer\&. .PP The IV must be exactly 16 bytes in size\&. .PP The SM4 key is fixed 16 bytes long\&. .PP \fIreturn\fR number of bytes generated upon success; a negative errno\-style error code if an error occurred .SH "AUTHOR" .PP \fBStephan Mueller\fR <\&smueller@chronox.de\&> .RS 4 Author. .RE .SH "COPYRIGHT" .br