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