md_internal.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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: Apache-2.0
  12. *
  13. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  14. * not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at
  16. *
  17. * http://www.apache.org/licenses/LICENSE-2.0
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  21. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. *
  25. * This file is part of mbed TLS (https://tls.mbed.org)
  26. */
  27. #ifndef MBEDTLS_MD_WRAP_H
  28. #define MBEDTLS_MD_WRAP_H
  29. #if !defined(MBEDTLS_CONFIG_FILE)
  30. #include "config.h"
  31. #else
  32. #include MBEDTLS_CONFIG_FILE
  33. #endif
  34. #include "md.h"
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /**
  39. * Message digest information.
  40. * Allows message digest functions to be called in a generic way.
  41. */
  42. struct mbedtls_md_info_t
  43. {
  44. /** Digest identifier */
  45. mbedtls_md_type_t type;
  46. /** Name of the message digest */
  47. const char * name;
  48. /** Output length of the digest function in bytes */
  49. int size;
  50. /** Block length of the digest function in bytes */
  51. int block_size;
  52. /** Digest initialisation function */
  53. void (*starts_func)( void *ctx );
  54. /** Digest update function */
  55. void (*update_func)( void *ctx, const unsigned char *input, size_t ilen );
  56. /** Digest finalisation function */
  57. void (*finish_func)( void *ctx, unsigned char *output );
  58. /** Generic digest function */
  59. void (*digest_func)( const unsigned char *input, size_t ilen,
  60. unsigned char *output );
  61. /** Allocate a new context */
  62. void * (*ctx_alloc_func)( void );
  63. /** Free the given context */
  64. void (*ctx_free_func)( void *ctx );
  65. /** Clone state from a context */
  66. void (*clone_func)( void *dst, const void *src );
  67. /** Internal use only */
  68. void (*process_func)( void *ctx, const unsigned char *input );
  69. };
  70. #if defined(MBEDTLS_MD2_C)
  71. extern const mbedtls_md_info_t mbedtls_md2_info;
  72. #endif
  73. #if defined(MBEDTLS_MD4_C)
  74. extern const mbedtls_md_info_t mbedtls_md4_info;
  75. #endif
  76. #if defined(MBEDTLS_MD5_C)
  77. extern const mbedtls_md_info_t mbedtls_md5_info;
  78. #endif
  79. #if defined(MBEDTLS_RIPEMD160_C)
  80. extern const mbedtls_md_info_t mbedtls_ripemd160_info;
  81. #endif
  82. #if defined(MBEDTLS_SHA1_C)
  83. extern const mbedtls_md_info_t mbedtls_sha1_info;
  84. #endif
  85. #if defined(MBEDTLS_SHA256_C)
  86. extern const mbedtls_md_info_t mbedtls_sha224_info;
  87. extern const mbedtls_md_info_t mbedtls_sha256_info;
  88. #endif
  89. #if defined(MBEDTLS_SHA512_C)
  90. extern const mbedtls_md_info_t mbedtls_sha384_info;
  91. extern const mbedtls_md_info_t mbedtls_sha512_info;
  92. #endif
  93. #ifdef __cplusplus
  94. }
  95. #endif
  96. #endif /* MBEDTLS_MD_WRAP_H */