md5.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* md5.h
  2. *
  3. * Copyright (C) 2006-2021 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. /* md5.h for openssl */
  22. #ifndef WOLFSSL_MD5_H_
  23. #define WOLFSSL_MD5_H_
  24. #include <wolfssl/wolfcrypt/settings.h>
  25. #ifndef NO_MD5
  26. #include <wolfssl/wolfcrypt/hash.h>
  27. #ifdef WOLFSSL_PREFIX
  28. #include "prefix_md5.h"
  29. #endif
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. typedef struct WOLFSSL_MD5_CTX {
  34. /* big enough to hold wolfcrypt md5, but check on init */
  35. #ifdef STM32_HASH
  36. void* holder[(112 + WC_ASYNC_DEV_SIZE + sizeof(STM32_HASH_Context)) / sizeof(void*)];
  37. #else
  38. void* holder[(112 + WC_ASYNC_DEV_SIZE) / sizeof(void*)];
  39. #endif
  40. } WOLFSSL_MD5_CTX;
  41. WOLFSSL_API int wolfSSL_MD5_Init(WOLFSSL_MD5_CTX*);
  42. WOLFSSL_API int wolfSSL_MD5_Update(WOLFSSL_MD5_CTX*, const void*, unsigned long);
  43. WOLFSSL_API int wolfSSL_MD5_Final(unsigned char*, WOLFSSL_MD5_CTX*);
  44. WOLFSSL_API int wolfSSL_MD5_Transform(WOLFSSL_MD5_CTX*, const unsigned char*);
  45. WOLFSSL_API unsigned char *wolfSSL_MD5(const unsigned char*, size_t, unsigned char*);
  46. typedef WOLFSSL_MD5_CTX MD5_CTX;
  47. #define MD5_Init wolfSSL_MD5_Init
  48. #define MD5_Update wolfSSL_MD5_Update
  49. #define MD5_Final wolfSSL_MD5_Final
  50. #define MD5_Transform wolfSSL_MD5_Transform
  51. #ifdef OPENSSL_EXTRA_BSD
  52. #define MD5Init wolfSSL_MD5_Init
  53. #define MD5Update wolfSSL_MD5_Update
  54. #define MD5Final wolfSSL_MD5_Final
  55. #endif
  56. /* "MD5" has some conflicts
  57. * If not FIPS and NO_OLD_SHA_NAMES defined
  58. * If FIPS V2 or higher and NO_OLD_MD5_NAME defined
  59. * If FIPS V2 and NO_OLD_WC_NAMES defined
  60. * If FIPS v1 not allowed
  61. */
  62. #if (defined(NO_OLD_MD5_NAME) && !defined(HAVE_FIPS)) || \
  63. (defined(NO_OLD_MD5_NAME) && defined(HAVE_FIPS) && \
  64. defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION >= 2) || \
  65. (defined(NO_OLD_WC_NAMES) && defined(HAVE_FIPS) && \
  66. defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION == 2)
  67. #define MD5 wolfSSL_MD5
  68. #endif
  69. /* FIPS v1 uses old MD5_DIGEST_SIZE naming */
  70. #if (!defined(HAVE_FIPS) || \
  71. (defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION >= 2)) && \
  72. defined(OPENSSL_EXTRA)
  73. #define MD5_DIGEST_LENGTH WC_MD5_DIGEST_SIZE
  74. #else
  75. #define MD5_DIGEST_LENGTH MD5_DIGEST_SIZE
  76. #endif
  77. #ifdef __cplusplus
  78. } /* extern "C" */
  79. #endif
  80. #endif /* NO_MD5 */
  81. #endif /* WOLFSSL_MD5_H_ */