blob: c2025981651bdaeecca3fb495653b2559521f699 [file] [log] [blame]
Paul Bakker17373852011-01-06 14:20:01 +00001/**
Manuel Pégourié-Gonnard50518f42015-05-26 11:04:15 +02002 * \file md_internal.h
Paul Bakker9af723c2014-05-01 13:03:14 +02003 *
Paul Bakker17373852011-01-06 14:20:01 +00004 * \brief Message digest wrappers.
5 *
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +01006 * \warning This in an internal header. Do not include directly.
7 *
Paul Bakker17373852011-01-06 14:20:01 +00008 * \author Adriaan de Jong <dejong@fox-it.com>
9 *
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010010 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +020011 * 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.
Paul Bakker17373852011-01-06 14:20:01 +000024 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +000025 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakker17373852011-01-06 14:20:01 +000026 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020027#ifndef MBEDTLS_MD_WRAP_H
28#define MBEDTLS_MD_WRAP_H
Paul Bakker17373852011-01-06 14:20:01 +000029
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020030#if !defined(MBEDTLS_CONFIG_FILE)
Paul Bakker314052f2011-08-15 09:07:52 +000031#include "config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020032#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020033#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020034#endif
Manuel Pégourié-Gonnard6c5abfa2015-02-13 14:12:07 +000035
Paul Bakker314052f2011-08-15 09:07:52 +000036#include "md.h"
Paul Bakker17373852011-01-06 14:20:01 +000037
Paul Bakker17373852011-01-06 14:20:01 +000038#ifdef __cplusplus
39extern "C" {
40#endif
41
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010042/**
43 * Message digest information.
44 * Allows message digest functions to be called in a generic way.
45 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020046struct mbedtls_md_info_t
Manuel Pégourié-Gonnardf5fc6492015-04-02 14:43:57 +010047{
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010048 /** Digest identifier */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020049 mbedtls_md_type_t type;
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010050
51 /** Name of the message digest */
52 const char * name;
53
Manuel Pégourié-Gonnardb8186a52015-06-18 14:58:58 +020054 /** Output length of the digest function in bytes */
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010055 int size;
56
Manuel Pégourié-Gonnardb8186a52015-06-18 14:58:58 +020057 /** Block length of the digest function in bytes */
Manuel Pégourié-Gonnard8379a822015-03-24 16:48:22 +010058 int block_size;
59
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010060 /** Digest initialisation function */
Andres Amaya Garcia5f872df2017-06-28 14:12:44 +010061 int (*starts_func)( void *ctx );
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010062
63 /** Digest update function */
Andres Amaya Garcia5f872df2017-06-28 14:12:44 +010064 int (*update_func)( void *ctx, const unsigned char *input, size_t ilen );
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010065
66 /** Digest finalisation function */
Andres Amaya Garcia5f872df2017-06-28 14:12:44 +010067 int (*finish_func)( void *ctx, unsigned char *output );
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010068
69 /** Generic digest function */
Andres Amaya Garcia5f872df2017-06-28 14:12:44 +010070 int (*digest_func)( const unsigned char *input, size_t ilen,
71 unsigned char *output );
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010072
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010073 /** Allocate a new context */
74 void * (*ctx_alloc_func)( void );
75
76 /** Free the given context */
77 void (*ctx_free_func)( void *ctx );
78
Manuel Pégourié-Gonnard052a6c92015-07-06 16:06:02 +020079 /** Clone state from a context */
80 void (*clone_func)( void *dst, const void *src );
81
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010082 /** Internal use only */
Andres Amaya Garcia5f872df2017-06-28 14:12:44 +010083 int (*process_func)( void *ctx, const unsigned char *input );
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010084};
85
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020086#if defined(MBEDTLS_MD2_C)
87extern const mbedtls_md_info_t mbedtls_md2_info;
Paul Bakker17373852011-01-06 14:20:01 +000088#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020089#if defined(MBEDTLS_MD4_C)
90extern const mbedtls_md_info_t mbedtls_md4_info;
Paul Bakker17373852011-01-06 14:20:01 +000091#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020092#if defined(MBEDTLS_MD5_C)
93extern const mbedtls_md_info_t mbedtls_md5_info;
Paul Bakker17373852011-01-06 14:20:01 +000094#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020095#if defined(MBEDTLS_RIPEMD160_C)
96extern const mbedtls_md_info_t mbedtls_ripemd160_info;
Manuel Pégourié-Gonnarde4d47a62014-01-17 20:41:32 +010097#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020098#if defined(MBEDTLS_SHA1_C)
99extern const mbedtls_md_info_t mbedtls_sha1_info;
Paul Bakker17373852011-01-06 14:20:01 +0000100#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200101#if defined(MBEDTLS_SHA256_C)
102extern const mbedtls_md_info_t mbedtls_sha224_info;
103extern const mbedtls_md_info_t mbedtls_sha256_info;
Paul Bakker17373852011-01-06 14:20:01 +0000104#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200105#if defined(MBEDTLS_SHA512_C)
106extern const mbedtls_md_info_t mbedtls_sha384_info;
107extern const mbedtls_md_info_t mbedtls_sha512_info;
Paul Bakker17373852011-01-06 14:20:01 +0000108#endif
109
110#ifdef __cplusplus
111}
112#endif
113
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200114#endif /* MBEDTLS_MD_WRAP_H */