Debian Codegraph @

lib/kcapi.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2015 - 2022, Stephan Mueller <[email protected]>
3 *
4 * License: see COPYING file in root directory
5 *
6 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
7 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
8 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
9 * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
10 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
11 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
12 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
13 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
14 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
15 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
16 * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
17 * DAMAGE.
18 */
19
20 #ifndef KCAPI_H
21 #define KCAPI_Hcxx . . $ `lib/kcapi.h:21:9`!
22
23 #include <stdint.h>
24 #include <sys/uio.h>
25
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30
31 #define DSO_DEPRECATEDcxx . . $ `lib/kcapi.h:31:9`!(x) \
32 __attribute__ ((deprecated ("API deprecated with library version " x)))
33
34 /*
35 * Flags for the encrypt / decrypt operations
36 *
37 * @KCAPI_ACCESS_HEURISTIC Allow the libkcapi heuristic to determine the
38 * optimal kernel access type
39 * @KCAPI_ACCESS_VMSPLICE Require libkcapi to always use the vmsplice zero
40 * copy kernel interface
41 * @KCAPI_ACCESS_SENDMSG Require libkcapi to always use the sendmsg kernel
42 * interface
43 */
44 #define KCAPI_ACCESS_HEURISTICcxx . . $ `lib/kcapi.h:44:9`! 0x0
45 #define KCAPI_ACCESS_VMSPLICEcxx . . $ `lib/kcapi.h:45:9`! 0x1
46 #define KCAPI_ACCESS_SENDMSGcxx . . $ `lib/kcapi.h:46:9`! 0x2
47
48 /*
49 * Flags for initializing a cipher handle
50 *
51 * @KCAPI_INIT_AIO Handle uses AIO kernel interface if available
52 */
53 #define KCAPI_INIT_AIOcxx . . $ `lib/kcapi.h:53:9`! (1<<0)
54
55 /*
56 * Opaque cipher handle
57 */
58 struct kcapi_handlecxx . . $ kcapi_handle#;
59
60 /**
61 * DOC: Symmetric Cipher API
62 *
63 * API function calls used to invoke symmetric ciphers.
64 */
65
66 /**
67 * kcapi_handle_reinit() - re-initialize a new kernel interface
68 *
69 * @newhandle: [out] cipher handle filled during the call
70 * @existing: [in] existing cipher handle from which a new handle shall be
71 * re-initialized
72 * @flags: [in] flags specifying the type of cipher handle
73 *
74 * The kernel crypto API interface operates with two types of file descriptors,
75 * the TFM file descriptor and the OP file descriptor.
76 *
77 * The TFM file descriptor receives the cipher-operation static information:
78 * the key, and the AEAD tag size.
79 *
80 * The OP file descriptor receives the volatile data, such as the plaintext /
81 * ciphertext, the IV, or the AEAD AD size.
82 *
83 * The kernel crypto API AF_ALG interface supports the concept that one TFM
84 * file descriptor can operate with multiple OP file descriptors. The different
85 * OP file descriptors can perform completely separate cipher operations
86 * using the same key which can execute in parallel. The parallel execution
87 * can be performed in the same or different process threads.
88 *
89 * kcapi_handle_reinit() function allows the allocation of a new cipher handle
90 * with a new OP file descriptor but using the same TFM file descriptor. To
91 * obtain a reference to the TFM file descriptor, an @existing cipher handle
92 * is used as source. kcapi_handle_reinit() can be invoked multiple times.
93 * Each resulting cipher handle must be deallocated with kcapi_cipher_destroy().
94 * The deallocation ensures that the TFM resource is only released if the
95 * last handle using this TFM resource is released.
96 *
97 * @return 0 upon success;
98 * -EINVAL - accept syscall failed
99 * -ENOMEM - cipher handle cannot be allocated
100 */
101 int kcapi_handle_reinitcxx . . $ kcapi_handle_reinit(9b16b5b23042e58d).(struct kcapi_handlecxx . . $ kcapi_handle# **newhandle,
102 struct kcapi_handlecxx . . $ kcapi_handle# *existing, uint32_tcxx . . $ uint32_t# flags);
103
104 /**
105 * kcapi_cipher_init() - initialize cipher handle
106 *
107 * @handle: [out] cipher handle filled during the call
108 * @ciphername: [in] kernel crypto API cipher name as specified in
109 * /proc/crypto
110 * @flags: [in] flags specifying the type of cipher handle
111 *
112 * This function provides the initialization of a symmetric cipher handle and
113 * establishes the connection to the kernel.
114 *
115 * On success, a pointer to kcapi_handle object is returned in *handle.
116 * Function kcapi_cipher_destroy() should be called afterwards to free
117 * resources.
118 *
119 * @return 0 upon success;
120 * -ENOENT - algorithm not available;
121 * -EOPNOTSUPP - AF_ALG family not available;
122 * -EINVAL - accept syscall failed
123 * -ENOMEM - cipher handle cannot be allocated
124 */
125 int kcapi_cipher_initcxx . . $ kcapi_cipher_init(b54728dab28c239a).(struct kcapi_handlecxx . . $ kcapi_handle# **handle, const char *ciphername,
126 uint32_tcxx . . $ uint32_t# flags);
127
128 /**
129 * kcapi_cipher_destroy() - close the cipher handle and release resources
130 *
131 * @handle: [in] cipher handle to release
132 */
133 void kcapi_cipher_destroycxx . . $ kcapi_cipher_destroy(aba29416d24fdd59).(struct kcapi_handlecxx . . $ kcapi_handle# *handle);
134
135 /**
136 * kcapi_cipher_setkey() - set the key for the cipher handle
137 *
138 * @handle: [in] cipher handle
139 * @key: [in] key buffer
140 * @keylen: [in] length of key buffer
141 *
142 * With this function, the caller sets the key for subsequent encryption or
143 * decryption operations.
144 *
145 * After the caller provided the key, the caller may securely destroy the key
146 * as it is now maintained by the kernel.
147 *
148 * @return 0 upon success (in case of an akcipher handle, a positive integer
149 * is returned that denominates the maximum output size of the
150 * cryptographic operation -- this value must be used as the size
151 * of the output buffer for one cryptographic operation);
152 * a negative errno-style error code if an error occurred
153 */
154 int kcapi_cipher_setkeycxx . . $ kcapi_cipher_setkey(4d0e261613a805ee).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
155 const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen);
156
157 /**
158 * kcapi_cipher_encrypt() - encrypt data (synchronous one shot)
159 *
160 * @handle: [in] cipher handle
161 * @in: [in] plaintext data buffer
162 * @inlen: [in] length of in buffer
163 * @iv: [in] IV to be used for cipher operation
164 * @out: [out] ciphertext data buffer
165 * @outlen: [in] length of out buffer
166 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
167 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE - use
168 * vmsplice access; KCAPI_ACCESS_SENDMSG - sendmsg access)
169 *
170 * It is perfectly legal to use the same buffer as the plaintext and
171 * ciphertext pointers. That would mean that after the encryption operation,
172 * the plaintext is overwritten with the ciphertext.
173 *
174 * The memory should be aligned at the page boundary using
175 * posix_memalign(sysconf(_SC_PAGESIZE)), If it is not aligned at the page
176 * boundary, the vmsplice call may not send all data to the kernel.
177 *
178 * The IV buffer must be exactly kcapi_cipher_ivsize() bytes in size.
179 *
180 * @return number of bytes encrypted upon success;
181 * a negative errno-style error code if an error occurred
182 */
183 ssize_tcxx . . $ ssize_t# kcapi_cipher_encryptcxx . . $ kcapi_cipher_encrypt(c011db556473c11f).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
184 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
185 const uint8_tcxx . . $ uint8_t# *iv,
186 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen, int access);
187
188 /**
189 * kcapi_cipher_encrypt_aio() - encrypt data (asynchronous one shot)
190 *
191 * @handle: [in] cipher handle
192 * @iniov: [in] head of scatter-gather list array holding the plaintext
193 * @outiov: [out] head of scatter-gather list of the destination buffers filled
194 * with ciphertext
195 * @iovlen: [in] number of scatter-gather list entries
196 * @iv: [in] IV to be used for cipher operation
197 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
198 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE - use
199 * vmsplice access; KCAPI_ACCESS_SENDMSG - sendmsg access)
200 *
201 * The individual scatter-gather list entries are processed with
202 * separate invocations of the the given cipher.
203 *
204 * The memory should be aligned at the page boundary using
205 * posix_memalign(sysconf(_SC_PAGESIZE)), If it is not aligned at the page
206 * boundary, the vmsplice call may not send all data to the kernel.
207 *
208 * The IV buffer must be exactly kcapi_cipher_ivsize() bytes in size.
209 *
210 * @return number of bytes encrypted upon success;
211 * a negative errno-style error code if an error occurred
212 */
213 ssize_tcxx . . $ ssize_t# kcapi_cipher_encrypt_aiocxx . . $ kcapi_cipher_encrypt_aio(642fe7813a90216d).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
214 struct ioveccxx . . $ iovec# *iniov, struct ioveccxx . . $ iovec# *outiov,
215 size_tcxx . . $ size_t# iovlen, const uint8_tcxx . . $ uint8_t# *iv,
216 int access);
217
218 /**
219 * kcapi_cipher_decrypt() - decrypt data (synchronous one shot)
220 *
221 * @handle: [in] cipher handle
222 * @in: [in] ciphertext data buffer
223 * @inlen: [in] length of in buffer
224 * @iv: [in] IV to be used for cipher operation
225 * @out: [out] plaintext data buffer
226 * @outlen: [in] length of out bufferS
227 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
228 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE - use
229 * vmsplice access; KCAPI_ACCESS_SENDMSG - sendmsg access)
230 *
231 * It is perfectly legal to use the same buffer as the plaintext and
232 * ciphertext pointers. That would mean that after the encryption operation,
233 * the ciphertext is overwritten with the plaintext.
234 *
235 * The memory should be aligned at the page boundary using
236 * posix_memalign(sysconf(_SC_PAGESIZE)), If it is not aligned at the page
237 * boundary, the vmsplice call may not send all data to the kernel.
238 *
239 * The IV buffer must be exactly kcapi_cipher_ivsize() bytes in size.
240 *
241 * @return number of bytes decrypted upon success;
242 * a negative errno-style error code if an error occurred
243 */
244 ssize_tcxx . . $ ssize_t# kcapi_cipher_decryptcxx . . $ kcapi_cipher_decrypt(c011db556473c11f).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
245 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
246 const uint8_tcxx . . $ uint8_t# *iv,
247 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen, int access);
248
249 /**
250 * kcapi_cipher_decrypt_aio() - decrypt data (asynchronous one shot)
251 *
252 * @handle: [in] cipher handle
253 * @iniov: [in] head of scatter-gather list array holding the ciphertext
254 * @outiov: [out] head of scatter-gather list with the destination buffers for
255 * the plaintext
256 * @iovlen: [in] number of scatter-gather list entries
257 * @iv: [in] IV to be used for cipher operation
258 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
259 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE - use
260 * vmsplice access; KCAPI_ACCESS_SENDMSG - sendmsg access)
261 *
262 * The individual scatter-gather list entries are processed with
263 * separate invocations of the the given cipher.
264 *
265 * The memory should be aligned at the page boundary using
266 * posix_memalign(sysconf(_SC_PAGESIZE)), If it is not aligned at the page
267 * boundary, the vmsplice call may not send all data to the kernel.
268 *
269 * The IV buffer must be exactly kcapi_cipher_ivsize() bytes in size.
270 *
271 * @return number of bytes decrypted upon success;
272 * a negative errno-style error code if an error occurred
273 */
274 ssize_tcxx . . $ ssize_t# kcapi_cipher_decrypt_aiocxx . . $ kcapi_cipher_decrypt_aio(642fe7813a90216d).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
275 struct ioveccxx . . $ iovec# *iniov, struct ioveccxx . . $ iovec# *outiov,
276 size_tcxx . . $ size_t# iovlen, const uint8_tcxx . . $ uint8_t# *iv,
277 int access);
278
279 /**
280 * kcapi_cipher_stream_init_enc() - start an encryption operation (stream)
281 *
282 * @handle: [in] cipher handle
283 * @iv: [in] IV to be used for cipher operation
284 * @iov: [in] scatter/gather list with data to be encrypted. This is
285 * the pointer to the first iov entry if an array of iov
286 * entries is supplied. See sendmsg(2) for details on how iov is
287 * to be used. This pointer may be NULL if no data to be encrypted
288 * is available at the point of the call.
289 * @iovlen: [in] number of scatter/gather list elements. If iov
290 * is NULL, this value must be zero.
291 *
292 * A stream encryption operation is started with this call. Multiple
293 * successive kcapi_cipher_stream_update() function calls can be invoked to
294 * send more plaintext data to be encrypted. The kernel buffers the input
295 * until kcapi_cipher_stream_op() picks up the encrypted data. Once plaintext
296 * is encrypted during the kcapi_cipher_stream_op() it is removed from the
297 * kernel buffer.
298 *
299 * The function calls of kcapi_cipher_stream_update() and
300 * kcapi_cipher_stream_op() can be mixed, even by multiple threads of an
301 * application.
302 *
303 * The IV buffer must be exactly kcapi_cipher_ivsize() bytes in size.
304 *
305 * @return number of bytes sent to the kernel upon success;
306 * a negative errno-style error code if an error occurred
307 */
308 ssize_tcxx . . $ ssize_t# kcapi_cipher_stream_init_enccxx . . $ kcapi_cipher_stream_init_enc(71df3816f1c2c97b).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
309 const uint8_tcxx . . $ uint8_t# *iv,
310 struct ioveccxx . . $ iovec# *iov, size_tcxx . . $ size_t# iovlen);
311 /**
312 * kcapi_cipher_stream_init_dec() - start a decryption operation (stream)
313 *
314 * @handle: [in] cipher handle
315 * @iv: [in] IV to be used for cipher operation
316 * @iov: [in] scatter/gather list with data to be encrypted. This is
317 * the pointer to the first iov entry if an array of iov
318 * entries is supplied. See sendmsg(2) for details on how iov is
319 * to be used. This pointer may be NULL if no data to be encrypted
320 * is available at the point of the call.
321 * @iovlen: [in] number of scatter/gather list elements. If iov
322 * is NULL, this value must be zero.
323 *
324 * A stream decryption operation is started with this call. Multiple
325 * successive kcapi_cipher_stream_update() function calls can be invoked to
326 * send more ciphertext data to be decrypted. The kernel buffers the input
327 * until kcapi_cipher_stream_op() picks up the decrypted data. Once ciphertext
328 * is decrypted during the kcapi_cipher_stream_op() it is removed from the
329 * kernel buffer.
330 *
331 * The function calls of kcapi_cipher_stream_update() and
332 * kcapi_cipher_stream_op() can be mixed, even by multiple threads of an
333 * application.
334 *
335 * The IV buffer must be exactly kcapi_cipher_ivsize() bytes in size.
336 *
337 * @return number of bytes sent to the kernel upon success;
338 * a negative errno-style error code if an error occurred
339 */
340 ssize_tcxx . . $ ssize_t# kcapi_cipher_stream_init_deccxx . . $ kcapi_cipher_stream_init_dec(71df3816f1c2c97b).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
341 const uint8_tcxx . . $ uint8_t# *iv,
342 struct ioveccxx . . $ iovec# *iov, size_tcxx . . $ size_t# iovlen);
343
344 /**
345 * kcapi_cipher_stream_update() - send more data for processing (stream)
346 *
347 * @handle: [in] cipher handle
348 * @iov: [in] scatter/gather list with data to be processed by the
349 * cipher operation.
350 * @iovlen: [in] number of scatter/gather list elements.
351 *
352 * Using this function call, more plaintext for encryption or ciphertext for
353 * decryption can be submitted to the kernel.
354 *
355 * This function may cause the caller to sleep if the kernel buffer holding
356 * the data is getting full. The process will be woken up once more buffer
357 * space becomes available by calling kcapi_cipher_stream_op().
358 *
359 * Note: with the separate API calls of kcapi_cipher_stream_update() and
360 * kcapi_cipher_stream_op() a multi-threaded application can be implemented
361 * where one thread sends data to be processed and one thread picks up data
362 * processed by the cipher operation.
363 *
364 * IMPORTANT NOTE: The kernel will only process
365 * sysconf(_SC_PAGESIZE) * ALG_MAX_PAGES at one time. If your input data is
366 * larger than this threshold, you MUST segment it into chunks of at most
367 * sysconf(_SC_PAGESIZE) * ALG_MAX_PAGES and invoke the
368 * kcapi_cipher_stream_update() on that segment followed by
369 * kcapi_cipher_stream_op() before the next chunk is processed. If this
370 * rule is not obeyed, the thread invoking kcapi_cipher_stream_update()
371 * will be put to sleep until another thread invokes kcapi_cipher_stream_op().
372 *
373 * WARNING: The memory referenced by @iov is not accessed by the kernel
374 * during this call. The memory is first accessed when kcapi_cipher_stream_op()
375 * is called. Thus, you MUST make sure that the referenced memory is still
376 * present at the time kcapi_cipher_stream_op() is called.
377 *
378 * @return number of bytes sent to the kernel upon success;
379 * a negative errno-style error code if an error occurred
380 */
381 ssize_tcxx . . $ ssize_t# kcapi_cipher_stream_updatecxx . . $ kcapi_cipher_stream_update(8a8f5b62e036cb66).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
382 struct ioveccxx . . $ iovec# *iov, size_tcxx . . $ size_t# iovlen);
383
384 /**
385 * kcapi_cipher_stream_update_last() - send last data for processing (stream)
386 *
387 * @handle: [in] cipher handle
388 * @iov: [in] scatter/gather list with data to be processed by the cipher
389 * operation.
390 * @iovlen: [in] number of scatter/gather list elements.
391 *
392 * Using this function call, more plaintext for encryption or ciphertext for
393 * decryption can be submitted to the kernel.
394 *
395 * This call is identical to the kcapi_cipher_stream_update() call with the
396 * exception that it marks the last data buffer before the cipher operation
397 * is triggered. This is call is important for stream ciphers like CTR or CTS
398 * mode when providing the last block. It is permissible to provide a zero
399 * buffer if all data including the last block is already provided by
400 * kcapi_cipher_stream_update.
401 *
402 * WARNING: If this call is not made for stream ciphers with input data
403 * that is not a multiple of the block size of the block cipher, the kernel
404 * will not return the last block that contains less data than the block
405 * size of the block cipher. For example, sending 257 bytes of data to be
406 * encrypted with ctr(aes), the kernel will return only 256 bytes without
407 * this call.
408 *
409 * @return number of bytes sent to the kernel upon success;
410 * a negative errno-style error code if an error occurred
411 */
412 ssize_tcxx . . $ ssize_t# kcapi_cipher_stream_update_lastcxx . . $ kcapi_cipher_stream_update_last(8a8f5b62e036cb66).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
413 struct ioveccxx . . $ iovec# *iov, size_tcxx . . $ size_t# iovlen);
414
415 /**
416 * kcapi_cipher_stream_op() - obtain processed data (stream)
417 *
418 * @handle: [in] cipher handle
419 * @iov: [out] scatter/gather list pointing to buffers to be filled with
420 * the resulting data from a cipher operation.
421 * @iovlen: [in] number of scatter/gather list elements.
422 *
423 * This call can be called interleaved with kcapi_cipher_stream_update() to
424 * fetch the processed data.
425 *
426 * This function may cause the caller to sleep if the kernel buffer holding
427 * the data is empty. The process will be woken up once more data is sent
428 * by calling kcapi_cipher_stream_update().
429 *
430 * Note, when supplying buffers that are not multiple of block size, the buffers
431 * will only be filled up to the maximum number of full block sizes that fit
432 * into the buffer.
433 *
434 * The kernel supports multithreaded applications where one or more threads
435 * send data via the kcapi_cipher_stream_update() function and another thread
436 * collects the processed data via kcapi_cipher_stream_op. The kernel, however,
437 * will return data via kcapi_cipher_stream_op() as soon as it has some data
438 * available. For example, one thread sends 1000 bytes to be encrypted and
439 * another thread already waits for the ciphertext. The kernel may send only,
440 * say, 500 bytes back to the waiting process during one
441 * kcapi_cipher_stream_op() call. In a subsequent calls to
442 * kcapi_cipher_stream_op() more ciphertext is returned. This implies that when
443 * the receiving thread shall collect all data there is,
444 * kcapi_cipher_stream_op() must be called in a loop until all data is received.
445 *
446 * @return number of bytes obtained from the kernel upon success;
447 * a negative errno-style error code if an error occurred
448 */
449 ssize_tcxx . . $ ssize_t# kcapi_cipher_stream_opcxx . . $ kcapi_cipher_stream_op(8a8f5b62e036cb66).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
450 struct ioveccxx . . $ iovec# *iov, size_tcxx . . $ size_t# iovlen);
451
452 /**
453 * kcapi_cipher_enc_aes_cbc - Convenience function for AES CBC encryption
454 *
455 * @key: [in] key buffer
456 * @keylen: [in] length of key buffer
457 * @in: [in] plaintext data buffer
458 * @inlen: [in] length of in buffer
459 * @iv: [in] IV to be used for cipher operation
460 * @out: [out] ciphertext data buffer
461 * @outlen: [in] length of out buffer
462 *
463 * The convenience function performs an AES CBC encryption operation
464 * using the provided key, the given input buffer and the given IV.
465 * The output is stored in the out buffer.
466 *
467 * Note, AES CBC requires an input data that is a multiple of 16 bytes.
468 * If you have data that is not guaranteed to be multiples of 16 bytes, either
469 * add zero bytes at the end of the buffer to pad it up to a multiple of 16
470 * bytes. Otherwise, the CTR mode encryption operation may be usable.
471 *
472 * The output buffer must be at least as large as the input buffer.
473 *
474 * The IV must be exactly 16 bytes in size.
475 *
476 * The AES type (AES-128, AES-192 or AES-256) is determined by the size
477 * of the given key. If the key is 16 bytes long, AES-128 is used. A 24 byte
478 * key implies AES-192 and a 32 byte key implies AES-256.
479 *
480 * @return number of bytes generated upon success;
481 * a negative errno-style error code if an error occurred
482 */
483 ssize_tcxx . . $ ssize_t# kcapi_cipher_enc_aes_cbccxx . . $ kcapi_cipher_enc_aes_cbc(e75b73ea416312ba).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
484 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
485 const uint8_tcxx . . $ uint8_t# *iv,
486 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
487
488 /**
489 * kcapi_cipher_dec_aes_cbc - Convenience function for AES CBC decryption
490 *
491 * @key: [in] key buffer
492 * @keylen: [in] length of key buffer
493 * @in: [in] ciphertext data buffer
494 * @inlen: [in] length of in buffer
495 * @iv: [in] IV to be used for cipher operation
496 * @out: [out] plaintext data buffer
497 * @outlen: [in] length of out buffer
498 *
499 * The convenience function performs an AES CBC decryption operation
500 * using the provided key, the given input buffer and the given IV.
501 * The output is stored in the out buffer.
502 *
503 * Note, AES CBC requires an input data that is a multiple of 16 bytes.
504 * If you have data that is not guaranteed to be multiples of 16 bytes, either
505 * add zero bytes at the end of the buffer to pad it up to a multiple of 16
506 * bytes. Otherwise, the CTR mode encryption operation may be usable.
507 *
508 * The output buffer must be at least as large as the input buffer.
509 *
510 * The IV must be exactly 16 bytes in size.
511 *
512 * The AES type (AES-128, AES-192 or AES-256) is determined by the size
513 * of the given key. If the key is 16 bytes long, AES-128 is used. A 24 byte
514 * key implies AES-192 and a 32 byte key implies AES-256.
515 *
516 * @return number of bytes generated upon success;
517 * a negative errno-style error code if an error occurred
518 */
519 ssize_tcxx . . $ ssize_t# kcapi_cipher_dec_aes_cbccxx . . $ kcapi_cipher_dec_aes_cbc(e75b73ea416312ba).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
520 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
521 const uint8_tcxx . . $ uint8_t# *iv,
522 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
523
524 /**
525 * kcapi_cipher_enc_aes_ctr - Convenience function for AES CTR encryption
526 *
527 * @key: [in] key buffer
528 * @keylen: [in] length of key buffer
529 * @in: [in] plaintext data buffer
530 * @inlen: [in] length of in buffer
531 * @ctr: [in] start counter value to be used for cipher operation
532 * @out: [out] ciphertext data buffer
533 * @outlen: [in] length of out buffer
534 *
535 * The convenience function performs an AES counter mode encryption operation
536 * using the provided key, the given input buffer and the given IV.
537 * The output is stored in the out buffer.
538 *
539 * The input buffer can be of arbitrary length.
540 *
541 * The output buffer must be at least as large as the input buffer.
542 *
543 * The start counter can contain all zeros (not a NULL buffer!) and must be
544 * exactly 16 bytes in size.
545 *
546 * The AES type (AES-128, AES-192 or AES-256) is determined by the size
547 * of the given key. If the key is 16 bytes long, AES-128 is used. A 24 byte
548 * key implies AES-192 and a 32 byte key implies AES-256.
549 *
550 * @return number of bytes generated upon success;
551 * a negative errno-style error code if an error occurred
552 */
553 ssize_tcxx . . $ ssize_t# kcapi_cipher_enc_aes_ctrcxx . . $ kcapi_cipher_enc_aes_ctr(e75b73ea416312ba).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
554 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
555 const uint8_tcxx . . $ uint8_t# *ctr,
556 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
557
558 /**
559 * kcapi_cipher_dec_aes_ctr - Convenience function for AES CTR decryption
560 *
561 * @key: [in] key buffer
562 * @keylen: [in] length of key buffer
563 * @in: [in] ciphertext data buffer
564 * @inlen: [in] length of in buffer
565 * @ctr: [in] start counter value to be used for cipher operation
566 * @out: [out] plaintext data buffer
567 * @outlen: [in] length of out buffer
568 *
569 * The convenience function performs an AES counter mode encryption operation
570 * using the provided key, the given input buffer and the given IV.
571 * The output is stored in the out buffer.
572 *
573 * The input buffer can be of arbitrary length.
574 *
575 * The output buffer must be at least as large as the input buffer.
576 *
577 * The start counter can contain all zeros (not a NULL buffer!) and must be
578 * exactly 16 bytes in size.
579 *
580 * The AES type (AES-128, AES-192 or AES-256) is determined by the size
581 * of the given key. If the key is 16 bytes long, AES-128 is used. A 24 byte
582 * key implies AES-192 and a 32 byte key implies AES-256.
583 *
584 * @return number of bytes generated upon success;
585 * a negative errno-style error code if an error occurred
586 */
587 ssize_tcxx . . $ ssize_t# kcapi_cipher_dec_aes_ctrcxx . . $ kcapi_cipher_dec_aes_ctr(e75b73ea416312ba).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
588 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
589 const uint8_tcxx . . $ uint8_t# *ctr,
590 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
591
592 /**
593 * kcapi_cipher_enc_sm4_cbc - Convenience function for SM4 CBC encryption
594 *
595 * @key: [in] key buffer
596 * @keylen: [in] length of key buffer
597 * @in: [in] plaintext data buffer
598 * @inlen: [in] length of in buffer
599 * @iv: [in] IV to be used for cipher operation
600 * @out: [out] ciphertext data buffer
601 * @outlen: [in] length of out buffer
602 *
603 * The convenience function performs an SM4 CBC encryption operation
604 * using the provided key, the given input buffer and the given IV.
605 * The output is stored in the out buffer.
606 *
607 * Note, SM4 CBC requires an input data that is a multiple of 16 bytes.
608 * If you have data that is not guaranteed to be multiples of 16 bytes, either
609 * add zero bytes at the end of the buffer to pad it up to a multiple of 16
610 * bytes. Otherwise, the CTR mode encryption operation may be usable.
611 *
612 * The output buffer must be at least as large as the input buffer.
613 *
614 * The IV must be exactly 16 bytes in size.
615 *
616 * The SM4 key is fixed 16 bytes long.
617 *
618 * @return number of bytes generated upon success;
619 * a negative errno-style error code if an error occurred
620 */
621 ssize_tcxx . . $ ssize_t# kcapi_cipher_enc_sm4_cbccxx . . $ kcapi_cipher_enc_sm4_cbc(e75b73ea416312ba).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
622 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
623 const uint8_tcxx . . $ uint8_t# *iv,
624 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
625
626 /**
627 * kcapi_cipher_dec_sm4_cbc - Convenience function for SM4 CBC decryption
628 *
629 * @key: [in] key buffer
630 * @keylen: [in] length of key buffer
631 * @in: [in] ciphertext data buffer
632 * @inlen: [in] length of in buffer
633 * @iv: [in] IV to be used for cipher operation
634 * @out: [out] plaintext data buffer
635 * @outlen: [in] length of out buffer
636 *
637 * The convenience function performs an SM4 CBC decryption operation
638 * using the provided key, the given input buffer and the given IV.
639 * The output is stored in the out buffer.
640 *
641 * Note, SM4 CBC requires an input data that is a multiple of 16 bytes.
642 * If you have data that is not guaranteed to be multiples of 16 bytes, either
643 * add zero bytes at the end of the buffer to pad it up to a multiple of 16
644 * bytes. Otherwise, the CTR mode encryption operation may be usable.
645 *
646 * The output buffer must be at least as large as the input buffer.
647 *
648 * The IV must be exactly 16 bytes in size.
649 *
650 * The SM4 key is fixed 16 bytes long.
651 *
652 * @return number of bytes generated upon success;
653 * a negative errno-style error code if an error occurred
654 */
655 ssize_tcxx . . $ ssize_t# kcapi_cipher_dec_sm4_cbccxx . . $ kcapi_cipher_dec_sm4_cbc(e75b73ea416312ba).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
656 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
657 const uint8_tcxx . . $ uint8_t# *iv,
658 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
659
660 /**
661 * kcapi_cipher_enc_sm4_ctr - Convenience function for SM4 CTR encryption
662 *
663 * @key: [in] key buffer
664 * @keylen: [in] length of key buffer
665 * @in: [in] plaintext data buffer
666 * @inlen: [in] length of in buffer
667 * @ctr: [in] start counter value to be used for cipher operation
668 * @out: [out] ciphertext data buffer
669 * @outlen: [in] length of out buffer
670 *
671 * The convenience function performs an SM4 counter mode encryption operation
672 * using the provided key, the given input buffer and the given IV.
673 * The output is stored in the out buffer.
674 *
675 * The input buffer can be of arbitrary length.
676 *
677 * The output buffer must be at least as large as the input buffer.
678 *
679 * The start counter can contain all zeros (not a NULL buffer!) and must be
680 * exactly 16 bytes in size.
681 *
682 * The SM4 key is fixed 16 bytes long.
683 *
684 * @return number of bytes generated upon success;
685 * a negative errno-style error code if an error occurred
686 */
687 ssize_tcxx . . $ ssize_t# kcapi_cipher_enc_sm4_ctrcxx . . $ kcapi_cipher_enc_sm4_ctr(e75b73ea416312ba).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
688 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
689 const uint8_tcxx . . $ uint8_t# *ctr,
690 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
691
692 /**
693 * kcapi_cipher_dec_sm4_ctr - Convenience function for SM4 CTR decryption
694 *
695 * @key: [in] key buffer
696 * @keylen: [in] length of key buffer
697 * @in: [in] ciphertext data buffer
698 * @inlen: [in] length of in buffer
699 * @ctr: [in] start counter value to be used for cipher operation
700 * @out: [out] plaintext data buffer
701 * @outlen: [in] length of out buffer
702 *
703 * The convenience function performs an SM4 counter mode encryption operation
704 * using the provided key, the given input buffer and the given IV.
705 * The output is stored in the out buffer.
706 *
707 * The input buffer can be of arbitrary length.
708 *
709 * The output buffer must be at least as large as the input buffer.
710 *
711 * The start counter can contain all zeros (not a NULL buffer!) and must be
712 * exactly 16 bytes in size.
713 *
714 * The SM4 key is fixed 16 bytes long.
715 *
716 * @return number of bytes generated upon success;
717 * a negative errno-style error code if an error occurred
718 */
719 ssize_tcxx . . $ ssize_t# kcapi_cipher_dec_sm4_ctrcxx . . $ kcapi_cipher_dec_sm4_ctr(e75b73ea416312ba).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
720 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
721 const uint8_tcxx . . $ uint8_t# *ctr,
722 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
723
724 /**
725 * kcapi_cipher_ivsize() - return size of IV required for cipher
726 *
727 * @handle: [in] cipher handle
728 *
729 * @return > 0 specifying the IV size;
730 * 0 on error
731 */
732 uint32_tcxx . . $ uint32_t# kcapi_cipher_ivsizecxx . . $ kcapi_cipher_ivsize(994c7fcc3809be77).(struct kcapi_handlecxx . . $ kcapi_handle# *handle);
733
734 /**
735 * kcapi_cipher_blocksize() - return size of one block of the cipher
736 *
737 * @handle: [in] cipher handle
738 *
739 * @return > 0 specifying the block size;
740 * 0 on error
741 */
742 uint32_tcxx . . $ uint32_t# kcapi_cipher_blocksizecxx . . $ kcapi_cipher_blocksize(994c7fcc3809be77).(struct kcapi_handlecxx . . $ kcapi_handle# *handle);
743
744
745 /**
746 * DOC: AEAD Cipher API
747 *
748 * The following API calls allow using the Authenticated Encryption with
749 * Associated Data.
750 */
751
752 /**
753 * kcapi_aead_init() - initialization of cipher handle
754 *
755 * @handle: [out] cipher handle filled during the call
756 * @ciphername: [in] kernel crypto API cipher name as specified in
757 * /proc/crypto
758 * @flags: [in] flags specifying the type of cipher handle
759 *
760 * This function initializes an AEAD cipher handle and establishes the
761 * connection to the kernel.
762 *
763 * On success, a pointer to kcapi_handle object is returned in *handle.
764 * Function kcapi_aead_destroy should be called afterwards to free resources.
765 *
766 * @return 0 upon success;
767 * -ENOENT - algorithm not available;
768 * -EOPNOTSUPP - AF_ALG family not available;
769 * -EINVAL - accept syscall failed
770 * -ENOMEM - cipher handle cannot be allocated
771 */
772 int kcapi_aead_initcxx . . $ kcapi_aead_init(b54728dab28c239a).(struct kcapi_handlecxx . . $ kcapi_handle# **handle, const char *ciphername,
773 uint32_tcxx . . $ uint32_t# flags);
774
775 /**
776 * kcapi_aead_destroy() - close the AEAD handle and release resources
777 *
778 * @handle: [in] cipher handle to release
779 */
780 void kcapi_aead_destroycxx . . $ kcapi_aead_destroy(aba29416d24fdd59).(struct kcapi_handlecxx . . $ kcapi_handle# *handle);
781
782 /**
783 * kcapi_aead_setkey() - set the key for the AEAD handle
784 *
785 * @handle: [in] cipher handle
786 * @key: [in] key buffer
787 * @keylen: [in] length of key buffer
788 *
789 * With this function, the caller sets the key for subsequent encryption or
790 * decryption operations.
791 *
792 * After the caller provided the key, the caller may securely destroy the key
793 * as it is now maintained by the kernel.
794 *
795 * @return 0 upon success;
796 * a negative errno-style error code if an error occurred
797 */
798 int kcapi_aead_setkeycxx . . $ kcapi_aead_setkey(4d0e261613a805ee).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
799 const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen);
800
801 /**
802 * kcapi_aead_settaglen() - set authentication tag size
803 *
804 * @handle: [in] cipher handle
805 * @taglen: [in] length of authentication tag
806 *
807 * Set the authentication tag size needed for encryption operation. The tag is
808 * created during encryption operation with the size provided with this call.
809 *
810 * @return 0 upon success;
811 * a negative errno-style error code if an error occurred
812 */
813 int kcapi_aead_settaglencxx . . $ kcapi_aead_settaglen(8327ae3352751b56).(struct kcapi_handlecxx . . $ kcapi_handle# *handle, uint32_tcxx . . $ uint32_t# taglen);
814
815 /**
816 * kcapi_aead_setassoclen() - set authentication data size
817 *
818 * @handle: [in] cipher handle
819 * @assoclen: [in] length of associated data length
820 *
821 * The associated data is retained in the cipher handle. During initialization
822 * of a cipher handle, it is sent to the kernel. The kernel cipher
823 * implementations may verify the appropriateness of the authentication
824 * data size and may return an error during initialization if the
825 * authentication size is not considered appropriate.
826 */
827 void kcapi_aead_setassoclencxx . . $ kcapi_aead_setassoclen(9c54bafaae9b2e82).(struct kcapi_handlecxx . . $ kcapi_handle# *handle, size_tcxx . . $ size_t# assoclen);
828
829 /**
830 * kcapi_aead_encrypt() - synchronously encrypt AEAD data (one shot)
831 *
832 * @handle: [in] cipher handle
833 * @in: [in] plaintext data buffer
834 * @inlen: [in] length of plaintext buffer
835 * @iv: [in] IV to be used for cipher operation
836 * @out: [out] data buffer holding cipher text and authentication tag
837 * @outlen: [in] length of out buffer
838 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
839 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE - use
840 * vmsplice access; KCAPI_ACCESS_SENDMSG - sendmsg access)
841 *
842 * The AEAD cipher operation requires the furnishing of the associated
843 * authentication data. In case such data is not required, it can be set to
844 * NULL and length value must be set to zero.
845 *
846 * It is perfectly legal to use the same buffer as the plaintext and
847 * ciphertext pointers. That would mean that after the encryption operation,
848 * the plaintext is overwritten with the ciphertext.
849 *
850 * The memory should be aligned at the page boundary using
851 * posix_memalign(sysconf(_SC_PAGESIZE)), If it is not aligned at the page
852 * boundary, the vmsplice call may not send all data to the kernel.
853 *
854 * The IV buffer must be exactly kcapi_cipher_ivsize() bytes in size.
855 *
856 * After invoking this function the caller should use
857 * kcapi_aead_getdata_output() to obtain the resulting ciphertext and
858 * authentication tag references.
859 *
860 * IMPORTANT NOTE: The kernel will only process
861 * sysconf(_SC_PAGESIZE) * ALG_MAX_PAGES at one time. Longer input data cannot
862 * be handled by the kernel.
863 *
864 * @return number of bytes encrypted upon success;
865 * a negative errno-style error code if an error occurred
866 */
867 ssize_tcxx . . $ ssize_t# kcapi_aead_encryptcxx . . $ kcapi_aead_encrypt(c011db556473c11f).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
868 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
869 const uint8_tcxx . . $ uint8_t# *iv,
870 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen,
871 int access);
872
873 /**
874 * kcapi_aead_encrypt_aio() - asynchronously encrypt AEAD data (one shot)
875 *
876 * @handle: [in] cipher handle
877 * @iniov: [in] array of scatter-gather list with input buffers
878 * @outiov: [out] array of scatter-gather list with output buffers
879 * @iovlen: [in] number of IOVECs in array
880 * @iv: [in] IV to be used for cipher operation
881 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
882 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE - use
883 * vmsplice access; KCAPI_ACCESS_SENDMSG - sendmsg access)
884 *
885 * The AEAD cipher operation requires the furnishing of the associated
886 * authentication data. In case such data is not required, it can be set to
887 * NULL and length value must be set to zero.
888 *
889 * Each IOVEC is processed with its individual AEAD cipher operation. The
890 * memory holding the input data will receive the processed data.
891 *
892 * The memory should be aligned at the page boundary using
893 * posix_memalign(sysconf(_SC_PAGESIZE)), If it is not aligned at the page
894 * boundary, the vmsplice call may not send all data to the kernel.
895 *
896 * The IV buffer must be exactly kcapi_cipher_ivsize() bytes in size.
897 *
898 * After invoking this function the caller should use
899 * kcapi_aead_getdata_output() to obtain the resulting ciphertext and
900 * authentication tag references.
901 *
902 * IMPORTANT NOTE: The kernel will only process
903 * sysconf(_SC_PAGESIZE) * ALG_MAX_PAGES at one time. Longer input data cannot
904 * be handled by the kernel.
905 *
906 * @return number of bytes encrypted upon success;
907 * a negative errno-style error code if an error occurred
908 */
909 ssize_tcxx . . $ ssize_t# kcapi_aead_encrypt_aiocxx . . $ kcapi_aead_encrypt_aio(642fe7813a90216d).(struct kcapi_handlecxx . . $ kcapi_handle# *handle, struct ioveccxx . . $ iovec# *iniov,
910 struct ioveccxx . . $ iovec# *outiov, size_tcxx . . $ size_t# iovlen,
911 const uint8_tcxx . . $ uint8_t# *iv, int access);
912
913 /**
914 * kcapi_aead_getdata_input() - get the pointers into input buffer
915 *
916 * @handle: [in] cipher handle
917 * @encdata: [in] data buffer returned by the encryption operation
918 * @encdatalen: [in] size of the encryption data buffer
919 * @enc: [in] does output buffer hold encryption or decryption result?
920 * @aad: [out] AD buffer pointer; when set to NULL, no data pointer is
921 * returned
922 * @aadlen: [out] length of AD; when aad was set to NULL, no information is
923 * returned
924 * @data: [out] pointer to output buffer from AEAD encryption operation
925 * when set to NULL, no data pointer is returned
926 * @datalen: [out] length of data buffer; when data was set to NULL, no
927 * information is returned
928 * @tag: [out] tag buffer pointer; when set to NULL, no data pointer is
929 * returned
930 * @taglen: [out] length of tag; when tag was set to NULL, no information
931 * is returned
932 *
933 * This function is a service function to the consumer to locate the right
934 * ciphertext buffer offset holding the authentication tag. In addition, it
935 * provides the consumer with the length of the tag and the length of the
936 * ciphertext.
937 */
938 void kcapi_aead_getdata_inputcxx . . $ kcapi_aead_getdata_input(a7c1d69e2d55782f).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
939 uint8_tcxx . . $ uint8_t# *encdata, size_tcxx . . $ size_t# encdatalen, int enc,
940 uint8_tcxx . . $ uint8_t# **aad, size_tcxx . . $ size_t# *aadlen,
941 uint8_tcxx . . $ uint8_t# **data, size_tcxx . . $ size_t# *datalen,
942 uint8_tcxx . . $ uint8_t# **tag, size_tcxx . . $ size_t# *taglen);
943
944 /**
945 * kcapi_aead_getdata_output() - get the pointers into output buffer
946 *
947 * @handle: [in] cipher handle
948 * @encdata: [in] data buffer returned by the encryption operation
949 * @encdatalen: [in] size of the encryption data buffer
950 * @enc: [in] does output buffer hold encryption or decryption result?
951 * @aad: [out] AD buffer pointer; when set to NULL, no data pointer is
952 * returned; returned pointer may also be NULL
953 * @aadlen: [out] length of AD; when aad was set to NULL, no information is
954 * returned
955 * @data: [out] pointer to output buffer from AEAD encryption operation
956 * when set to NULL, no data pointer is returned
957 * @datalen: [out] length of data buffer; when data was set to NULL, no
958 * information is returned
959 * @tag: [out] tag buffer pointer; when set to NULL, no data pointer is
960 * returned; returned pointer may also be NULL
961 * @taglen: [out] length of tag; when tag was set to NULL, no information
962 * is returned
963 *
964 * This function is a service function to the consumer to locate the right
965 * ciphertext buffer offset holding the authentication tag. In addition, it
966 * provides the consumer with the length of the tag and the length of the
967 * ciphertext.
968 */
969 void kcapi_aead_getdata_outputcxx . . $ kcapi_aead_getdata_output(a7c1d69e2d55782f).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
970 uint8_tcxx . . $ uint8_t# *encdata, size_tcxx . . $ size_t# encdatalen, int enc,
971 uint8_tcxx . . $ uint8_t# **aad, size_tcxx . . $ size_t# *aadlen,
972 uint8_tcxx . . $ uint8_t# **data, size_tcxx . . $ size_t# *datalen,
973 uint8_tcxx . . $ uint8_t# **tag, size_tcxx . . $ size_t# *taglen);
974
975 /**
976 * kcapi_aead_decrypt() - synchronously decrypt AEAD data (one shot)
977 *
978 * @handle: [in] cipher handle
979 * @in: [in] ciphertext data buffer
980 * @inlen: [in] length of in buffer
981 * @iv: [in] IV to be used for cipher operation
982 * @out: [out] plaintext data buffer
983 * @outlen: [in] length of out buffer
984 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
985 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE
986 * use vmsplice access; KCAPI_ACCESS_SENDMSG sendmsg access)
987 *
988 * The AEAD cipher operation requires the furnishing of the associated
989 * authentication data. In case such data is not required, it can be set to
990 * NULL and length value must be set to zero.
991 *
992 * It is perfectly legal to use the same buffer as the plaintext and
993 * ciphertext pointers. That would mean that after the encryption operation,
994 * the ciphertext is overwritten with the plaintext.
995 *
996 * The memory should be aligned at the page boundary using
997 * posix_memalign(sysconf(_SC_PAGESIZE)), If it is not aligned at the page
998 * boundary, the vmsplice call may not send all data to the kernel.
999 *
1000 * The IV buffer must be exactly kcapi_cipher_ivsize() bytes in size.
1001 *
1002 * To catch authentication errors (i.e. integrity violations) during
1003 * the decryption operation, the return value of this call should be
1004 * checked. If this function returns -EBADMSG, an authentication error
1005 * was detected.
1006 *
1007 * IMPORTANT NOTE: The kernel will only process
1008 * sysconf(_SC_PAGESIZE) * ALG_MAX_PAGES at one time. Longer input data cannot
1009 * be handled by the kernel.
1010 *
1011 * @return number of bytes decrypted upon success;
1012 * a negative errno-style error code if an error occurred
1013 */
1014 ssize_tcxx . . $ ssize_t# kcapi_aead_decryptcxx . . $ kcapi_aead_decrypt(c011db556473c11f).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
1015 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
1016 const uint8_tcxx . . $ uint8_t# *iv,
1017 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen, int access);
1018
1019 /**
1020 * kcapi_aead_decrypt_aio() - asynchronously decrypt AEAD data (one shot)
1021 *
1022 * @handle: [in] cipher handle
1023 * @iniov: [in] array of scatter-gather list with input buffers
1024 * @outiov: [out] array of scatter-gather list with output buffers
1025 * @iovlen: [in] number of IOVECs in array
1026 * @iv: [in] IV to be used for cipher operation
1027 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
1028 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE - use
1029 * vmsplice access; KCAPI_ACCESS_SENDMSG - sendmsg access)
1030 *
1031 * The AEAD cipher operation requires the furnishing of the associated
1032 * authentication data. In case such data is not required, it can be set to
1033 * NULL and length value must be set to zero.
1034 *
1035 * Each IOVEC is processed with its individual AEAD cipher operation. The
1036 * memory holding the input data will receive the processed data.
1037 *
1038 * The memory should be aligned at the page boundary using
1039 * posix_memalign(sysconf(_SC_PAGESIZE)), If it is not aligned at the page
1040 * boundary, the vmsplice call may not send all data to the kernel.
1041 *
1042 * The IV buffer must be exactly kcapi_cipher_ivsize() bytes in size.
1043 *
1044 * To catch authentication errors (i.e. integrity violations) during
1045 * the decryption operation, the return value of this call should be
1046 * checked. If this function returns -EBADMSG, an authentication error
1047 * was detected.
1048 *
1049 * IMPORTANT NOTE: The kernel will only process
1050 * sysconf(_SC_PAGESIZE) * ALG_MAX_PAGES at one time. Longer input data cannot
1051 * be handled by the kernel.
1052 *
1053 * @return number of bytes encrypted upon success;
1054 * a negative errno-style error code if an error occurred
1055 */
1056 ssize_tcxx . . $ ssize_t# kcapi_aead_decrypt_aiocxx . . $ kcapi_aead_decrypt_aio(642fe7813a90216d).(struct kcapi_handlecxx . . $ kcapi_handle# *handle, struct ioveccxx . . $ iovec# *iniov,
1057 struct ioveccxx . . $ iovec# *outiov, size_tcxx . . $ size_t# iovlen,
1058 const uint8_tcxx . . $ uint8_t# *iv, int access);
1059
1060 /**
1061 * kcapi_aead_stream_init_enc() - start an encryption operation (stream)
1062 *
1063 * @handle: [in] cipher handle
1064 * @iv: [in] IV to be used for cipher operation
1065 * @iov: [in] scatter/gather list with data to be encrypted. This is the
1066 * pointer to
1067 * the first iov entry if an array of iov entries is supplied. See
1068 * sendmsg(2) for details on how iov is to be used. This pointer may be
1069 * NULL if no data to be encrypted is available at the point of the call.
1070 * @iovlen: [in] number of scatter/gather list elements. If iov is NULL,
1071 * this value must be zero.
1072 *
1073 * A stream encryption operation is started with this call. Multiple
1074 * successive kcapi_aead_stream_update() function calls can be invoked to
1075 * send more plaintext data to be encrypted. The kernel buffers the input
1076 * until kcapi_aead_stream_op() picks up the encrypted data. Once plaintext
1077 * is encrypted during the kcapi_aead_stream_op() it is removed from the
1078 * kernel buffer.
1079 *
1080 * Note, unlike the corresponding symmetric cipher API, the function calls of
1081 * kcapi_aead_stream_update() and kcapi_aead_stream_op() cannot be mixed! This
1082 * due to the nature of AEAD where the cipher operation ensures the integrity
1083 * of the entire data (decryption) or calculates a message digest over the
1084 * entire data (encryption).
1085 *
1086 * When using the stream API, the caller must ensure that data is sent
1087 * in the correct order (regardless whether data is sent in multiple chunks
1088 * using kcapi_aead_stream_init_enc() or kcapi_cipher_stream_update()): (i)
1089 * the complete associated data must be provided, followed by (ii) the
1090 * plaintext.
1091 *
1092 * The IV buffer must be exactly kcapi_cipher_ivsize() bytes in size.
1093 *
1094 * @return number of bytes sent to the kernel upon success;
1095 * a negative errno-style error code if an error occurred
1096 */
1097 ssize_tcxx . . $ ssize_t# kcapi_aead_stream_init_enccxx . . $ kcapi_aead_stream_init_enc(71df3816f1c2c97b).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
1098 const uint8_tcxx . . $ uint8_t# *iv,
1099 struct ioveccxx . . $ iovec# *iov, size_tcxx . . $ size_t# iovlen);
1100
1101 /**
1102 * kcapi_aead_stream_init_dec() - start a decryption operation (stream)
1103 *
1104 * @handle: [in] cipher handle
1105 * @iv: [in] IV to be used for cipher operation
1106 * @iov: [in] scatter/gather list with data to be encrypted. This is the
1107 * pointer to the first iov entry if an array of iov entries is supplied.
1108 * See sendmsg(2) for details on how iov is to be used. This pointer may be
1109 * NULL if no data to be encrypted is available at the point of the call.
1110 * @iovlen: [in] number of scatter/gather list elements. If iov is NULL,
1111 * this value must be zero.
1112 *
1113 * A stream decryption operation is started with this call. Multiple
1114 * successive kcapi_aead_stream_update() function calls can be invoked to
1115 * send more ciphertext data to be encrypted. The kernel buffers the input
1116 * until kcapi_aead_stream_op() picks up the decrypted data. Once ciphertext
1117 * is decrypted during the kcapi_aead_stream_op() it is removed from the
1118 * kernel buffer.
1119 *
1120 * Note, unlike the corresponding symmetric cipher API, the function calls of
1121 * kcapi_aead_stream_update() and kcapi_aead_stream_op() cannot be mixed! This
1122 * due to the nature of AEAD where the cipher operation ensures the integrity
1123 * of the entire data (decryption) or calculates a message digest over the
1124 * entire data (encryption).
1125 *
1126 * When using the stream API, the caller must ensure that data is sent
1127 * in the correct order (regardless whether data is sent in multiple chunks
1128 * using kcapi_aead_stream_init_enc() or kcapi_cipher_stream_update()): (i)
1129 * the complete associated data must be provided, followed by (ii) the
1130 * plaintext. For decryption, also (iii) the tag value must be sent.
1131 *
1132 * The IV buffer must be exactly kcapi_cipher_ivsize() bytes in size.
1133 *
1134 * @return number of bytes sent to the kernel upon success;
1135 * a negative errno-style error code if an error occurred
1136 */
1137 ssize_tcxx . . $ ssize_t# kcapi_aead_stream_init_deccxx . . $ kcapi_aead_stream_init_dec(71df3816f1c2c97b).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
1138 const uint8_tcxx . . $ uint8_t# *iv,
1139 struct ioveccxx . . $ iovec# *iov, size_tcxx . . $ size_t# iovlen);
1140
1141 /**
1142 * kcapi_aead_stream_update() - send more data for processing (stream)
1143 *
1144 * @handle: [in] cipher handle
1145 * @iov: [in] scatter/gather list with data to be processed by the cipher
1146 * operation.
1147 * @iovlen: [in] number of scatter/gather list elements.
1148 *
1149 * Using this function call, more plaintext for encryption or ciphertext for
1150 * decryption can be submitted to the kernel.
1151 *
1152 * Note, see the order of input data as outlined in
1153 * kcapi_aead_stream_init_dec().
1154 *
1155 * This function may cause the caller to sleep if the kernel buffer holding
1156 * the data is getting full. The process will be woken up once more buffer
1157 * space becomes available by calling kcapi_aead_stream_op().
1158 *
1159 * Note: The last block of input data MUST be provided with
1160 * kcapi_aead_stream_update_last() as the kernel must be informed about the
1161 * completion of the input data.
1162 *
1163 * With the separate API calls of kcapi_aead_stream_update() and
1164 * kcapi_aead_stream_op() a multi-threaded application can be implemented
1165 * where one thread sends data to be processed and one thread picks up data
1166 * processed by the cipher operation.
1167 *
1168 * WARNING: The memory referenced by @iov is not accessed by the kernel
1169 * during this call. The memory is first accessed when kcapi_cipher_stream_op()
1170 * is called. Thus, you MUST make sure that the referenced memory is still
1171 * present at the time kcapi_cipher_stream_op() is called.
1172 *
1173 * @return number of bytes sent to the kernel upon success;
1174 * a negative errno-style error code if an error occurred
1175 */
1176 ssize_tcxx . . $ ssize_t# kcapi_aead_stream_updatecxx . . $ kcapi_aead_stream_update(8a8f5b62e036cb66).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
1177 struct ioveccxx . . $ iovec# *iov, size_tcxx . . $ size_t# iovlen);
1178
1179 /**
1180 * kcapi_aead_stream_update_last() - send last data for processing (stream)
1181 *
1182 * @handle: [in] cipher handle
1183 * @iov: [in] scatter/gather list with data to be processed by the cipher
1184 * operation.
1185 * @iovlen: [in] number of scatter/gather list elements.
1186 *
1187 * Using this function call, more plaintext for encryption or ciphertext for
1188 * decryption can be submitted to the kernel.
1189 *
1190 * This call is identical to the kcapi_aead_stream_update() call with the
1191 * exception that it marks the last data buffer before the cipher operation
1192 * is triggered. Typically, the tag value is provided with this call.
1193 *
1194 * WARNING: The memory referenced by @iov is not accessed by the kernel
1195 * during this call. The memory is first accessed when kcapi_cipher_stream_op()
1196 * is called. Thus, you MUST make sure that the referenced memory is still
1197 * present at the time kcapi_cipher_stream_op() is called.
1198 *
1199 * @return number of bytes sent to the kernel upon success;
1200 * a negative errno-style error code if an error occurred
1201 */
1202 ssize_tcxx . . $ ssize_t# kcapi_aead_stream_update_lastcxx . . $ kcapi_aead_stream_update_last(8a8f5b62e036cb66).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
1203 struct ioveccxx . . $ iovec# *iov, size_tcxx . . $ size_t# iovlen);
1204
1205 /**
1206 * kcapi_aead_stream_op() - obtain processed data (stream)
1207 *
1208 * @handle: [in] cipher handle
1209 * @iov: [out] scatter/gather list pointing to buffers to be filled with
1210 * the resulting data from a cipher operation.
1211 * @iovlen: [in] number of outiov scatter/gather list elements.
1212 *
1213 * This function may cause the caller to sleep if the kernel buffer holding
1214 * the data is empty. The process will be woken up once more data is sent
1215 * by calling kcapi_cipher_stream_update().
1216 *
1217 * Note, when supplying buffers that are not multiple of block size, the buffers
1218 * will only be filled up to the maximum number of full block sizes that fit
1219 * into the buffer.
1220 *
1221 * @return number of bytes obtained from the kernel upon success;
1222 * a negative errno-style error code if an error occurred
1223 */
1224 ssize_tcxx . . $ ssize_t# kcapi_aead_stream_opcxx . . $ kcapi_aead_stream_op(8a8f5b62e036cb66).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
1225 struct ioveccxx . . $ iovec# *iov, size_tcxx . . $ size_t# iovlen);
1226
1227 /**
1228 * kcapi_aead_ivsize() - return size of IV required for cipher
1229 *
1230 * @handle: [in] cipher handle
1231 *
1232 * @return > 0 specifying the IV size;
1233 * 0 on error
1234 */
1235 uint32_tcxx . . $ uint32_t# kcapi_aead_ivsizecxx . . $ kcapi_aead_ivsize(994c7fcc3809be77).(struct kcapi_handlecxx . . $ kcapi_handle# *handle);
1236
1237 /**
1238 * kcapi_aead_blocksize() - return size of one block of the cipher
1239 *
1240 * @handle: [in] cipher handle
1241 *
1242 * @return > 0 specifying the block size;
1243 * 0 on error
1244 */
1245 uint32_tcxx . . $ uint32_t# kcapi_aead_blocksizecxx . . $ kcapi_aead_blocksize(994c7fcc3809be77).(struct kcapi_handlecxx . . $ kcapi_handle# *handle);
1246
1247 /**
1248 * kcapi_aead_authsize() - return the maximum size of the tag
1249 *
1250 * @handle: [in] cipher handle
1251 *
1252 * The returned maximum is the largest size of the authenticaation tag that can
1253 * be produced by the AEAD cipher. Smaller tag sizes may be chosen depending on
1254 * the AEAD cipher type.
1255 *
1256 * @return > 0 specifying the block size;
1257 * 0 on error
1258 */
1259 uint32_tcxx . . $ uint32_t# kcapi_aead_authsizecxx . . $ kcapi_aead_authsize(994c7fcc3809be77).(struct kcapi_handlecxx . . $ kcapi_handle# *handle);
1260
1261 /**
1262 * kcapi_aead_inbuflen_enc() - return minimum encryption input buffer length
1263 *
1264 * @handle: [in] cipher handle
1265 * @inlen: [in] size of plaintext
1266 * @assoclen: [in] size of associated data (AD)
1267 * @taglen: [in] size of authentication tag
1268 *
1269 * @return minimum size of input data length in bytes
1270 */
1271 size_tcxx . . $ size_t# kcapi_aead_inbuflen_enccxx . . $ kcapi_aead_inbuflen_enc(7ed64dbb494a2be8).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
1272 size_tcxx . . $ size_t# inlen, size_tcxx . . $ size_t# assoclen, size_tcxx . . $ size_t# taglen);
1273
1274 /**
1275 * kcapi_aead_inbuflen_dec() - return minimum decryption input buffer length
1276 *
1277 * @handle: [in] cipher handle
1278 * @inlen: [in] size of ciphertext
1279 * @assoclen: [in] size of associated data (AD)
1280 * @taglen: [in] size of authentication tag
1281 *
1282 * @return minimum size of output data length in bytes
1283 */
1284 size_tcxx . . $ size_t# kcapi_aead_inbuflen_deccxx . . $ kcapi_aead_inbuflen_dec(7ed64dbb494a2be8).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
1285 size_tcxx . . $ size_t# inlen, size_tcxx . . $ size_t# assoclen, size_tcxx . . $ size_t# taglen);
1286
1287 /**
1288 * kcapi_aead_outbuflen_enc() - return minimum encryption output buffer length
1289 *
1290 * @handle: [in] cipher handle
1291 * @inlen: [in] size of plaintext
1292 * @assoclen: [in] size of associated data (AD)
1293 * @taglen: [in] size of authentication tag
1294 *
1295 * @return minimum size of output data length in bytes
1296 */
1297 size_tcxx . . $ size_t# kcapi_aead_outbuflen_enccxx . . $ kcapi_aead_outbuflen_enc(7ed64dbb494a2be8).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
1298 size_tcxx . . $ size_t# inlen, size_tcxx . . $ size_t# assoclen, size_tcxx . . $ size_t# taglen);
1299
1300 /**
1301 * kcapi_aead_outbuflen_dec() - return minimum decryption output buffer length
1302 *
1303 * @handle: [in] cipher handle
1304 * @inlen: [in] size of ciphertext
1305 * @assoclen: [in] size of associated data (AD)
1306 * @taglen: [in] size of authentication tag
1307 *
1308 * @return minimum size of output data length in bytes
1309 */
1310 size_tcxx . . $ size_t# kcapi_aead_outbuflen_deccxx . . $ kcapi_aead_outbuflen_dec(7ed64dbb494a2be8).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
1311 size_tcxx . . $ size_t# inlen, size_tcxx . . $ size_t# assoclen, size_tcxx . . $ size_t# taglen);
1312
1313 /**
1314 * kcapi_aead_ccm_nonce_to_iv() - convert CCM nonce into IV
1315 *
1316 * @nonce: [in] buffer with nonce
1317 * @noncelen: [in] length of nonce
1318 * @iv: [out] newly allocated buffer with IV
1319 * @ivlen: [out] length of IV
1320 *
1321 * This service function converts a CCM nonce value into an IV usable by
1322 * the kernel crypto API.
1323 *
1324 * Caller must free iv.
1325 *
1326 * @return 0 upon success;
1327 * < 0 upon failure
1328 */
1329 int kcapi_aead_ccm_nonce_to_ivcxx . . $ kcapi_aead_ccm_nonce_to_iv(28c625d051fa9729).(const uint8_tcxx . . $ uint8_t# *nonce, uint32_tcxx . . $ uint32_t# noncelen,
1330 uint8_tcxx . . $ uint8_t# **iv, uint32_tcxx . . $ uint32_t# *ivlen);
1331
1332
1333 /**
1334 * DOC: Message Digest Cipher API
1335 */
1336
1337 /**
1338 * kcapi_md_init() - initialize cipher handle
1339 *
1340 * @handle: [out] cipher handle filled during the call
1341 * @ciphername: [in] kernel crypto API cipher name as specified in /proc/crypto
1342 * @flags: [in] flags specifying the type of cipher handle
1343 *
1344 * This function provides the initialization of a (keyed) message digest handle
1345 * and establishes the connection to the kernel.
1346 *
1347 * On success, a pointer to kcapi_handle object is returned in *handle.
1348 * Function kcapi_md_destroy should be called afterwards to free resources.
1349 *
1350 * @return 0 upon success;
1351 * -ENOENT - algorithm not available;
1352 * -EOPNOTSUPP - AF_ALG family not available;
1353 * -EINVAL - accept syscall failed;
1354 * -ENOMEM - cipher handle cannot be allocated
1355 */
1356 int kcapi_md_initcxx . . $ kcapi_md_init(b54728dab28c239a).(struct kcapi_handlecxx . . $ kcapi_handle# **handle, const char *ciphername,
1357 uint32_tcxx . . $ uint32_t# flags);
1358
1359 /**
1360 * kcapi_md_destroy() - close the message digest handle and release resources
1361 *
1362 * @handle: [in] cipher handle to release
1363 */
1364 void kcapi_md_destroycxx . . $ kcapi_md_destroy(aba29416d24fdd59).(struct kcapi_handlecxx . . $ kcapi_handle# *handle);
1365
1366 /**
1367 * kcapi_md_setkey() - set the key for the message digest handle
1368 *
1369 * @handle: [in] cipher handle
1370 * @key: [in] key buffer
1371 * @keylen: [in] length of key buffer
1372 *
1373 * With this function, the caller sets the key for subsequent hashing
1374 * operations. This call is applicable for keyed message digests.
1375 *
1376 * After the caller provided the key, the caller may securely destroy the key
1377 * as it is now maintained by the kernel.
1378 *
1379 * @return 0 upon success;
1380 * a negative errno-style error code if an error occurred
1381 */
1382 int kcapi_md_setkeycxx . . $ kcapi_md_setkey(4d0e261613a805ee).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
1383 const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen);
1384
1385 /**
1386 * kcapi_md_update() - message digest update function (stream)
1387 *
1388 * @handle: [in] cipher handle
1389 * @buffer: [in] holding the data to add to the message digest
1390 * @len: [in] buffer length
1391 *
1392 * The input buffer can be at most INT_MAX in size.
1393 *
1394 * @return 0 upon success;
1395 * a negative errno-style error code if an error occurred
1396 */
1397 ssize_tcxx . . $ ssize_t# kcapi_md_updatecxx . . $ kcapi_md_update(1f5d0f6abfafb9e8).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
1398 const uint8_tcxx . . $ uint8_t# *buffer, size_tcxx . . $ size_t# len);
1399
1400 /**
1401 * kcapi_md_final() - message digest finalization function (stream)
1402 *
1403 * @handle: [in] cipher handle
1404 * @buffer: [out] filled with the message digest
1405 * @len: [in] buffer length
1406 *
1407 * @return size of message digest upon success;
1408 * -EIO - data cannot be obtained;
1409 * -ENOMEM - buffer is too small for the complete message digest,
1410 * the buffer is filled with the truncated message digest
1411 */
1412 ssize_tcxx . . $ ssize_t# kcapi_md_finalcxx . . $ kcapi_md_final(e37e70272ed35378).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
1413 uint8_tcxx . . $ uint8_t# *buffer, size_tcxx . . $ size_t# len);
1414
1415 /**
1416 * kcapi_md_digest() - calculate message digest on buffer (one-shot)
1417 *
1418 * @handle: [in] cipher handle
1419 * @in: [in] buffer with input data
1420 * @inlen: [in] length of input buffer
1421 * @out: [out] buffer for message digest
1422 * @outlen: [in] length of out
1423 *
1424 * With this one-shot function, a message digest of the given buffer is
1425 * generated. The output buffer must be allocated by the caller and have at
1426 * least the length of the message digest size for the chosen message digest.
1427 *
1428 * The message digest handle must have been initialized, potentially by also
1429 * setting the key using the generic message digest API functions.
1430 *
1431 * The input buffer can be at most INT_MAX in size.
1432 *
1433 * @return size of message digest upon success;
1434 * -EIO - data cannot be obtained;
1435 * -ENOMEM - buffer is too small for the complete message digest,
1436 * the buffer is filled with the truncated message digest
1437 */
1438 ssize_tcxx . . $ ssize_t# kcapi_md_digestcxx . . $ kcapi_md_digest(6368db0609283dea).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
1439 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
1440 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
1441
1442 /**
1443 * kcapi_md_sha1 - SHA-1 message digest on one buffer
1444 *
1445 * @in: [in] buffer with input data
1446 * @inlen: [in] length of input buffer
1447 * @out: [out] buffer for message digest
1448 * @outlen: [in] length of out
1449 *
1450 * With this one-shot convenience function, a message digest of the given buffer
1451 * is generated. The output buffer must be allocated by the caller and have at
1452 * least the length of the message digest size for the chosen message digest.
1453 *
1454 * @return size of message digest upon success;
1455 * -EIO - data cannot be obtained;
1456 * -ENOMEM - buffer is too small for the complete message digest,
1457 * the buffer is filled with the truncated message digest
1458 */
1459 ssize_tcxx . . $ ssize_t# kcapi_md_sha1cxx . . $ kcapi_md_sha1(238794e3f4f6fd4d).(const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
1460 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
1461
1462 /**
1463 * kcapi_md_sha224 - SHA-224 message digest on one buffer
1464 *
1465 * @in: [in] buffer with input data
1466 * @inlen: [in] length of input buffer
1467 * @out: [out] buffer for message digest
1468 * @outlen: [in] length of out
1469 *
1470 * With this one-shot convenience function, a message digest of the given buffer
1471 * is generated. The output buffer must be allocated by the caller and have at
1472 * least the length of the message digest size for the chosen message digest.
1473 *
1474 * @return size of message digest upon success;
1475 * -EIO - data cannot be obtained;
1476 * -ENOMEM - buffer is too small for the complete message digest,
1477 * the buffer is filled with the truncated message digest
1478 */
1479 ssize_tcxx . . $ ssize_t# kcapi_md_sha224cxx . . $ kcapi_md_sha224(238794e3f4f6fd4d).(const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
1480 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
1481
1482 /**
1483 * kcapi_md_sha256 - SHA-256 message digest on one buffer
1484 *
1485 * @in: [in] buffer with input data
1486 * @inlen: [in] length of input buffer
1487 * @out: [out] buffer for message digest
1488 * @outlen: [in] length of out
1489 *
1490 * With this one-shot convenience function, a message digest of the given buffer
1491 * is generated. The output buffer must be allocated by the caller and have at
1492 * least the length of the message digest size for the chosen message digest.
1493 *
1494 * @return size of message digest upon success;
1495 * -EIO - data cannot be obtained;
1496 * -ENOMEM - buffer is too small for the complete message digest,
1497 * the buffer is filled with the truncated message digest
1498 */
1499 ssize_tcxx . . $ ssize_t# kcapi_md_sha256cxx . . $ kcapi_md_sha256(238794e3f4f6fd4d).(const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
1500 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
1501
1502 /**
1503 * kcapi_md_sha384 - SHA-384 message digest on one buffer
1504 *
1505 * @in: [in] buffer with input data
1506 * @inlen: [in] length of input buffer
1507 * @out: [out] buffer for message digest
1508 * @outlen: [in] length of out
1509 *
1510 * With this one-shot convenience function, a message digest of the given buffer
1511 * is generated. The output buffer must be allocated by the caller and have at
1512 * least the length of the message digest size for the chosen message digest.
1513 *
1514 * @return size of message digest upon success;
1515 * -EIO - data cannot be obtained;
1516 * -ENOMEM - buffer is too small for the complete message digest,
1517 * the buffer is filled with the truncated message digest
1518 */
1519 ssize_tcxx . . $ ssize_t# kcapi_md_sha384cxx . . $ kcapi_md_sha384(238794e3f4f6fd4d).(const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
1520 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
1521
1522 /**
1523 * kcapi_md_sha512 - SHA-512 message digest on one buffer
1524 *
1525 * @in: [in] buffer with input data
1526 * @inlen: [in] length of input buffer
1527 * @out: [out] buffer for message digest
1528 * @outlen: [in] length of out
1529 *
1530 * With this one-shot convenience function, a message digest of the given buffer
1531 * is generated. The output buffer must be allocated by the caller and have at
1532 * least the length of the message digest size for the chosen message digest.
1533 *
1534 * @return size of message digest upon success;
1535 * -EIO - data cannot be obtained;
1536 * -ENOMEM - buffer is too small for the complete message digest,
1537 * the buffer is filled with the truncated message digest
1538 */
1539 ssize_tcxx . . $ ssize_t# kcapi_md_sha512cxx . . $ kcapi_md_sha512(238794e3f4f6fd4d).(const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
1540 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
1541
1542 /**
1543 * kcapi_md_sm3 - SM3 message digest on one buffer
1544 *
1545 * @in: [in] buffer with input data
1546 * @inlen: [in] length of input buffer
1547 * @out: [out] buffer for message digest
1548 * @outlen: [in] length of out
1549 *
1550 * With this one-shot convenience function, a message digest of the given buffer
1551 * is generated. The output buffer must be allocated by the caller and have at
1552 * least the length of the message digest size for the chosen message digest.
1553 *
1554 * @return size of message digest upon success;
1555 * -EIO - data cannot be obtained;
1556 * -ENOMEM - buffer is too small for the complete message digest,
1557 * the buffer is filled with the truncated message digest
1558 */
1559 ssize_tcxx . . $ ssize_t# kcapi_md_sm3cxx . . $ kcapi_md_sm3(238794e3f4f6fd4d).(const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
1560 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
1561
1562 /**
1563 * kcapi_md_hmac_sha1 - HMAC SHA-1 keyed message digest on one buffer
1564 *
1565 * @key: [in] buffer with HMAC key
1566 * @keylen: [in] length of HMAC key buffer
1567 * @in: [in] buffer with input data
1568 * @inlen: [in] length of input buffer
1569 * @out: [out] buffer for message digest
1570 * @outlen: [in] length of out
1571 *
1572 * With this one-shot convenience function, a keyed message digest of the given
1573 * buffer is generated. The output buffer must be allocated by the caller and
1574 * have at least the length of the message digest size for the chosen keyed
1575 * message digest.
1576 *
1577 * @return size of message digest upon success;
1578 * -EIO - data cannot be obtained;
1579 * -ENOMEM - buffer is too small for the complete message digest,
1580 * the buffer is filled with the truncated message digest
1581 */
1582 ssize_tcxx . . $ ssize_t# kcapi_md_hmac_sha1cxx . . $ kcapi_md_hmac_sha1(533748020b1119fc).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
1583 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
1584 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
1585
1586 /**
1587 * kcapi_md_hmac_sha224 - HMAC SHA-224 keyed message digest on one buffer
1588 *
1589 * @key: [in] buffer with HMAC key
1590 * @keylen: [in] length of HMAC key buffer
1591 * @in: [in] buffer with input data
1592 * @inlen: [in] length of input buffer
1593 * @out: [out] buffer for message digest
1594 * @outlen: [in] length of out
1595 *
1596 * With this one-shot convenience function, a keyed message digest of the given
1597 * buffer is generated. The output buffer must be allocated by the caller and
1598 * have at least the length of the message digest size for the chosen keyed
1599 * message digest.
1600 *
1601 * @return size of message digest upon success;
1602 * -EIO - data cannot be obtained;
1603 * -ENOMEM - buffer is too small for the complete message digest,
1604 * the buffer is filled with the truncated message digest
1605 */
1606 ssize_tcxx . . $ ssize_t# kcapi_md_hmac_sha224cxx . . $ kcapi_md_hmac_sha224(533748020b1119fc).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
1607 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
1608 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
1609
1610 /**
1611 * kcapi_md_hmac_sha256 - HMAC SHA-256 keyed message digest on one buffer
1612 *
1613 * @key: [in] buffer with HMAC key
1614 * @keylen: [in] length of HMAC key buffer
1615 * @in: [in] buffer with input data
1616 * @inlen: [in] length of input buffer
1617 * @out: [out] buffer for message digest
1618 * @outlen: [in] length of out
1619 *
1620 * With this one-shot convenience function, a keyed message digest of the given
1621 * buffer is generated. The output buffer must be allocated by the caller and
1622 * have at least the length of the message digest size for the chosen keyed
1623 * message digest.
1624 *
1625 * @return size of message digest upon success;
1626 * -EIO - data cannot be obtained;
1627 * -ENOMEM - buffer is too small for the complete message digest,
1628 * the buffer is filled with the truncated message digest
1629 */
1630 ssize_tcxx . . $ ssize_t# kcapi_md_hmac_sha256cxx . . $ kcapi_md_hmac_sha256(533748020b1119fc).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
1631 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
1632 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
1633
1634 /**
1635 * kcapi_md_hmac_sha384 - HMAC SHA-384 keyed message digest on one buffer
1636 *
1637 * @key: [in] buffer with HMAC key
1638 * @keylen: [in] length of HMAC key buffer
1639 * @in: [in] buffer with input data
1640 * @inlen: [in] length of input buffer
1641 * @out: [out] buffer for message digest
1642 * @outlen: [in] length of out
1643 *
1644 * With this one-shot convenience function, a keyed message digest of the given
1645 * buffer is generated. The output buffer must be allocated by the caller and
1646 * have at least the length of the message digest size for the chosen keyed
1647 * message digest.
1648 *
1649 * @return size of message digest upon success;
1650 * -EIO - data cannot be obtained;
1651 * -ENOMEM - buffer is too small for the complete message digest,
1652 * the buffer is filled with the truncated message digest
1653 */
1654 ssize_tcxx . . $ ssize_t# kcapi_md_hmac_sha384cxx . . $ kcapi_md_hmac_sha384(533748020b1119fc).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
1655 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
1656 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
1657
1658 /**
1659 * kcapi_md_hmac_sha512 - HMAC SHA-512 keyed message digest on one buffer
1660 *
1661 * @key: [in] buffer with HMAC key
1662 * @keylen: [in] length of HMAC key buffer
1663 * @in: [in] buffer with input data
1664 * @inlen: [in] length of input buffer
1665 * @out: [out] buffer for message digest
1666 * @outlen: [in] length of out
1667 *
1668 * With this one-shot convenience function, a keyed message digest of the given
1669 * buffer is generated. The output buffer must be allocated by the caller and
1670 * have at least the length of the message digest size for the chosen keyed
1671 * message digest.
1672 *
1673 * @return size of message digest upon success;
1674 * -EIO - data cannot be obtained;
1675 * -ENOMEM - buffer is too small for the complete message digest,
1676 * the buffer is filled with the truncated message digest
1677 */
1678 ssize_tcxx . . $ ssize_t# kcapi_md_hmac_sha512cxx . . $ kcapi_md_hmac_sha512(533748020b1119fc).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
1679 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
1680 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
1681
1682 /**
1683 * kcapi_md_hmac_sm3 - HMAC SM3 keyed message digest on one buffer
1684 *
1685 * @key: [in] buffer with HMAC key
1686 * @keylen: [in] length of HMAC key buffer
1687 * @in: [in] buffer with input data
1688 * @inlen: [in] length of input buffer
1689 * @out: [out] buffer for message digest
1690 * @outlen: [in] length of out
1691 *
1692 * With this one-shot convenience function, a keyed message digest of the given
1693 * buffer is generated. The output buffer must be allocated by the caller and
1694 * have at least the length of the message digest size for the chosen keyed
1695 * message digest.
1696 *
1697 * @return size of message digest upon success;
1698 * -EIO - data cannot be obtained;
1699 * -ENOMEM - buffer is too small for the complete message digest,
1700 * the buffer is filled with the truncated message digest
1701 */
1702 ssize_tcxx . . $ ssize_t# kcapi_md_hmac_sm3cxx . . $ kcapi_md_hmac_sm3(533748020b1119fc).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
1703 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
1704 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen);
1705
1706 /**
1707 * kcapi_md_digestsize() - return the size of the message digest
1708 *
1709 * @handle: [in] cipher handle
1710 *
1711 * The returned message digest size can be used before the kcapi_md_final
1712 * function invocation to determine the right memory size to be allocated for
1713 * this call.
1714 *
1715 * @return > 0 specifying the block size;
1716 * 0 on error
1717 */
1718 uint32_tcxx . . $ uint32_t# kcapi_md_digestsizecxx . . $ kcapi_md_digestsize(994c7fcc3809be77).(struct kcapi_handlecxx . . $ kcapi_handle# *handle);
1719
1720 /**
1721 * kcapi_md_blocksize() - return size of one block of the message digest
1722 *
1723 * @handle: [in] cipher handle
1724 *
1725 * @return > 0 specifying the block size;
1726 * 0 on error
1727 */
1728 uint32_tcxx . . $ uint32_t# kcapi_md_blocksizecxx . . $ kcapi_md_blocksize(994c7fcc3809be77).(struct kcapi_handlecxx . . $ kcapi_handle# *handle);
1729
1730
1731 /**
1732 * DOC: Random Number API
1733 */
1734
1735 /**
1736 * kcapi_rng_init() - initialize cipher handle
1737 *
1738 * @handle: [out] cipher handle filled during the call
1739 * @ciphername: [in] kernel crypto API cipher name as specified in
1740 * /proc/crypto
1741 * @flags: [in] flags specifying the type of cipher handle (unused for RNG)
1742 *
1743 * This function provides the initialization of a random number generator handle
1744 * and establishes the connection to the kernel.
1745 *
1746 * On success, a pointer to kcapi_handle object is returned in *handle.
1747 * Function kcapi_rng_destroy should be called afterwards to free resources.
1748 *
1749 * @return 0 upon success;
1750 * -ENOENT - algorithm not available;
1751 * -EOPNOTSUPP - AF_ALG family not available;
1752 * -EINVAL - accept syscall failed
1753 * -ENOMEM - cipher handle cannot be allocated
1754 */
1755 int kcapi_rng_initcxx . . $ kcapi_rng_init(b54728dab28c239a).(struct kcapi_handlecxx . . $ kcapi_handle# **handle, const char *ciphername,
1756 uint32_tcxx . . $ uint32_t# flags);
1757
1758 /**
1759 * kcapi_rng_destroy() - close the RNG handle and release resources
1760 *
1761 * @handle: [in] cipher handle to release
1762 */
1763 void kcapi_rng_destroycxx . . $ kcapi_rng_destroy(aba29416d24fdd59).(struct kcapi_handlecxx . . $ kcapi_handle# *handle);
1764
1765 /**
1766 * kcapi_rng_seed() - seed the RNG
1767 *
1768 * @handle: [in] cipher handle
1769 * @seed: [in] seed data
1770 * @seedlen: [in] size of seed
1771 *
1772 * Note, this call must be called to initialize the selected RNG. When the
1773 * SP800-90A DRBG is used, this call causes the DRBG to seed itself from the
1774 * internal noise sources.
1775 *
1776 * Note, in case of using the SP800-90A DRBG, the seed buffer may be NULL. If
1777 * it is not NULL, the DRBG uses the given data either as personalization string
1778 * in case of the initial seeding or additional data for reseeding.
1779 *
1780 * @return 0 upon success;
1781 * a negative errno-style error code if an error occurred
1782 */
1783 int kcapi_rng_seedcxx . . $ kcapi_rng_seed(1245f63d3d64d4aa).(struct kcapi_handlecxx . . $ kcapi_handle# *handle, uint8_tcxx . . $ uint8_t# *seed,
1784 uint32_tcxx . . $ uint32_t# seedlen);
1785
1786 /**
1787 * kcapi_rng_setentropy() - set the initial entropy of the RNG
1788 *
1789 * @handle: [in] cipher handle
1790 * @ent: [in] entropy data
1791 * @entlen: [in] size of entropy
1792 *
1793 * Note, this call must be called to initialize the selected RNG. When the
1794 * SP800-90A DRBG is used, this call causes the DRBG to seed itself from the
1795 * provided data in 'ent'.
1796 *
1797 * Note, in case of using the SP800-90A DRBG, the CRYPTO_USER_API_RNG_CAVP
1798 * kernel config knob must be set to 'y' to use this API.
1799 *
1800 * @return 0 upon success;
1801 * a negative errno-style error code if an error occurred
1802 */
1803 int kcapi_rng_setentropycxx . . $ kcapi_rng_setentropy(1245f63d3d64d4aa).(struct kcapi_handlecxx . . $ kcapi_handle# *handle, uint8_tcxx . . $ uint8_t# *ent,
1804 uint32_tcxx . . $ uint32_t# entlen);
1805
1806 /**
1807 * kcapi_rng_setaddtl() - send additional data to the RNG
1808 *
1809 * @handle: [in] cipher handle
1810 * @addtl: [in] additional data to be sent
1811 * @len: [in] size of additional data
1812 *
1813 * Note, this call must be called immediately prior to calling kcapi_rng_generate
1814 * in order to send additional data to be consumed by the RNG.
1815 *
1816 * Note, in case of using the SP800-90A DRBG, the CRYPTO_USER_API_RNG_CAVP
1817 * kernel config knob must be set to 'y' to use this API.
1818 *
1819 * @return 0 upon success;
1820 * a negative errno-style error code if an error occurred
1821 */
1822 int kcapi_rng_setaddtlcxx . . $ kcapi_rng_setaddtl(1245f63d3d64d4aa).(struct kcapi_handlecxx . . $ kcapi_handle# *handle, uint8_tcxx . . $ uint8_t# *addtl,
1823 uint32_tcxx . . $ uint32_t# len);
1824
1825 /**
1826 * kcapi_rng_generate() - generate a random number
1827 *
1828 * @handle: [in] cipher handle
1829 * @buffer: [out] filled with the random number
1830 * @len: [in] buffer length
1831 *
1832 * @return size of random number generated upon success;
1833 * -EIO - data cannot be obtained
1834 */
1835 ssize_tcxx . . $ ssize_t# kcapi_rng_generatecxx . . $ kcapi_rng_generate(e37e70272ed35378).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
1836 uint8_tcxx . . $ uint8_t# *buffer, size_tcxx . . $ size_t# len);
1837
1838 /**
1839 * kcapi_rng_get_bytes - Convenience function to generate random bytes
1840 *
1841 * @buffer: [out] filled with the random number
1842 * @outlen: [in] buffer length
1843 *
1844 * This convenience function generates random bytes of the size of outlen
1845 * and stores them into the provided buffer.
1846 *
1847 * @return size of random number generated upon success;
1848 * -EIO - data cannot be obtained
1849 */
1850 ssize_tcxx . . $ ssize_t# kcapi_rng_get_bytescxx . . $ kcapi_rng_get_bytes(de74abb410f03b30).(uint8_tcxx . . $ uint8_t# *buffer, size_tcxx . . $ size_t# outlen);
1851
1852 /**
1853 * kcapi_rng_seedsize() - return required seed size of DRNG
1854 *
1855 * @handle: [in] cipher handle
1856 *
1857 * @return > 0 specifying the block size;
1858 * 0 on error
1859 */
1860 uint32_tcxx . . $ uint32_t# kcapi_rng_seedsizecxx . . $ kcapi_rng_seedsize(994c7fcc3809be77).(struct kcapi_handlecxx . . $ kcapi_handle# *handle);
1861
1862 /**
1863 * DOC: Common API
1864 *
1865 * The following API calls are common to all cipher types.
1866 */
1867
1868 enum kcapi_verbositycxx . . $ kcapi_verbosity# {
1869 KCAPI_LOG_NONEcxx . . $ KCAPI_LOG_NONE.,
1870 KCAPI_LOG_ERRcxx . . $ KCAPI_LOG_ERR.,
1871 KCAPI_LOG_WARNcxx . . $ KCAPI_LOG_WARN.,
1872 KCAPI_LOG_VERBOSEcxx . . $ KCAPI_LOG_VERBOSE.,
1873 KCAPI_LOG_DEBUGcxx . . $ KCAPI_LOG_DEBUG.,
1874 };
1875
1876 /**
1877 * kcapi_set_verbosity() - set the verbosity level of the library
1878 *
1879 * @level: [in] verbosity level:
1880 * LOG_ERR: only log error messages (default)
1881 * LOG_WARN: log warnings and error messages
1882 * LOG_VERBOSE: log verbose messages, warnings and error messages
1883 * LOG_DEBUG: log all details of library operation
1884 */
1885 void kcapi_set_verbositycxx . . $ kcapi_set_verbosity(dcea45016c0305c8).(enum kcapi_verbositycxx . . $ kcapi_verbosity# level);
1886
1887 /**
1888 * kcapi_versionstring() - obtain version string of kcapi library
1889 *
1890 * @buf: [out] buffer to place version string into
1891 * @buflen: [in] length of buffer
1892 */
1893 void kcapi_versionstringcxx . . $ kcapi_versionstring(2ae3250752bf8d86).(char *buf, uint32_tcxx . . $ uint32_t# buflen);
1894
1895 /**
1896 * kcapi_version() - return machine-usable version number of kcapi library
1897 *
1898 * The function returns a version number that is monotonic increasing
1899 * for newer versions. The version numbers are multiples of 100. For example,
1900 * version 1.2.3 is converted to 1020300 -- the last two digits are reserved
1901 * for future use.
1902 *
1903 * The result of this function can be used in comparing the version number
1904 * in a calling program if version-specific calls need to be make.
1905 *
1906 * @return Version number of kcapi library
1907 */
1908 uint32_tcxx . . $ uint32_t# kcapi_versioncxx . . $ kcapi_version(db52760e79bf9054).(void);
1909
1910 /**
1911 * kcapi_pad_iv() - realign the IV as necessary for cipher
1912 *
1913 * @handle: [in] cipher handle
1914 * @iv: [in] current IV buffer
1915 * @ivlen: [in] length of IV buffer
1916 * @newiv: [out] buffer of aligned IV
1917 * @newivlen: [out] length of newly aligned IV
1918 *
1919 * The function pads the least significant bits of the provided IV up to the
1920 * block size of the cipher with zeros. In case the provided IV is longer than
1921 * the block size, the least significant bits are truncated to the block size.
1922 *
1923 * The function allocates memory for newiv in case the return code indicates
1924 * success. The consumer must free the memory after use.
1925 *
1926 * @return 0 for success;
1927 * a negative errno-style error code if an error occurred
1928 */
1929 int kcapi_pad_ivcxx . . $ kcapi_pad_iv(cc7eda497594f08e).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
1930 const uint8_tcxx . . $ uint8_t# *iv, uint32_tcxx . . $ uint32_t# ivlen,
1931 uint8_tcxx . . $ uint8_t# **newiv, uint32_tcxx . . $ uint32_t# *newivlen);
1932
1933 /**
1934 * kcapi_memset_secure() - memset() implementation that will not be optimized
1935 * away by the compiler
1936 *
1937 * @s: [in] see memset(3)
1938 * @c: [in] see memset(3)
1939 * @n: [in] see memset(3)
1940 *
1941 * The parameters, he logic and the return code is identical to memset(3).
1942 */
1943 void kcapi_memset_securecxx . . $ kcapi_memset_secure(e37d57925061d5c9).(void *s, int c, size_tcxx . . $ size_t# n);
1944
1945 /**
1946 * DOC: Asymmetric Cipher API
1947 *
1948 * API function calls used to invoke asymmetric ciphers.
1949 */
1950
1951 /**
1952 * kcapi_akcipher_init() - initialize cipher handle
1953 *
1954 * @handle: [out] cipher handle filled during the call
1955 * @ciphername: [in] kernel crypto API cipher name as specified in
1956 * /proc/crypto
1957 * @flags: [in] flags specifying the type of cipher handle
1958 *
1959 * This function provides the initialization of an asymmetric cipher handle and
1960 * establishes the connection to the kernel.
1961 *
1962 * On success, a pointer to kcapi_handle object is returned in *handle.
1963 * Function kcapi_akcipher_destroy should be called afterwards to free
1964 * resources.
1965 *
1966 * @return 0 upon success;
1967 * -ENOENT - algorithm not available;
1968 * -EOPNOTSUPP - AF_ALG family not available;
1969 * -EINVAL - accept syscall failed
1970 * -ENOMEM - cipher handle cannot be allocated
1971 */
1972 int kcapi_akcipher_initcxx . . $ kcapi_akcipher_init(b54728dab28c239a).(struct kcapi_handlecxx . . $ kcapi_handle# **handle, const char *ciphername,
1973 uint32_tcxx . . $ uint32_t# flags);
1974
1975 /**
1976 * kcapi_akcipher_destroy() - close the cipher handle and release resources
1977 *
1978 * @handle: [in] cipher handle to release
1979 */
1980 void kcapi_akcipher_destroycxx . . $ kcapi_akcipher_destroy(aba29416d24fdd59).(struct kcapi_handlecxx . . $ kcapi_handle# *handle);
1981
1982 /**
1983 * kcapi_akcipher_setkey() - set the private key for the cipher handle
1984 *
1985 * @handle: [in] cipher handle
1986 * @key: [in] key buffer in DER format
1987 * @keylen: [in] length of key buffer
1988 *
1989 * With this function, the caller sets the key for subsequent cipher operations.
1990 *
1991 * The key must be in DER format as follows
1992 *
1993 * SEQUENCE {
1994 * version INTEGER,
1995 * n INTEGER ({ rsa_get_n }),
1996 * e INTEGER ({ rsa_get_e }),
1997 * d INTEGER ({ rsa_get_d }),
1998 * prime1 INTEGER,
1999 * prime2 INTEGER,
2000 * exponent1 INTEGER,
2001 * exponent2 INTEGER,
2002 * coefficient INTEGER
2003 *}
2004 *
2005 * After the caller provided the key, the caller may securely destroy the key
2006 * as it is now maintained by the kernel.
2007 *
2008 * @return upon success the value of the maximum size for the asymmetric
2009 * operation is returned (e.g. the modulus size);
2010 * a negative errno-style error code if an error occurred
2011 */
2012 int kcapi_akcipher_setkeycxx . . $ kcapi_akcipher_setkey(4d0e261613a805ee).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2013 const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen);
2014
2015 /**
2016 * kcapi_akcipher_setpubkey() - set the public key for the cipher handle
2017 *
2018 * @handle: [in] cipher handle
2019 * @key: [in] key buffer in DER format
2020 * @keylen: [in] length of key buffer
2021 *
2022 * With this function, the caller sets the key for subsequent cipher operations.
2023 *
2024 * The key must be in DER format as follows
2025 *
2026 * SEQUENCE {
2027 * n INTEGER ({ rsa_get_n }),
2028 * e INTEGER ({ rsa_get_e })
2029 *}
2030 *
2031 * After the caller provided the key, the caller may securely destroy the key
2032 * as it is now maintained by the kernel.
2033 *
2034 * @return upon success the value of the maximum size for the asymmetric
2035 * operation is returned (e.g. the modulus size);
2036 * a negative errno-style error code if an error occurred
2037 */
2038 int kcapi_akcipher_setpubkeycxx . . $ kcapi_akcipher_setpubkey(4d0e261613a805ee).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2039 const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen);
2040
2041 /**
2042 * kcapi_akcipher_encrypt() - encrypt data
2043 *
2044 * @handle: [in] cipher handle
2045 * @in: [in] plaintext data buffer
2046 * @inlen: [in] length of in buffer
2047 * @out: [out] ciphertext data buffer
2048 * @outlen: [in] length of out buffer
2049 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
2050 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE - use
2051 * vmsplice access; KCAPI_ACCESS_SENDMSG - sendmsg access)
2052 *
2053 * It is perfectly legal to use the same buffer as the plaintext and
2054 * ciphertext pointers. That would mean that after the encryption operation,
2055 * the plaintext is overwritten with the ciphertext.
2056 *
2057 * The memory should be aligned at the page boundary using
2058 * posix_memalign(sysconf(_SC_PAGESIZE)), If it is not aligned at the page
2059 * boundary, the vmsplice call may not send all data to the kernel.
2060 *
2061 * If the output size is insufficiently large, -EINVAL is returned. The
2062 * output buffer must be at least as large as the modululs of the uses key.
2063 *
2064 * @return number of bytes returned by the encryption operation upon success;
2065 * a negative errno-style error code if an error occurred
2066 */
2067 ssize_tcxx . . $ ssize_t# kcapi_akcipher_encryptcxx . . $ kcapi_akcipher_encrypt(454d408f80500942).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2068 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
2069 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen, int access);
2070
2071 /**
2072 * kcapi_akcipher_encrypt_aio() - encrypt data (asynchronous one shot)
2073 *
2074 * @handle: [in] cipher handle
2075 * @iniov: [in] head of scatter-gather list array holding the plaintext
2076 * @outiov: [out] head of scatter-gather list of the destination buffers filled
2077 * with ciphertext
2078 * @iovlen: [in] number of scatter-gather list entries
2079 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
2080 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE - use
2081 * vmsplice access; KCAPI_ACCESS_SENDMSG - sendmsg access)
2082 *
2083 * The individual scatter-gather list entries are processed with
2084 * separate invocations of the the given cipher.
2085 *
2086 * The memory should be aligned at the page boundary using
2087 * posix_memalign(sysconf(_SC_PAGESIZE)), If it is not aligned at the page
2088 * boundary, the vmsplice call may not send all data to the kernel.
2089 *
2090 * @return number of bytes encrypted upon success;
2091 * a negative errno-style error code if an error occurred
2092 */
2093 ssize_tcxx . . $ ssize_t# kcapi_akcipher_encrypt_aiocxx . . $ kcapi_akcipher_encrypt_aio(de09309eb3f0c76b).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2094 struct ioveccxx . . $ iovec# *iniov, struct ioveccxx . . $ iovec# *outiov,
2095 size_tcxx . . $ size_t# iovlen, int access);
2096
2097 /**
2098 * kcapi_akcipher_decrypt() - decrypt data
2099 *
2100 * @handle: [in] cipher handle
2101 * @in: [in] ciphertext data buffer
2102 * @inlen: [in] length of in buffer
2103 * @out: [out] plaintext data buffer
2104 * @outlen: [in] length of out buffer
2105 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
2106 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE - use
2107 * vmsplice access; KCAPI_ACCESS_SENDMSG - sendmsg access)
2108 *
2109 * It is perfectly legal to use the same buffer as the plaintext and
2110 * ciphertext pointers. That would mean that after the decryption operation,
2111 * the ciphertext is overwritten with the plaintext.
2112 *
2113 * The memory should be aligned at the page boundary using
2114 * posix_memalign(sysconf(_SC_PAGESIZE)), If it is not aligned at the page
2115 * boundary, the vmsplice call may not send all data to the kernel.
2116 *
2117 * If the output size is insufficiently large, -EINVAL is returned. The
2118 * output buffer must be at least as large as the modululs of the uses key.
2119 *
2120 * @return number of bytes returned by the decryption operation upon success;
2121 * a negative errno-style error code if an error occurred
2122 */
2123 ssize_tcxx . . $ ssize_t# kcapi_akcipher_decryptcxx . . $ kcapi_akcipher_decrypt(454d408f80500942).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2124 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
2125 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen, int access);
2126
2127 /**
2128 * kcapi_akcipher_decrypt_aio() - decrypt data (asynchronous one shot)
2129 *
2130 * @handle: [in] cipher handle
2131 * @iniov: [in] head of scatter-gather list array holding the plaintext
2132 * @outiov: [out] head of scatter-gather list of the destination buffers filled
2133 * with ciphertext
2134 * @iovlen: [in] number of scatter-gather list entries
2135 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
2136 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE - use
2137 * vmsplice access; KCAPI_ACCESS_SENDMSG - sendmsg access)
2138 *
2139 * The individual scatter-gather list entries are processed with
2140 * separate invocations of the the given cipher.
2141 *
2142 * The memory should be aligned at the page boundary using
2143 * posix_memalign(sysconf(_SC_PAGESIZE)), If it is not aligned at the page
2144 * boundary, the vmsplice call may not send all data to the kernel.
2145 *
2146 * @return number of bytes decrypted upon success;
2147 * a negative errno-style error code if an error occurred
2148 */
2149 ssize_tcxx . . $ ssize_t# kcapi_akcipher_decrypt_aiocxx . . $ kcapi_akcipher_decrypt_aio(de09309eb3f0c76b).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2150 struct ioveccxx . . $ iovec# *iniov, struct ioveccxx . . $ iovec# *outiov,
2151 size_tcxx . . $ size_t# iovlen, int access);
2152
2153 /**
2154 * kcapi_akcipher_sign() - signature generation
2155 *
2156 * @handle: [in] cipher handle
2157 * @in: [in] message data buffer
2158 * @inlen: [in] length of in buffer
2159 * @out: [out] signature data buffer
2160 * @outlen: [in] length of out buffer
2161 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
2162 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE - use
2163 * vmsplice access; KCAPI_ACCESS_SENDMSG - sendmsg access)
2164 *
2165 * It is perfectly legal to use the same buffer as the message and
2166 * signature pointers. That would mean that after the signature generation
2167 * operation, the message is overwritten with the signature.
2168 *
2169 * The memory should be aligned at the page boundary using
2170 * posix_memalign(sysconf(_SC_PAGESIZE)), If it is not aligned at the page
2171 * boundary, the vmsplice call may not send all data to the kernel.
2172 *
2173 * If the output size is insufficiently large, -EINVAL is returned. The
2174 * output buffer must be at least as large as the modululs of the uses key.
2175 *
2176 * @return number of bytes returned by the signature gen operation upon success;
2177 * a negative errno-style error code if an error occurred
2178 */
2179 ssize_tcxx . . $ ssize_t# kcapi_akcipher_signcxx . . $ kcapi_akcipher_sign(454d408f80500942).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2180 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
2181 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen, int access);
2182
2183 /**
2184 * kcapi_akcipher_sign_aio() - sign data (asynchronous one shot)
2185 *
2186 * @handle: [in] cipher handle
2187 * @iniov: [in] head of scatter-gather list array holding the plaintext
2188 * @outiov: [out] head of scatter-gather list of the destination buffers filled
2189 * with ciphertext
2190 * @iovlen: [in] number of scatter-gather list entries
2191 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
2192 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE - use
2193 * vmsplice access; KCAPI_ACCESS_SENDMSG - sendmsg access)
2194 *
2195 * The individual scatter-gather list entries are processed with
2196 * separate invocations of the the given cipher.
2197 *
2198 * The memory should be aligned at the page boundary using
2199 * posix_memalign(sysconf(_SC_PAGESIZE)), If it is not aligned at the page
2200 * boundary, the vmsplice call may not send all data to the kernel.
2201 *
2202 * @return number of bytes signed upon success;
2203 * a negative errno-style error code if an error occurred
2204 */
2205 ssize_tcxx . . $ ssize_t# kcapi_akcipher_sign_aiocxx . . $ kcapi_akcipher_sign_aio(de09309eb3f0c76b).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2206 struct ioveccxx . . $ iovec# *iniov, struct ioveccxx . . $ iovec# *outiov,
2207 size_tcxx . . $ size_t# iovlen, int access);
2208
2209 /**
2210 * kcapi_akcipher_verify() - signature verification
2211 *
2212 * @handle: [in] cipher handle
2213 * @in: [in] message data buffer
2214 * @inlen: [in] length of in buffer
2215 * @out: [out] signature data buffer
2216 * @outlen: [in] length of out buffer
2217 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
2218 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE - use
2219 * vmsplice access; KCAPI_ACCESS_SENDMSG - sendmsg access)
2220 *
2221 * It is perfectly legal to use the same buffer as the message and
2222 * signature pointers. That would mean that after the signature generation
2223 * operation, the message is overwritten with the signature.
2224 *
2225 * The memory should be aligned at the page boundary using
2226 * posix_memalign(sysconf(_SC_PAGESIZE)), If it is not aligned at the page
2227 * boundary, the vmsplice call may not send all data to the kernel.
2228 *
2229 * If the output size is insufficiently large, -EINVAL is returned. The
2230 * output buffer must be at least as large as the modululs of the uses key.
2231 *
2232 * To catch signature verification errors, the return value of this
2233 * call should be checked. If this function returns -EBADMSG, the
2234 * verification of the signature failed.
2235 *
2236 * @return number of bytes returned by the signature ver operation upon success;
2237 * a negative errno-style error code if an error occurred
2238 */
2239 ssize_tcxx . . $ ssize_t# kcapi_akcipher_verifycxx . . $ kcapi_akcipher_verify(454d408f80500942).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2240 const uint8_tcxx . . $ uint8_t# *in, size_tcxx . . $ size_t# inlen,
2241 uint8_tcxx . . $ uint8_t# *out, size_tcxx . . $ size_t# outlen, int access);
2242
2243 /**
2244 * kcapi_akcipher_verify_aio() - verify data (asynchronous one shot)
2245 *
2246 * @handle: [in] cipher handle
2247 * @iniov: [in] head of scatter-gather list array holding the plaintext
2248 * @outiov: [out] head of scatter-gather list of the destination buffers filled
2249 * with ciphertext
2250 * @iovlen: [in] number of scatter-gather list entries
2251 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
2252 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE - use
2253 * vmsplice access; KCAPI_ACCESS_SENDMSG - sendmsg access)
2254 *
2255 * The individual scatter-gather list entries are processed with
2256 * separate invocations of the the given cipher.
2257 *
2258 * The memory should be aligned at the page boundary using
2259 * posix_memalign(sysconf(_SC_PAGESIZE)), If it is not aligned at the page
2260 * boundary, the vmsplice call may not send all data to the kernel.
2261 *
2262 * @return number of bytes verify upon success;
2263 * a negative errno-style error code if an error occurred
2264 */
2265 ssize_tcxx . . $ ssize_t# kcapi_akcipher_verify_aiocxx . . $ kcapi_akcipher_verify_aio(de09309eb3f0c76b).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2266 struct ioveccxx . . $ iovec# *iniov, struct ioveccxx . . $ iovec# *outiov,
2267 size_tcxx . . $ size_t# iovlen, int access);
2268
2269 /**
2270 * kcapi_akcipher_stream_init_enc() - start an encryption operation (stream)
2271 *
2272 * @handle: [in] cipher handle
2273 * @iov: [in] scatter/gather list with data to be encrypted. This is the
2274 * pointer to the first iov entry if an array of iov entries is supplied.
2275 * See sendmsg(2) for details on how iov is to be used. This pointer may be
2276 * NULL if no data to be encrypted is available at the point of the call.
2277 * @iovlen: [in] number of scatter/gather list elements. If iov is NULL,
2278 * this value must be zero.
2279 *
2280 * A stream encryption operation is started with this call. Multiple
2281 * successive kcapi_akcipher_stream_update() function calls can be invoked to
2282 * send more plaintext data to be encrypted. The last invocation to supply data
2283 * must be done with kcapi_akcipher_stream_update_last(). The kernel buffers the
2284 * input until kcapi_akcipher_stream_op() picks up the encrypted data. Once
2285 * plaintext is encrypted during the kcapi_cipher_stream_op() it is removed
2286 * from the kernel buffer.
2287 *
2288 * The function calls of kcapi_akcipher_stream_update() and
2289 * kcapi_akcipher_stream_op() can be mixed, even by multiple threads of an
2290 * application.
2291 *
2292 * @return number of bytes sent to the kernel upon success;
2293 * a negative errno-style error code if an error occurred
2294 */
2295 ssize_tcxx . . $ ssize_t# kcapi_akcipher_stream_init_enccxx . . $ kcapi_akcipher_stream_init_enc(8a8f5b62e036cb66).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2296 struct ioveccxx . . $ iovec# *iov, size_tcxx . . $ size_t# iovlen);
2297
2298 /**
2299 * kcapi_akcipher_stream_init_dec() - start an decryption operation (stream)
2300 * @handle: [in] cipher handle
2301 * @iov: [in] scatter/gather list with data to be decrypted. This is the
2302 * pointer to the first iov entry if an array of iov entries is supplied.
2303 * See sendmsg(2) for details on how iov is to be used. This pointer may be
2304 * NULL if no data to be decrypted is available at the point of the call.
2305 * @iovlen: [in] number of scatter/gather list elements. If iov is NULL,
2306 * this value must be zero.
2307 *
2308 * A stream decryption operation is started with this call. Multiple
2309 * successive kcapi_akcipher_stream_update() function calls can be invoked to
2310 * send more plaintext data to be decrypted. The last invocation to supply data
2311 * must be done with kcapi_akcipher_stream_update_last(). The kernel buffers the
2312 * input until kcapi_akcipher_stream_op() picks up the encrypted data. Once
2313 * plaintext is decrypted during the kcapi_cipher_stream_op() it is removed
2314 * from the kernel buffer.
2315 *
2316 * The function calls of kcapi_akcipher_stream_update() and
2317 * kcapi_akcipher_stream_op() can be mixed, even by multiple threads of an
2318 * application.
2319 *
2320 * @return number of bytes sent to the kernel upon success;
2321 * a negative errno-style error code if an error occurred
2322 */
2323 ssize_tcxx . . $ ssize_t# kcapi_akcipher_stream_init_deccxx . . $ kcapi_akcipher_stream_init_dec(8a8f5b62e036cb66).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2324 struct ioveccxx . . $ iovec# *iov, size_tcxx . . $ size_t# iovlen);
2325
2326 /**
2327 * kcapi_akcipher_stream_init_sgn() - start an signing operation (stream)
2328 *
2329 * @handle: [in] cipher handle
2330 * @iov: [in] scatter/gather list with data to be signed. This is the
2331 * pointer to the first iov entry if an array of iov entries is supplied.
2332 * See sendmsg(2) for details on how iov is to be used. This pointer may be
2333 * NULL if no data to be signed is available at the point of the call.
2334 * @iovlen: [in] number of scatter/gather list elements. If iov is NULL,
2335 * this value must be zero.
2336 *
2337 * A stream signing operation is started with this call. Multiple
2338 * successive kcapi_akcipher_stream_update() function calls can be invoked to
2339 * send more plaintext data to be signed. The last invocation to supply data
2340 * must be done with kcapi_akcipher_stream_update_last(). The kernel buffers the
2341 * input until kcapi_akcipher_stream_op() picks up the signed data. Once
2342 * plaintext is signed during the kcapi_cipher_stream_op() it is removed
2343 * from the kernel buffer.
2344 *
2345 * The function calls of kcapi_akcipher_stream_update() and
2346 * kcapi_akcipher_stream_op() can be mixed, even by multiple threads of an
2347 * application.
2348 *
2349 * @return number of bytes sent to the kernel upon success;
2350 * a negative errno-style error code if an error occurred
2351 */
2352 ssize_tcxx . . $ ssize_t# kcapi_akcipher_stream_init_sgncxx . . $ kcapi_akcipher_stream_init_sgn(8a8f5b62e036cb66).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2353 struct ioveccxx . . $ iovec# *iov, size_tcxx . . $ size_t# iovlen);
2354
2355 /**
2356 * kcapi_akcipher_stream_init_vfy() - start an signature verification operation
2357 * (stream)
2358 *
2359 * @handle: [in] cipher handle
2360 * @iov: [in] scatter/gather list with data to be verified. This is the
2361 * pointer to the first iov entry if an array of iov entries is supplied.
2362 * See sendmsg(2) for details on how iov is to be used. This pointer may be
2363 * NULL if no data to be verified is available at the point of the call.
2364 * @iovlen: [in] number of scatter/gather list elements. If iov is NULL,
2365 * this value must be zero.
2366 *
2367 * A stream signature verification operation is started with this call. Multiple
2368 * successive kcapi_akcipher_stream_update() function calls can be invoked to
2369 * send more plaintext data to be verified. The last invocation to supply data
2370 * must be done with kcapi_akcipher_stream_update_last(). The kernel buffers the
2371 * input until kcapi_akcipher_stream_op() picks up the verified data. Once
2372 * plaintext is verified during the kcapi_cipher_stream_op() it is removed
2373 * from the kernel buffer.
2374 *
2375 * The function calls of kcapi_akcipher_stream_update() and
2376 * kcapi_akcipher_stream_op() can be mixed, even by multiple threads of an
2377 * application.
2378 *
2379 * @return number of bytes sent to the kernel upon success;
2380 * a negative errno-style error code if an error occurred
2381 */
2382 ssize_tcxx . . $ ssize_t# kcapi_akcipher_stream_init_vfycxx . . $ kcapi_akcipher_stream_init_vfy(8a8f5b62e036cb66).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2383 struct ioveccxx . . $ iovec# *iov, size_tcxx . . $ size_t# iovlen);
2384
2385
2386 /**
2387 * kcapi_akcipher_stream_update() - send more data for processing (stream)
2388 *
2389 * @handle: [in] cipher handle
2390 * @iov: [in] scatter/gather list with data to be processed by the cipher
2391 * operation.
2392 * @iovlen: [in] number of scatter/gather list elements.
2393 *
2394 * Using this function call, more data can be submitted to the kernel.
2395 *
2396 * This function may cause the caller to sleep if the kernel buffer holding
2397 * the data is getting full. The process will be woken up once more buffer
2398 * space becomes available by calling kcapi_akcipher_stream_op().
2399 *
2400 * Note: with the separate API calls of kcapi_akcipher_stream_update() and
2401 * kcapi_akcipher_stream_op() a multi-threaded application can be implemented
2402 * where one thread sends data to be processed and one thread picks up data
2403 * processed by the cipher operation.
2404 *
2405 * WARNING: The memory referenced by @iov is not accessed by the kernel
2406 * during this call. The memory is first accessed when kcapi_cipher_stream_op()
2407 * is called. Thus, you MUST make sure that the referenced memory is still
2408 * present at the time kcapi_cipher_stream_op() is called.
2409 *
2410 * @return number of bytes sent to the kernel upon success;
2411 * a negative errno-style error code if an error occurred
2412 */
2413 ssize_tcxx . . $ ssize_t# kcapi_akcipher_stream_updatecxx . . $ kcapi_akcipher_stream_update(8a8f5b62e036cb66).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2414 struct ioveccxx . . $ iovec# *iov, size_tcxx . . $ size_t# iovlen);
2415
2416 /**
2417 * kcapi_akcipher_stream_update_last() - send last data for processing (stream)
2418 *
2419 * @handle: [in] cipher handle
2420 * @iov: [in] scatter/gather list with data to be processed by the cipher
2421 * operation.
2422 * @iovlen: [in] number of scatter/gather list elements.
2423 *
2424 * Using this function call, more data can be submitted to the kernel.
2425 *
2426 * This call is identical to the kcapi_akcipher_stream_update() call with the
2427 * exception that it marks the last data buffer before the cipher operation
2428 * is triggered.
2429 *
2430 * This call must be used if all data is delivered to the kernel and
2431 * kcapi_akcipher_stream_op() will be invoked as a next step. This call
2432 * notifies the kernel that no further data is to be expected.
2433 *
2434 * WARNING: The memory referenced by @iov is not accessed by the kernel
2435 * during this call. The memory is first accessed when kcapi_cipher_stream_op()
2436 * is called. Thus, you MUST make sure that the referenced memory is still
2437 * present at the time kcapi_cipher_stream_op() is called.
2438 *
2439 * @return number of bytes sent to the kernel upon success;
2440 * a negative errno-style error code if an error occurred
2441 */
2442 ssize_tcxx . . $ ssize_t# kcapi_akcipher_stream_update_lastcxx . . $ kcapi_akcipher_stream_update_last(8a8f5b62e036cb66).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2443 struct ioveccxx . . $ iovec# *iov, size_tcxx . . $ size_t# iovlen);
2444
2445
2446 /**
2447 * kcapi_akcipher_stream_op() - obtain processed data (stream)
2448 *
2449 * @handle: [in] cipher handle
2450 * @iov: [in/out] scatter/gather list pointing to buffers to be filled
2451 * with the resulting data from a cipher operation.
2452 * @iovlen: [in] number of scatter/gather list elements.
2453 *
2454 * This call can be called interleaved with kcapi_akcipher_stream_update() to
2455 * fetch the processed data.
2456 *
2457 * This function may cause the caller to sleep if the kernel buffer holding
2458 * the data is empty. The process will be woken up once more data is sent
2459 * by calling kcapi_cipher_stream_update().
2460 *
2461 * Note, when supplying buffers that are not multiple of block size, the buffers
2462 * will only be filled up to the maximum number of full block sizes that fit
2463 * into the buffer.
2464 *
2465 * @return number of bytes obtained from the kernel upon success;
2466 * a negative errno-style error code if an error occurred
2467 */
2468 ssize_tcxx . . $ ssize_t# kcapi_akcipher_stream_opcxx . . $ kcapi_akcipher_stream_op(8a8f5b62e036cb66).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2469 struct ioveccxx . . $ iovec# *iov, size_tcxx . . $ size_t# iovlen);
2470
2471 /**
2472 * DOC: Key-Agreement Protocol Primitives
2473 *
2474 * API function calls used to invoke Diffie-Hellmand or EC-Diffie-Hellman
2475 * operations.
2476 */
2477
2478 /**
2479 * kcapi_kpp_init() - initialize cipher handle
2480 *
2481 * @handle: [out] cipher handle filled during the call
2482 * @ciphername: [in] kernel crypto API cipher name as specified in
2483 * /proc/crypto
2484 * @flags: [in] flags specifying the type of cipher handle
2485 *
2486 * This function provides the initialization of a KPP cipher handle and
2487 * establishes the connection to the kernel.
2488 *
2489 * On success, a pointer to kcapi_handle object is returned in *handle.
2490 * Function kcapi_kpp_destroy should be called afterwards to free
2491 * resources.
2492 *
2493 * @return 0 upon success;
2494 * -ENOENT - algorithm not available;
2495 * -EOPNOTSUPP - AF_ALG family not available;
2496 * -EINVAL - accept syscall failed
2497 * -ENOMEM - cipher handle cannot be allocated
2498 */
2499 int kcapi_kpp_initcxx . . $ kcapi_kpp_init(b54728dab28c239a).(struct kcapi_handlecxx . . $ kcapi_handle# **handle, const char *ciphername,
2500 uint32_tcxx . . $ uint32_t# flags);
2501
2502 /**
2503 * kcapi_kpp_destroy() - close the cipher handle and release resources
2504 *
2505 * @handle: [in] cipher handle to release
2506 */
2507 void kcapi_kpp_destroycxx . . $ kcapi_kpp_destroy(aba29416d24fdd59).(struct kcapi_handlecxx . . $ kcapi_handle# *handle);
2508
2509 /**
2510 * kcapi_kpp_dh_setparam_pkcs3 - set the PG parameters using PKCS3 format
2511 *
2512 * @handle: [in] cipher handle
2513 * @pkcs3: [in] parameter buffer in DER format
2514 * @pkcs3len: [in] length of key buffer
2515 *
2516 * With this function, the caller sets the PG parameters for subsequent cipher
2517 * operations.
2518 *
2519 * The parameter set must be in DER format as follows
2520 *
2521 * SEQUENCE {
2522 * prime INTEGER ({ dh_get_p }),
2523 * base INTEGER ({ dh_get_g })
2524 *}
2525 *
2526 * The following command generates such parameter set where the output
2527 * file content is has the correct DER structure:
2528 *
2529 * openssl dhparam -outform DER -out dhparam.der 2048
2530 *
2531 * Note, this function defines that the subsequent key generation and
2532 * shared secret operation performs an FFC Diffie-Hellman operation.
2533 *
2534 * After the caller provided the key, the caller may destroy the parameter
2535 * as it is now maintained by the kernel.
2536 *
2537 * @return upon success the value of the maximum size for the KPP
2538 * operation is returned (e.g. the prime size);
2539 * a negative errno-style error code if an error occurred
2540 */
2541 int kcapi_kpp_dh_setparam_pkcs3cxx . . $ kcapi_kpp_dh_setparam_pkcs3(4d0e261613a805ee).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2542 const uint8_tcxx . . $ uint8_t# *pkcs3, uint32_tcxx . . $ uint32_t# pkcs3len);
2543
2544 /* ECC curve IDs */
2545 #define ECC_CURVE_NIST_P192cxx . . $ `lib/kcapi.h:2545:9`! 0x0001
2546 #define ECC_CURVE_NIST_P256cxx . . $ `lib/kcapi.h:2546:9`! 0x0002
2547
2548 /**
2549 * kcapi_kpp_ecdh_setcurve - set the ECC curve to be used for ECDH
2550 *
2551 * @handle: [in] cipher handle
2552 * @curve_id: [in] ID of the ECC curve
2553 *
2554 * With this function, the caller sets the ECC curve for subsequent cipher
2555 * operations. The curve ID is one of the ECC_CURVE_* identifiers.
2556 *
2557 * Note, this function defines that the subsequent key generation and
2558 * shared secret operation performs an ECC Diffie-Hellman operation.
2559 *
2560 * @return 0 upon success;
2561 * a negative errno-style error code if an error occurred
2562 */
2563 int kcapi_kpp_ecdh_setcurvecxx . . $ kcapi_kpp_ecdh_setcurve(1ab0afd9dd9aa87d).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2564 unsigned long curve_id);
2565
2566 /**
2567 * kcapi_kpp_setkey - set the private key of the DH / ECDH operation
2568 *
2569 * @handle: [in] cipher handle
2570 * @key: [in] key buffer
2571 * @keylen: [in] length of key buffer
2572 *
2573 * With this function, the caller sets the key for subsequent DH / ECDH
2574 * public key generation or shared secret generation operations.
2575 *
2576 * If the key / keylen is zero, the kernel tries to generate the private key
2577 * itself and retains it internally. This is useful if the DH / ECDH operation
2578 * shall be performed on ephemeral keys where the caller is only interested
2579 * in eventually obtain the shared secret.
2580 *
2581 * After the caller provided the key, the caller may securely destroy the key
2582 * as it is now maintained by the kernel.
2583 *
2584 * Note, the key can only be set after the DH parameters or the ECC curve
2585 * has been set.
2586 *
2587 * @return in case of success a positive integer is returned that denominates
2588 * the maximum output size of the cryptographic operation -- this value
2589 * must be used as the size of the output buffer for one cryptographic
2590 * operation);
2591 * a negative errno-style error code if an error occurred -- the error
2592 * -EOPNOTSUPP is returned in case a kernel-triggered private
2593 * key generation is requested, but the underlying cipher implementation
2594 * does not support this operation.
2595 */
2596 int kcapi_kpp_setkeycxx . . $ kcapi_kpp_setkey(4d0e261613a805ee).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2597 const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen);
2598
2599 /**
2600 * kcapi_kpp_keygen - generate a public key
2601 *
2602 * @handle: [in] cipher handle
2603 * @pubkey: [out] generated public key
2604 * @pubkeylen: [in] length of key buffer
2605 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
2606 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE - use
2607 * vmsplice access; KCAPI_ACCESS_SENDMSG - sendmsg access)
2608 *
2609 * @return number of bytes returned by the key generation operation upon
2610 * success; a negative errno-style error code if an error occurred
2611 */
2612 ssize_tcxx . . $ ssize_t# kcapi_kpp_keygencxx . . $ kcapi_kpp_keygen(49ba53eeb7197631).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2613 uint8_tcxx . . $ uint8_t# *pubkey, size_tcxx . . $ size_t# pubkeylen, int access);
2614
2615 /**
2616 * kcapi_kpp_ssgen - generate a shared secret
2617 *
2618 * @handle: [in] cipher handle
2619 * @pubkey: [in] public key of peer that shall be used to generate the shared
2620 * secret with
2621 * @pubkeylen: [in] length of the public key buffer
2622 * @ss: [out] generated shared secret
2623 * @sslen: [in] length of key buffer
2624 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
2625 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE - use
2626 * vmsplice access; KCAPI_ACCESS_SENDMSG - sendmsg access)
2627 *
2628 * @return number of bytes returned by the shared secret generation operation
2629 * upon success; a negative errno-style error code if an error occurred
2630 */
2631 ssize_tcxx . . $ ssize_t# kcapi_kpp_ssgencxx . . $ kcapi_kpp_ssgen(454d408f80500942).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2632 const uint8_tcxx . . $ uint8_t# *pubkey, size_tcxx . . $ size_t# pubkeylen,
2633 uint8_tcxx . . $ uint8_t# *ss, size_tcxx . . $ size_t# sslen, int access);
2634
2635 /**
2636 * kcapi_kpp_keygen_aio() - generate a public key (asynchronous one shot)
2637 *
2638 * @handle: [in] cipher handle
2639 * @outiov: [out] head of scatter-gather list of the destination buffers filled
2640 * with the generated public key
2641 * @iovlen: [in] number of scatter-gather list entries
2642 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
2643 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE - use
2644 * vmsplice access; KCAPI_ACCESS_SENDMSG - sendmsg access)
2645 *
2646 * The individual scatter-gather list entries are processed with
2647 * separate invocations of the the given cipher.
2648 *
2649 * The memory should be aligned at the page boundary using
2650 * posix_memalign(sysconf(_SC_PAGESIZE)), If it is not aligned at the page
2651 * boundary, the vmsplice call may not send all data to the kernel.
2652 *
2653 * @return number of bytes verify upon success;
2654 * a negative errno-style error code if an error occurred
2655 */
2656 ssize_tcxx . . $ ssize_t# kcapi_kpp_keygen_aiocxx . . $ kcapi_kpp_keygen_aio(4c3f03a5f648dec0).(struct kcapi_handlecxx . . $ kcapi_handle# *handle, struct ioveccxx . . $ iovec# *outiov,
2657 size_tcxx . . $ size_t# iovlen, int access);
2658
2659 /**
2660 * kcapi_kpp_ssgen_aio() - generate a shared secret (asynchronous one shot)
2661 *
2662 * @handle: [in] cipher handle
2663 * @iniov: [in] head of scatter-gather list of the source buffers with the
2664 * public keys of the peer
2665 * @outiov: [out] head of scatter-gather list of the destination buffers filled
2666 * with the generated shared secret
2667 * @iovlen: [in] number of scatter-gather list entries
2668 * @access: [in] kernel access type (KCAPI_ACCESS_HEURISTIC - use internal
2669 * heuristic for fastest kernel access; KCAPI_ACCESS_VMSPLICE - use
2670 * vmsplice access; KCAPI_ACCESS_SENDMSG - sendmsg access)
2671 *
2672 * The individual scatter-gather list entries are processed with
2673 * separate invocations of the the given cipher.
2674 *
2675 * The memory should be aligned at the page boundary using
2676 * posix_memalign(sysconf(_SC_PAGESIZE)), If it is not aligned at the page
2677 * boundary, the vmsplice call may not send all data to the kernel.
2678 *
2679 * @return number of bytes verify upon success;
2680 * a negative errno-style error code if an error occurred
2681 */
2682 ssize_tcxx . . $ ssize_t# kcapi_kpp_ssgen_aiocxx . . $ kcapi_kpp_ssgen_aio(de09309eb3f0c76b).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2683 struct ioveccxx . . $ iovec# *iniov, struct ioveccxx . . $ iovec# *outiov,
2684 size_tcxx . . $ size_t# iovlen, int access);
2685
2686 /**
2687 * DOC: Key Derivation Functions
2688 *
2689 * API function calls used to invoke a KDF.
2690 * The KDF functions are based on a message digest or keyed message digest
2691 * function. The caller must have the handle allocated with kcapi_md_init.
2692 * If the caller wishes to use a keyed message digest, the caller must invoke
2693 * kcapi_md_setkey before those functions.
2694 */
2695
2696 /**
2697 * kcapi_kdf_dpi() - Double Pipeline Mode Key Derivation Function
2698 *
2699 * @handle: [in] cipher handle allocated by caller. This cipher handle
2700 * must be allocated with kcapi_md_init(). If the caller is interested in
2701 * a KDF using a keyed message digest, the caller should also call
2702 * kcapi_md_setkey() before invoking this function.
2703 * @src: [in] Input data that should be transformed into a key (see below).
2704 * @slen: [in] Length of the src input data.
2705 * @dst: [out] Buffer to store the generated key in,
2706 * @dlen: [in] Length of the dst buffer. This value defines the number of bytes
2707 * generated by the KDF.
2708 *
2709 * This function is an implementation of the KDF in double pipeline iteration
2710 * mode according with counter to SP800-108 section 5.3.
2711 *
2712 * The caller must provide Label || 0x00 || Context in src. This src pointer
2713 * may also be NULL if the caller wishes not to provide anything.
2714 *
2715 * @return 0 upon success;
2716 * a negative errno-style error code if an error occurred
2717 */
2718 ssize_tcxx . . $ ssize_t# kcapi_kdf_dpicxx . . $ kcapi_kdf_dpi(6368db0609283dea).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2719 const uint8_tcxx . . $ uint8_t# *src, size_tcxx . . $ size_t# slen,
2720 uint8_tcxx . . $ uint8_t# *dst, size_tcxx . . $ size_t# dlen);
2721
2722 /**
2723 * kcapi_kdf_fb() - Feedback Mode Key Derivation Function
2724 *
2725 * @handle: [in] cipher handle allocated by caller. This cipher handle
2726 * must be allocated with kcapi_md_init(). If the caller is interested in
2727 * a KDF using a keyed message digest, the caller should also call
2728 * kcapi_md_setkey() before invoking this function.
2729 * @src: [in] Input data that should be transformed into a key (see below).
2730 * @slen: [in] Length of the src input data.
2731 * @dst: [out] Buffer to store the generated key in,
2732 * @dlen: [in] Length of the dst buffer. This value defines the number of bytes
2733 * generated by the KDF.
2734 *
2735 * This function is an implementation of the KDF in feedback mode with a
2736 * non-NULL IV and with counter according to SP800-108 section 5.2. The IV is
2737 * supplied with src and must be equal to the digestsize of the used cipher.
2738 *
2739 * In addition, the caller must provide Label || 0x00 || Context in src. This
2740 * src pointer must not be NULL as the IV is required. The ultimate format of
2741 * the src pointer is IV || Label || 0x00 || Context where the length of the
2742 * IV is equal to the block size (i.e. the digest size of the underlying
2743 * hash) of the PRF.
2744 *
2745 * @return 0 upon success;
2746 * a negative errno-style error code if an error occurred
2747 */
2748 ssize_tcxx . . $ ssize_t# kcapi_kdf_fbcxx . . $ kcapi_kdf_fb(6368db0609283dea).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2749 const uint8_tcxx . . $ uint8_t# *src, size_tcxx . . $ size_t# slen,
2750 uint8_tcxx . . $ uint8_t# *dst, size_tcxx . . $ size_t# dlen);
2751
2752 /**
2753 * kcapi_kdf_ctr() - Counter Mode Key Derivation Function
2754 *
2755 * @handle: [in] cipher handle allocated by caller. This cipher handle
2756 * must be allocated with kcapi_md_init(). If the caller is interested in
2757 * a KDF using a keyed message digest, the caller should also call
2758 * kcapi_md_setkey() before invoking this function.
2759 * @src: [in] Input data that should be transformed into a key (see below).
2760 * @slen: [in] Length of the src input data.
2761 * @dst: [out] Buffer to store the generated key in,
2762 * @dlen: [in] Length of the dst buffer. This value defines the number of bytes
2763 * generated by the KDF.
2764 *
2765 * This function is an implementation of the KDF in counter mode according to
2766 * SP800-108 section 5.1 as well as SP800-56A section 5.8.1 (Single-step KDF).
2767 *
2768 * SP800-108:
2769 * The caller must provide Label || 0x00 || Context in src. This src pointer
2770 * may also be NULL if the caller wishes not to provide anything.
2771 *
2772 * SP800-56A:
2773 * If a keyed MAC is used, the key shall NOT be the shared secret from the DH
2774 * operation, but an independently generated key. The src pointer is defined
2775 * as Z || other info where Z is the shared secret from DH and other info is an
2776 * arbitrary string (see SP800-56A section 5.8.1.2).
2777 *
2778 * @return 0 upon success;
2779 * a negative errno-style error code if an error occurred
2780 */
2781 ssize_tcxx . . $ ssize_t# kcapi_kdf_ctrcxx . . $ kcapi_kdf_ctr(6368db0609283dea).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
2782 const uint8_tcxx . . $ uint8_t# *src, size_tcxx . . $ size_t# slen,
2783 uint8_tcxx . . $ uint8_t# *dst, size_tcxx . . $ size_t# dlen);
2784
2785 /**
2786 * kcapi_pbkdf() - Password-based Key Derivation Function
2787 *
2788 * @hashname: [in] kernel crypto API name of a keyed hash (e.g. hmac(sha1))
2789 * @pw: [in] Password a key shall be derived from
2790 * @pwlen: [in] Length of password string
2791 * @salt: [in] Salt as defined in SP800-132
2792 * @saltlen: [in] Length of salt buffer
2793 * @count: [in] Numbers of iterations to be performed for the PBKDF
2794 * @key: [out] Buffer to store the generated key in
2795 * @keylen: [in] Size of the key to be generated (i.e. length of the key buffer)
2796 *
2797 * This function is an implementation of the PBKDF as defined in SP800-132.
2798 *
2799 * @return 0 upon success;
2800 * a negative errno-style error code if an error occurred
2801 */
2802 ssize_tcxx . . $ ssize_t# kcapi_pbkdfcxx . . $ kcapi_pbkdf(ee93b57b1aa2dcd2).(const char *hashname,
2803 const uint8_tcxx . . $ uint8_t# *pw, uint32_tcxx . . $ uint32_t# pwlen,
2804 const uint8_tcxx . . $ uint8_t# *salt, size_tcxx . . $ size_t# saltlen,
2805 uint32_tcxx . . $ uint32_t# count,
2806 uint8_tcxx . . $ uint8_t# *key, size_tcxx . . $ size_t# keylen);
2807
2808 /**
2809 * kcapi_pbkdf_iteration_count() - Calculate numbers of iterations for a PBKDF
2810 *
2811 * @hashname: [in] kernel crypto API name of a keyed hash (e.g. hmac(sha1))
2812 * @timeshresh: [in] Time duration in nanoseconds that the PBKDF operation
2813 * shall at least require. If that value is 0, a default of (1<<27)
2814 * nanoseconds is used.
2815 *
2816 * The function measures the time the PBKDF operation takes for different
2817 * round counts for the given keyed message digest type.
2818 *
2819 * The result should be taken as the iteration count for a PBKDF operation.
2820 *
2821 * If an error occurs with the PBKDF calculation, a value of 1<<18 is returned.
2822 *
2823 * @return number of iterations a PBKDF should take on this computer.
2824 */
2825 uint32_tcxx . . $ uint32_t# kcapi_pbkdf_iteration_countcxx . . $ kcapi_pbkdf_iteration_count(b323a3098472c9f4).(const char *hashname, uint64_tcxx . . $ uint64_t# timeshresh);
2826
2827 /**
2828 * kcapi_hkdf() - Extract-and-Expand HKDF (RFC5869)
2829 *
2830 * @hashname: [in] kernel crypto API name of a keyed hash (e.g. hmac(sha1))
2831 * @ikm: [in] Input Keying Material (IKM) -- must be provided
2832 * @ikmlen: [in] IKM buffer length -- must be non-zero
2833 * @salt: [in] salt buffer -- may be NULL
2834 * @saltlen: [in] salt buffer length -- may be zero
2835 * @info: [in] info buffer -- may be NULL
2836 * @infolen: [in] info buffer length -- may be zero
2837 * @dst: [out] Buffer to store the generated key in,
2838 * @dlen: [in] Length of the dst buffer. This value defines the number of bytes
2839 * generated by the KDF.
2840 *
2841 * Perform the key-derivation function according to RFC5869. The input data
2842 * is defined in sections 2.2 und 2.3 of RFC5869.
2843 *
2844 * @return 0 upon success;
2845 * a negative errno-style error code if an error occurred
2846 */
2847 ssize_tcxx . . $ ssize_t# kcapi_hkdfcxx . . $ kcapi_hkdf(13e6a99234fd95db).(const char *hashname,
2848 const uint8_tcxx . . $ uint8_t# *ikm, size_tcxx . . $ size_t# ikmlen,
2849 const uint8_tcxx . . $ uint8_t# *salt, uint32_tcxx . . $ uint32_t# saltlen,
2850 const uint8_tcxx . . $ uint8_t# *info, size_tcxx . . $ size_t# infolen,
2851 uint8_tcxx . . $ uint8_t# *dst, size_tcxx . . $ size_t# dlen);
2852
2853 /**
2854 * kcapi_set_maxsplicesize - Set maximum buffer size for splice
2855 *
2856 * @handle: [in] cipher handle allocated by caller.
2857 * @size: [in] New maximum buffer size in bytes
2858 *
2859 * When using vmsplice/splice to avoid copying of data into the kernel,
2860 * the kernel enforces a maximum number of bytes which can be spliced.
2861 * If larger data is to be processed, sendmsg will be used.
2862 *
2863 * Using this call, the buffer size can be increased.
2864 *
2865 * NOTE: Splice uses a pipe pair. Therefore, the maximum number of bytes that
2866 * can be stored with the pipe governs the maximum data size to be spliced.
2867 * Increasing the pipe buffer size is only allowed up to the maximum
2868 * specified with /proc/sys/fs/pipe-max-size.
2869 *
2870 * @return 0 upon success;
2871 * a negative errno-style error code if an error occurred
2872 */
2873 int kcapi_set_maxsplicesizecxx . . $ kcapi_set_maxsplicesize(8327ae3352751b56).(struct kcapi_handlecxx . . $ kcapi_handle# *handle, unsigned int size);
2874
2875 /**
2876 * kcapi_get_maxsplicesize - Get maximum buffer size for splice
2877 *
2878 * @handle: [in] cipher handle allocated by caller.
2879 *
2880 * The call returns the maximum number of bytes that can be handled
2881 * with splice.
2882 *
2883 * @return Maximum buffer size in bytes
2884 */
2885 int kcapi_get_maxsplicesizecxx . . $ kcapi_get_maxsplicesize(cad780c06c088da8).(struct kcapi_handlecxx . . $ kcapi_handle# *handle);
2886
2887 #ifdef __cplusplus
2888 }
2889 #endif
2890
2891 #endif /* KCAPI_H */