PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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  md5_ctxt
 

Macros

#define MD5_BUFLEN   64
 
#define md5_sta   md5_st.md5_state32[0]
 
#define md5_stb   md5_st.md5_state32[1]
 
#define md5_stc   md5_st.md5_state32[2]
 
#define md5_std   md5_st.md5_state32[3]
 
#define md5_st8   md5_st.md5_state8
 
#define md5_n   md5_count.md5_count64
 
#define md5_n8   md5_count.md5_count8
 
#define MD5_CTX   md5_ctxt
 
#define MD5Init(x)   md5_init((x))
 
#define MD5Update(x, y, z)   md5_loop((x), (y), (z))
 
#define MD5Final(x, y)
 

Functions

void md5_init (md5_ctxt *)
 
void md5_loop (md5_ctxt *, const uint8 *, unsigned int)
 
void md5_pad (md5_ctxt *)
 
void md5_result (uint8 *, md5_ctxt *)
 

Macro Definition Documentation

#define MD5_BUFLEN   64

Definition at line 36 of file md5.h.

Referenced by md5_loop(), and md5_pad().

#define MD5_CTX   md5_ctxt
#define md5_n   md5_count.md5_count64

Definition at line 57 of file md5.h.

#define md5_n8   md5_count.md5_count8

Definition at line 58 of file md5.h.

#define md5_st8   md5_st.md5_state8

Definition at line 50 of file md5.h.

#define md5_sta   md5_st.md5_state32[0]

Definition at line 46 of file md5.h.

#define md5_stb   md5_st.md5_state32[1]

Definition at line 47 of file md5.h.

#define md5_stc   md5_st.md5_state32[2]

Definition at line 48 of file md5.h.

#define md5_std   md5_st.md5_state32[3]

Definition at line 49 of file md5.h.

#define MD5Final (   x,
 
)
Value:
do { \
md5_pad((y)); \
md5_result((x), (y)); \
} while (0)
void md5_result(uint8 *, md5_ctxt *)
Definition: md5.c:215
void md5_pad(md5_ctxt *)
Definition: md5.c:177

Definition at line 73 of file md5.h.

Referenced by int_md5_finish(), and uuid_generate_internal().

#define MD5Init (   x)    md5_init((x))

Definition at line 71 of file md5.h.

Referenced by int_md5_reset(), and uuid_generate_internal().

#define MD5Update (   x,
  y,
 
)    md5_loop((x), (y), (z))

Definition at line 72 of file md5.h.

Referenced by int_md5_update(), and uuid_generate_internal().

Function Documentation

void md5_init ( md5_ctxt )

Definition at line 138 of file md5.c.

References MD5_A0, MD5_B0, md5_ctxt::md5_buf, MD5_C0, MD5_D0, and md5_ctxt::md5_i.

139 {
140  ctxt->md5_n = 0;
141  ctxt->md5_i = 0;
142  ctxt->md5_sta = MD5_A0;
143  ctxt->md5_stb = MD5_B0;
144  ctxt->md5_stc = MD5_C0;
145  ctxt->md5_std = MD5_D0;
146  memset(ctxt->md5_buf, 0, sizeof(ctxt->md5_buf));
147 }
#define MD5_D0
Definition: md5.c:98
#define MD5_A0
Definition: md5.c:95
#define MD5_B0
Definition: md5.c:96
#define MD5_C0
Definition: md5.c:97
void md5_loop ( md5_ctxt ,
const uint8 ,
unsigned  int 
)

Definition at line 150 of file md5.c.

References i, md5_ctxt::md5_buf, MD5_BUFLEN, md5_calc(), md5_ctxt::md5_i, and memmove.

