2 * \file mbedtls_sha512.h
4 * \brief SHA-384 and SHA-512 cryptographic hash function
6 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
7 * SPDX-License-Identifier: Apache-2.0
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * This file is part of mbed TLS (https://tls.mbed.org)
23 #ifndef MBEDTLS_SHA512_H
24 #define MBEDTLS_SHA512_H
26 #if !defined(MBEDTLS_CONFIG_FILE)
29 #include MBEDTLS_CONFIG_FILE
35 #if !defined(MBEDTLS_SHA512_ALT)
36 // Regular implementation
44 * \brief SHA-512 context structure
48 uint64_t total
[2]; /*!< number of bytes processed */
49 uint64_t state
[8]; /*!< intermediate digest state */
50 unsigned char buffer
[128]; /*!< data block being processed */
51 int is384
; /*!< 0 => SHA-512, else SHA-384 */
53 mbedtls_sha512_context
;
56 * \brief Initialize SHA-512 context
58 * \param ctx SHA-512 context to be initialized
60 void mbedtls_sha512_init( mbedtls_sha512_context
*ctx
);
63 * \brief Clear SHA-512 context
65 * \param ctx SHA-512 context to be cleared
67 void mbedtls_sha512_free( mbedtls_sha512_context
*ctx
);
70 * \brief Clone (the state of) a SHA-512 context
72 * \param dst The destination context
73 * \param src The context to be cloned
75 void mbedtls_sha512_clone( mbedtls_sha512_context
*dst
,
76 const mbedtls_sha512_context
*src
);
79 * \brief SHA-512 context setup
81 * \param ctx context to be initialized
82 * \param is384 0 = use SHA512, 1 = use SHA384
84 void mbedtls_sha512_starts( mbedtls_sha512_context
*ctx
, int is384
);
87 * \brief SHA-512 process buffer
89 * \param ctx SHA-512 context
90 * \param input buffer holding the data
91 * \param ilen length of the input data
93 void mbedtls_sha512_update( mbedtls_sha512_context
*ctx
, const unsigned char *input
,
97 * \brief SHA-512 final digest
99 * \param ctx SHA-512 context
100 * \param output SHA-384/512 checksum result
102 void mbedtls_sha512_finish( mbedtls_sha512_context
*ctx
, unsigned char output
[64] );
108 #else /* MBEDTLS_SHA512_ALT */
109 #include "sha512_alt.h"
110 #endif /* MBEDTLS_SHA512_ALT */
117 * \brief Output = SHA-512( input buffer )
119 * \param input buffer holding the data
120 * \param ilen length of the input data
121 * \param output SHA-384/512 checksum result
122 * \param is384 0 = use SHA512, 1 = use SHA384
124 void mbedtls_sha512( const unsigned char *input
, size_t ilen
,
125 unsigned char output
[64], int is384
);
128 * \brief Checkup routine
130 * \return 0 if successful, or 1 if the test failed
132 int mbedtls_sha512_self_test( int verbose
);
135 void mbedtls_sha512_process( mbedtls_sha512_context
*ctx
, const unsigned char data
[128] );
141 #endif /* mbedtls_sha512.h */