source: azure_iot_hub/trunk/wolfssl-3.15.7/wolfssl/wolfcrypt/sha512.h

Last change on this file was 389, checked in by coas-nagasima, 5 years ago

ビルドが通るよう更新

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 5.4 KB
Line 
1/* sha512.h
2 *
3 * Copyright (C) 2006-2018 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#if defined(HAVE_FIPS) && \
35 defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
36 #include <wolfssl/wolfcrypt/fips.h>
37#endif /* HAVE_FIPS_VERSION >= 2 */
38
39#if defined(HAVE_FIPS) && \
40 (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2))
41 #ifdef WOLFSSL_SHA512
42 #define wc_Sha512 Sha512
43 #define WC_SHA512 SHA512
44 #define WC_SHA512_BLOCK_SIZE SHA512_BLOCK_SIZE
45 #define WC_SHA512_DIGEST_SIZE SHA512_DIGEST_SIZE
46 #define WC_SHA512_PAD_SIZE SHA512_PAD_SIZE
47 #endif /* WOLFSSL_SHA512 */
48 #ifdef WOLFSSL_SHA384
49 #define wc_Sha384 Sha384
50 #define WC_SHA384 SHA384
51 #define WC_SHA384_BLOCK_SIZE SHA384_BLOCK_SIZE
52 #define WC_SHA384_DIGEST_SIZE SHA384_DIGEST_SIZE
53 #define WC_SHA384_PAD_SIZE SHA384_PAD_SIZE
54 #endif /* WOLFSSL_SHA384 */
55
56 #define CYASSL_SHA512
57 #if defined(WOLFSSL_SHA384)
58 #define CYASSL_SHA384
59 #endif
60 /* for fips @wc_fips */
61 #include <cyassl/ctaocrypt/sha512.h>
62#endif
63
64#ifdef __cplusplus
65 extern "C" {
66#endif
67
68/* avoid redefinition of structs */
69#if !defined(HAVE_FIPS) || \
70 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))
71
72#ifdef WOLFSSL_ASYNC_CRYPT
73 #include <wolfssl/wolfcrypt/async.h>
74#endif
75
76#if defined(_MSC_VER)
77 #define SHA512_NOINLINE __declspec(noinline)
78#elif defined(__GNUC__)
79 #define SHA512_NOINLINE __attribute__((noinline))
80#else
81 #define SHA512_NOINLINE
82#endif
83
84#ifdef WOLFSSL_SHA512
85
86#if !defined(NO_OLD_SHA_NAMES)
87 #define SHA512 WC_SHA512
88#endif
89
90#if !defined(NO_OLD_WC_NAMES)
91 #define Sha512 wc_Sha512
92 #define SHA512_BLOCK_SIZE WC_SHA512_BLOCK_SIZE
93 #define SHA512_DIGEST_SIZE WC_SHA512_DIGEST_SIZE
94 #define SHA512_PAD_SIZE WC_SHA512_PAD_SIZE
95#endif
96
97#endif /* WOLFSSL_SHA512 */
98
99/* in bytes */
100enum {
101#ifdef WOLFSSL_SHA512
102 WC_SHA512 = WC_HASH_TYPE_SHA512,
103#endif
104 WC_SHA512_BLOCK_SIZE = 128,
105 WC_SHA512_DIGEST_SIZE = 64,
106 WC_SHA512_PAD_SIZE = 112
107};
108
109
110#ifdef WOLFSSL_IMX6_CAAM
111 #include "wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h"
112#else
113/* wc_Sha512 digest */
114typedef struct wc_Sha512 {
115 word64 digest[WC_SHA512_DIGEST_SIZE / sizeof(word64)];
116 word64 buffer[WC_SHA512_BLOCK_SIZE / sizeof(word64)];
117 word32 buffLen; /* in bytes */
118 word64 loLen; /* length in bytes */
119 word64 hiLen; /* length in bytes */
120 void* heap;
121#ifdef USE_INTEL_SPEEDUP
122 const byte* data;
123#endif
124#ifdef WOLFSSL_ASYNC_CRYPT
125 WC_ASYNC_DEV asyncDev;
126#endif /* WOLFSSL_ASYNC_CRYPT */
127#ifdef WOLFSSL_SMALL_STACK_CACHE
128 word64* W;
129#endif
130} wc_Sha512;
131#endif
132
133#endif /* HAVE_FIPS */
134
135#ifdef WOLFSSL_SHA512
136
137WOLFSSL_API int wc_InitSha512(wc_Sha512*);
138WOLFSSL_API int wc_InitSha512_ex(wc_Sha512*, void*, int);
139WOLFSSL_API int wc_Sha512Update(wc_Sha512*, const byte*, word32);
140WOLFSSL_API int wc_Sha512FinalRaw(wc_Sha512*, byte*);
141WOLFSSL_API int wc_Sha512Final(wc_Sha512*, byte*);
142WOLFSSL_API void wc_Sha512Free(wc_Sha512*);
143
144WOLFSSL_API int wc_Sha512GetHash(wc_Sha512*, byte*);
145WOLFSSL_API int wc_Sha512Copy(wc_Sha512* src, wc_Sha512* dst);
146
147#endif /* WOLFSSL_SHA512 */
148
149#if defined(WOLFSSL_SHA384)
150
151/* avoid redefinition of structs */
152#if !defined(HAVE_FIPS) || \
153 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))
154
155#if !defined(NO_OLD_SHA_NAMES)
156 #define SHA384 WC_SHA384
157#endif
158
159#if !defined(NO_OLD_WC_NAMES)
160 #define Sha384 wc_Sha384
161 #define SHA384_BLOCK_SIZE WC_SHA384_BLOCK_SIZE
162 #define SHA384_DIGEST_SIZE WC_SHA384_DIGEST_SIZE
163 #define SHA384_PAD_SIZE WC_SHA384_PAD_SIZE
164#endif
165
166/* in bytes */
167enum {
168 WC_SHA384 = WC_HASH_TYPE_SHA384,
169 WC_SHA384_BLOCK_SIZE = WC_SHA512_BLOCK_SIZE,
170 WC_SHA384_DIGEST_SIZE = 48,
171 WC_SHA384_PAD_SIZE = WC_SHA512_PAD_SIZE
172};
173
174
175typedef wc_Sha512 wc_Sha384;
176#endif /* HAVE_FIPS */
177
178WOLFSSL_API int wc_InitSha384(wc_Sha384*);
179WOLFSSL_API int wc_InitSha384_ex(wc_Sha384*, void*, int);
180WOLFSSL_API int wc_Sha384Update(wc_Sha384*, const byte*, word32);
181WOLFSSL_API int wc_Sha384FinalRaw(wc_Sha384*, byte*);
182WOLFSSL_API int wc_Sha384Final(wc_Sha384*, byte*);
183WOLFSSL_API void wc_Sha384Free(wc_Sha384*);
184
185WOLFSSL_API int wc_Sha384GetHash(wc_Sha384*, byte*);
186WOLFSSL_API int wc_Sha384Copy(wc_Sha384* src, wc_Sha384* dst);
187
188#endif /* WOLFSSL_SHA384 */
189
190#ifdef __cplusplus
191 } /* extern "C" */
192#endif
193
194#endif /* WOLFSSL_SHA512 || WOLFSSL_SHA384 */
195#endif /* WOLF_CRYPT_SHA512_H */
196
Note: See TracBrowser for help on using the repository browser.