1 /* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2014 Sam Lantinga <slouken (at) libsdl.org> 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any damages 7 arising from the use of this software. 8 9 Permission is granted to anyone to use this software for any purpose, 10 including commercial applications, and to alter it and redistribute it 11 freely, subject to the following restrictions: 12 13 1. The origin of this software must not be misrepresented; you must not 14 claim that you wrote the original software. If you use this software 15 in a product, an acknowledgment in the product documentation would be 16 appreciated but is not required. 17 2. Altered source versions must be plainly marked as such, and must not be 18 misrepresented as being the original software. 19 3. This notice may not be removed or altered from any source distribution. 20 */ 21 22 /** 23 * \file SDL_test_md5.h 24 * 25 * Include file for SDL test framework. 26 * 27 * This code is a part of the SDL2_test library, not the main SDL library. 28 */ 29 30 /* 31 *********************************************************************** 32 ** Header file for implementation of MD5 ** 33 ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** 34 ** Created: 2/17/90 RLR ** 35 ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** 36 ** Revised (for MD5): RLR 4/27/91 ** 37 ** -- G modified to have y&~z instead of y&z ** 38 ** -- FF, GG, HH modified to add in last register done ** 39 ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** 40 ** -- distinct additive constant for each step ** 41 ** -- round 4 added, working mod 7 ** 42 *********************************************************************** 43 */ 44 45 /* 46 *********************************************************************** 47 ** Message-digest routines: ** 48 ** To form the message digest for a message M ** 49 ** (1) Initialize a context buffer mdContext using MD5Init ** 50 ** (2) Call MD5Update on mdContext and M ** 51 ** (3) Call MD5Final on mdContext ** 52 ** The message digest is now in mdContext->digest[0...15] ** 53 *********************************************************************** 54 */ 55 56 #ifndef _SDL_test_md5_h 57 #define _SDL_test_md5_h 58 59 #include "begin_code.h" 60 /* Set up for C function definitions, even when using C++ */ 61 #ifdef __cplusplus 62 extern "C" { 63 #endif 64 65 /* ------------ Definitions --------- */ 66 67 /* typedef a 32-bit type */ 68 typedef unsigned long int MD5UINT4; 69 70 /* Data structure for MD5 (Message-Digest) computation */ 71 typedef struct { 72 MD5UINT4 i[2]; /* number of _bits_ handled mod 2^64 */ 73 MD5UINT4 buf[4]; /* scratch buffer */ 74 unsigned char in[64]; /* input buffer */ 75 unsigned char digest[16]; /* actual digest after Md5Final call */ 76 } SDLTest_Md5Context; 77 78 /* ---------- Function Prototypes ------------- */ 79 80 /** 81 * /brief initialize the context 82 * 83 * /param mdContext pointer to context variable 84 * 85 * Note: The function initializes the message-digest context 86 * mdContext. Call before each new use of the context - 87 * all fields are set to zero. 88 */ 89 void SDLTest_Md5Init(SDLTest_Md5Context * mdContext); 90 91 92 /** 93 * /brief update digest from variable length data 94 * 95 * /param mdContext pointer to context variable 96 * /param inBuf pointer to data array/string 97 * /param inLen length of data array/string 98 * 99 * Note: The function updates the message-digest context to account 100 * for the presence of each of the characters inBuf[0..inLen-1] 101 * in the message whose digest is being computed. 102 */ 103 104 void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf, 105 unsigned int inLen); 106 107 108 /* 109 * /brief complete digest computation 110 * 111 * /param mdContext pointer to context variable 112 * 113 * Note: The function terminates the message-digest computation and 114 * ends with the desired message digest in mdContext.digest[0..15]. 115 * Always call before using the digest[] variable. 116 */ 117 118 void SDLTest_Md5Final(SDLTest_Md5Context * mdContext); 119 120 121 /* Ends C function definitions when using C++ */ 122 #ifdef __cplusplus 123 } 124 #endif 125 #include "close_code.h" 126 127 #endif /* _SDL_test_md5_h */ 128 129 /* vi: set ts=4 sw=4 expandtab: */ 130