source: asp3_tinet_ecnl_rx/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/hash.h@ 337

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

ASP3版ECNLを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 4.1 KB
Line 
1/* hash.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_HASH_H
24#define WOLF_CRYPT_HASH_H
25
26#include <wolfssl/wolfcrypt/types.h>
27
28#ifndef NO_MD5
29 #include <wolfssl/wolfcrypt/md5.h>
30#endif
31#ifndef NO_SHA
32 #include <wolfssl/wolfcrypt/sha.h>
33#endif
34#if defined(WOLFSSL_SHA224) || !defined(NO_SHA256)
35 #include <wolfssl/wolfcrypt/sha256.h>
36#endif
37#if defined(WOLFSSL_SHA384) || defined(WOLFSSL_SHA512)
38 #include <wolfssl/wolfcrypt/sha512.h>
39#endif
40
41#ifdef __cplusplus
42 extern "C" {
43#endif
44
45/* Hash types */
46enum wc_HashType {
47 WC_HASH_TYPE_NONE = 0,
48 WC_HASH_TYPE_MD2 = 1,
49 WC_HASH_TYPE_MD4 = 2,
50 WC_HASH_TYPE_MD5 = 3,
51 WC_HASH_TYPE_SHA = 4, /* SHA-1 (not old SHA-0) */
52 WC_HASH_TYPE_SHA224 = 9,
53 WC_HASH_TYPE_SHA256 = 5,
54 WC_HASH_TYPE_SHA384 = 6,
55 WC_HASH_TYPE_SHA512 = 7,
56 WC_HASH_TYPE_MD5_SHA = 8,
57};
58
59typedef union {
60 #ifndef NO_MD5
61 wc_Md5 md5;
62 #endif
63 #ifndef NO_SHA
64 wc_Sha sha;
65 #endif
66 #ifdef WOLFSSL_SHA224
67 wc_Sha224 sha224;
68 #endif
69 #ifndef NO_SHA256
70 wc_Sha256 sha256;
71 #endif
72 #ifdef WOLFSSL_SHA384
73 wc_Sha384 sha384;
74 #endif
75 #ifdef WOLFSSL_SHA512
76 wc_Sha512 sha512;
77 #endif
78} wc_HashAlg;
79
80/* Find largest possible digest size
81 Note if this gets up to the size of 80 or over check smallstack build */
82#if defined(WOLFSSL_SHA512)
83 #define WC_MAX_DIGEST_SIZE WC_SHA512_DIGEST_SIZE
84#elif defined(WOLFSSL_SHA384)
85 #define WC_MAX_DIGEST_SIZE WC_SHA384_DIGEST_SIZE
86#elif !defined(NO_SHA256)
87 #define WC_MAX_DIGEST_SIZE WC_SHA256_DIGEST_SIZE
88#elif defined(WOLFSSL_SHA224)
89 #define WC_MAX_DIGEST_SIZE WC_SHA224_DIGEST_SIZE
90#elif !defined(NO_SHA)
91 #define WC_MAX_DIGEST_SIZE WC_SHA_DIGEST_SIZE
92#elif !defined(NO_MD5)
93 #define WC_MAX_DIGEST_SIZE WC_MD5_DIGEST_SIZE
94#else
95 #define WC_MAX_DIGEST_SIZE 64 /* default to max size of 64 */
96#endif
97
98#if !defined(NO_ASN) || !defined(NO_DH) || defined(HAVE_ECC)
99WOLFSSL_API int wc_HashGetOID(enum wc_HashType hash_type);
100#endif
101
102WOLFSSL_API int wc_HashGetDigestSize(enum wc_HashType hash_type);
103WOLFSSL_API int wc_Hash(enum wc_HashType hash_type,
104 const byte* data, word32 data_len,
105 byte* hash, word32 hash_len);
106
107/* generic hash operation wrappers */
108WOLFSSL_API int wc_HashInit(wc_HashAlg* hash, enum wc_HashType type);
109WOLFSSL_API int wc_HashUpdate(wc_HashAlg* hash, enum wc_HashType type,
110 const byte* data, word32 dataSz);
111WOLFSSL_API int wc_HashFinal(wc_HashAlg* hash, enum wc_HashType type,
112 byte* out);
113
114
115#ifndef NO_MD5
116#include <wolfssl/wolfcrypt/md5.h>
117WOLFSSL_API int wc_Md5Hash(const byte* data, word32 len, byte* hash);
118#endif
119
120#ifndef NO_SHA
121#include <wolfssl/wolfcrypt/sha.h>
122WOLFSSL_API int wc_ShaHash(const byte*, word32, byte*);
123#endif
124
125#ifndef NO_SHA256
126#include <wolfssl/wolfcrypt/sha256.h>
127WOLFSSL_API int wc_Sha256Hash(const byte*, word32, byte*);
128
129 #if defined(WOLFSSL_SHA224)
130 WOLFSSL_API int wc_Sha224Hash(const byte*, word32, byte*);
131 #endif /* defined(WOLFSSL_SHA224) */
132#endif
133
134#ifdef WOLFSSL_SHA512
135#include <wolfssl/wolfcrypt/sha512.h>
136WOLFSSL_API int wc_Sha512Hash(const byte*, word32, byte*);
137
138 #if defined(WOLFSSL_SHA384)
139 WOLFSSL_API int wc_Sha384Hash(const byte*, word32, byte*);
140 #endif /* defined(WOLFSSL_SHA384) */
141#endif /* WOLFSSL_SHA512 */
142
143#ifdef __cplusplus
144 } /* extern "C" */
145#endif
146
147#endif /* WOLF_CRYPT_HASH_H */
Note: See TracBrowser for help on using the repository browser.