mbed library sources. Supersedes mbed-src.

Fork of mbed-dev by mbed official

Committer:
<>
Date:
Fri Oct 28 11:17:30 2016 +0100
Revision:
149:156823d33999
This updates the lib to the mbed lib v128

NOTE: This release includes a restructuring of the file and directory locations and thus some
include paths in your code may need updating accordingly.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 149:156823d33999 1 /**
<> 149:156823d33999 2 * \file sha256.h
<> 149:156823d33999 3 *
<> 149:156823d33999 4 * \brief SHA-224 and SHA-256 cryptographic hash function
<> 149:156823d33999 5 *
<> 149:156823d33999 6 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
<> 149:156823d33999 7 * SPDX-License-Identifier: Apache-2.0
<> 149:156823d33999 8 *
<> 149:156823d33999 9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
<> 149:156823d33999 10 * not use this file except in compliance with the License.
<> 149:156823d33999 11 * You may obtain a copy of the License at
<> 149:156823d33999 12 *
<> 149:156823d33999 13 * http://www.apache.org/licenses/LICENSE-2.0
<> 149:156823d33999 14 *
<> 149:156823d33999 15 * Unless required by applicable law or agreed to in writing, software
<> 149:156823d33999 16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
<> 149:156823d33999 17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<> 149:156823d33999 18 * See the License for the specific language governing permissions and
<> 149:156823d33999 19 * limitations under the License.
<> 149:156823d33999 20 *
<> 149:156823d33999 21 * This file is part of mbed TLS (https://tls.mbed.org)
<> 149:156823d33999 22 */
<> 149:156823d33999 23 #ifndef MBEDTLS_SHA256_ALT_SW_H
<> 149:156823d33999 24 #define MBEDTLS_SHA256_ALT_SW_H
<> 149:156823d33999 25
<> 149:156823d33999 26 #if !defined(MBEDTLS_CONFIG_FILE)
<> 149:156823d33999 27 #include "config.h"
<> 149:156823d33999 28 #else
<> 149:156823d33999 29 #include MBEDTLS_CONFIG_FILE
<> 149:156823d33999 30 #endif
<> 149:156823d33999 31
<> 149:156823d33999 32 #if defined(MBEDTLS_SHA256_C)
<> 149:156823d33999 33 #if defined(MBEDTLS_SHA256_ALT)
<> 149:156823d33999 34
<> 149:156823d33999 35 #include <stddef.h>
<> 149:156823d33999 36 #include <stdint.h>
<> 149:156823d33999 37
<> 149:156823d33999 38 #ifdef __cplusplus
<> 149:156823d33999 39 extern "C" {
<> 149:156823d33999 40 #endif
<> 149:156823d33999 41
<> 149:156823d33999 42 /**
<> 149:156823d33999 43 * \brief SHA-256 context structure
<> 149:156823d33999 44 */
<> 149:156823d33999 45 typedef struct
<> 149:156823d33999 46 {
<> 149:156823d33999 47 uint32_t total[2]; /*!< number of bytes processed */
<> 149:156823d33999 48 uint32_t state[8]; /*!< intermediate digest state */
<> 149:156823d33999 49 unsigned char buffer[64]; /*!< data block being processed */
<> 149:156823d33999 50 int is224; /*!< 0 => SHA-256, else SHA-224 */
<> 149:156823d33999 51 }
<> 149:156823d33999 52 mbedtls_sha256_sw_context;
<> 149:156823d33999 53
<> 149:156823d33999 54 /**
<> 149:156823d33999 55 * \brief Initialize SHA-256 context
<> 149:156823d33999 56 *
<> 149:156823d33999 57 * \param ctx SHA-256 context to be initialized
<> 149:156823d33999 58 */
<> 149:156823d33999 59 void mbedtls_sha256_sw_init( mbedtls_sha256_sw_context *ctx );
<> 149:156823d33999 60
<> 149:156823d33999 61 /**
<> 149:156823d33999 62 * \brief Clear SHA-256 context
<> 149:156823d33999 63 *
<> 149:156823d33999 64 * \param ctx SHA-256 context to be cleared
<> 149:156823d33999 65 */
<> 149:156823d33999 66 void mbedtls_sha256_sw_free( mbedtls_sha256_sw_context *ctx );
<> 149:156823d33999 67
<> 149:156823d33999 68 /**
<> 149:156823d33999 69 * \brief Clone (the state of) a SHA-256 context
<> 149:156823d33999 70 *
<> 149:156823d33999 71 * \param dst The destination context
<> 149:156823d33999 72 * \param src The context to be cloned
<> 149:156823d33999 73 */
<> 149:156823d33999 74 void mbedtls_sha256_sw_clone( mbedtls_sha256_sw_context *dst,
<> 149:156823d33999 75 const mbedtls_sha256_sw_context *src );
<> 149:156823d33999 76
<> 149:156823d33999 77 /**
<> 149:156823d33999 78 * \brief SHA-256 context setup
<> 149:156823d33999 79 *
<> 149:156823d33999 80 * \param ctx context to be initialized
<> 149:156823d33999 81 * \param is224 0 = use SHA256, 1 = use SHA224
<> 149:156823d33999 82 */
<> 149:156823d33999 83 void mbedtls_sha256_sw_starts( mbedtls_sha256_sw_context *ctx, int is224 );
<> 149:156823d33999 84
<> 149:156823d33999 85 /**
<> 149:156823d33999 86 * \brief SHA-256 process buffer
<> 149:156823d33999 87 *
<> 149:156823d33999 88 * \param ctx SHA-256 context
<> 149:156823d33999 89 * \param input buffer holding the data
<> 149:156823d33999 90 * \param ilen length of the input data
<> 149:156823d33999 91 */
<> 149:156823d33999 92 void mbedtls_sha256_sw_update( mbedtls_sha256_sw_context *ctx, const unsigned char *input,
<> 149:156823d33999 93 size_t ilen );
<> 149:156823d33999 94
<> 149:156823d33999 95 /**
<> 149:156823d33999 96 * \brief SHA-256 final digest
<> 149:156823d33999 97 *
<> 149:156823d33999 98 * \param ctx SHA-256 context
<> 149:156823d33999 99 * \param output SHA-224/256 checksum result
<> 149:156823d33999 100 */
<> 149:156823d33999 101 void mbedtls_sha256_sw_finish( mbedtls_sha256_sw_context *ctx, unsigned char output[32] );
<> 149:156823d33999 102
<> 149:156823d33999 103 /* Internal use */
<> 149:156823d33999 104 void mbedtls_sha256_sw_process( mbedtls_sha256_sw_context *ctx, const unsigned char data[64] );
<> 149:156823d33999 105
<> 149:156823d33999 106 #ifdef __cplusplus
<> 149:156823d33999 107 }
<> 149:156823d33999 108 #endif
<> 149:156823d33999 109
<> 149:156823d33999 110 #endif /* MBEDTLS_SHA256_ALT */
<> 149:156823d33999 111 #endif /* MBEDTLS_SHA256_C */
<> 149:156823d33999 112
<> 149:156823d33999 113 #endif /* sha256_alt_sw.h */