Mistake on this page?
Report an issue in GitHub or email us
TARGET_M480/sha/sha_alt_hw.h
1 /*
2  * Copyright (c) 2015-2016, Nuvoton Technology Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef MBEDTLS_SHA_ALT_HW_H
20 #define MBEDTLS_SHA_ALT_HW_H
21 
22 #if defined(MBEDTLS_SHA1_ALT) || defined(MBEDTLS_SHA256_ALT) || defined(MBEDTLS_SHA512_ALT)
23 
24 #include <stddef.h>
25 #include <stdint.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 /**
32  * \brief SHA context structure
33  */
34 typedef struct {
35  uint32_t total; /*!< number of bytes processed */
36  uint8_t buffer[128]; /*!< data block being processed. Max of SHA-1/SHA-256/SHA-512 */
37  uint16_t buffer_left;
38  uint16_t blocksize; /*!< block size */
39  uint32_t blocksize_mask; /*!< block size mask */
40 
41  int is224_384; /*!< 0 => SHA-256/SHA-512, else SHA-224/384 */
42 }
43 crypto_sha_context;
44 
45 void crypto_sha_update(crypto_sha_context *ctx, const unsigned char *input, size_t ilen);
46 void crypto_sha_update_nobuf(crypto_sha_context *ctx, const unsigned char *input, size_t ilen, int islast);
47 void crypto_sha_getinternstate(unsigned char output[], size_t olen);
48 
49 #if defined(MBEDTLS_SHA1_ALT)
50 
51 void mbedtls_sha1_hw_init( crypto_sha_context *ctx );
52 void mbedtls_sha1_hw_free( crypto_sha_context *ctx );
53 void mbedtls_sha1_hw_starts( crypto_sha_context *ctx );
54 void mbedtls_sha1_hw_update( crypto_sha_context *ctx, const unsigned char *input, size_t ilen );
55 void mbedtls_sha1_hw_finish( crypto_sha_context *ctx, unsigned char output[20] );
56 void mbedtls_sha1_hw_process( crypto_sha_context *ctx, const unsigned char data[64] );
57 
58 #endif /* MBEDTLS_SHA1_ALT */
59 
60 #if defined(MBEDTLS_SHA256_ALT)
61 
62 void mbedtls_sha256_hw_init( crypto_sha_context *ctx );
63 void mbedtls_sha256_hw_free( crypto_sha_context *ctx );
64 void mbedtls_sha256_hw_starts( crypto_sha_context *ctx, int is224 );
65 void mbedtls_sha256_hw_update( crypto_sha_context *ctx, const unsigned char *input,
66  size_t ilen );
67 void mbedtls_sha256_hw_finish( crypto_sha_context *ctx, unsigned char output[32] );
68 void mbedtls_sha256_hw_process( crypto_sha_context *ctx, const unsigned char data[64] );
69 
70 #endif /* MBEDTLS_SHA256_ALT */
71 
72 #if defined(MBEDTLS_SHA512_ALT)
73 
74 void mbedtls_sha512_hw_init( crypto_sha_context *ctx );
75 void mbedtls_sha512_hw_free( crypto_sha_context *ctx );
76 void mbedtls_sha512_hw_starts( crypto_sha_context *ctx, int is384 );
77 void mbedtls_sha512_hw_update( crypto_sha_context *ctx, const unsigned char *input,
78  size_t ilen );
79 void mbedtls_sha512_hw_finish( crypto_sha_context *ctx, unsigned char output[64] );
80 void mbedtls_sha512_hw_process( crypto_sha_context *ctx, const unsigned char data[128] );
81 
82 #endif /* MBEDTLS_SHA512_ALT */
83 
84 #ifdef __cplusplus
85 }
86 #endif
87 
88 #endif /* MBEDTLS_SHA1_ALT || MBEDTLS_SHA256_ALT || MBEDTLS_SHA512_ALT */
89 
90 #endif /* sha_alt.h */
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.