linux/crypto/algif_skcipher.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * algif_skcipher: User-space interface for skcipher algorithms
 *
 * This file provides the user-space API for symmetric key ciphers.
 *
 * Copyright (c) 2010 Herbert Xu <[email protected]>
 *
 * The following concept of the memory management is used:
 *
 * The kernel maintains two SGLs, the TX SGL and the RX SGL. The TX SGL is
 * filled by user space with the data submitted via sendmsg. Filling up the TX
 * SGL does not cause a crypto operation -- the data will only be tracked by
 * the kernel. Upon receipt of one recvmsg call, the caller must provide a
 * buffer which is tracked with the RX SGL.
 *
 * During the processing of the recvmsg operation, the cipher request is
 * allocated and prepared. As part of the recvmsg operation, the processed
 * TX buffers are extracted from the TX SGL into a separate SGL.
 *
 * After the completion of the crypto operation, the RX SGL and the cipher
 * request is released. The extracted TX SGL parts are released together with
 * the RX SGL release.
 */

#include <crypto/scatterwalk.h>
#include <crypto/skcipher.h>
#include <crypto/if_alg.h>
#include <linux/init.h>
#include <linux/list.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/net.h>
#include <net/sock.h>

static int skcipher_sendmsg(struct socket *sock, struct msghdr *msg,
			    size_t size)
{}

static int algif_skcipher_export(struct sock *sk, struct skcipher_request *req)
{}

static void algif_skcipher_done(void *data, int err)
{}

static int _skcipher_recvmsg(struct socket *sock, struct msghdr *msg,
			     size_t ignored, int flags)
{}

static int skcipher_recvmsg(struct socket *sock, struct msghdr *msg,
			    size_t ignored, int flags)
{}

static struct proto_ops algif_skcipher_ops =;

static int skcipher_check_key(struct socket *sock)
{}

static int skcipher_sendmsg_nokey(struct socket *sock, struct msghdr *msg,
				  size_t size)
{}

static int skcipher_recvmsg_nokey(struct socket *sock, struct msghdr *msg,
				  size_t ignored, int flags)
{}

static struct proto_ops algif_skcipher_ops_nokey =;

static void *skcipher_bind(const char *name, u32 type, u32 mask)
{}

static void skcipher_release(void *private)
{}

static int skcipher_setkey(void *private, const u8 *key, unsigned int keylen)
{}

static void skcipher_sock_destruct(struct sock *sk)
{}

static int skcipher_accept_parent_nokey(void *private, struct sock *sk)
{}

static int skcipher_accept_parent(void *private, struct sock *sk)
{}

static const struct af_alg_type algif_type_skcipher =;

static int __init algif_skcipher_init(void)
{}

static void __exit algif_skcipher_exit(void)
{}

module_init();
module_exit(algif_skcipher_exit);
MODULE_DESCRIPTION();
MODULE_LICENSE();