ReactOS  0.4.14-dev-50-g13bb5e2
crypt_lmhash.c File Reference
#include <stdarg.h>
#include "ntstatus.h"
#include "windef.h"
#include "winternl.h"
#include "crypt.h"
Include dependency graph for crypt_lmhash.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 

Functions

static void CRYPT_LMhash (unsigned char *dst, const unsigned char *pwd, const int len)
 
NTSTATUS WINAPI SystemFunction006 (LPCSTR password, LPSTR hash)
 
NTSTATUS WINAPI SystemFunction008 (const BYTE *challenge, const BYTE *hash, LPBYTE response)
 
NTSTATUS WINAPI SystemFunction009 (const BYTE *challenge, const BYTE *hash, LPBYTE response)
 
NTSTATUS WINAPI SystemFunction001 (const BYTE *data, const BYTE *key, LPBYTE output)
 
NTSTATUS WINAPI SystemFunction002 (const BYTE *data, const BYTE *key, LPBYTE output)
 
NTSTATUS WINAPI SystemFunction003 (const BYTE *key, LPBYTE output)
 
NTSTATUS WINAPI SystemFunction004 (const struct ustring *in, const struct ustring *key, struct ustring *out)
 
NTSTATUS WINAPI SystemFunction005 (const struct ustring *in, const struct ustring *key, struct ustring *out)
 
NTSTATUS WINAPI SystemFunction012 (const BYTE *in, const BYTE *key, LPBYTE out)
 
NTSTATUS WINAPI SystemFunction013 (const BYTE *in, const BYTE *key, LPBYTE out)
 
NTSTATUS WINAPI SystemFunction024 (const BYTE *in, const BYTE *key, LPBYTE out)
 
NTSTATUS WINAPI SystemFunction025 (const BYTE *in, const BYTE *key, LPBYTE out)
 

Variables

static const unsigned char CRYPT_LMhash_Magic [8]
 

Macro Definition Documentation

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 29 of file crypt_lmhash.c.

Function Documentation

◆ CRYPT_LMhash()

static void CRYPT_LMhash ( unsigned char dst,
const unsigned char pwd,
const int  len 
)
static

Definition at line 39 of file crypt_lmhash.c.

40 {
41  int i, max = 14;
42  unsigned char tmp_pwd[14] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
43 
44  max = len > max ? max : len;
45 
46  for (i = 0; i < max; i++)
47  tmp_pwd[i] = pwd[i];
48 
50  CRYPT_DEShash( &dst[8], &tmp_pwd[7], CRYPT_LMhash_Magic );
51 }
#define max(a, b)
Definition: svc.c:63
static const unsigned char CRYPT_LMhash_Magic[8]
Definition: crypt_lmhash.c:36
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
void pwd(int argc, const char *argv[])
Definition: cmds.c:1401
GLenum GLsizei len
Definition: glext.h:6722
unsigned char * CRYPT_DEShash(unsigned char *dst, const unsigned char *key, const unsigned char *src) DECLSPEC_HIDDEN
Definition: crypt_des.c:259
GLenum GLenum dst
Definition: glext.h:6340

Referenced by SystemFunction006().

◆ SystemFunction001()

NTSTATUS WINAPI SystemFunction001 ( const BYTE data,
const BYTE key,
LPBYTE  output 
)

Definition at line 121 of file crypt_lmhash.c.

122 {
123  if (!data || !output)
124  return STATUS_UNSUCCESSFUL;
126  return STATUS_SUCCESS;
127 }
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
unsigned char * CRYPT_DEShash(unsigned char *dst, const unsigned char *key, const unsigned char *src) DECLSPEC_HIDDEN
Definition: crypt_des.c:259
return STATUS_SUCCESS
Definition: btrfs.c:2966
Definition: path.c:42

◆ SystemFunction002()

NTSTATUS WINAPI SystemFunction002 ( const BYTE data,
const BYTE key,
LPBYTE  output 
)

Definition at line 144 of file crypt_lmhash.c.