151 {
152  unsigned int gap,
153  i;
154 
155  ctxt->md5_n += len * 8; /* byte to bit */
156  gap = MD5_BUFLEN - ctxt->md5_i;
157 
158  if (len >= gap)
159  {
160  memmove(ctxt->md5_buf + ctxt->md5_i, input, gap);
161  md5_calc(ctxt->md5_buf, ctxt);
162 
163  for (i = gap; i + MD5_BUFLEN <= len; i += MD5_BUFLEN)
164  md5_calc((uint8 *) (input + i), ctxt);
165 
166  ctxt->md5_i = len - i;
167  memmove(ctxt->md5_buf, input + i, ctxt->md5_i);
168  }
169  else
170  {
171  memmove(ctxt->md5_buf + ctxt->md5_i, input, len);
172  ctxt->md5_i += len;
173  }
174 }
unsigned char uint8
Definition: c.h:266
#define MD5_BUFLEN
Definition: md5.h:36
#define memmove(d, s, c)
Definition: c.h:1058
static void md5_calc(uint8 *, md5_ctxt *)
Definition: md5.c:245
int i
void md5_pad ( md5_ctxt )

Definition at line 177 of file md5.c.

References md5_ctxt::md5_buf, MD5_BUFLEN, md5_calc(), md5_ctxt::md5_i, md5_paddat, and memmove.

178 {
179  unsigned int gap;
180 
181  /* Don't count up padding. Keep md5_n. */
182  gap = MD5_BUFLEN - ctxt->md5_i;
183  if (gap > 8)
184  {
185  memmove(ctxt->md5_buf + ctxt->md5_i, md5_paddat,
186  gap - sizeof(ctxt->md5_n));
187  }
188  else
189  {
190  /* including gap == 8 */
191  memmove(ctxt->md5_buf + ctxt->md5_i, md5_paddat, gap);
192  md5_calc(ctxt->md5_buf, ctxt);
193  memmove(ctxt->md5_buf, md5_paddat + gap,
194  MD5_BUFLEN - sizeof(ctxt->md5_n));
195  }
196 
197  /* 8 byte word */
198 #ifndef WORDS_BIGENDIAN
199  memmove(&ctxt->md5_buf[56], &ctxt->md5_n8[0], 8);
200 #else
201  ctxt->md5_buf[56] = ctxt->md5_n8[7];
202  ctxt->md5_buf[57] = ctxt->md5_n8[6];
203  ctxt->md5_buf[58] = ctxt->md5_n8[5];
204  ctxt->md5_buf[59] = ctxt->md5_n8[4];
205  ctxt->md5_buf[60] = ctxt->md5_n8[3];
206  ctxt->md5_buf[61] = ctxt->md5_n8[2];
207  ctxt->md5_buf[62] = ctxt->md5_n8[1];
208  ctxt->md5_buf[63] = ctxt->md5_n8[0];
209 #endif
210 
211  md5_calc(ctxt->md5_buf, ctxt);
212 }
#define MD5_BUFLEN
Definition: md5.h:36
static const uint8 md5_paddat[MD5_BUFLEN]
Definition: md5.c:124
#define memmove(d, s, c)
Definition: c.h:1058
static void md5_calc(uint8 *, md5_ctxt *)
Definition: md5.c:245
void md5_result ( uint8 ,
md5_ctxt  
)

Definition at line 215 of file md5.c.

References memmove.

216 {
217  /* 4 byte words */
218 #ifndef WORDS_BIGENDIAN
219  memmove(digest, &ctxt->md5_st8[0], 16);
220 #else
221  digest[0] = ctxt->md5_st8[3];
222  digest[1] = ctxt->md5_st8[2];
223  digest[2] = ctxt->md5_st8[1];
224  digest[3] = ctxt->md5_st8[0];
225  digest[4] = ctxt->md5_st8[7];
226  digest[5] = ctxt->md5_st8[6];
227  digest[6] = ctxt->md5_st8[5];
228  digest[7] = ctxt->md5_st8[4];
229  digest[8] = ctxt->md5_st8[11];
230  digest[9] = ctxt->md5_st8[10];
231  digest[10] = ctxt->md5_st8[9];
232  digest[11] = ctxt->md5_st8[8];
233  digest[12] = ctxt->md5_st8[15];
234  digest[13] = ctxt->md5_st8[14];
235  digest[14] = ctxt->md5_st8[13];
236  digest[15] = ctxt->md5_st8[12];
237 #endif
238 }
#define memmove(d, s, c)
Definition: c.h:1058