md2.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* md2.h
  2. *
  3. * Copyright (C) 2006-2022 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. /*!
  22. \file wolfssl/wolfcrypt/md2.h
  23. */
  24. #ifndef WOLF_CRYPT_MD2_H
  25. #define WOLF_CRYPT_MD2_H
  26. #include <wolfssl/wolfcrypt/types.h>
  27. #ifdef WOLFSSL_MD2
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /* in bytes */
  32. enum {
  33. MD2 = WC_HASH_TYPE_MD2,
  34. MD2_BLOCK_SIZE = 16,
  35. MD2_DIGEST_SIZE = 16,
  36. MD2_PAD_SIZE = 16,
  37. MD2_X_SIZE = 48
  38. };
  39. /* Md2 digest */
  40. typedef struct Md2 {
  41. word32 count; /* bytes % PAD_SIZE */
  42. byte X[MD2_X_SIZE];
  43. byte C[MD2_BLOCK_SIZE];
  44. byte buffer[MD2_BLOCK_SIZE];
  45. } Md2;
  46. WOLFSSL_API void wc_InitMd2(Md2* md2);
  47. WOLFSSL_API void wc_Md2Update(Md2* md2, const byte* data, word32 len);
  48. WOLFSSL_API void wc_Md2Final(Md2* md2, byte* hash);
  49. WOLFSSL_API int wc_Md2Hash(const byte* data, word32 len, byte* hash);
  50. #ifdef __cplusplus
  51. } /* extern "C" */
  52. #endif
  53. #endif /* WOLFSSL_MD2 */
  54. #endif /* WOLF_CRYPT_MD2_H */