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