ReactOS  0.4.14-dev-50-g13bb5e2
util.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

ULONG ComputeCrc32 (const BYTE *pData, INT iLen, ULONG initial_crc) DECLSPEC_HIDDEN
 
SECURITY_STATUS SECUR32_CreateNTLM1SessionKey (PBYTE password, int len, PBYTE session_key) DECLSPEC_HIDDEN
 
SECURITY_STATUS SECUR32_CreateNTLM2SubKeys (PNegoHelper helper) DECLSPEC_HIDDEN
 
arc4_infoSECUR32_arc4Alloc (void) DECLSPEC_HIDDEN
 
void SECUR32_arc4Init (arc4_info *a4i, const BYTE *key, unsigned int keyLen) DECLSPEC_HIDDEN
 
void SECUR32_arc4Process (arc4_info *a4i, BYTE *inoutString, unsigned int length) DECLSPEC_HIDDEN
 
void SECUR32_arc4Cleanup (arc4_info *a4i) DECLSPEC_HIDDEN
 

Function Documentation

◆ ComputeCrc32()

ULONG ComputeCrc32 ( const BYTE pData,
INT  iLen,
ULONG  initial_crc 
)

Definition at line 109 of file util.c.

110 {
111  ULONG crc = ~initial_crc;
112 
113  while (iLen > 0)
114  {
115  crc = CRC_table[(crc ^ *pData) & 0xff] ^ (crc >> 8);
116  pData++;
117  iLen--;
118  }
119  return ~crc;
120 }
static const ULONG CRC_table[256]
Definition: util.c:29
unsigned int ULONG
Definition: retypes.h:1
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

Referenced by ntlm_CreateSignature().

◆ SECUR32_arc4Alloc()

arc4_info* SECUR32_arc4Alloc ( void  )

Definition at line 189 of file util.c.

190 {
191  arc4_info *a4i = HeapAlloc(GetProcessHeap(), 0, sizeof(arc4_info));
192  return a4i;
193 }
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)

Referenced by ntlm_AcceptSecurityContext(), and ntlm_InitializeSecurityContextW().

◆ SECUR32_arc4Cleanup()

void SECUR32_arc4Cleanup ( arc4_info a4i)

Definition at line 246 of file util.c.

247 {
248  HeapFree(GetProcessHeap(), 0, a4i);
249 }
#define GetProcessHeap()
Definition: compat.h:395
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by ntlm_DeleteSecurityContext().

◆ SECUR32_arc4Init()

void SECUR32_arc4Init ( arc4_info a4i,
const BYTE key,
unsigned int  keyLen 
)

Definition at line 199 of file util.c.

200 {
201  unsigned int keyIndex = 0, stateIndex = 0;
202  unsigned int i, a;
203 
204  TRACE("(%p, %p, %d)\n", a4i, key, keyLen);
205 
206  a4i->x = a4i->y = 0;
207 
208  for (i=0; i<256; i++)
209  a4i->state[i] = i;
210 
211  for (i=0; i<256; i++)
212  {
213  a = a4i->state[i];
214  stateIndex += key[keyIndex] + a;
215  stateIndex &= 0xff;
216  a4i->state[i] = a4i->state[stateIndex];
217  a4i->state[stateIndex] = a;
218  if (++keyIndex >= keyLen)
219  keyIndex = 0;
220  }
221 
222 }
unsigned char x
Definition: ntlm.h:17
unsigned char state[256]
Definition: ntlm.h:18
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
#define a
Definition: ke_i.h:78
#define TRACE(s)
Definition: solgame.cpp:4
#define for
Definition: utility.h:88
unsigned char y
Definition: ntlm.h:17
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
Definition: path.c:42

Referenced by ntlm_AcceptSecurityContext(), and ntlm_InitializeSecurityContextW().

◆ SECUR32_arc4Process()

void SECUR32_arc4Process ( arc4_info a4i,
BYTE inoutString,
unsigned int  length 
)

Definition at line 224 of file util.c.