145 {
146  if (!data || !output)
147  return STATUS_UNSUCCESSFUL;
149  return STATUS_SUCCESS;
150 }
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
unsigned char * CRYPT_DESunhash(unsigned char *dst, const unsigned char *key, const unsigned char *src) DECLSPEC_HIDDEN
Definition: crypt_des.c:299
return STATUS_SUCCESS
Definition: btrfs.c:2966
Definition: path.c:42

◆ SystemFunction003()

NTSTATUS WINAPI SystemFunction003 ( const BYTE key,
LPBYTE  output 
)

Definition at line 166 of file crypt_lmhash.c.

167 {
168  if (!output)
169  return STATUS_UNSUCCESSFUL;
171  return STATUS_SUCCESS;
172 }
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
static const unsigned char CRYPT_LMhash_Magic[8]
Definition: crypt_lmhash.c:36
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
unsigned char * CRYPT_DEShash(unsigned char *dst, const unsigned char *key, const unsigned char *src) DECLSPEC_HIDDEN
Definition: crypt_des.c:259
return STATUS_SUCCESS
Definition: btrfs.c:2966
Definition: path.c:42

◆ SystemFunction004()

NTSTATUS WINAPI SystemFunction004 ( const struct ustring in,
const struct ustring key,
struct ustring out 
)

Definition at line 193 of file crypt_lmhash.c.

196 {
197  union {
198  unsigned char uc[8];
199  unsigned int ui[2];
200  } data;
201  unsigned char deskey[7];
202  unsigned int crypt_len, ofs;
203 
204  if (key->Length<=0)
206 
207  crypt_len = ((in->Length+7)&~7);
208  if (out->MaximumLength < (crypt_len+8))
210 
211  data.ui[0] = in->Length;
212  data.ui[1] = 1;
213 
214  if (key->Length<sizeof deskey)
215  {
216  memset(deskey, 0, sizeof deskey);
217  memcpy(deskey, key->Buffer, key->Length);
218  }
219  else
220  memcpy(deskey, key->Buffer, sizeof deskey);
221 
222  CRYPT_DEShash(out->Buffer, deskey, data.uc);
223 
224  for(ofs=0; ofs<(crypt_len-8); ofs+=8)
225  CRYPT_DEShash(out->Buffer+8+ofs, deskey, in->Buffer+ofs);
226 
227  memset(data.uc, 0, sizeof data.uc);
228  memcpy(data.uc, in->Buffer+ofs, in->Length +8-crypt_len);
229  CRYPT_DEShash(out->Buffer+8+ofs, deskey, data.uc);
230 
231  out->Length = crypt_len+8;
232 
233  return STATUS_SUCCESS;
234 }
static void deskey(const unsigned char *key, short edf, ulong32 *keyout)
Definition: des.c:1285
UINT ui
Definition: oleauto.h:49
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:462
static FILE * out
Definition: regtests2xml.c:44
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLuint in
Definition: glext.h:9616
unsigned char * CRYPT_DEShash(unsigned char *dst, const unsigned char *key, const unsigned char *src) DECLSPEC_HIDDEN
Definition: crypt_des.c:259
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define memset(x, y, z)
Definition: compat.h:39
Definition: path.c:42

Referenced by ScmEncryptPassword().

◆ SystemFunction005()

NTSTATUS WINAPI SystemFunction005 ( const struct ustring in,
const struct ustring key,
struct ustring out 
)

Definition at line 252 of file crypt_lmhash.c.

