1 /** 2 * \file sha1.h 3 * 4 * \brief SHA-1 cryptographic hash function 5 * 6 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 7 * SPDX-License-Identifier: Apache-2.0 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); you may 10 * not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 * 21 * This file is part of mbed TLS (https://tls.mbed.org) 22 */ 23 #ifndef MBEDTLS_SHA1_ALT_H 24 #define MBEDTLS_SHA1_ALT_H 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 #include "sec_crypto_sha.h" 31 /** 32 * \brief SHA-1 context structure 33 */ 34 35 typedef struct { 36 sc_sha_t sc_sha; 37 sc_sha_context_t sc_ctx; 38 } 39 mbedtls_sha1_context; 40 41 /** 42 * \brief Initialize SHA-1 context 43 * 44 * \param ctx SHA-1 context to be initialized 45 */ 46 void mbedtls_sha1_init(mbedtls_sha1_context *ctx); 47 48 /** 49 * \brief Clear SHA-1 context 50 * 51 * \param ctx SHA-1 context to be cleared 52 */ 53 void mbedtls_sha1_free(mbedtls_sha1_context *ctx); 54 55 /** 56 * \brief Clone (the state of) a SHA-1 context 57 * 58 * \param dst The destination context 59 * \param src The context to be cloned 60 */ 61 void mbedtls_sha1_clone(mbedtls_sha1_context *dst, const mbedtls_sha1_context *src); 62 63 /** 64 * \brief SHA-1 context setup 65 * 66 * \param ctx context to be initialized 67 */ 68 void mbedtls_sha1_starts(mbedtls_sha1_context *ctx); 69 70 /** 71 * \brief SHA-1 process buffer 72 * 73 * \param ctx SHA-1 context 74 * \param input buffer holding the data 75 * \param ilen length of the input data 76 */ 77 void mbedtls_sha1_update(mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen); 78 79 /** 80 * \brief SHA-1 final digest 81 * 82 * \param ctx SHA-1 context 83 * \param output SHA-1 checksum result 84 */ 85 void mbedtls_sha1_finish(mbedtls_sha1_context *ctx, unsigned char output[20]); 86 87 /* Internal use */ 88 void mbedtls_sha1_process(mbedtls_sha1_context *ctx, const unsigned char data[64]); 89 90 #ifdef __cplusplus 91 } 92 #endif 93 94 #endif /* mbedtls_sha1.h */ 95