include/SDL_test_md5.h
changeset 6713 fa17a97389ed
child 6885 700f1b25f77f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/include/SDL_test_md5.h	Wed Nov 28 19:19:57 2012 -0800
     1.3 @@ -0,0 +1,133 @@
     1.4 +/*
     1.5 +  Simple DirectMedia Layer
     1.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     1.7 +
     1.8 +  This software is provided 'as-is', without any express or implied
     1.9 +  warranty.  In no event will the authors be held liable for any damages
    1.10 +  arising from the use of this software.
    1.11 +
    1.12 +  Permission is granted to anyone to use this software for any purpose,
    1.13 +  including commercial applications, and to alter it and redistribute it
    1.14 +  freely, subject to the following restrictions:
    1.15 +
    1.16 +  1. The origin of this software must not be misrepresented; you must not
    1.17 +     claim that you wrote the original software. If you use this software
    1.18 +     in a product, an acknowledgment in the product documentation would be
    1.19 +     appreciated but is not required.
    1.20 +  2. Altered source versions must be plainly marked as such, and must not be
    1.21 +     misrepresented as being the original software.
    1.22 +  3. This notice may not be removed or altered from any source distribution.
    1.23 +*/
    1.24 +
    1.25 +/**
    1.26 + *  \file SDL_test_md5.h
    1.27 + *  
    1.28 + *  Include file for SDL test framework.
    1.29 + *
    1.30 + *  This code is a part of the SDL2_test library, not the main SDL library.
    1.31 + */
    1.32 +
    1.33 +/*
    1.34 + ***********************************************************************
    1.35 + ** Header file for implementation of MD5                             **
    1.36 + ** RSA Data Security, Inc. MD5 Message-Digest Algorithm              **
    1.37 + ** Created: 2/17/90 RLR                                              **
    1.38 + ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version               **
    1.39 + ** Revised (for MD5): RLR 4/27/91                                    **
    1.40 + **   -- G modified to have y&~z instead of y&z                       **
    1.41 + **   -- FF, GG, HH modified to add in last register done             **
    1.42 + **   -- Access pattern: round 2 works mod 5, round 3 works mod 3     **
    1.43 + **   -- distinct additive constant for each step                     **
    1.44 + **   -- round 4 added, working mod 7                                 **
    1.45 + ***********************************************************************
    1.46 +*/
    1.47 +
    1.48 +/*
    1.49 + ***********************************************************************
    1.50 + **  Message-digest routines:                                         **
    1.51 + **  To form the message digest for a message M                       **
    1.52 + **    (1) Initialize a context buffer mdContext using MD5Init        **
    1.53 + **    (2) Call MD5Update on mdContext and M                          **
    1.54 + **    (3) Call MD5Final on mdContext                                 **
    1.55 + **  The message digest is now in mdContext->digest[0...15]           **
    1.56 + ***********************************************************************
    1.57 +*/
    1.58 +
    1.59 +#ifndef _SDL_test_md5_h
    1.60 +#define _SDL_test_md5_h
    1.61 +
    1.62 +#include "begin_code.h"
    1.63 +/* Set up for C function definitions, even when using C++ */
    1.64 +#ifdef __cplusplus
    1.65 +/* *INDENT-OFF* */
    1.66 +extern "C" {
    1.67 +/* *INDENT-ON* */
    1.68 +#endif
    1.69 +
    1.70 +/* ------------ Definitions --------- */
    1.71 +
    1.72 +/* typedef a 32-bit type */
    1.73 +  typedef unsigned long int MD5UINT4;
    1.74 +
    1.75 +/* Data structure for MD5 (Message-Digest) computation */
    1.76 +  typedef struct {
    1.77 +    MD5UINT4  i[2];		/* number of _bits_ handled mod 2^64 */
    1.78 +    MD5UINT4  buf[4];		/* scratch buffer */
    1.79 +    unsigned char in[64];	/* input buffer */
    1.80 +    unsigned char digest[16];	/* actual digest after Md5Final call */
    1.81 +  } SDLTest_Md5Context;
    1.82 +
    1.83 +/* ---------- Function Prototypes ------------- */
    1.84 +
    1.85 +/** 
    1.86 + * /brief initialize the context
    1.87 + *
    1.88 + * /param  mdContext		pointer to context variable
    1.89 + *
    1.90 + * Note: The function initializes the message-digest context
    1.91 + *       mdContext. Call before each new use of the context - 
    1.92 + *       all fields are set to zero.
    1.93 + */
    1.94 + void SDLTest_Md5Init(SDLTest_Md5Context * mdContext);
    1.95 +
    1.96 +
    1.97 +/**
    1.98 + * /brief update digest from variable length data
    1.99 + * 
   1.100 + * /param  mdContext       pointer to context variable
   1.101 + * /param  inBuf           pointer to data array/string
   1.102 + * /param  inLen           length of data array/string
   1.103 + *
   1.104 + * Note: The function updates the message-digest context to account 
   1.105 + *       for the presence of each of the characters inBuf[0..inLen-1]
   1.106 + *       in the message whose digest is being computed.
   1.107 +*/
   1.108 +
   1.109 + void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf,
   1.110 +				 unsigned int inLen);
   1.111 +
   1.112 +
   1.113 +/*
   1.114 + * /brief complete digest computation
   1.115 + *
   1.116 + * /param mdContext		pointer to context variable
   1.117 + *
   1.118 + * Note: The function terminates the message-digest computation and
   1.119 + *       ends with the desired message digest in mdContext.digest[0..15].
   1.120 + *       Always call before using the digest[] variable.
   1.121 +*/
   1.122 +
   1.123 + void SDLTest_Md5Final(SDLTest_Md5Context * mdContext);
   1.124 +
   1.125 +
   1.126 +/* Ends C function definitions when using C++ */
   1.127 +#ifdef __cplusplus
   1.128 +/* *INDENT-OFF* */
   1.129 +}
   1.130 +/* *INDENT-ON* */
   1.131 +#endif
   1.132 +#include "close_code.h"
   1.133 +
   1.134 +#endif /* _SDL_test_md5_h */
   1.135 +
   1.136 +/* vi: set ts=4 sw=4 expandtab: */