md_internal.h 3.0 KB

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