225 {
226  BYTE *const s=a4i->state;
227  unsigned int x = a4i->x;
228  unsigned int y = a4i->y;
229  unsigned int a, b;
230 
231  while(length--)
232  {
233  x = (x+1) & 0xff;
234  a = s[x];
235  y = (y+a) & 0xff;
236  b = s[y];
237  s[x] = b;
238  s[y] = a;
239  *inoutString++ ^= s[(a+b) & 0xff];
240  }
241 
242  a4i->x = x;
243  a4i->y = y;
244 }
unsigned char x
Definition: ntlm.h:17
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
unsigned char state[256]
Definition: ntlm.h:18
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned char BYTE
Definition: mem.h:68
GLdouble s
Definition: gl.h:2039
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
unsigned char y
Definition: ntlm.h:17
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by ntlm_CreateSignature(), ntlm_DecryptMessage(), and ntlm_EncryptMessage().

◆ SECUR32_CreateNTLM1SessionKey()

SECURITY_STATUS SECUR32_CreateNTLM1SessionKey ( PBYTE  password,
int  len,
PBYTE  session_key 
)

Definition at line 122 of file util.c.

123 {
124  MD4_CTX ctx;
125  BYTE ntlm_hash[16];
126 
127  TRACE("(%p, %p)\n", password, session_key);
128 
129  MD4Init(&ctx);
130  MD4Update(&ctx, password, len);
131  MD4Final(&ctx);
132 
133  memcpy(ntlm_hash, ctx.digest, 0x10);
134 
135  MD4Init(&ctx);
136  MD4Update(&ctx, ntlm_hash, 0x10u);
137  MD4Final(&ctx);
138 
139  memcpy(session_key, ctx.digest, 0x10);
140 
141  return SEC_E_OK;
142 }
unsigned char digest[16]
Definition: util.c:86
VOID WINAPI MD4Final(MD4_CTX *ctx)
Definition: md4.c:113
VOID WINAPI MD4Init(MD4_CTX *ctx)
Definition: md4.c:45
#define TRACE(s)
Definition: solgame.cpp:4
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
#define SEC_E_OK
Definition: winerror.h:2356
Definition: util.c:81
VOID WINAPI MD4Update(MD4_CTX *ctx, const unsigned char *buf, unsigned int len)
Definition: md4.c:59

◆ SECUR32_CreateNTLM2SubKeys()

SECURITY_STATUS SECUR32_CreateNTLM2SubKeys ( PNegoHelper  helper)

Definition at line 156 of file util.c.

157 {
158  helper->crypt.ntlm2.send_sign_key = HeapAlloc(GetProcessHeap(), 0, 16);
159  helper->crypt.ntlm2.send_seal_key = HeapAlloc(GetProcessHeap(), 0, 16);
160  helper->crypt.ntlm2.recv_sign_key = HeapAlloc(GetProcessHeap(), 0, 16);
161  helper->crypt.ntlm2.recv_seal_key = HeapAlloc(GetProcessHeap(), 0, 16);
162 
163  if(helper->mode == NTLM_CLIENT)
164  {
166  helper->crypt.ntlm2.send_sign_key);
168  helper->crypt.ntlm2.send_seal_key);
170  helper->crypt.ntlm2.recv_sign_key);
172  helper->crypt.ntlm2.recv_seal_key);
173  }
174  else
175  {
177  helper->crypt.ntlm2.send_sign_key);
179  helper->crypt.ntlm2.send_seal_key);
181  helper->crypt.ntlm2.recv_sign_key);
183  helper->crypt.ntlm2.recv_seal_key);
184  }
185 
186  return SEC_E_OK;
187 }
HelperMode mode
Definition: ntlm.h:27
static const char server_to_client_sign_constant[]
Definition: util.c:78
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
struct _NegoHelper::@521 crypt
static void SECUR32_CalcNTLM2Subkey(const BYTE *session_key, const char *magic, PBYTE subkey)
Definition: util.c:144
#define SEC_E_OK
Definition: winerror.h:2356
BYTE * session_key
Definition: ntlm.h:36
static const char client_to_server_seal_constant[]
Definition: util.c:77
static const char server_to_client_seal_constant[]
Definition: util.c:79
static const char client_to_server_sign_constant[]
Definition: util.c:76