blob: 04de48291844e0af67107cad1d45a8fcb42c83b5 [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>
Darryl Greena40a1012018-01-05 15:33:17 +00009 */
10/*
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010011 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +020012 * 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.
Paul Bakker17373852011-01-06 14:20:01 +000025 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +000026 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakker17373852011-01-06 14:20:01 +000027 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020028#ifndef MBEDTLS_MD_WRAP_H
29#define MBEDTLS_MD_WRAP_H
Paul Bakker17373852011-01-06 14:20:01 +000030
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020031#if !defined(MBEDTLS_CONFIG_FILE)
Paul Bakker314052f2011-08-15 09:07:52 +000032#include "config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020033#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020034#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020035#endif
Manuel Pégourié-Gonnard6c5abfa2015-02-13 14:12:07 +000036
Paul Bakker314052f2011-08-15 09:07:52 +000037#include "md.h"
Paul Bakker17373852011-01-06 14:20:01 +000038
Paul Bakker17373852011-01-06 14:20:01 +000039#ifdef __cplusplus
40extern "C" {
41#endif
42
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010043/**
44 * Message digest information.
45 * Allows message digest functions to be called in a generic way.
46 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020047struct mbedtls_md_info_t
Manuel Pégourié-Gonnardf5fc6492015-04-02 14:43:57 +010048{
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010049 /** Digest identifier */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020050 mbedtls_md_type_t type;
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010051
52 /** Name of the message digest */
53 const char * name;
54
Manuel Pégourié-Gonnardb8186a52015-06-18 14:58:58 +020055 /** Output length of the digest function in bytes */
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010056 int size;
57
Manuel Pégourié-Gonnardb8186a52015-06-18 14:58:58 +020058 /** Block length of the digest function in bytes */
Manuel Pégourié-Gonnard8379a822015-03-24 16:48:22 +010059 int block_size;
60
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010061 /** Digest initialisation function */
Andres Amaya Garcia5f872df2017-06-28 14:12:44 +010062 int (*starts_func)( void *ctx );
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010063
64 /** Digest update function */
Andres Amaya Garcia5f872df2017-06-28 14:12:44 +010065 int (*update_func)( void *ctx, const unsigned char *input, size_t ilen );
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010066
67 /** Digest finalisation function */
Andres Amaya Garcia5f872df2017-06-28 14:12:44 +010068 int (*finish_func)( void *ctx, unsigned char *output );
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010069
70 /** Generic digest function */
Andres Amaya Garcia5f872df2017-06-28 14:12:44 +010071 int (*digest_func)( const unsigned char *input, size_t ilen,
72 unsigned char *output );
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010073
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010074 /** Allocate a new context */
75 void * (*ctx_alloc_func)( void );
76
77 /** Free the given context */
78 void (*ctx_free_func)( void *ctx );
79
Manuel Pégourié-Gonnard052a6c92015-07-06 16:06:02 +020080 /** Clone state from a context */
81 void (*clone_func)( void *dst, const void *src );
82
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010083 /** Internal use only */
Andres Amaya Garcia5f872df2017-06-28 14:12:44 +010084 int (*process_func)( void *ctx, const unsigned char *input );
Manuel Pégourié-Gonnardca878db2015-03-24 12:13:30 +010085};
86
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020087#if defined(MBEDTLS_MD2_C)
88extern const mbedtls_md_info_t mbedtls_md2_info;
Paul Bakker17373852011-01-06 14:20:01 +000089#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020090#if defined(MBEDTLS_MD4_C)
91extern const mbedtls_md_info_t mbedtls_md4_info;
Paul Bakker17373852011-01-06 14:20:01 +000092#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020093#if defined(MBEDTLS_MD5_C)
94extern const mbedtls_md_info_t mbedtls_md5_info;
Paul Bakker17373852011-01-06 14:20:01 +000095#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020096#if defined(MBEDTLS_RIPEMD160_C)
97extern const mbedtls_md_info_t mbedtls_ripemd160_info;
Manuel Pégourié-Gonnarde4d47a62014-01-17 20:41:32 +010098#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020099#if defined(MBEDTLS_SHA1_C)
100extern const mbedtls_md_info_t mbedtls_sha1_info;
Paul Bakker17373852011-01-06 14:20:01 +0000101#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200102#if defined(MBEDTLS_SHA256_C)
103extern const mbedtls_md_info_t mbedtls_sha224_info;
104extern const mbedtls_md_info_t mbedtls_sha256_info;
Paul Bakker17373852011-01-06 14:20:01 +0000105#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200106#if defined(MBEDTLS_SHA512_C)
107extern const mbedtls_md_info_t mbedtls_sha384_info;
108extern const mbedtls_md_info_t mbedtls_sha512_info;
Paul Bakker17373852011-01-06 14:20:01 +0000109#endif
110
111#ifdef __cplusplus
112}
113#endif
114
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200115#endif /* MBEDTLS_MD_WRAP_H */