mbed library sources. Supersedes mbed-src.
Fork of mbed-dev by
targets/TARGET_NUVOTON/TARGET_NUC472/crypto/sha/sha_alt_hw.h@149:156823d33999, 2016-10-28 (annotated)
- Committer:
- <>
- Date:
- Fri Oct 28 11:17:30 2016 +0100
- Revision:
- 149:156823d33999
This updates the lib to the mbed lib v128
NOTE: This release includes a restructuring of the file and directory locations and thus some
include paths in your code may need updating accordingly.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 149:156823d33999 | 1 | /* mbed Microcontroller Library |
<> | 149:156823d33999 | 2 | * Copyright (c) 2015-2016 Nuvoton |
<> | 149:156823d33999 | 3 | * |
<> | 149:156823d33999 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
<> | 149:156823d33999 | 5 | * you may not use this file except in compliance with the License. |
<> | 149:156823d33999 | 6 | * You may obtain a copy of the License at |
<> | 149:156823d33999 | 7 | * |
<> | 149:156823d33999 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
<> | 149:156823d33999 | 9 | * |
<> | 149:156823d33999 | 10 | * Unless required by applicable law or agreed to in writing, software |
<> | 149:156823d33999 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
<> | 149:156823d33999 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
<> | 149:156823d33999 | 13 | * See the License for the specific language governing permissions and |
<> | 149:156823d33999 | 14 | * limitations under the License. |
<> | 149:156823d33999 | 15 | */ |
<> | 149:156823d33999 | 16 | #ifndef MBEDTLS_SHA_ALT_HW_H |
<> | 149:156823d33999 | 17 | #define MBEDTLS_SHA_ALT_HW_H |
<> | 149:156823d33999 | 18 | |
<> | 149:156823d33999 | 19 | #if !defined(MBEDTLS_CONFIG_FILE) |
<> | 149:156823d33999 | 20 | #include "config.h" |
<> | 149:156823d33999 | 21 | #else |
<> | 149:156823d33999 | 22 | #include MBEDTLS_CONFIG_FILE |
<> | 149:156823d33999 | 23 | #endif |
<> | 149:156823d33999 | 24 | |
<> | 149:156823d33999 | 25 | #if defined(MBEDTLS_SHA1_C) || defined(MBEDTLS_SHA256_C) || defined(MBEDTLS_SHA512_C) |
<> | 149:156823d33999 | 26 | |
<> | 149:156823d33999 | 27 | #include <stddef.h> |
<> | 149:156823d33999 | 28 | #include <stdint.h> |
<> | 149:156823d33999 | 29 | |
<> | 149:156823d33999 | 30 | #ifdef __cplusplus |
<> | 149:156823d33999 | 31 | extern "C" { |
<> | 149:156823d33999 | 32 | #endif |
<> | 149:156823d33999 | 33 | |
<> | 149:156823d33999 | 34 | /** |
<> | 149:156823d33999 | 35 | * \brief SHA context structure |
<> | 149:156823d33999 | 36 | */ |
<> | 149:156823d33999 | 37 | typedef struct |
<> | 149:156823d33999 | 38 | { |
<> | 149:156823d33999 | 39 | uint32_t total; /*!< number of bytes processed */ |
<> | 149:156823d33999 | 40 | unsigned char buffer[128]; /*!< data block being processed. Max of SHA-1/SHA-256/SHA-512 */ |
<> | 149:156823d33999 | 41 | uint16_t buffer_left; |
<> | 149:156823d33999 | 42 | uint16_t blocksize; /*!< block size */ |
<> | 149:156823d33999 | 43 | uint32_t blocksize_mask; /*!< block size mask */ |
<> | 149:156823d33999 | 44 | |
<> | 149:156823d33999 | 45 | int is224; /*!< 0 => SHA-256, else SHA-224 */ |
<> | 149:156823d33999 | 46 | } |
<> | 149:156823d33999 | 47 | crypto_sha_context; |
<> | 149:156823d33999 | 48 | |
<> | 149:156823d33999 | 49 | void crypto_sha_update(crypto_sha_context *ctx, const unsigned char *input, size_t ilen); |
<> | 149:156823d33999 | 50 | void crypto_sha_update_nobuf(crypto_sha_context *ctx, const unsigned char *input, size_t ilen, int islast); |
<> | 149:156823d33999 | 51 | void crypto_sha_getinternstate(unsigned char output[], size_t olen); |
<> | 149:156823d33999 | 52 | |
<> | 149:156823d33999 | 53 | #if defined(MBEDTLS_SHA1_ALT) |
<> | 149:156823d33999 | 54 | |
<> | 149:156823d33999 | 55 | void mbedtls_sha1_hw_init( crypto_sha_context *ctx ); |
<> | 149:156823d33999 | 56 | void mbedtls_sha1_hw_free( crypto_sha_context *ctx ); |
<> | 149:156823d33999 | 57 | void mbedtls_sha1_hw_clone( crypto_sha_context *dst, |
<> | 149:156823d33999 | 58 | const crypto_sha_context *src ); |
<> | 149:156823d33999 | 59 | void mbedtls_sha1_hw_starts( crypto_sha_context *ctx ); |
<> | 149:156823d33999 | 60 | void mbedtls_sha1_hw_update( crypto_sha_context *ctx, const unsigned char *input, size_t ilen ); |
<> | 149:156823d33999 | 61 | void mbedtls_sha1_hw_finish( crypto_sha_context *ctx, unsigned char output[20] ); |
<> | 149:156823d33999 | 62 | void mbedtls_sha1_hw_process( crypto_sha_context *ctx, const unsigned char data[64] ); |
<> | 149:156823d33999 | 63 | |
<> | 149:156823d33999 | 64 | #endif /* MBEDTLS_SHA1_ALT */ |
<> | 149:156823d33999 | 65 | |
<> | 149:156823d33999 | 66 | #if defined(MBEDTLS_SHA256_ALT) |
<> | 149:156823d33999 | 67 | |
<> | 149:156823d33999 | 68 | void mbedtls_sha256_hw_init( crypto_sha_context *ctx ); |
<> | 149:156823d33999 | 69 | void mbedtls_sha256_hw_free( crypto_sha_context *ctx ); |
<> | 149:156823d33999 | 70 | void mbedtls_sha256_hw_clone( crypto_sha_context *dst, |
<> | 149:156823d33999 | 71 | const crypto_sha_context *src ); |
<> | 149:156823d33999 | 72 | void mbedtls_sha256_hw_starts( crypto_sha_context *ctx, int is224 ); |
<> | 149:156823d33999 | 73 | void mbedtls_sha256_hw_update( crypto_sha_context *ctx, const unsigned char *input, |
<> | 149:156823d33999 | 74 | size_t ilen ); |
<> | 149:156823d33999 | 75 | void mbedtls_sha256_hw_finish( crypto_sha_context *ctx, unsigned char output[32] ); |
<> | 149:156823d33999 | 76 | void mbedtls_sha256_hw_process( crypto_sha_context *ctx, const unsigned char data[64] ); |
<> | 149:156823d33999 | 77 | |
<> | 149:156823d33999 | 78 | #endif /* MBEDTLS_SHA256_ALT */ |
<> | 149:156823d33999 | 79 | |
<> | 149:156823d33999 | 80 | #ifdef __cplusplus |
<> | 149:156823d33999 | 81 | } |
<> | 149:156823d33999 | 82 | #endif |
<> | 149:156823d33999 | 83 | |
<> | 149:156823d33999 | 84 | #endif /* MBEDTLS_SHA1_C || MBEDTLS_SHA256_C || MBEDTLS_SHA512_C*/ |
<> | 149:156823d33999 | 85 | |
<> | 149:156823d33999 | 86 | #endif /* sha_alt.h */ |