OpenVAS Libraries  9.0.3
md5.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  MD5Context
 

Macros

#define HEADER_MD5_H
 
#define uint32   unsigned
 

Functions

void MD5Init (struct MD5Context *context)
 
void MD5Update (struct MD5Context *context, unsigned char const *buf, unsigned len)
 
void MD5Final (unsigned char digest[16], struct MD5Context *context)
 

Macro Definition Documentation

◆ HEADER_MD5_H

#define HEADER_MD5_H

Definition at line 25 of file md5.h.

◆ uint32

#define uint32   unsigned

Definition at line 42 of file md5.h.

Function Documentation

◆ MD5Final()

void MD5Final ( unsigned char  digest[16],
struct MD5Context context 
)

Definition at line 107 of file md5.c.

References MD5Context::bits, and MD5Context::in.

Referenced by hmac_md5_final(), ntlmssp_genauth_ntlm2(), and simple_packet_signature_ntlmssp().

108 {
109  unsigned int count;
110  unsigned char *p;
111 
112  /* Compute number of bytes mod 64 */
113  count = (ctx->bits[0] >> 3) & 0x3F;
114 
115  /* Set the first char of padding to 0x80. This is safe since there is
116  always at least one byte free */
117  p = ctx->in + count;
118  *p++ = 0x80;
119 
120  /* Bytes of padding needed to make 64 bytes */
121  count = 64 - 1 - count;
122 
123  /* Pad out to 56 mod 64 */
124  if (count < 8) {
125  /* Two lots of padding: Pad the first block to 64 bytes */
126  memset(p, 0, count);
127  byteReverse(ctx->in, 16);
128  MD5Transform(ctx->buf, (uint32 *) ctx->in);
129 
130  /* Now fill the next block with 56 bytes */
131  memset(ctx->in, 0, 56);
132  } else {
133  /* Pad block to 56 bytes */
134  memset(p, 0, count - 8);
135  }
136  byteReverse(ctx->in, 14);
137 
138  /* Append length in bits and transform */
139  ((uint32 *) ctx->in)[14] = ctx->bits[0];
140  ((uint32 *) ctx->in)[15] = ctx->bits[1];
141 
142  MD5Transform(ctx->buf, (uint32 *) ctx->in);
143  byteReverse((unsigned char *) ctx->buf, 4);
144  memmove(digest, ctx->buf, 16);
145  memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
146 }
#define uint32
Definition: genrand.c:49
Here is the caller graph for this function:

◆ MD5Init()

void MD5Init ( struct MD5Context context)

Definition at line 44 of file md5.c.

References MD5Context::bits, and MD5Context::buf.

Referenced by hmac_md5_final(), hmac_md5_init_limK_to_64(), ntlmssp_genauth_ntlm2(), and simple_packet_signature_ntlmssp().

45 {
46  ctx->buf[0] = 0x67452301;
47  ctx->buf[1] = 0xefcdab89;
48  ctx->buf[2] = 0x98badcfe;
49  ctx->buf[3] = 0x10325476;
50 
51  ctx->bits[0] = 0;
52  ctx->bits[1] = 0;
53 }
Here is the caller graph for this function:

◆ MD5Update()

void MD5Update ( struct MD5Context context,
unsigned char const *  buf,
unsigned  len 
)

Definition at line 59 of file md5.c.

References MD5Context::bits, MD5Context::in, and uint32.

Referenced by hmac_md5_final(), hmac_md5_init_limK_to_64(), hmac_md5_update(), ntlmssp_genauth_ntlm2(), and simple_packet_signature_ntlmssp().

60 {
61  register uint32 t;
62 
63  /* Update bitcount */
64 
65  t = ctx->bits[0];
66  if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
67  ctx->bits[1]++; /* Carry from low to high */
68  ctx->bits[1] += len >> 29;
69 
70  t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
71 
72  /* Handle any leading odd-sized chunks */
73 
74  if (t) {
75  unsigned char *p = (unsigned char *) ctx->in + t;
76 
77  t = 64 - t;
78  if (len < t) {
79  memmove(p, buf, len);
80  return;
81  }
82  memmove(p, buf, t);
83  byteReverse(ctx->in, 16);
84  MD5Transform(ctx->buf, (uint32 *) ctx->in);
85  buf += t;
86  len -= t;
87  }
88  /* Process data in 64-byte chunks */
89 
90  while (len >= 64) {
91  memmove(ctx->in, buf, 64);
92  byteReverse(ctx->in, 16);
93  MD5Transform(ctx->buf, (uint32 *) ctx->in);
94  buf += 64;
95  len -= 64;
96  }
97 
98  /* Handle any remaining bytes of data. */
99 
100  memmove(ctx->in, buf, len);
101 }
#define uint32
Definition: genrand.c:49
Here is the caller graph for this function: