Header And Logo

PostgreSQL
| The world's most advanced open source database.

Data Structures | Defines | Functions

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

Defines

#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 *)

Define 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

Definition at line 70 of file md5.h.

Referenced by init_md5(), int_md5_finish(), int_md5_free(), int_md5_reset(), and int_md5_update().

#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,
  y 
)
Value:
do {                \
    md5_pad((y));       \
    md5_result((x), (y));   \
} while (0)

Definition at line 73 of file md5.h.

Referenced by int_md5_finish().

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

Definition at line 71 of file md5.h.

Referenced by int_md5_reset().

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

Definition at line 72 of file md5.h.

Referenced by int_md5_update().


Function Documentation

void md5_init ( md5_ctxt  ) 

Definition at line 138 of file md5.c.

References md5_ctxt::md5_buf, and md5_ctxt::md5_i.

{
    ctxt->md5_n = 0;
    ctxt->md5_i = 0;
    ctxt->md5_sta = MD5_A0;
    ctxt->md5_stb = MD5_B0;
    ctxt->md5_stc = MD5_C0;
    ctxt->md5_std = MD5_D0;
    memset(ctxt->md5_buf, 0, sizeof(ctxt->md5_buf));
}

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.

{
    unsigned int gap,
                i;

    ctxt->md5_n += len * 8;     /* byte to bit */
    gap = MD5_BUFLEN - ctxt->md5_i;

    if (len >= gap)
    {
        memmove(ctxt->md5_buf + ctxt->md5_i, input, gap);
        md5_calc(ctxt->md5_buf, ctxt);

        for (i = gap; i + MD5_BUFLEN <= len; i += MD5_BUFLEN)
            md5_calc((uint8 *) (input + i), ctxt);

        ctxt->md5_i = len - i;
        memmove(ctxt->md5_buf, input + i, ctxt->md5_i);
    }
    else
    {
        memmove(ctxt->md5_buf + ctxt->md5_i, input, len);
        ctxt->md5_i += len;
    }
}

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.

{
    unsigned int gap;

    /* Don't count up padding. Keep md5_n. */
    gap = MD5_BUFLEN - ctxt->md5_i;
    if (gap > 8)
    {
        memmove(ctxt->md5_buf + ctxt->md5_i, md5_paddat,
                gap - sizeof(ctxt->md5_n));
    }
    else
    {
        /* including gap == 8 */
        memmove(ctxt->md5_buf + ctxt->md5_i, md5_paddat, gap);
        md5_calc(ctxt->md5_buf, ctxt);
        memmove(ctxt->md5_buf, md5_paddat + gap,
                MD5_BUFLEN - sizeof(ctxt->md5_n));
    }

    /* 8 byte word */
#ifndef WORDS_BIGENDIAN
    memmove(&ctxt->md5_buf[56], &ctxt->md5_n8[0], 8);
#else
    ctxt->md5_buf[56] = ctxt->md5_n8[7];
    ctxt->md5_buf[57] = ctxt->md5_n8[6];
    ctxt->md5_buf[58] = ctxt->md5_n8[5];
    ctxt->md5_buf[59] = ctxt->md5_n8[4];
    ctxt->md5_buf[60] = ctxt->md5_n8[3];
    ctxt->md5_buf[61] = ctxt->md5_n8[2];
    ctxt->md5_buf[62] = ctxt->md5_n8[1];
    ctxt->md5_buf[63] = ctxt->md5_n8[0];
#endif

    md5_calc(ctxt->md5_buf, ctxt);
}

void md5_result ( uint8 ,
md5_ctxt  
)

Definition at line 215 of file md5.c.

References memmove.

{
    /* 4 byte words */
#ifndef WORDS_BIGENDIAN
    memmove(digest, &ctxt->md5_st8[0], 16);
#else
    digest[0] = ctxt->md5_st8[3];
    digest[1] = ctxt->md5_st8[2];
    digest[2] = ctxt->md5_st8[1];
    digest[3] = ctxt->md5_st8[0];
    digest[4] = ctxt->md5_st8[7];
    digest[5] = ctxt->md5_st8[6];
    digest[6] = ctxt->md5_st8[5];
    digest[7] = ctxt->md5_st8[4];
    digest[8] = ctxt->md5_st8[11];
    digest[9] = ctxt->md5_st8[10];
    digest[10] = ctxt->md5_st8[9];
    digest[11] = ctxt->md5_st8[8];
    digest[12] = ctxt->md5_st8[15];
    digest[13] = ctxt->md5_st8[14];
    digest[14] = ctxt->md5_st8[13];
    digest[15] = ctxt->md5_st8[12];
#endif
}