OpenVAS Scanner 23.32.3
hmacmd5.c File Reference

Unix SMB/CIFS implementation. HMAC MD5 code for use in NTLMv2. More...

#include "hmacmd5.h"
#include <string.h>
Include dependency graph for hmacmd5.c:

Go to the source code of this file.

Functions

void hmac_md5_init_limK_to_64 (const uchar *key, int key_len, HMACMD5Context *ctx)
 The microsoft version of hmac_md5 initialisation.
void hmac_md5_update (const uchar *text, int text_len, HMACMD5Context *ctx)
 Update hmac_md5 "inner" buffer.
void hmac_md5_final (uchar *digest, HMACMD5Context *ctx)
 Finish off hmac_md5 "inner" buffer and generate outer one.
void hmac_md5 (uchar key[16], uchar *data, int data_len, uchar *digest)
 Function to calculate an HMAC MD5 digest from data. Use the microsoft hmacmd5 init method because the key is 16 bytes.

Detailed Description

Unix SMB/CIFS implementation. HMAC MD5 code for use in NTLMv2.

taken direct from rfc2104 implementation and modified for suitable use for ntlmv2.

Definition in file hmacmd5.c.

Function Documentation

◆ hmac_md5()

void hmac_md5 ( uchar key[16],
uchar * data,
int data_len,
uchar * digest )

Function to calculate an HMAC MD5 digest from data. Use the microsoft hmacmd5 init method because the key is 16 bytes.

Definition at line 82 of file hmacmd5.c.

83{
85 hmac_md5_init_limK_to_64 (key, 16, &ctx);
86 if (data_len != 0)
87 {
88 hmac_md5_update (data, data_len, &ctx);
89 }
90 hmac_md5_final (digest, &ctx);
91}
void hmac_md5_final(uchar *digest, HMACMD5Context *ctx)
Finish off hmac_md5 "inner" buffer and generate outer one.
Definition hmacmd5.c:64
void hmac_md5_update(const uchar *text, int text_len, HMACMD5Context *ctx)
Update hmac_md5 "inner" buffer.
Definition hmacmd5.c:55
void hmac_md5_init_limK_to_64(const uchar *key, int key_len, HMACMD5Context *ctx)
The microsoft version of hmac_md5 initialisation.
Definition hmacmd5.c:24

References hmac_md5_final(), hmac_md5_init_limK_to_64(), hmac_md5_update(), and uchar.

Referenced by ntlmssp_genauth_ntlm2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hmac_md5_final()

void hmac_md5_final ( uchar * digest,
HMACMD5Context * ctx )

Finish off hmac_md5 "inner" buffer and generate outer one.

Definition at line 64 of file hmacmd5.c.

66{
67 struct MD5Context ctx_o;
68
69 MD5Final (digest, &ctx->ctx);
70
71 MD5Init (&ctx_o);
72 MD5Update (&ctx_o, ctx->k_opad, 64);
73 MD5Update (&ctx_o, digest, 16);
74 MD5Final (digest, &ctx_o);
75}
void MD5Init(struct MD5Context *ctx)
Definition md5.c:55
void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
Definition md5.c:123
void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
Definition md5.c:71
struct MD5Context ctx
Definition hmacmd5.h:30
uchar k_opad[65]
Definition hmacmd5.h:32

References HMACMD5Context::ctx, HMACMD5Context::k_opad, MD5Final(), MD5Init(), MD5Update(), and uchar.

Referenced by hmac_md5(), nasl_ntv2_owf_gen(), SMBOWFencrypt_ntv2_ntlmssp(), and SMBsesskeygen_ntv2_ntlmssp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hmac_md5_init_limK_to_64()

void hmac_md5_init_limK_to_64 ( const uchar * key,
int key_len,
HMACMD5Context * ctx )

The microsoft version of hmac_md5 initialisation.

Definition at line 24 of file hmacmd5.c.

25{
26 int i;
27
28 /* if key is longer than 64 bytes truncate it */
29 if (key_len > 64)
30 {
31 key_len = 64;
32 }
33
34 /* start out by storing key in pads */
35 ZERO_STRUCT (ctx->k_ipad);
36 ZERO_STRUCT (ctx->k_opad);
37 memcpy (ctx->k_ipad, key, key_len);
38 memcpy (ctx->k_opad, key, key_len);
39
40 /* XOR key with ipad and opad values */
41 for (i = 0; i < 64; i++)
42 {
43 ctx->k_ipad[i] ^= 0x36;
44 ctx->k_opad[i] ^= 0x5c;
45 }
46
47 MD5Init (&ctx->ctx);
48 MD5Update (&ctx->ctx, ctx->k_ipad, 64);
49}
#define ZERO_STRUCT(x)
Definition genrand.c:56
uchar k_ipad[65]
Definition hmacmd5.h:31

References HMACMD5Context::ctx, HMACMD5Context::k_ipad, HMACMD5Context::k_opad, MD5Init(), MD5Update(), uchar, and ZERO_STRUCT.

Referenced by hmac_md5(), nasl_ntv2_owf_gen(), SMBOWFencrypt_ntv2_ntlmssp(), and SMBsesskeygen_ntv2_ntlmssp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hmac_md5_update()

void hmac_md5_update ( const uchar * text,
int text_len,
HMACMD5Context * ctx )

Update hmac_md5 "inner" buffer.

Definition at line 55 of file hmacmd5.c.

56{
57 MD5Update (&ctx->ctx, text, text_len); /* then text of datagram */
58}

References HMACMD5Context::ctx, MD5Update(), and uchar.

Referenced by hmac_md5(), nasl_ntv2_owf_gen(), SMBOWFencrypt_ntv2_ntlmssp(), and SMBsesskeygen_ntv2_ntlmssp().

Here is the call graph for this function:
Here is the caller graph for this function: