hmac.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* hmac.h
  2. *
  3. * Copyright (C) 2013 wolfSSL Inc.
  4. *
  5. * This file is part of CyaSSL.
  6. *
  7. * CyaSSL 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. * CyaSSL 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-1301, USA
  20. */
  21. /* hmac.h defines mini hamc openssl compatibility layer
  22. *
  23. */
  24. #ifndef CYASSL_HMAC_H_
  25. #define CYASSL_HMAC_H_
  26. #include <cyassl/ctaocrypt/settings.h>
  27. #ifdef YASSL_PREFIX
  28. #include "prefix_hmac.h"
  29. #endif
  30. #include <cyassl/openssl/evp.h>
  31. #include <cyassl/ctaocrypt/hmac.h>
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. CYASSL_API unsigned char* CyaSSL_HMAC(const CYASSL_EVP_MD* evp_md,
  36. const void* key, int key_len,
  37. const unsigned char* d, int n, unsigned char* md,
  38. unsigned int* md_len);
  39. typedef struct CYASSL_HMAC_CTX {
  40. Hmac hmac;
  41. int type;
  42. } CYASSL_HMAC_CTX;
  43. CYASSL_API void CyaSSL_HMAC_Init(CYASSL_HMAC_CTX* ctx, const void* key,
  44. int keylen, const EVP_MD* type);
  45. CYASSL_API void CyaSSL_HMAC_Update(CYASSL_HMAC_CTX* ctx,
  46. const unsigned char* data, int len);
  47. CYASSL_API void CyaSSL_HMAC_Final(CYASSL_HMAC_CTX* ctx, unsigned char* hash,
  48. unsigned int* len);
  49. CYASSL_API void CyaSSL_HMAC_cleanup(CYASSL_HMAC_CTX* ctx);
  50. typedef struct CYASSL_HMAC_CTX HMAC_CTX;
  51. #define HMAC(a,b,c,d,e,f,g) CyaSSL_HMAC((a),(b),(c),(d),(e),(f),(g))
  52. #define HMAC_Init CyaSSL_HMAC_Init
  53. #define HMAC_Update CyaSSL_HMAC_Update
  54. #define HMAC_Final CyaSSL_HMAC_Final
  55. #define HMAC_cleanup CyaSSL_HMAC_cleanup
  56. #ifdef __cplusplus
  57. } /* extern "C" */
  58. #endif
  59. #endif /* CYASSL_HMAC_H_ */