Lines Matching +full:retain +full:- +full:state +full:- +full:shutdown
2 * algif_rng: User-space interface for random number generators
4 * This file provides the user-space API for random number generators.
11 * 1. Redistributions of source code must retain the above copyright
25 * the restrictions contained in a BSD-style copyright.)
51 MODULE_DESCRIPTION("User-space interface for random number generators");
68 kfree_sensitive(ctx->addtl); in rng_reset_addtl()
69 ctx->addtl = NULL; in rng_reset_addtl()
70 ctx->addtl_len = 0; in rng_reset_addtl()
110 struct sock *sk = sock->sk; in rng_recvmsg()
112 struct rng_ctx *ctx = ask->private; in rng_recvmsg()
114 return _rng_recvmsg(ctx->drng, msg, len, NULL, 0); in rng_recvmsg()
120 struct sock *sk = sock->sk; in rng_test_recvmsg()
122 struct rng_ctx *ctx = ask->private; in rng_test_recvmsg()
125 lock_sock(sock->sk); in rng_test_recvmsg()
126 ret = _rng_recvmsg(ctx->drng, msg, len, ctx->addtl, ctx->addtl_len); in rng_test_recvmsg()
128 release_sock(sock->sk); in rng_test_recvmsg()
136 struct alg_sock *ask = alg_sk(sock->sk); in rng_test_sendmsg()
137 struct rng_ctx *ctx = ask->private; in rng_test_sendmsg()
139 lock_sock(sock->sk); in rng_test_sendmsg()
141 err = -EMSGSIZE; in rng_test_sendmsg()
146 ctx->addtl = kmalloc(len, GFP_KERNEL); in rng_test_sendmsg()
147 if (!ctx->addtl) { in rng_test_sendmsg()
148 err = -ENOMEM; in rng_test_sendmsg()
152 err = memcpy_from_msg(ctx->addtl, msg, len); in rng_test_sendmsg()
157 ctx->addtl_len = len; in rng_test_sendmsg()
160 release_sock(sock->sk); in rng_test_sendmsg()
172 .shutdown = sock_no_shutdown,
191 .shutdown = sock_no_shutdown,
209 return ERR_PTR(-ENOMEM); in rng_bind()
217 pctx->drng = rng; in rng_bind()
227 crypto_free_rng(pctx->drng); in rng_release()
228 kfree_sensitive(pctx->entropy); in rng_release()
235 struct rng_ctx *ctx = ask->private; in rng_sock_destruct()
238 sock_kfree_s(sk, ctx, ctx->len); in rng_sock_destruct()
251 return -ENOMEM; in rng_accept_parent()
253 ctx->len = len; in rng_accept_parent()
254 ctx->addtl = NULL; in rng_accept_parent()
255 ctx->addtl_len = 0; in rng_accept_parent()
258 * No seeding done at that point -- if multiple accepts are in rng_accept_parent()
260 * state of the RNG. in rng_accept_parent()
263 ctx->drng = pctx->drng; in rng_accept_parent()
264 ask->private = ctx; in rng_accept_parent()
265 sk->sk_destruct = rng_sock_destruct; in rng_accept_parent()
268 * Non NULL pctx->entropy means that CAVP test has been initiated on in rng_accept_parent()
271 if (IS_ENABLED(CONFIG_CRYPTO_USER_API_RNG_CAVP) && pctx->entropy) in rng_accept_parent()
272 sk->sk_socket->ops = &algif_rng_test_ops; in rng_accept_parent()
284 return crypto_rng_reset(pctx->drng, seed, seedlen); in rng_setkey()
294 return -EACCES; in rng_setentropy()
296 if (pctx->entropy) in rng_setentropy()
297 return -EINVAL; in rng_setentropy()
300 return -EMSGSIZE; in rng_setentropy()
308 crypto_rng_alg(pctx->drng)->set_ent(pctx->drng, kentropy, len); in rng_setentropy()
313 pctx->entropy = kentropy; in rng_setentropy()