255 {
256  union {
257  unsigned char uc[8];
258  unsigned int ui[2];
259  } data;
260  unsigned char deskey[7];
261  unsigned int ofs, crypt_len;
262 
263  if (key->Length<=0)
265 
266  if (key->Length<sizeof deskey)
267  {
268  memset(deskey, 0, sizeof deskey);
269  memcpy(deskey, key->Buffer, key->Length);
270  }
271  else
272  memcpy(deskey, key->Buffer, sizeof deskey);
273 
274  CRYPT_DESunhash(data.uc, deskey, in->Buffer);
275 
276  if (data.ui[1] != 1)
278 
279  crypt_len = data.ui[0];
280  if (crypt_len > out->MaximumLength)
282 
283  for (ofs=0; (ofs+8)<crypt_len; ofs+=8)
284  CRYPT_DESunhash(out->Buffer+ofs, deskey, in->Buffer+ofs+8);
285 
286  if (ofs<crypt_len)
287  {
288  CRYPT_DESunhash(data.uc, deskey, in->Buffer+ofs+8);
289  memcpy(out->Buffer+ofs, data.uc, crypt_len-ofs);
290  }
291 
292  out->Length = crypt_len;
293 
294  return STATUS_SUCCESS;
295 }
static void deskey(const unsigned char *key, short edf, ulong32 *keyout)
Definition: des.c:1285
UINT ui
Definition: oleauto.h:49
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:462
static FILE * out
Definition: regtests2xml.c:44
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char * CRYPT_DESunhash(unsigned char *dst, const unsigned char *key, const unsigned char *src) DECLSPEC_HIDDEN
Definition: crypt_des.c:299
GLuint in
Definition: glext.h:9616
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define memset(x, y, z)
Definition: compat.h:39
#define STATUS_UNKNOWN_REVISION
Definition: ntstatus.h:310
Definition: path.c:42

Referenced by ScmDecryptPassword().

◆ SystemFunction006()

NTSTATUS WINAPI SystemFunction006 ( LPCSTR  password,
LPSTR  hash 
)

Definition at line 53 of file crypt_lmhash.c.

