Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

130 linhas
4.5 KiB

  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2018 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. * Include file for SDL test framework.
  22. *
  23. * This code is a part of the SDL2_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 "begin_code.h"
  52. /* Set up for C function definitions, even when using C++ */
  53. #ifdef __cplusplus
  54. extern "C" {
  55. #endif
  56. /* ------------ Definitions --------- */
  57. /* typedef a 32-bit type */
  58. typedef unsigned long int MD5UINT4;
  59. /* Data structure for MD5 (Message-Digest) computation */
  60. typedef struct {
  61. MD5UINT4 i[2]; /* number of _bits_ handled mod 2^64 */
  62. MD5UINT4 buf[4]; /* scratch buffer */
  63. unsigned char in[64]; /* input buffer */
  64. unsigned char digest[16]; /* actual digest after Md5Final call */
  65. } SDLTest_Md5Context;
  66. /* ---------- Function Prototypes ------------- */
  67. /**
  68. * \brief initialize the context
  69. *
  70. * \param mdContext pointer to context variable
  71. *
  72. * Note: The function initializes the message-digest context
  73. * mdContext. Call before each new use of the context -
  74. * all fields are set to zero.
  75. */
  76. void SDLTest_Md5Init(SDLTest_Md5Context * mdContext);
  77. /**
  78. * \brief update digest from variable length data
  79. *
  80. * \param mdContext pointer to context variable
  81. * \param inBuf pointer to data array/string
  82. * \param inLen length of data array/string
  83. *
  84. * Note: The function updates the message-digest context to account
  85. * for the presence of each of the characters inBuf[0..inLen-1]
  86. * in the message whose digest is being computed.
  87. */
  88. void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf,
  89. unsigned int inLen);
  90. /**
  91. * \brief complete digest computation
  92. *
  93. * \param mdContext pointer to context variable
  94. *
  95. * Note: The function terminates the message-digest computation and
  96. * ends with the desired message digest in mdContext.digest[0..15].
  97. * Always call before using the digest[] variable.
  98. */
  99. void SDLTest_Md5Final(SDLTest_Md5Context * mdContext);
  100. /* Ends C function definitions when using C++ */
  101. #ifdef __cplusplus
  102. }
  103. #endif
  104. #include "close_code.h"
  105. #endif /* SDL_test_md5_h_ */
  106. /* vi: set ts=4 sw=4 expandtab: */