1 /* 2 * Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 /*! 8 @addtogroup cc_sha512_t_h 9 @{ 10 */ 11 12 13 /*! 14 @file 15 @brief This file contains all of the CryptoCell SHA-512 truncated APIs, their 16 enums and definitions. 17 */ 18 19 #ifndef _MBEDTLS_CC_SHA512_T_H 20 #define _MBEDTLS_CC_SHA512_T_H 21 22 #include <mbedtls/sha512.h> 23 24 /*! 25 @brief This function initializes the SHA-512_t context. 26 */ 27 void mbedtls_sha512_t_init( 28 /*! The SHA-512_t context to initialize. */ 29 mbedtls_sha512_context *ctx 30 ); 31 32 /*! 33 @brief This function clears the SHA-512_t context. 34 */ 35 void mbedtls_sha512_t_free( 36 /*! The SHA-512_t context to clear. */ 37 mbedtls_sha512_context *ctx 38 ); 39 40 /*! 41 @brief This function starts a SHA-512_t checksum calculation. 42 */ 43 void mbedtls_sha512_t_starts( 44 /*! The SHA-512_t context to initialize. */ 45 mbedtls_sha512_context *ctx, 46 /*! Determines which function to use: 0: Use SHA-512/256, or 1: 47 Use SHA-512/224. */ 48 int is224 49 ); 50 51 /*! 52 @brief This function feeds an input buffer into an ongoing SHA-512_t 53 checksum calculation. 54 */ 55 void mbedtls_sha512_t_update( 56 /*! The SHA-512_t context. */ 57 mbedtls_sha512_context *ctx, 58 /*! The buffer holding the input data. */ 59 const unsigned char *input, 60 /*! The length of the input data. */ 61 size_t ilen 62 ); 63 64 /*! 65 @brief This function finishes the SHA-512_t operation, and writes 66 the result to the output buffer. 67 68 <ul><li>For SHA512/224, the output buffer will include 69 the 28 leftmost bytes of the SHA-512 digest.</li> 70 <li>For SHA512/256, the output buffer will include 71 the 32 leftmost bytes of the SHA-512 digest.</li></ul> 72 */ 73 void mbedtls_sha512_t_finish( 74 /*! The SHA-512_t context. */ 75 mbedtls_sha512_context *ctx, 76 /*! The SHA-512/256 or SHA-512/224 checksum result. */ 77 unsigned char output[32], 78 /*! Determines which function to use: 0: Use SHA-512/256, or 1: 79 Use SHA-512/224. */ 80 int is224 81 ); 82 83 /*! 84 @brief This function calculates the SHA-512 checksum of a buffer. 85 86 The function performs the following operations: 87 <ul><li>Allocates the context.<li><li>Calculates 88 the checksum.</li><li>Frees the context.</li></ul> 89 The SHA-512 result is calculated as 90 output = SHA-512(input buffer). 91 */ 92 void mbedtls_sha512_t( 93 /*! The buffer holding the input data. */ 94 const unsigned char *input, 95 /*! The length of the input data. */ 96 size_t ilen, 97 /*! The SHA-512/256 or SHA-512/224 checksum result. */ 98 unsigned char output[32], 99 /*! Determines which function to use: 0: Use SHA-512/256, or 1: 100 Use SHA-512/224. */ 101 int is224 102 ); 103 104 /*! 105 @} 106 */ 107 #endif 108