fs/smb/client/smbencrypt.c
Source file repositories/reference/linux-study-clean/fs/smb/client/smbencrypt.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/client/smbencrypt.c- Extension
.c- Size
- 2124 bytes
- Lines
- 84
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/slab.hlinux/fips.hlinux/fs.hlinux/string.hlinux/kernel.hlinux/random.hcifs_fs_sb.hcifs_unicode.hcifsglob.hcifs_debug.hcifsproto.h../common/md4.h
Detected Declarations
function Copyrightfunction E_md4hash
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
Unix SMB/Netbios implementation.
Version 1.9.
SMB parameters and setup
Copyright (C) Andrew Tridgell 1992-2000
Copyright (C) Luke Kenneth Casson Leighton 1996-2000
Modified by Jeremy Allison 1995.
Copyright (C) Andrew Bartlett <abartlet@samba.org> 2002-2003
Modified by Steve French (sfrench@us.ibm.com) 2002-2003
*/
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/fips.h>
#include <linux/fs.h>
#include <linux/string.h>
#include <linux/kernel.h>
#include <linux/random.h>
#include "cifs_fs_sb.h"
#include "cifs_unicode.h"
#include "cifsglob.h"
#include "cifs_debug.h"
#include "cifsproto.h"
#include "../common/md4.h"
/* following came from the other byteorder.h to avoid include conflicts */
#define CVAL(buf,pos) (((unsigned char *)(buf))[pos])
#define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8)
#define SSVAL(buf,pos,val) SSVALX((buf),(pos),((__u16)(val)))
/* produce a md4 message digest from data of length n bytes */
static int
mdfour(unsigned char *md4_hash, unsigned char *link_str, int link_len)
{
int rc;
struct md4_ctx mctx;
rc = cifs_md4_init(&mctx);
if (rc) {
cifs_dbg(VFS, "%s: Could not init MD4\n", __func__);
goto mdfour_err;
}
rc = cifs_md4_update(&mctx, link_str, link_len);
if (rc) {
cifs_dbg(VFS, "%s: Could not update MD4\n", __func__);
goto mdfour_err;
}
rc = cifs_md4_final(&mctx, md4_hash);
if (rc)
cifs_dbg(VFS, "%s: Could not finalize MD4\n", __func__);
mdfour_err:
return rc;
}
/*
* Creates the MD4 Hash of the users password in NT UNICODE.
*/
int
E_md4hash(const unsigned char *passwd, unsigned char *p16,
const struct nls_table *codepage)
{
int rc;
int len;
__le16 wpwd[129];
/* Password cannot be longer than 128 characters */
if (passwd) /* Password must be converted to NT unicode */
len = cifs_strtoUTF16(wpwd, passwd, 128, codepage);
else {
len = 0;
*wpwd = 0; /* Ensure string is null terminated */
}
rc = mdfour(p16, (unsigned char *) wpwd, len * sizeof(__le16));
memzero_explicit(wpwd, sizeof(wpwd));
return rc;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/fips.h`, `linux/fs.h`, `linux/string.h`, `linux/kernel.h`, `linux/random.h`, `cifs_fs_sb.h`.
- Detected declarations: `function Copyright`, `function E_md4hash`.
- 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.