net/sctp/auth.c
Source file repositories/reference/linux-study-clean/net/sctp/auth.c
File Facts
- System
- Linux kernel
- Corpus path
net/sctp/auth.c- Extension
.c- Size
- 25103 bytes
- Lines
- 982
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- 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/sha1.hcrypto/sha2.hlinux/slab.hlinux/types.hnet/sctp/sctp.hnet/sctp/auth.h
Detected Declarations
function sctp_hmac_supportedfunction sctp_auth_key_putfunction sctp_auth_shkey_destroyfunction sctp_auth_shkey_releasefunction sctp_auth_shkey_holdfunction sctp_auth_destroy_keysfunction key_for_each_safefunction Examplesfunction sctp_auth_asoc_copy_shkeysfunction key_for_eachfunction sctp_auth_asoc_init_active_keyfunction sctp_auth_asoc_get_hmacfunction __sctp_auth_find_hmacidfunction sctp_auth_asoc_verify_hmac_idfunction sctp_auth_asoc_set_default_hmacfunction __sctp_auth_cidfunction sctp_auth_send_cidfunction sctp_auth_recv_cidfunction zerofunction sctp_auth_ep_add_chunkidfunction sctp_auth_ep_set_hmacsfunction sctp_auth_set_keyfunction key_for_eachfunction sctp_auth_set_active_keyfunction key_for_eachfunction sctp_auth_del_key_idfunction key_for_eachfunction sctp_auth_deact_key_idfunction key_for_eachfunction refcount_readfunction sctp_auth_initfunction sctp_auth_free
Annotated Snippet
if (sctp_auth_send_cid(chunk->chunk_hdr->type, asoc)) {
chunk->auth = 1;
if (!chunk->shkey) {
chunk->shkey = asoc->shkey;
sctp_auth_shkey_hold(chunk->shkey);
}
}
}
return 0;
}
/* Find the endpoint pair shared key based on the key_id */
struct sctp_shared_key *sctp_auth_get_shkey(
const struct sctp_association *asoc,
__u16 key_id)
{
struct sctp_shared_key *key;
/* First search associations set of endpoint pair shared keys */
key_for_each(key, &asoc->endpoint_shared_keys) {
if (key->key_id == key_id) {
if (!key->deactivated)
return key;
break;
}
}
return NULL;
}
const struct sctp_hmac *sctp_auth_get_hmac(__u16 hmac_id)
{
return &sctp_hmac_list[hmac_id];
}
/* Get an hmac description information that we can use to build
* the AUTH chunk
*/
const struct sctp_hmac *
sctp_auth_asoc_get_hmac(const struct sctp_association *asoc)
{
struct sctp_hmac_algo_param *hmacs;
__u16 n_elt;
__u16 id = 0;
int i;
/* If we have a default entry, use it */
if (asoc->default_hmac_id)
return &sctp_hmac_list[asoc->default_hmac_id];
/* Since we do not have a default entry, find the first entry
* we support and return that. Do not cache that id.
*/
hmacs = asoc->peer.peer_hmacs;
if (!hmacs)
return NULL;
n_elt = (ntohs(hmacs->param_hdr.length) -
sizeof(struct sctp_paramhdr)) >> 1;
for (i = 0; i < n_elt; i++) {
id = ntohs(hmacs->hmac_ids[i]);
if (sctp_hmac_supported(id))
return &sctp_hmac_list[id];
}
return NULL;
}
static int __sctp_auth_find_hmacid(__be16 *hmacs, int n_elts, __be16 hmac_id)
{
int found = 0;
int i;
for (i = 0; i < n_elts; i++) {
if (hmac_id == hmacs[i]) {
found = 1;
break;
}
}
return found;
}
/* See if the HMAC_ID is one that we claim as supported */
int sctp_auth_asoc_verify_hmac_id(const struct sctp_association *asoc,
__be16 hmac_id)
{
struct sctp_hmac_algo_param *hmacs;
__u16 n_elt;
Annotation
- Immediate include surface: `crypto/sha1.h`, `crypto/sha2.h`, `linux/slab.h`, `linux/types.h`, `net/sctp/sctp.h`, `net/sctp/auth.h`.
- Detected declarations: `function sctp_hmac_supported`, `function sctp_auth_key_put`, `function sctp_auth_shkey_destroy`, `function sctp_auth_shkey_release`, `function sctp_auth_shkey_hold`, `function sctp_auth_destroy_keys`, `function key_for_each_safe`, `function Examples`, `function sctp_auth_asoc_copy_shkeys`, `function key_for_each`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
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.