Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
sha1_alt.h
00001 /* 00002 * sha1_alt.h 00003 * 00004 * Copyright (C) 2018, Arm Limited, All Rights Reserved 00005 * SPDX-License-Identifier: Apache-2.0 00006 * 00007 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00008 * not use this file except in compliance with the License. 00009 * You may obtain a copy of the License at 00010 * 00011 * http://www.apache.org/licenses/LICENSE-2.0 00012 * 00013 * Unless required by applicable law or agreed to in writing, software 00014 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00015 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00016 * See the License for the specific language governing permissions and 00017 * limitations under the License. 00018 * 00019 */ 00020 00021 #ifndef __SHA1_ALT__ 00022 #define __SHA1_ALT__ 00023 #if defined(MBEDTLS_SHA1_ALT) 00024 #include "crys_hash.h" 00025 #ifdef __cplusplus 00026 extern "C" { 00027 #endif 00028 00029 00030 /** 00031 * \brief SHA-1 context structure 00032 */ 00033 typedef struct 00034 { 00035 CRYS_HASHUserContext_t crys_hash_ctx; 00036 } mbedtls_sha1_context; 00037 00038 /** 00039 * \brief This function initializes a SHA-1 context. 00040 * 00041 * \param ctx The SHA-1 context to initialize. 00042 * 00043 * \warning SHA-1 is considered a weak message digest and its use 00044 * constitutes a security risk. We recommend considering 00045 * stronger message digests instead. 00046 * 00047 */ 00048 void mbedtls_sha1_init( mbedtls_sha1_context *ctx ); 00049 00050 /** 00051 * \brief This function clears a SHA-1 context. 00052 * 00053 * \param ctx The SHA-1 context to clear. 00054 * 00055 * \warning SHA-1 is considered a weak message digest and its use 00056 * constitutes a security risk. We recommend considering 00057 * stronger message digests instead. 00058 * 00059 */ 00060 void mbedtls_sha1_free( mbedtls_sha1_context *ctx ); 00061 00062 /** 00063 * \brief This function clones the state of a SHA-1 context. 00064 * 00065 * \param dst The destination context. 00066 * \param src The context to clone. 00067 * 00068 * \warning SHA-1 is considered a weak message digest and its use 00069 * constitutes a security risk. We recommend considering 00070 * stronger message digests instead. 00071 * 00072 */ 00073 void mbedtls_sha1_clone( mbedtls_sha1_context *dst, 00074 const mbedtls_sha1_context *src ); 00075 00076 /** 00077 * \brief This function starts a SHA-1 checksum calculation. 00078 * 00079 * \param ctx The context to initialize. 00080 * 00081 * \return \c 0 if successful 00082 * 00083 * \warning SHA-1 is considered a weak message digest and its use 00084 * constitutes a security risk. We recommend considering 00085 * stronger message digests instead. 00086 * 00087 */ 00088 int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx ); 00089 00090 /** 00091 * \brief This function feeds an input buffer into an ongoing SHA-1 00092 * checksum calculation. 00093 * 00094 * \param ctx The SHA-1 context. 00095 * \param input The buffer holding the input data. 00096 * \param ilen The length of the input data. 00097 * 00098 * \return \c 0 if successful 00099 * 00100 * \warning SHA-1 is considered a weak message digest and its use 00101 * constitutes a security risk. We recommend considering 00102 * stronger message digests instead. 00103 * 00104 */ 00105 int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx, 00106 const unsigned char *input, 00107 size_t ilen ); 00108 00109 /** 00110 * \brief This function finishes the SHA-1 operation, and writes 00111 * the result to the output buffer. 00112 * 00113 * \param ctx The SHA-1 context. 00114 * \param output The SHA-1 checksum result. 00115 * 00116 * \return \c 0 if successful 00117 * 00118 * \warning SHA-1 is considered a weak message digest and its use 00119 * constitutes a security risk. We recommend considering 00120 * stronger message digests instead. 00121 * 00122 */ 00123 int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx, 00124 unsigned char output[20] ); 00125 00126 /** 00127 * \brief SHA-1 process data block (internal use only) 00128 * 00129 * \param ctx SHA-1 context 00130 * \param data The data block being processed. 00131 * 00132 * \return \c 0 if successful 00133 * 00134 * \warning SHA-1 is considered a weak message digest and its use 00135 * constitutes a security risk. We recommend considering 00136 * stronger message digests instead. 00137 * 00138 */ 00139 int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx, 00140 const unsigned char data[64] ); 00141 00142 #ifdef __cplusplus 00143 } 00144 #endif 00145 00146 #endif //MBEDTLS_SHA1_ALT 00147 #endif //__SHA1_ALT__ 00148
Generated on Tue Jul 12 2022 12:45:45 by
