In addition to the send/write/read/recv system call familty, the AF_ALG interface can be accessed with the zero-copy interface of splice/vmsplice. As the name indicates, the kernel tries to avoid a copy operation into kernel space.
The zero-copy operation requires data to be aligned at the page boundary. Non-aligned data can be used as well, but may require more operations of the kernel which would defeat the speed gains obtained from the zero-copy interface.
The system-interent limit for the size of one zero-copy operation is 16 pages. If more data is to be sent to AF_ALG, user space must slice the input into segments with a maximum size of 16 pages.
Zero-copy can be used with the following code example (a complete working example is provided with libkcapi):
int pipes[2]; pipe(pipes); /* input data in iov */ vmsplice(pipes[1], iov, iovlen, SPLICE_F_GIFT); /* opfd is the file descriptor returned from accept() system call */ splice(pipes[0], NULL, opfd, NULL, ret, 0); read(opfd, out, outlen);