md_internal.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /**
  2. * \file md_internal.h
  3. *
  4. * \brief Message digest wrappers.
  5. *
  6. * \warning This in an internal header. Do not include directly.
  7. *
  8. * \author Adriaan de Jong <dejong@fox-it.com>
  9. *
  10. * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
  11. * SPDX-License-Identifier: GPL-2.0
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License along
  24. * with this program; if not, write to the Free Software Foundation, Inc.,
  25. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  26. *
  27. * This file is part of mbed TLS (https://tls.mbed.org)
  28. */
  29. #ifndef MBEDTLS_MD_WRAP_H
  30. #define MBEDTLS_MD_WRAP_H
  31. #if !defined(MBEDTLS_CONFIG_FILE)
  32. #include "config.h"
  33. #else
  34. #include MBEDTLS_CONFIG_FILE
  35. #endif
  36. #include "md.h"
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40. /**
  41. * Message digest information.
  42. * Allows message digest functions to be called in a generic way.
  43. */
  44. struct mbedtls_md_info_t
  45. {
  46. /** Digest identifier */
  47. mbedtls_md_type_t type;
  48. /** Name of the message digest */
  49. const char * name;
  50. /** Output length of the digest function in bytes */
  51. int size;
  52. /** Block length of the digest function in bytes */
  53. int block_size;
  54. /** Digest initialisation function */
  55. void (*starts_func)( void *ctx );
  56. /** Digest update function */
  57. void (*update_func)( void *ctx, const unsigned char *input, size_t ilen );
  58. /** Digest finalisation function */
  59. void (*finish_func)( void *ctx, unsigned char *output );
  60. /** Generic digest function */
  61. void (*digest_func)( const unsigned char *input, size_t ilen,
  62. unsigned char *output );
  63. /** Allocate a new context */
  64. void * (*ctx_alloc_func)( void );
  65. /** Free the given context */
  66. void (*ctx_free_func)( void *ctx );
  67. /** Clone state from a context */
  68. void (*clone_func)( void *dst, const void *src );
  69. /** Internal use only */
  70. void (*process_func)( void *ctx, const unsigned char *input );
  71. };
  72. #if defined(MBEDTLS_MD2_C)
  73. extern const mbedtls_md_info_t mbedtls_md2_info;
  74. #endif
  75. #if defined(MBEDTLS_MD4_C)
  76. extern const mbedtls_md_info_t mbedtls_md4_info;
  77. #endif
  78. #if defined(MBEDTLS_MD5_C)
  79. extern const mbedtls_md_info_t mbedtls_md5_info;
  80. #endif
  81. #if defined(MBEDTLS_RIPEMD160_C)
  82. extern const mbedtls_md_info_t mbedtls_ripemd160_info;
  83. #endif
  84. #if defined(MBEDTLS_SHA1_C)
  85. extern const mbedtls_md_info_t mbedtls_sha1_info;
  86. #endif
  87. #if defined(MBEDTLS_SHA256_C)
  88. extern const mbedtls_md_info_t mbedtls_sha224_info;
  89. extern const mbedtls_md_info_t mbedtls_sha256_info;
  90. #endif
  91. #if defined(MBEDTLS_SHA512_C)
  92. extern const mbedtls_md_info_t mbedtls_sha384_info;
  93. extern const mbedtls_md_info_t mbedtls_sha512_info;
  94. #endif
  95. #ifdef __cplusplus
  96. }
  97. #endif
  98. #endif /* MBEDTLS_MD_WRAP_H */