source: azure_iot_hub_f767zi/trunk/wolfssl-4.7.0/wolfssl/wolfcrypt/sha512.h

Last change on this file was 464, checked in by coas-nagasima, 3 years ago

WolfSSLとAzure IoT SDKを更新

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 6.8 KB
Line 
1/* sha512.h
2 *
3 * Copyright (C) 2006-2020 wolfSSL Inc.
4 *
5 * This file is part of wolfSSL.
6 *
7 * wolfSSL is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * wolfSSL is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 */
21
22/*!
23 \file wolfssl/wolfcrypt/sha512.h
24*/
25
26
27#ifndef WOLF_CRYPT_SHA512_H
28#define WOLF_CRYPT_SHA512_H
29
30#include <wolfssl/wolfcrypt/types.h>
31
32#if defined(WOLFSSL_SHA512) || defined(WOLFSSL_SHA384)
33
34
35#if defined(HAVE_FIPS) && \
36 defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
37 #include <wolfssl/wolfcrypt/fips.h>
38#endif /* HAVE_FIPS_VERSION >= 2 */
39
40#if defined(HAVE_FIPS) && \
41 (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2))
42 #ifdef WOLFSSL_SHA512
43 #define wc_Sha512 Sha512
44 #define WC_SHA512 SHA512
45 #define WC_SHA512_BLOCK_SIZE SHA512_BLOCK_SIZE
46 #define WC_SHA512_DIGEST_SIZE SHA512_DIGEST_SIZE
47 #define WC_SHA512_PAD_SIZE SHA512_PAD_SIZE
48 #endif /* WOLFSSL_SHA512 */
49 #ifdef WOLFSSL_SHA384
50 #define wc_Sha384 Sha384
51 #define WC_SHA384 SHA384
52 #define WC_SHA384_BLOCK_SIZE SHA384_BLOCK_SIZE
53 #define WC_SHA384_DIGEST_SIZE SHA384_DIGEST_SIZE
54 #define WC_SHA384_PAD_SIZE SHA384_PAD_SIZE
55 #endif /* WOLFSSL_SHA384 */
56
57 #define CYASSL_SHA512
58 #if defined(WOLFSSL_SHA384)
59 #define CYASSL_SHA384
60 #endif
61 /* for fips @wc_fips */
62 #include <cyassl/ctaocrypt/sha512.h>
63#endif
64
65#ifdef __cplusplus
66 extern "C" {
67#endif
68
69/* avoid redefinition of structs */
70#if !defined(HAVE_FIPS) || \
71 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))
72
73#ifdef WOLFSSL_ASYNC_CRYPT
74 #include <wolfssl/wolfcrypt/async.h>
75#endif
76#ifdef WOLFSSL_ESP32WROOM32_CRYPT
77 #include <wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h>
78#endif
79#if defined(WOLFSSL_SILABS_SE_ACCEL)
80 #include <wolfssl/wolfcrypt/port/silabs/silabs_hash.h>
81#endif
82
83#if defined(_MSC_VER)
84 #define SHA512_NOINLINE __declspec(noinline)
85#elif defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__)
86 #define SHA512_NOINLINE __attribute__((noinline))
87#else
88 #define SHA512_NOINLINE
89#endif
90
91#ifdef WOLFSSL_SHA512
92
93#if !defined(NO_OLD_SHA_NAMES)
94 #define SHA512 WC_SHA512
95#endif
96
97#if !defined(NO_OLD_WC_NAMES)
98 #define Sha512 wc_Sha512
99 #define SHA512_BLOCK_SIZE WC_SHA512_BLOCK_SIZE
100 #define SHA512_DIGEST_SIZE WC_SHA512_DIGEST_SIZE
101 #define SHA512_PAD_SIZE WC_SHA512_PAD_SIZE
102#endif
103
104#endif /* WOLFSSL_SHA512 */
105
106/* in bytes */
107enum {
108#ifdef WOLFSSL_SHA512
109 WC_SHA512 = WC_HASH_TYPE_SHA512,
110#endif
111 WC_SHA512_BLOCK_SIZE = 128,
112 WC_SHA512_DIGEST_SIZE = 64,
113 WC_SHA512_PAD_SIZE = 112
114};
115
116
117#ifdef WOLFSSL_IMX6_CAAM
118 #include "wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h"
119#elif defined (WOLFSSL_PSOC6_CRYPTO)
120 #include "wolfssl/wolfcrypt/port/cypress/psoc6_crypto.h"
121#else
122/* wc_Sha512 digest */
123struct wc_Sha512 {
124 word64 digest[WC_SHA512_DIGEST_SIZE / sizeof(word64)];
125 word64 buffer[WC_SHA512_BLOCK_SIZE / sizeof(word64)];
126 word32 buffLen; /* in bytes */
127 word64 loLen; /* length in bytes */
128 word64 hiLen; /* length in bytes */
129 void* heap;
130#ifdef USE_INTEL_SPEEDUP
131 const byte* data;
132#endif
133#ifdef WOLFSSL_ASYNC_CRYPT
134 WC_ASYNC_DEV asyncDev;
135#endif /* WOLFSSL_ASYNC_CRYPT */
136#ifdef WOLFSSL_SMALL_STACK_CACHE
137 word64* W;
138#endif
139#if defined(WOLFSSL_ESP32WROOM32_CRYPT) && \
140 !defined(NO_WOLFSSL_ESP32WROOM32_CRYPT_HASH)
141 WC_ESP32SHA ctx;
142#endif
143#if defined(WOLFSSL_SILABS_SE_ACCEL)
144 wc_silabs_sha_t silabsCtx;
145#endif
146
147#if defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB)
148 word32 flags; /* enum wc_HashFlags in hash.h */
149#endif
150};
151
152#ifndef WC_SHA512_TYPE_DEFINED
153 typedef struct wc_Sha512 wc_Sha512;
154 #define WC_SHA512_TYPE_DEFINED
155#endif
156#endif
157
158#endif /* HAVE_FIPS */
159
160#ifdef WOLFSSL_ARMASM
161WOLFSSL_LOCAL void Transform_Sha512_Len(wc_Sha512* sha512, const byte* data,
162 word32 len);
163#endif
164
165#ifdef WOLFSSL_SHA512
166
167
168WOLFSSL_API int wc_InitSha512(wc_Sha512*);
169WOLFSSL_API int wc_InitSha512_ex(wc_Sha512*, void*, int);
170WOLFSSL_API int wc_Sha512Update(wc_Sha512*, const byte*, word32);
171WOLFSSL_API int wc_Sha512FinalRaw(wc_Sha512*, byte*);
172WOLFSSL_API int wc_Sha512Final(wc_Sha512*, byte*);
173WOLFSSL_API void wc_Sha512Free(wc_Sha512*);
174
175WOLFSSL_API int wc_Sha512GetHash(wc_Sha512*, byte*);
176WOLFSSL_API int wc_Sha512Copy(wc_Sha512* src, wc_Sha512* dst);
177
178#if defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB)
179 WOLFSSL_API int wc_Sha512SetFlags(wc_Sha512* sha512, word32 flags);
180 WOLFSSL_API int wc_Sha512GetFlags(wc_Sha512* sha512, word32* flags);
181#endif
182
183#endif /* WOLFSSL_SHA512 */
184
185#if defined(WOLFSSL_SHA384)
186
187/* avoid redefinition of structs */
188#if !defined(HAVE_FIPS) || \
189 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))
190
191#if !defined(NO_OLD_SHA_NAMES)
192 #define SHA384 WC_SHA384
193#endif
194
195#if !defined(NO_OLD_WC_NAMES)
196 #define Sha384 wc_Sha384
197 #define SHA384_BLOCK_SIZE WC_SHA384_BLOCK_SIZE
198 #define SHA384_DIGEST_SIZE WC_SHA384_DIGEST_SIZE
199 #define SHA384_PAD_SIZE WC_SHA384_PAD_SIZE
200#endif
201
202/* in bytes */
203enum {
204 WC_SHA384 = WC_HASH_TYPE_SHA384,
205 WC_SHA384_BLOCK_SIZE = WC_SHA512_BLOCK_SIZE,
206 WC_SHA384_DIGEST_SIZE = 48,
207 WC_SHA384_PAD_SIZE = WC_SHA512_PAD_SIZE
208};
209
210
211#ifndef WC_SHA384_TYPE_DEFINED
212 typedef struct wc_Sha512 wc_Sha384;
213 #define WC_SHA384_TYPE_DEFINED
214#endif
215#endif /* HAVE_FIPS */
216
217WOLFSSL_API int wc_InitSha384(wc_Sha384*);
218WOLFSSL_API int wc_InitSha384_ex(wc_Sha384*, void*, int);
219WOLFSSL_API int wc_Sha384Update(wc_Sha384*, const byte*, word32);
220WOLFSSL_API int wc_Sha384FinalRaw(wc_Sha384*, byte*);
221WOLFSSL_API int wc_Sha384Final(wc_Sha384*, byte*);
222WOLFSSL_API void wc_Sha384Free(wc_Sha384*);
223
224WOLFSSL_API int wc_Sha384GetHash(wc_Sha384*, byte*);
225WOLFSSL_API int wc_Sha384Copy(wc_Sha384* src, wc_Sha384* dst);
226
227#if defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB)
228 WOLFSSL_API int wc_Sha384SetFlags(wc_Sha384* sha384, word32 flags);
229 WOLFSSL_API int wc_Sha384GetFlags(wc_Sha384* sha384, word32* flags);
230#endif
231
232#endif /* WOLFSSL_SHA384 */
233
234#ifdef __cplusplus
235 } /* extern "C" */
236#endif
237
238#endif /* WOLFSSL_SHA512 || WOLFSSL_SHA384 */
239#endif /* WOLF_CRYPT_SHA512_H */
240
Note: See TracBrowser for help on using the repository browser.