SDL  2.0
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

◆ MD5UINT4

typedef unsigned long int MD5UINT4

Definition at line 68 of file SDL_test_md5.h.

Function Documentation

◆ SDLTest_Md5Final()

void SDLTest_Md5Final ( SDLTest_Md5Context mdContext)

complete digest computation

Parameters
mdContextpointer 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().

181 {
182  MD5UINT4 in[16];
183  int mdi;
184  unsigned int i, ii;
185  unsigned int padLen;
186 
187  if (mdContext == NULL) return;
188 
189  /*
190  * save number of bits
191  */
192  in[14] = mdContext->i[0];
193  in[15] = mdContext->i[1];
194 
195  /*
196  * compute number of bytes mod 64
197  */
198  mdi = (int) ((mdContext->i[0] >> 3) & 0x3F);
199 
200  /*
201  * pad out to 56 mod 64
202  */
203  padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
204  SDLTest_Md5Update(mdContext, MD5PADDING, padLen);
205 
206  /*
207  * append length in bits and transform
208  */
209  for (i = 0, ii = 0; i < 14; i++, ii += 4)
210  in[i] = (((MD5UINT4) mdContext->in[ii + 3]) << 24) |
211  (((MD5UINT4) mdContext->in[ii + 2]) << 16) |
212  (((MD5UINT4) mdContext->in[ii + 1]) << 8) |
213  ((MD5UINT4) mdContext->in[ii]);
214  SDLTest_Md5Transform(mdContext->buf, in);
215 
216  /*
217  * store buffer in digest
218  */
219  for (i = 0, ii = 0; i < 4; i++, ii += 4) {
220  mdContext->digest[ii] = (unsigned char) (mdContext->buf[i] & 0xFF);
221  mdContext->digest[ii + 1] =
222  (unsigned char) ((mdContext->buf[i] >> 8) & 0xFF);
223  mdContext->digest[ii + 2] =
224  (unsigned char) ((mdContext->buf[i] >> 16) & 0xFF);
225  mdContext->digest[ii + 3] =
226  (unsigned char) ((mdContext->buf[i] >> 24) & 0xFF);
227  }
228 }
static unsigned char MD5PADDING[64]
Definition: SDL_test_md5.c:61
unsigned char in[64]
Definition: SDL_test_md5.h:74
MD5UINT4 buf[4]
Definition: SDL_test_md5.h:73
static void SDLTest_Md5Transform(MD5UINT4 *buf, MD5UINT4 *in)
Definition: SDL_test_md5.c:232
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:50
#define NULL
Definition: begin_code.h:164
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
Definition: SDL_test_md5.c:131
GLuint in
unsigned char digest[16]
Definition: SDL_test_md5.h:75

◆ SDLTest_Md5Init()

void SDLTest_Md5Init ( SDLTest_Md5Context mdContext)

initialize the context

Parameters
mdContextpointer 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().

111 {
112  if (mdContext==NULL) return;
113 
114  mdContext->i[0] = mdContext->i[1] = (MD5UINT4) 0;
115 
116  /*
117  * Load magic initialization constants.
118  */
119  mdContext->buf[0] = (MD5UINT4) 0x67452301;
120  mdContext->buf[1] = (MD5UINT4) 0xefcdab89;
121  mdContext->buf[2] = (MD5UINT4) 0x98badcfe;
122  mdContext->buf[3] = (MD5UINT4) 0x10325476;
123 }
MD5UINT4 buf[4]
Definition: SDL_test_md5.h:73
#define NULL
Definition: begin_code.h:164
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

Parameters
mdContextpointer to context variable
inBufpointer to data array/string
inLenlength 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().

133 {
134  MD5UINT4 in[16];
135  int mdi;
136  unsigned int i, ii;
137 
138  if (mdContext == NULL) return;
139  if (inBuf == NULL || inLen < 1) return;
140 
141  /*
142  * compute number of bytes mod 64
143  */
144  mdi = (int) ((mdContext->i[0] >> 3) & 0x3F);
145 
146  /*
147  * update number of bits
148  */
149  if ((mdContext->i[0] + ((MD5UINT4) inLen << 3)) < mdContext->i[0])
150  mdContext->i[1]++;
151  mdContext->i[0] += ((MD5UINT4) inLen << 3);
152  mdContext->i[1] += ((MD5UINT4) inLen >> 29);
153 
154  while (inLen--) {
155  /*
156  * add new character to buffer, increment mdi
157  */
158  mdContext->in[mdi++] = *inBuf++;
159 
160  /*
161  * transform if necessary
162  */
163  if (mdi == 0x40) {
164  for (i = 0, ii = 0; i < 16; i++, ii += 4)
165  in[i] = (((MD5UINT4) mdContext->in[ii + 3]) << 24) |
166  (((MD5UINT4) mdContext->in[ii + 2]) << 16) |
167  (((MD5UINT4) mdContext->in[ii + 1]) << 8) |
168  ((MD5UINT4) mdContext->in[ii]);
169  SDLTest_Md5Transform(mdContext->buf, in);
170  mdi = 0;
171  }
172  }
173 }
unsigned char in[64]
Definition: SDL_test_md5.h:74
MD5UINT4 buf[4]
Definition: SDL_test_md5.h:73
static void SDLTest_Md5Transform(MD5UINT4 *buf, MD5UINT4 *in)
Definition: SDL_test_md5.c:232
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:50
#define NULL
Definition: begin_code.h:164
unsigned long int MD5UINT4
Definition: SDL_test_md5.h:68
GLuint in