fs/smb/server/asn1.c
Source file repositories/reference/linux-study-clean/fs/smb/server/asn1.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/server/asn1.c- Extension
.c- Size
- 5693 bytes
- Lines
- 242
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- 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
linux/module.hlinux/types.hlinux/kernel.hlinux/mm.hlinux/slab.hlinux/oid_registry.hglob.hasn1.hconnection.hauth.hksmbd_spnego_negtokeninit.asn1.hksmbd_spnego_negtokentarg.asn1.h
Detected Declarations
function ksmbd_decode_negTokenInitfunction ksmbd_decode_negTokenTargfunction compute_asn_hdr_len_bytesfunction encode_asn_tagfunction build_spnego_ntlmssp_neg_blobfunction build_spnego_ntlmssp_auth_blobfunction ksmbd_gssapi_this_mechfunction ksmbd_neg_token_init_mech_typefunction ksmbd_neg_token_allocfunction ksmbd_neg_token_init_mech_tokenfunction ksmbd_neg_token_targ_resp_token
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* The ASB.1/BER parsing code is derived from ip_nat_snmp_basic.c which was in
* turn derived from the gxsnmp package by Gregory McLean & Jochen Friedrich
*
* Copyright (c) 2000 RP Internet (www.rpi.net.au).
*/
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/oid_registry.h>
#include "glob.h"
#include "asn1.h"
#include "connection.h"
#include "auth.h"
#include "ksmbd_spnego_negtokeninit.asn1.h"
#include "ksmbd_spnego_negtokentarg.asn1.h"
#define NTLMSSP_OID_LEN 10
static char NTLMSSP_OID_STR[NTLMSSP_OID_LEN] = { 0x2b, 0x06, 0x01, 0x04, 0x01,
0x82, 0x37, 0x02, 0x02, 0x0a };
int
ksmbd_decode_negTokenInit(unsigned char *security_blob, int length,
struct ksmbd_conn *conn)
{
return asn1_ber_decoder(&ksmbd_spnego_negtokeninit_decoder, conn,
security_blob, length);
}
int
ksmbd_decode_negTokenTarg(unsigned char *security_blob, int length,
struct ksmbd_conn *conn)
{
return asn1_ber_decoder(&ksmbd_spnego_negtokentarg_decoder, conn,
security_blob, length);
}
static int compute_asn_hdr_len_bytes(int len)
{
if (len > 0xFFFFFF)
return 4;
else if (len > 0xFFFF)
return 3;
else if (len > 0xFF)
return 2;
else if (len > 0x7F)
return 1;
else
return 0;
}
static void encode_asn_tag(char *buf, unsigned int *ofs, char tag, char seq,
int length)
{
int i;
int index = *ofs;
char hdr_len = compute_asn_hdr_len_bytes(length);
int len = length + 2 + hdr_len;
/* insert tag */
buf[index++] = tag;
if (!hdr_len) {
buf[index++] = len;
} else {
buf[index++] = 0x80 | hdr_len;
for (i = hdr_len - 1; i >= 0; i--)
buf[index++] = (len >> (i * 8)) & 0xFF;
}
/* insert seq */
len = len - (index - *ofs);
buf[index++] = seq;
if (!hdr_len) {
buf[index++] = len;
} else {
buf[index++] = 0x80 | hdr_len;
for (i = hdr_len - 1; i >= 0; i--)
buf[index++] = (len >> (i * 8)) & 0xFF;
}
*ofs += (index - *ofs);
Annotation
- Immediate include surface: `linux/module.h`, `linux/types.h`, `linux/kernel.h`, `linux/mm.h`, `linux/slab.h`, `linux/oid_registry.h`, `glob.h`, `asn1.h`.
- Detected declarations: `function ksmbd_decode_negTokenInit`, `function ksmbd_decode_negTokenTarg`, `function compute_asn_hdr_len_bytes`, `function encode_asn_tag`, `function build_spnego_ntlmssp_neg_blob`, `function build_spnego_ntlmssp_auth_blob`, `function ksmbd_gssapi_this_mech`, `function ksmbd_neg_token_init_mech_type`, `function ksmbd_neg_token_alloc`, `function ksmbd_neg_token_init_mech_token`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- 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.