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