Mbed OS Reference
Loading...
Searching...
No Matches
TARGET_Silicon_Labs/sha1_alt.h
Go to the documentation of this file.
1/**
2 * \file sha1_alt.h
3 *
4 * \brief SHA-1 cryptographic hash function
5 *
6 * Copyright (C) 2015-2016, Silicon Labs, http://www.silabs.com
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#ifndef MBEDTLS_SHA1_ALT_H
22#define MBEDTLS_SHA1_ALT_H
23
24#if defined(MBEDTLS_SHA1_ALT)
25
26#include <stdint.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/**
33 * \brief SHA-1 context structure
34 */
35typedef struct
36{
37 uint32_t state[8]; /*!< intermediate digest state */
38 uint32_t total[2]; /*!< number of bytes processed */
39 unsigned char buffer[64]; /*!< data block being processed */
40}
42
43/**
44 * \brief Initialize SHA-1 context
45 *
46 * \param ctx SHA-1 context to be initialized
47 */
49
50/**
51 * \brief Clear SHA-1 context
52 *
53 * \param ctx SHA-1 context to be cleared
54 */
56
57/**
58 * \brief Clone (the state of) a SHA-1 context
59 *
60 * \param dst The destination context
61 * \param src The context to be cloned
62 */
64 const mbedtls_sha1_context *src );
65
66/**
67 * \brief SHA-1 context setup
68 *
69 * \param ctx context to be initialized
70 *
71 * \returns error code
72 */
74
75/**
76 * \brief SHA-1 process buffer
77 *
78 * \param ctx SHA-1 context
79 * \param input buffer holding the data
80 * \param ilen length of the input data
81 *
82 * \returns error code
83 */
84int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen );
85
86/**
87 * \brief SHA-1 final digest
88 *
89 * \param ctx SHA-1 context
90 * \param output SHA-1 checksum result
91 *
92 * \returns error code
93 */
94int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx, unsigned char output[20] );
95
96/* Internal use */
97int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx, const unsigned char data[64] );
98
99#if !defined(MBEDTLS_DEPRECATED_REMOVED)
100#if defined(MBEDTLS_DEPRECATED_WARNING)
101#define MBEDTLS_DEPRECATED __attribute__((deprecated))
102#else
103#define MBEDTLS_DEPRECATED
104#endif
105/**
106 * \brief SHA-1 context setup
107 *
108 * \deprecated Superseded by mbedtls_sha1_starts_ret() in 2.7.0
109 *
110 * \param ctx The SHA-1 context to be initialized.
111 *
112 * \warning SHA-1 is considered a weak message digest and its use
113 * constitutes a security risk. We recommend considering
114 * stronger message digests instead.
115 *
116 */
117MBEDTLS_DEPRECATED void mbedtls_sha1_starts( mbedtls_sha1_context *ctx );
118
119/**
120 * \brief SHA-1 process buffer
121 *
122 * \deprecated Superseded by mbedtls_sha1_update_ret() in 2.7.0
123 *
124 * \param ctx The SHA-1 context.
125 * \param input The buffer holding the input data.
126 * \param ilen The length of the input data.
127 *
128 * \warning SHA-1 is considered a weak message digest and its use
129 * constitutes a security risk. We recommend considering
130 * stronger message digests instead.
131 *
132 */
133MBEDTLS_DEPRECATED void mbedtls_sha1_update( mbedtls_sha1_context *ctx,
134 const unsigned char *input,
135 size_t ilen );
136
137/**
138 * \brief SHA-1 final digest
139 *
140 * \deprecated Superseded by mbedtls_sha1_finish_ret() in 2.7.0
141 *
142 * \param ctx The SHA-1 context.
143 * \param output The SHA-1 checksum result.
144 *
145 * \warning SHA-1 is considered a weak message digest and its use
146 * constitutes a security risk. We recommend considering
147 * stronger message digests instead.
148 *
149 */
150MBEDTLS_DEPRECATED void mbedtls_sha1_finish( mbedtls_sha1_context *ctx,
151 unsigned char output[20] );
152
153/**
154 * \brief SHA-1 process data block (internal use only)
155 *
156 * \deprecated Superseded by mbedtls_internal_sha1_process() in 2.7.0
157 *
158 * \param ctx The SHA-1 context.
159 * \param data The data block being processed.
160 *
161 * \warning SHA-1 is considered a weak message digest and its use
162 * constitutes a security risk. We recommend considering
163 * stronger message digests instead.
164 *
165 */
166MBEDTLS_DEPRECATED void mbedtls_sha1_process( mbedtls_sha1_context *ctx,
167 const unsigned char data[64] );
168
169#undef MBEDTLS_DEPRECATED
170#endif /* !MBEDTLS_DEPRECATED_REMOVED */
171
172#ifdef __cplusplus
173}
174#endif
175
176#endif /* #if defined(MBEDTLS_SHA1_ALT) */
177
178#endif /* #ifndef MBEDTLS_SHA1_ALT_H */
void mbedtls_sha1_free(mbedtls_sha1_context *ctx)
This function clears a SHA-1 context.
void mbedtls_sha1_clone(mbedtls_sha1_context *dst, const mbedtls_sha1_context *src)
This function clones the state of a SHA-1 context.
void mbedtls_sha1_update(mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing SHA-1 checksum calculation.
int mbedtls_sha1_update_ret(mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing SHA-1 checksum calculation.
int mbedtls_internal_sha1_process(mbedtls_sha1_context *ctx, const unsigned char data[64])
SHA-1 process data block (internal use only).
void mbedtls_sha1_process(mbedtls_sha1_context *ctx, const unsigned char data[64])
SHA-1 process data block (internal use only).
int mbedtls_sha1_starts_ret(mbedtls_sha1_context *ctx)
This function starts a SHA-1 checksum calculation.
void mbedtls_sha1_starts(mbedtls_sha1_context *ctx)
This function starts a SHA-1 checksum calculation.
int mbedtls_sha1_finish_ret(mbedtls_sha1_context *ctx, unsigned char output[20])
This function finishes the SHA-1 operation, and writes the result to the output buffer.
void mbedtls_sha1_finish(mbedtls_sha1_context *ctx, unsigned char output[20])
This function finishes the SHA-1 operation, and writes the result to the output buffer.
void mbedtls_sha1_init(mbedtls_sha1_context *ctx)
This function initializes a SHA-1 context.
The SHA-1 context structure.