source: asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/sha512.h@ 352

Last change on this file since 352 was 352, checked in by coas-nagasima, 6 years ago

arm向けASP3版ECNLを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 4.2 KB
Line 
1/* sha512.h
2 *
3 * Copyright (C) 2006-2017 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#ifndef WOLF_CRYPT_SHA512_H
24#define WOLF_CRYPT_SHA512_H
25
26#include <wolfssl/wolfcrypt/types.h>
27
28#ifdef WOLFSSL_SHA512
29
30/* for fips @wc_fips */
31#ifdef HAVE_FIPS
32 #define wc_Sha512 Sha512
33 #define WC_SHA512 SHA512
34 #define WC_SHA512_BLOCK_SIZE SHA512_BLOCK_SIZE
35 #define WC_SHA512_DIGEST_SIZE SHA512_DIGEST_SIZE
36 #define WC_SHA512_PAD_SIZE SHA512_PAD_SIZE
37 #ifdef WOLFSSL_SHA384
38 #define wc_Sha384 Sha384
39 #define WC_SHA384 SHA384
40 #define WC_SHA384_BLOCK_SIZE SHA384_BLOCK_SIZE
41 #define WC_SHA384_DIGEST_SIZE SHA384_DIGEST_SIZE
42 #define WC_SHA384_PAD_SIZE SHA384_PAD_SIZE
43 #endif /* WOLFSSL_SHA384 */
44
45 #define CYASSL_SHA512
46 #if defined(WOLFSSL_SHA384)
47 #define CYASSL_SHA384
48 #endif
49 #include <cyassl/ctaocrypt/sha512.h>
50#endif
51
52#ifdef __cplusplus
53 extern "C" {
54#endif
55
56#ifndef HAVE_FIPS /* avoid redefinition of structs */
57
58#ifdef WOLFSSL_ASYNC_CRYPT
59 #include <wolfssl/wolfcrypt/async.h>
60#endif
61
62#ifndef NO_OLD_WC_NAMES
63 #define Sha512 wc_Sha512
64 #define SHA512 WC_SHA512
65 #define SHA512_BLOCK_SIZE WC_SHA512_BLOCK_SIZE
66 #define SHA512_DIGEST_SIZE WC_SHA512_DIGEST_SIZE
67 #define SHA512_PAD_SIZE WC_SHA512_PAD_SIZE
68#endif
69
70/* in bytes */
71enum {
72 WC_SHA512 = 4, /* hash type unique */
73 WC_SHA512_BLOCK_SIZE = 128,
74 WC_SHA512_DIGEST_SIZE = 64,
75 WC_SHA512_PAD_SIZE = 112
76};
77
78
79/* wc_Sha512 digest */
80typedef struct wc_Sha512 {
81 word32 buffLen; /* in bytes */
82 word64 loLen; /* length in bytes */
83 word64 hiLen; /* length in bytes */
84 word64 digest[WC_SHA512_DIGEST_SIZE / sizeof(word64)];
85 word64 buffer[WC_SHA512_BLOCK_SIZE / sizeof(word64)];
86 void* heap;
87#ifdef WOLFSSL_ASYNC_CRYPT
88 WC_ASYNC_DEV asyncDev;
89#endif /* WOLFSSL_ASYNC_CRYPT */
90} wc_Sha512;
91
92#endif /* HAVE_FIPS */
93
94WOLFSSL_API int wc_InitSha512(wc_Sha512*);
95WOLFSSL_API int wc_InitSha512_ex(wc_Sha512*, void*, int);
96WOLFSSL_API int wc_Sha512Update(wc_Sha512*, const byte*, word32);
97WOLFSSL_API int wc_Sha512Final(wc_Sha512*, byte*);
98WOLFSSL_API void wc_Sha512Free(wc_Sha512*);
99
100WOLFSSL_API int wc_Sha512GetHash(wc_Sha512*, byte*);
101WOLFSSL_API int wc_Sha512Copy(wc_Sha512* src, wc_Sha512* dst);
102
103#if defined(WOLFSSL_SHA384)
104
105#ifndef HAVE_FIPS /* avoid redefinition of structs */
106
107#ifndef NO_OLD_WC_NAMES
108 #define Sha384 wc_Sha384
109 #define SHA384 WC_SHA384
110 #define SHA384_BLOCK_SIZE WC_SHA384_BLOCK_SIZE
111 #define SHA384_DIGEST_SIZE WC_SHA384_DIGEST_SIZE
112 #define SHA384_PAD_SIZE WC_SHA384_PAD_SIZE
113#endif
114
115/* in bytes */
116enum {
117 WC_SHA384 = 5, /* hash type unique */
118 WC_SHA384_BLOCK_SIZE = WC_SHA512_BLOCK_SIZE,
119 WC_SHA384_DIGEST_SIZE = 48,
120 WC_SHA384_PAD_SIZE = WC_SHA512_PAD_SIZE
121};
122
123typedef wc_Sha512 wc_Sha384;
124#endif /* HAVE_FIPS */
125
126WOLFSSL_API int wc_InitSha384(wc_Sha384*);
127WOLFSSL_API int wc_InitSha384_ex(wc_Sha384*, void*, int);
128WOLFSSL_API int wc_Sha384Update(wc_Sha384*, const byte*, word32);
129WOLFSSL_API int wc_Sha384Final(wc_Sha384*, byte*);
130WOLFSSL_API void wc_Sha384Free(wc_Sha384*);
131
132WOLFSSL_API int wc_Sha384GetHash(wc_Sha384*, byte*);
133WOLFSSL_API int wc_Sha384Copy(wc_Sha384* src, wc_Sha384* dst);
134
135#endif /* WOLFSSL_SHA384 */
136
137#ifdef __cplusplus
138 } /* extern "C" */
139#endif
140
141#endif /* WOLFSSL_SHA512 */
142#endif /* WOLF_CRYPT_SHA512_H */
143
Note: See TracBrowser for help on using the repository browser.