SDL_test_md5.h File Reference
`#include "begin_code.h"`
`#include "close_code.h"`
Include dependency graph for SDL_test_md5.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

struct | SDLTest_Md5Context

## Typedefs

typedef unsigned long int | MD5UINT4

## Functions

void | SDLTest_Md5Init (SDLTest_Md5Context *mdContext)
| initialize the context More...
void | SDLTest_Md5Update (SDLTest_Md5Context *mdContext, unsigned char *inBuf, unsigned int inLen)
| update digest from variable length data More...
void | SDLTest_Md5Final (SDLTest_Md5Context *mdContext)
| complete digest computation More...

## Detailed Description

Include file for SDL test framework.

This code is a part of the SDL2_test library, not the main SDL library.

Definition in file SDL_test_md5.h.

## Typedef Documentation

typedef unsigned long int MD5UINT4

Definition at line 68 of file SDL_test_md5.h.

## Function Documentation

void SDLTest_Md5Final | ( | SDLTest_Md5Context * | mdContext | ) |

complete digest computation

Parameters

  mdContext | pointer to context variable

Note: The function terminates the message-digest computation and ends with the desired message digest in mdContext.digest[0..15]. Always call before using the digest[] variable.

Definition at line 180 of file SDL_test_md5.c.

References SDLTest_Md5Context::buf, SDLTest_Md5Context::digest, i, SDLTest_Md5Context::i, SDLTest_Md5Context::in, MD5PADDING, NULL, SDLTest_Md5Transform(), and SDLTest_Md5Update().

Referenced by SDLTest_GenerateExecKey().

{
MD5UINT4 in[16];
int mdi;
unsigned int i, ii;
unsigned int padLen;
if (mdContext == NULL) return;
/*
* save number of bits
*/
in[14] = mdContext->i[0];
in[15] = mdContext->i[1];
/*
* compute number of bytes mod 64
*/
mdi = (int) ((mdContext->i[0] >> 3) & 0x3F);
/*
* pad out to 56 mod 64
*/
padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
SDLTest_Md5Update(mdContext, MD5PADDING, padLen);
/*
* append length in bits and transform
*/
for (i = 0, ii = 0; i < 14; i++, ii += 4)
in[i] = (((MD5UINT4) mdContext->in[ii + 3]) << 24) |
(((MD5UINT4) mdContext->in[ii + 2]) << 16) |
(((MD5UINT4) mdContext->in[ii + 1]) << 8) |
((MD5UINT4) mdContext->in[ii]);
SDLTest_Md5Transform(mdContext->buf, in);
/*
* store buffer in digest
*/
for (i = 0, ii = 0; i < 4; i++, ii += 4) {
mdContext->digest[ii] = (unsigned char) (mdContext->buf[i] & 0xFF);
mdContext->digest[ii + 1] =
(unsigned char) ((mdContext->buf[i] >> 8) & 0xFF);
mdContext->digest[ii + 2] =
(unsigned char) ((mdContext->buf[i] >> 16) & 0xFF);
mdContext->digest[ii + 3] =
(unsigned char) ((mdContext->buf[i] >> 24) & 0xFF);
}
}
SDLTest_Md5Context::i
MD5UINT4 i[2]
Definition: SDL_test_md5.h:72
MD5PADDING
static unsigned char MD5PADDING[64]
Definition: SDL_test_md5.c:61
SDLTest_Md5Context::in
unsigned char in[64]
Definition: SDL_test_md5.h:74
SDLTest_Md5Context::buf
MD5UINT4 buf[4]
Definition: SDL_test_md5.h:73
SDLTest_Md5Transform
static void SDLTest_Md5Transform(MD5UINT4 *buf, MD5UINT4 *in)
Definition: SDL_test_md5.c:232
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:42
NULL
#define NULL
Definition: begin_code.h:143
MD5UINT4
unsigned long int MD5UINT4
Definition: SDL_test_md5.h:68
SDLTest_Md5Update
void SDLTest_Md5Update(SDLTest_Md5Context *mdContext, unsigned char *inBuf, unsigned int inLen)
update digest from variable length data
Definition: SDL_test_md5.c:131
in
GLuint in
Definition: SDL_opengl_glext.h:7940
SDLTest_Md5Context::digest
unsigned char digest[16]
Definition: SDL_test_md5.h:75

