crypto/algif_aead.c
Source file repositories/reference/linux-study-clean/crypto/algif_aead.c
File Facts
- System
- Linux kernel
- Corpus path
crypto/algif_aead.c- Extension
.c- Size
- 12009 bytes
- Lines
- 450
- Domain
- Kernel Services
- Bucket
- crypto
- Inferred role
- Kernel Services: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
crypto/internal/aead.hcrypto/scatterwalk.hcrypto/if_alg.hlinux/init.hlinux/list.hlinux/kernel.hlinux/mm.hlinux/module.hlinux/net.hnet/sock.h
Detected Declarations
function Copyrightfunction aead_sendmsgfunction _aead_recvmsgfunction aead_recvmsgfunction aead_check_keyfunction aead_sendmsg_nokeyfunction aead_recvmsg_nokeyfunction aead_releasefunction aead_setauthsizefunction aead_setkeyfunction aead_sock_destructfunction aead_accept_parent_nokeyfunction aead_accept_parentfunction algif_aead_initfunction algif_aead_exitmodule init algif_aead_init
Annotated Snippet
static struct proto_ops algif_aead_ops = {
.family = PF_ALG,
.connect = sock_no_connect,
.socketpair = sock_no_socketpair,
.getname = sock_no_getname,
.ioctl = sock_no_ioctl,
.listen = sock_no_listen,
.shutdown = sock_no_shutdown,
.mmap = sock_no_mmap,
.bind = sock_no_bind,
.accept = sock_no_accept,
.release = af_alg_release,
.sendmsg = aead_sendmsg,
.recvmsg = aead_recvmsg,
.poll = af_alg_poll,
};
static int aead_check_key(struct socket *sock)
{
int err = 0;
struct sock *psk;
struct alg_sock *pask;
struct crypto_aead *tfm;
struct sock *sk = sock->sk;
struct alg_sock *ask = alg_sk(sk);
lock_sock(sk);
if (!atomic_read(&ask->nokey_refcnt))
goto unlock_child;
psk = ask->parent;
pask = alg_sk(ask->parent);
tfm = pask->private;
err = -ENOKEY;
lock_sock_nested(psk, SINGLE_DEPTH_NESTING);
if (crypto_aead_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
goto unlock;
atomic_dec(&pask->nokey_refcnt);
atomic_set(&ask->nokey_refcnt, 0);
err = 0;
unlock:
release_sock(psk);
unlock_child:
release_sock(sk);
return err;
}
static int aead_sendmsg_nokey(struct socket *sock, struct msghdr *msg,
size_t size)
{
int err;
err = aead_check_key(sock);
if (err)
return err;
return aead_sendmsg(sock, msg, size);
}
static int aead_recvmsg_nokey(struct socket *sock, struct msghdr *msg,
size_t ignored, int flags)
{
int err;
err = aead_check_key(sock);
if (err)
return err;
return aead_recvmsg(sock, msg, ignored, flags);
}
static struct proto_ops algif_aead_ops_nokey = {
.family = PF_ALG,
.connect = sock_no_connect,
.socketpair = sock_no_socketpair,
.getname = sock_no_getname,
.ioctl = sock_no_ioctl,
.listen = sock_no_listen,
.shutdown = sock_no_shutdown,
.mmap = sock_no_mmap,
.bind = sock_no_bind,
.accept = sock_no_accept,
Annotation
- Immediate include surface: `crypto/internal/aead.h`, `crypto/scatterwalk.h`, `crypto/if_alg.h`, `linux/init.h`, `linux/list.h`, `linux/kernel.h`, `linux/mm.h`, `linux/module.h`.
- Detected declarations: `function Copyright`, `function aead_sendmsg`, `function _aead_recvmsg`, `function aead_recvmsg`, `function aead_check_key`, `function aead_sendmsg_nokey`, `function aead_recvmsg_nokey`, `function aead_release`, `function aead_setauthsize`, `function aead_setkey`.
- Atlas domain: Kernel Services / crypto.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.