/usr/src/linux-headers-5.15.0-190/include/crypto
NameSizeModeActions
internal/-0755rm
acompress.h90730644editdlrm
aead.h188320644editdlrm
aes.h25630644editdlrm
akcipher.h132320644editdlrm
algapi.h75450644editdlrm
arc4.h4840644editdlrm
asym_tpm_subtype.h5210644editdlrm
authenc.h6350644editdlrm
b128ops.h24710644editdlrm
blake2b.h16370644editdlrm
blake2s.h26800644editdlrm
blowfish.h4150644editdlrm
cast5.h5900644editdlrm
cast6.h6070644editdlrm
cast_common.h2320644editdlrm
chacha.h33950644editdlrm
chacha20poly1305.h16990644editdlrm
cryptd.h20500644editdlrm
ctr.h14560644editdlrm
curve25519.h20650644editdlrm
des.h17240644editdlrm
dh.h25740644editdlrm
drbg.h92090644editdlrm
ecc_curve.h13370644editdlrm
ecdh.h24870644editdlrm
engine.h42090644editdlrm
gcm.h8670644editdlrm
gf128mul.h96470644editdlrm
ghash.h3880644editdlrm
hash.h348590644editdlrm
hash_info.h9980644editdlrm
hmac.h1730644editdlrm
if_alg.h68440644editdlrm
kpp.h101440644editdlrm
md5.h4970644editdlrm
nhpoly1305.h22360644editdlrm
null.h3460644editdlrm
padlock.h4380644editdlrm
pcrypt.h8150644editdlrm
pkcs7.h11810644editdlrm
poly1305.h25000644editdlrm
public_key.h24400644editdlrm
rng.h67480644editdlrm
scatterwalk.h39890644editdlrm
serpent.h6960644editdlrm
sha1.h12100644editdlrm
sha1_base.h25120644editdlrm
sha2.h38490644editdlrm
sha3.h8790644editdlrm
sha256_base.h26210644editdlrm
sha512_base.h32550644editdlrm
skcipher.h204280644editdlrm
sm2.h7490644editdlrm
sm3.h8970644editdlrm
sm3_base.h26080644editdlrm
sm4.h11440644editdlrm
streebog.h9490644editdlrm
twofish.h7430644editdlrm
xts.h11250644editdlrm
Edit: /usr/src/linux-headers-5.15.0-190/include/crypto/if_alg.h (6844B)
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * if_alg: User-space algorithm interface * * Copyright (c) 2010 Herbert Xu */ #ifndef _CRYPTO_IF_ALG_H #define _CRYPTO_IF_ALG_H #include #include #include #include #include #include #include #include #include #define ALG_MAX_PAGES 16 struct crypto_async_request; struct alg_sock { /* struct sock must be the first member of struct alg_sock */ struct sock sk; struct sock *parent; atomic_t refcnt; atomic_t nokey_refcnt; const struct af_alg_type *type; void *private; }; struct af_alg_control { struct af_alg_iv *iv; int op; unsigned int aead_assoclen; }; struct af_alg_type { void *(*bind)(const char *name, u32 type, u32 mask); void (*release)(void *private); int (*setkey)(void *private, const u8 *key, unsigned int keylen); int (*setentropy)(void *private, sockptr_t entropy, unsigned int len); int (*accept)(void *private, struct sock *sk); int (*accept_nokey)(void *private, struct sock *sk); int (*setauthsize)(void *private, unsigned int authsize); struct proto_ops *ops; struct proto_ops *ops_nokey; struct module *owner; char name[14]; }; struct af_alg_sgl { struct scatterlist sg[ALG_MAX_PAGES + 1]; struct page *pages[ALG_MAX_PAGES]; unsigned int npages; }; /* TX SGL entry */ struct af_alg_tsgl { struct list_head list; unsigned int cur; /* Last processed SG entry */ struct scatterlist sg[]; /* Array of SGs forming the SGL */ }; #define MAX_SGL_ENTS ((4096 - sizeof(struct af_alg_tsgl)) / \ sizeof(struct scatterlist) - 1) /* RX SGL entry */ struct af_alg_rsgl { struct af_alg_sgl sgl; struct list_head list; size_t sg_num_bytes; /* Bytes of data in that SGL */ }; /** * struct af_alg_async_req - definition of crypto request * @iocb: IOCB for AIO operations * @sk: Socket the request is associated with * @first_rsgl: First RX SG * @last_rsgl: Pointer to last RX SG * @rsgl_list: Track RX SGs * @tsgl: Private, per request TX SGL of buffers to process * @tsgl_entries: Number of entries in priv. TX SGL * @outlen: Number of output bytes generated by crypto op * @areqlen: Length of this data structure * @cra_u: Cipher request */ struct af_alg_async_req { struct kiocb *iocb; struct sock *sk; struct af_alg_rsgl first_rsgl; struct af_alg_rsgl *last_rsgl; struct list_head rsgl_list; struct scatterlist *tsgl; unsigned int tsgl_entries; unsigned int outlen; unsigned int areqlen; union { struct aead_request aead_req; struct skcipher_request skcipher_req; } cra_u; /* req ctx trails this struct */ }; /** * struct af_alg_ctx - definition of the crypto context * * The crypto context tracks the input data during the lifetime of an AF_ALG * socket. * * @tsgl_list: Link to TX SGL * @iv: IV for cipher operation * @aead_assoclen: Length of AAD for AEAD cipher operations * @completion: Work queue for synchronous operation * @used: TX bytes sent to kernel. This variable is used to * ensure that user space cannot cause the kernel * to allocate too much memory in sendmsg operation. * @rcvused: Total RX bytes to be filled by kernel. This variable * is used to ensure user space cannot cause the kernel * to allocate too much memory in a recvmsg operation. * @more: More data to be expected from user space? * @merge: Shall new data from user space be merged into existing * SG? * @enc: Cryptographic operation to be performed when * recvmsg is invoked. * @write: True if we are in the middle of a write. * @init: True if metadata has been sent. * @len: Length of memory allocated for this data structure. * @inflight: Non-zero when AIO requests are in flight. */ struct af_alg_ctx { struct list_head tsgl_list; void *iv; size_t aead_assoclen; struct crypto_wait wait; size_t used; atomic_t rcvused; bool more:1, merge:1, enc:1, write:1, init:1; unsigned int len; unsigned int inflight; }; int af_alg_register_type(const struct af_alg_type *type); int af_alg_unregister_type(const struct af_alg_type *type); int af_alg_release(struct socket *sock); void af_alg_release_parent(struct sock *sk); int af_alg_accept(struct sock *sk, struct socket *newsock, bool kern); int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len); void af_alg_free_sg(struct af_alg_sgl *sgl); static inline struct alg_sock *alg_sk(struct sock *sk) { return (struct alg_sock *)sk; } /** * Size of available buffer for sending data from user space to kernel. * * @sk socket of connection to user space * @return number of bytes still available */ static inline int af_alg_sndbuf(struct sock *sk) { struct alg_sock *ask = alg_sk(sk); struct af_alg_ctx *ctx = ask->private; return max_t(int, max_t(int, sk->sk_sndbuf & PAGE_MASK, PAGE_SIZE) - ctx->used, 0); } /** * Can the send buffer still be written to? * * @sk socket of connection to user space * @return true => writable, false => not writable */ static inline bool af_alg_writable(struct sock *sk) { return PAGE_SIZE <= af_alg_sndbuf(sk); } /** * Size of available buffer used by kernel for the RX user space operation. * * @sk socket of connection to user space * @return number of bytes still available */ static inline int af_alg_rcvbuf(struct sock *sk) { struct alg_sock *ask = alg_sk(sk); struct af_alg_ctx *ctx = ask->private; return max_t(int, max_t(int, sk->sk_rcvbuf & PAGE_MASK, PAGE_SIZE) - atomic_read(&ctx->rcvused), 0); } /** * Can the RX buffer still be written to? * * @sk socket of connection to user space * @return true => writable, false => not writable */ static inline bool af_alg_readable(struct sock *sk) { return PAGE_SIZE <= af_alg_rcvbuf(sk); } unsigned int af_alg_count_tsgl(struct sock *sk, size_t bytes); void af_alg_pull_tsgl(struct sock *sk, size_t used, struct scatterlist *dst); void af_alg_wmem_wakeup(struct sock *sk); int af_alg_wait_for_data(struct sock *sk, unsigned flags, unsigned min); int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size, unsigned int ivsize); ssize_t af_alg_sendpage(struct socket *sock, struct page *page, int offset, size_t size, int flags); void af_alg_free_resources(struct af_alg_async_req *areq); void af_alg_async_cb(struct crypto_async_request *_req, int err); __poll_t af_alg_poll(struct file *file, struct socket *sock, poll_table *wait); struct af_alg_async_req *af_alg_alloc_areq(struct sock *sk, unsigned int areqlen); int af_alg_get_rsgl(struct sock *sk, struct msghdr *msg, int flags, struct af_alg_async_req *areq, size_t maxsize, size_t *outlen); #endif /* _CRYPTO_IF_ALG_H */