SDL_test_md5.h 4.6 KB

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