54 {
55  CRYPT_LMhash( (unsigned char*)hash, (const unsigned char*)password, strlen(password) );
56 
57  return STATUS_SUCCESS;
58 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static void CRYPT_LMhash(unsigned char *dst, const unsigned char *pwd, const int len)
Definition: crypt_lmhash.c:39
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
return STATUS_SUCCESS
Definition: btrfs.c:2966
Definition: _hash_fun.h:40

Referenced by MsvpChangePassword(), MsvpCheckPassword(), SamChangePasswordUser(), SampInitHashes(), and SamSetInformationUser().

◆ SystemFunction008()

NTSTATUS WINAPI SystemFunction008 ( const BYTE challenge,
const BYTE hash,
LPBYTE  response 
)

Definition at line 79 of file crypt_lmhash.c.

80 {
81  BYTE key[7*3];
82 
83  if (!challenge || !response)
84  return STATUS_UNSUCCESSFUL;
85 
86  memset(key, 0, sizeof key);
87  memcpy(key, hash, 0x10);
88 
89  CRYPT_DEShash(response, key, challenge);
90  CRYPT_DEShash(response+8, key+7, challenge);
91  CRYPT_DEShash(response+16, key+14, challenge);
92 
93  return STATUS_SUCCESS;
94 }
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
unsigned char * CRYPT_DEShash(unsigned char *dst, const unsigned char *key, const unsigned char *src) DECLSPEC_HIDDEN
Definition: crypt_des.c:259
return STATUS_SUCCESS
Definition: btrfs.c:2966
Definition: _hash_fun.h:40
#define memset(x, y, z)
Definition: compat.h:39
Definition: path.c:42

Referenced by SystemFunction009().

◆ SystemFunction009()

NTSTATUS WINAPI SystemFunction009 ( const BYTE challenge,
const BYTE hash,
LPBYTE  response 
)

Definition at line 101 of file crypt_lmhash.c.

102 {
103  return SystemFunction008(challenge, hash, response);
104 }
NTSTATUS WINAPI SystemFunction008(const BYTE *challenge, const BYTE *hash, LPBYTE response)
Definition: crypt_lmhash.c:79
Definition: _hash_fun.h:40

◆ SystemFunction012()

NTSTATUS WINAPI SystemFunction012 ( const BYTE in,
const BYTE key,
LPBYTE  out 
)

Definition at line 316 of file crypt_lmhash.c.

317 {
318  if (!in || !out)
319  return STATUS_UNSUCCESSFUL;
320 
321  CRYPT_DEShash(out, key, in);
322  CRYPT_DEShash(out+8, key+7, in+8);
323  return STATUS_SUCCESS;
324 }
static FILE * out
Definition: regtests2xml.c:44
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
GLuint in
Definition: glext.h:9616
unsigned char * CRYPT_DEShash(unsigned char *dst, const unsigned char *key, const unsigned char *src) DECLSPEC_HIDDEN
Definition: crypt_des.c:259
return STATUS_SUCCESS
Definition: btrfs.c:2966
Definition: path.c:42

Referenced by SamChangePasswordUser().

◆ SystemFunction013()

NTSTATUS WINAPI SystemFunction013 ( const BYTE in,
const BYTE key,
LPBYTE  out 
)

Definition at line 345 of file crypt_lmhash.c.

346 {
347  if (!in || !out)
348  return STATUS_UNSUCCESSFUL;
349 
351  CRYPT_DESunhash(out+8, key+7, in+8);
352  return STATUS_SUCCESS;
353 }
static FILE * out
Definition: regtests2xml.c:44
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
unsigned char * CRYPT_DESunhash(unsigned char *dst, const unsigned char *key, const unsigned char *src) DECLSPEC_HIDDEN
Definition: crypt_des.c:299
GLuint in
Definition: glext.h:9616
return STATUS_SUCCESS
Definition: btrfs.c:2966
Definition: path.c:42

◆ SystemFunction024()

NTSTATUS WINAPI SystemFunction024 ( const BYTE in,
const BYTE key,
LPBYTE  out 
)

Definition at line 368 of file crypt_lmhash.c.

369 {
370  BYTE deskey[0x10];
371 
372  memcpy(deskey, key, 4);
373  memcpy(deskey+4, key, 4);
374  memcpy(deskey+8, key, 4);
375  memcpy(deskey+12, key, 4);
376 
378  CRYPT_DEShash(out+8, deskey+7, in+8);
379 
380  return STATUS_SUCCESS;
381 }
static void deskey(const unsigned char *key, short edf, ulong32 *keyout)
Definition: des.c:1285
static FILE * out
Definition: regtests2xml.c:44
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
GLuint in
Definition: glext.h:9616
unsigned char * CRYPT_DEShash(unsigned char *dst, const unsigned char *key, const unsigned char *src) DECLSPEC_HIDDEN
Definition: crypt_des.c:259
return STATUS_SUCCESS
Definition: btrfs.c:2966
Definition: path.c:42

◆ SystemFunction025()

NTSTATUS WINAPI SystemFunction025 ( const BYTE in,
const BYTE key,
LPBYTE  out 
)

Definition at line 396 of file crypt_lmhash.c.

397 {
398  BYTE deskey[0x10];
399 
400  memcpy(deskey, key, 4);
401  memcpy(deskey+4, key, 4);
402  memcpy(deskey+8, key, 4);
403  memcpy(deskey+12, key, 4);
404 
406  CRYPT_DESunhash(out+8, deskey+7, in+8);
407 
408  return STATUS_SUCCESS;
409 }
static void deskey(const unsigned char *key, short edf, ulong32 *keyout)
Definition: des.c:1285
static FILE * out
Definition: regtests2xml.c:44
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
unsigned char * CRYPT_DESunhash(unsigned char *dst, const unsigned char *key, const unsigned char *src) DECLSPEC_HIDDEN
Definition: crypt_des.c:299
GLuint in
Definition: glext.h:9616
return STATUS_SUCCESS
Definition: btrfs.c:2966
Definition: path.c:42

Variable Documentation

◆ CRYPT_LMhash_Magic

const unsigned char CRYPT_LMhash_Magic[8]
static
Initial value:
=
{ 'K', 'G', 'S', '!', '@', '#', '$', '%' }

Definition at line 36 of file crypt_lmhash.c.

Referenced by CRYPT_LMhash(), and SystemFunction003().