Modified mbed TLS headers for AES functionality only to reduce build size

Dependents:   BLE_Gateway_Linker_fix BLE_Gateway

Fork of mbedtls by sandbox

Committer:
electronichamsters
Date:
Mon Jul 10 04:00:25 2017 +0000
Revision:
5:f09f5ed830ca
Parent:
1:24750b9ad5ef
working gateway

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Christopher Haster 1:24750b9ad5ef 1 /**
Christopher Haster 1:24750b9ad5ef 2 * \file mbedtls_sha512.h
Christopher Haster 1:24750b9ad5ef 3 *
Christopher Haster 1:24750b9ad5ef 4 * \brief SHA-384 and SHA-512 cryptographic hash function
Christopher Haster 1:24750b9ad5ef 5 *
Christopher Haster 1:24750b9ad5ef 6 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
Christopher Haster 1:24750b9ad5ef 7 * SPDX-License-Identifier: Apache-2.0
Christopher Haster 1:24750b9ad5ef 8 *
Christopher Haster 1:24750b9ad5ef 9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
Christopher Haster 1:24750b9ad5ef 10 * not use this file except in compliance with the License.
Christopher Haster 1:24750b9ad5ef 11 * You may obtain a copy of the License at
Christopher Haster 1:24750b9ad5ef 12 *
Christopher Haster 1:24750b9ad5ef 13 * http://www.apache.org/licenses/LICENSE-2.0
Christopher Haster 1:24750b9ad5ef 14 *
Christopher Haster 1:24750b9ad5ef 15 * Unless required by applicable law or agreed to in writing, software
Christopher Haster 1:24750b9ad5ef 16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
Christopher Haster 1:24750b9ad5ef 17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Christopher Haster 1:24750b9ad5ef 18 * See the License for the specific language governing permissions and
Christopher Haster 1:24750b9ad5ef 19 * limitations under the License.
Christopher Haster 1:24750b9ad5ef 20 *
Christopher Haster 1:24750b9ad5ef 21 * This file is part of mbed TLS (https://tls.mbed.org)
Christopher Haster 1:24750b9ad5ef 22 */
Christopher Haster 1:24750b9ad5ef 23 #ifndef MBEDTLS_SHA512_H
Christopher Haster 1:24750b9ad5ef 24 #define MBEDTLS_SHA512_H
Christopher Haster 1:24750b9ad5ef 25
Christopher Haster 1:24750b9ad5ef 26 #if !defined(MBEDTLS_CONFIG_FILE)
Christopher Haster 1:24750b9ad5ef 27 #include "config.h"
Christopher Haster 1:24750b9ad5ef 28 #else
Christopher Haster 1:24750b9ad5ef 29 #include MBEDTLS_CONFIG_FILE
Christopher Haster 1:24750b9ad5ef 30 #endif
Christopher Haster 1:24750b9ad5ef 31
Christopher Haster 1:24750b9ad5ef 32 #include <stddef.h>
Christopher Haster 1:24750b9ad5ef 33 #include <stdint.h>
Christopher Haster 1:24750b9ad5ef 34
Christopher Haster 1:24750b9ad5ef 35 #if !defined(MBEDTLS_SHA512_ALT)
Christopher Haster 1:24750b9ad5ef 36 // Regular implementation
Christopher Haster 1:24750b9ad5ef 37 //
Christopher Haster 1:24750b9ad5ef 38
Christopher Haster 1:24750b9ad5ef 39 #ifdef __cplusplus
Christopher Haster 1:24750b9ad5ef 40 extern "C" {
Christopher Haster 1:24750b9ad5ef 41 #endif
Christopher Haster 1:24750b9ad5ef 42
Christopher Haster 1:24750b9ad5ef 43 /**
Christopher Haster 1:24750b9ad5ef 44 * \brief SHA-512 context structure
Christopher Haster 1:24750b9ad5ef 45 */
Christopher Haster 1:24750b9ad5ef 46 typedef struct
Christopher Haster 1:24750b9ad5ef 47 {
Christopher Haster 1:24750b9ad5ef 48 uint64_t total[2]; /*!< number of bytes processed */
Christopher Haster 1:24750b9ad5ef 49 uint64_t state[8]; /*!< intermediate digest state */
Christopher Haster 1:24750b9ad5ef 50 unsigned char buffer[128]; /*!< data block being processed */
Christopher Haster 1:24750b9ad5ef 51 int is384; /*!< 0 => SHA-512, else SHA-384 */
Christopher Haster 1:24750b9ad5ef 52 }
Christopher Haster 1:24750b9ad5ef 53 mbedtls_sha512_context;
Christopher Haster 1:24750b9ad5ef 54
Christopher Haster 1:24750b9ad5ef 55 /**
Christopher Haster 1:24750b9ad5ef 56 * \brief Initialize SHA-512 context
Christopher Haster 1:24750b9ad5ef 57 *
Christopher Haster 1:24750b9ad5ef 58 * \param ctx SHA-512 context to be initialized
Christopher Haster 1:24750b9ad5ef 59 */
Christopher Haster 1:24750b9ad5ef 60 void mbedtls_sha512_init( mbedtls_sha512_context *ctx );
Christopher Haster 1:24750b9ad5ef 61
Christopher Haster 1:24750b9ad5ef 62 /**
Christopher Haster 1:24750b9ad5ef 63 * \brief Clear SHA-512 context
Christopher Haster 1:24750b9ad5ef 64 *
Christopher Haster 1:24750b9ad5ef 65 * \param ctx SHA-512 context to be cleared
Christopher Haster 1:24750b9ad5ef 66 */
Christopher Haster 1:24750b9ad5ef 67 void mbedtls_sha512_free( mbedtls_sha512_context *ctx );
Christopher Haster 1:24750b9ad5ef 68
Christopher Haster 1:24750b9ad5ef 69 /**
Christopher Haster 1:24750b9ad5ef 70 * \brief Clone (the state of) a SHA-512 context
Christopher Haster 1:24750b9ad5ef 71 *
Christopher Haster 1:24750b9ad5ef 72 * \param dst The destination context
Christopher Haster 1:24750b9ad5ef 73 * \param src The context to be cloned
Christopher Haster 1:24750b9ad5ef 74 */
Christopher Haster 1:24750b9ad5ef 75 void mbedtls_sha512_clone( mbedtls_sha512_context *dst,
Christopher Haster 1:24750b9ad5ef 76 const mbedtls_sha512_context *src );
Christopher Haster 1:24750b9ad5ef 77
Christopher Haster 1:24750b9ad5ef 78 /**
Christopher Haster 1:24750b9ad5ef 79 * \brief SHA-512 context setup
Christopher Haster 1:24750b9ad5ef 80 *
Christopher Haster 1:24750b9ad5ef 81 * \param ctx context to be initialized
Christopher Haster 1:24750b9ad5ef 82 * \param is384 0 = use SHA512, 1 = use SHA384
Christopher Haster 1:24750b9ad5ef 83 */
Christopher Haster 1:24750b9ad5ef 84 void mbedtls_sha512_starts( mbedtls_sha512_context *ctx, int is384 );
Christopher Haster 1:24750b9ad5ef 85
Christopher Haster 1:24750b9ad5ef 86 /**
Christopher Haster 1:24750b9ad5ef 87 * \brief SHA-512 process buffer
Christopher Haster 1:24750b9ad5ef 88 *
Christopher Haster 1:24750b9ad5ef 89 * \param ctx SHA-512 context
Christopher Haster 1:24750b9ad5ef 90 * \param input buffer holding the data
Christopher Haster 1:24750b9ad5ef 91 * \param ilen length of the input data
Christopher Haster 1:24750b9ad5ef 92 */
Christopher Haster 1:24750b9ad5ef 93 void mbedtls_sha512_update( mbedtls_sha512_context *ctx, const unsigned char *input,
Christopher Haster 1:24750b9ad5ef 94 size_t ilen );
Christopher Haster 1:24750b9ad5ef 95
Christopher Haster 1:24750b9ad5ef 96 /**
Christopher Haster 1:24750b9ad5ef 97 * \brief SHA-512 final digest
Christopher Haster 1:24750b9ad5ef 98 *
Christopher Haster 1:24750b9ad5ef 99 * \param ctx SHA-512 context
Christopher Haster 1:24750b9ad5ef 100 * \param output SHA-384/512 checksum result
Christopher Haster 1:24750b9ad5ef 101 */
Christopher Haster 1:24750b9ad5ef 102 void mbedtls_sha512_finish( mbedtls_sha512_context *ctx, unsigned char output[64] );
Christopher Haster 1:24750b9ad5ef 103
Christopher Haster 1:24750b9ad5ef 104 #ifdef __cplusplus
Christopher Haster 1:24750b9ad5ef 105 }
Christopher Haster 1:24750b9ad5ef 106 #endif
Christopher Haster 1:24750b9ad5ef 107
Christopher Haster 1:24750b9ad5ef 108 #else /* MBEDTLS_SHA512_ALT */
Christopher Haster 1:24750b9ad5ef 109 #include "sha512_alt.h"
Christopher Haster 1:24750b9ad5ef 110 #endif /* MBEDTLS_SHA512_ALT */
Christopher Haster 1:24750b9ad5ef 111
Christopher Haster 1:24750b9ad5ef 112 #ifdef __cplusplus
Christopher Haster 1:24750b9ad5ef 113 extern "C" {
Christopher Haster 1:24750b9ad5ef 114 #endif
Christopher Haster 1:24750b9ad5ef 115
Christopher Haster 1:24750b9ad5ef 116 /**
Christopher Haster 1:24750b9ad5ef 117 * \brief Output = SHA-512( input buffer )
Christopher Haster 1:24750b9ad5ef 118 *
Christopher Haster 1:24750b9ad5ef 119 * \param input buffer holding the data
Christopher Haster 1:24750b9ad5ef 120 * \param ilen length of the input data
Christopher Haster 1:24750b9ad5ef 121 * \param output SHA-384/512 checksum result
Christopher Haster 1:24750b9ad5ef 122 * \param is384 0 = use SHA512, 1 = use SHA384
Christopher Haster 1:24750b9ad5ef 123 */
Christopher Haster 1:24750b9ad5ef 124 void mbedtls_sha512( const unsigned char *input, size_t ilen,
Christopher Haster 1:24750b9ad5ef 125 unsigned char output[64], int is384 );
Christopher Haster 1:24750b9ad5ef 126
Christopher Haster 1:24750b9ad5ef 127 /**
Christopher Haster 1:24750b9ad5ef 128 * \brief Checkup routine
Christopher Haster 1:24750b9ad5ef 129 *
Christopher Haster 1:24750b9ad5ef 130 * \return 0 if successful, or 1 if the test failed
Christopher Haster 1:24750b9ad5ef 131 */
Christopher Haster 1:24750b9ad5ef 132 int mbedtls_sha512_self_test( int verbose );
Christopher Haster 1:24750b9ad5ef 133
Christopher Haster 1:24750b9ad5ef 134 /* Internal use */
Christopher Haster 1:24750b9ad5ef 135 void mbedtls_sha512_process( mbedtls_sha512_context *ctx, const unsigned char data[128] );
Christopher Haster 1:24750b9ad5ef 136
Christopher Haster 1:24750b9ad5ef 137 #ifdef __cplusplus
Christopher Haster 1:24750b9ad5ef 138 }
Christopher Haster 1:24750b9ad5ef 139 #endif
Christopher Haster 1:24750b9ad5ef 140
Christopher Haster 1:24750b9ad5ef 141 #endif /* mbedtls_sha512.h */