void SDLTest_Md5Init | ( | SDLTest_Md5Context * | mdContext | ) |

initialize the context

Parameters

  mdContext | pointer to context variable

Note: The function initializes the message-digest context mdContext. Call before each new use of the context - all fields are set to zero.

Definition at line 110 of file SDL_test_md5.c.

References SDLTest_Md5Context::buf, SDLTest_Md5Context::i, and NULL.

Referenced by SDLTest_GenerateExecKey().

{
if (mdContext==NULL) return;
mdContext->i[0] = mdContext->i[1] = (MD5UINT4) 0;
/*
* Load magic initialization constants.
*/
mdContext->buf[0] = (MD5UINT4) 0x67452301;
mdContext->buf[1] = (MD5UINT4) 0xefcdab89;
mdContext->buf[2] = (MD5UINT4) 0x98badcfe;
mdContext->buf[3] = (MD5UINT4) 0x10325476;
}
SDLTest_Md5Context::i
MD5UINT4 i[2]
Definition: SDL_test_md5.h:72
SDLTest_Md5Context::buf
MD5UINT4 buf[4]
Definition: SDL_test_md5.h:73
NULL
#define NULL
Definition: begin_code.h:143
MD5UINT4
unsigned long int MD5UINT4
Definition: SDL_test_md5.h:68

void SDLTest_Md5Update | ( | SDLTest_Md5Context * | mdContext,
|  | unsigned char * | inBuf,
|  | unsigned int | inLen
| ) |  |

update digest from variable length data

Parameters

  mdContext | pointer to context variable
  inBuf | pointer to data array/string
  inLen | length of data array/string

Note: The function updates the message-digest context to account for the presence of each of the characters inBuf[0..inLen-1] in the message whose digest is being computed.

Definition at line 131 of file SDL_test_md5.c.

References SDLTest_Md5Context::buf, i, SDLTest_Md5Context::i, SDLTest_Md5Context::in, NULL, and SDLTest_Md5Transform().

Referenced by SDLTest_GenerateExecKey(), and SDLTest_Md5Final().

{
MD5UINT4 in[16];
int mdi;
unsigned int i, ii;
if (mdContext == NULL) return;
if (inBuf == NULL || inLen < 1) return;
/*
* compute number of bytes mod 64
*/
mdi = (int) ((mdContext->i[0] >> 3) & 0x3F);
/*
* update number of bits
*/
if ((mdContext->i[0] + ((MD5UINT4) inLen << 3)) < mdContext->i[0])
mdContext->i[1]++;
mdContext->i[0] += ((MD5UINT4) inLen << 3);
mdContext->i[1] += ((MD5UINT4) inLen >> 29);
while (inLen--) {
/*
* add new character to buffer, increment mdi
*/
mdContext->in[mdi++] = *inBuf++;
/*
* transform if necessary
*/
if (mdi == 0x40) {
for (i = 0, ii = 0; i < 16; i++, ii += 4)
in[i] = (((MD5UINT4) mdContext->in[ii + 3]) << 24) |
(((MD5UINT4) mdContext->in[ii + 2]) << 16) |
(((MD5UINT4) mdContext->in[ii + 1]) << 8) |
((MD5UINT4) mdContext->in[ii]);
SDLTest_Md5Transform(mdContext->buf, in);
mdi = 0;
}
}
}
SDLTest_Md5Context::i
MD5UINT4 i[2]
Definition: SDL_test_md5.h:72
SDLTest_Md5Context::in
unsigned char in[64]
Definition: SDL_test_md5.h:74
SDLTest_Md5Context::buf
MD5UINT4 buf[4]
Definition: SDL_test_md5.h:73
SDLTest_Md5Transform
static void SDLTest_Md5Transform(MD5UINT4 *buf, MD5UINT4 *in)
Definition: SDL_test_md5.c:232
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:42
NULL
#define NULL
Definition: begin_code.h:143
MD5UINT4
unsigned long int MD5UINT4
Definition: SDL_test_md5.h:68
in
GLuint in
Definition: SDL_opengl_glext.h:7940