source: azure_iot_hub/trunk/wolfssl-3.15.7/wolfssl/wolfcrypt/hash.h@ 388

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

Azure IoT Hub Device C SDK を使ったサンプルの追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-chdr
File size: 5.0 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 \file wolfssl/wolfcrypt/hash.h
24*/
25
26#ifndef WOLF_CRYPT_HASH_H
27#define WOLF_CRYPT_HASH_H
28
29#include <wolfssl/wolfcrypt/types.h>
30
31#ifndef NO_MD5
32 #include <wolfssl/wolfcrypt/md5.h>
33#endif
34#ifndef NO_SHA
35 #include <wolfssl/wolfcrypt/sha.h>
36#endif
37#if defined(WOLFSSL_SHA224) || !defined(NO_SHA256)
38 #include <wolfssl/wolfcrypt/sha256.h>
39#endif
40#if defined(WOLFSSL_SHA384) || defined(WOLFSSL_SHA512)
41 #include <wolfssl/wolfcrypt/sha512.h>
42#endif
43#ifdef HAVE_BLAKE2
44 #include <wolfssl/wolfcrypt/blake2.h>
45#endif
46#ifdef WOLFSSL_SHA3
47 #include <wolfssl/wolfcrypt/sha3.h>
48#endif
49#ifndef NO_MD4
50 #include <wolfssl/wolfcrypt/md4.h>
51#endif
52#ifdef WOLFSSL_MD2
53 #include <wolfssl/wolfcrypt/md2.h>
54#endif
55
56
57#ifdef __cplusplus
58 extern "C" {
59#endif
60
61#if !defined(HAVE_FIPS) && !defined(NO_OLD_WC_NAMES)
62 #define MAX_DIGEST_SIZE WC_MAX_DIGEST_SIZE
63#endif
64
65
66typedef union {
67 #ifndef NO_MD5
68 wc_Md5 md5;
69 #endif
70 #ifndef NO_SHA
71 wc_Sha sha;
72 #endif
73 #ifdef WOLFSSL_SHA224
74 wc_Sha224 sha224;
75 #endif
76 #ifndef NO_SHA256
77 wc_Sha256 sha256;
78 #endif
79 #ifdef WOLFSSL_SHA384
80 wc_Sha384 sha384;
81 #endif
82 #ifdef WOLFSSL_SHA512
83 wc_Sha512 sha512;
84 #endif
85} wc_HashAlg;
86
87/* Find largest possible digest size
88 Note if this gets up to the size of 80 or over check smallstack build */
89#if defined(WOLFSSL_SHA3)
90 #define WC_MAX_DIGEST_SIZE WC_SHA3_512_DIGEST_SIZE
91 #define WC_MAX_BLOCK_SIZE WC_SHA3_224_BLOCK_SIZE /* 224 is the largest block size */
92#elif defined(WOLFSSL_SHA512)
93 #define WC_MAX_DIGEST_SIZE WC_SHA512_DIGEST_SIZE
94 #define WC_MAX_BLOCK_SIZE WC_SHA512_BLOCK_SIZE
95#elif defined(HAVE_BLAKE2)
96 #define WC_MAX_DIGEST_SIZE BLAKE2B_OUTBYTES
97 #define WC_MAX_BLOCK_SIZE BLAKE2B_BLOCKBYTES
98#elif defined(WOLFSSL_SHA384)
99 #define WC_MAX_DIGEST_SIZE WC_SHA384_DIGEST_SIZE
100 #define WC_MAX_BLOCK_SIZE WC_SHA384_BLOCK_SIZE
101#elif !defined(NO_SHA256)
102 #define WC_MAX_DIGEST_SIZE WC_SHA256_DIGEST_SIZE
103 #define WC_MAX_BLOCK_SIZE WC_SHA256_BLOCK_SIZE
104#elif defined(WOLFSSL_SHA224)
105 #define WC_MAX_DIGEST_SIZE WC_SHA224_DIGEST_SIZE
106 #define WC_MAX_BLOCK_SIZE WC_SHA224_BLOCK_SIZE
107#elif !defined(NO_SHA)
108 #define WC_MAX_DIGEST_SIZE WC_SHA_DIGEST_SIZE
109 #define WC_MAX_BLOCK_SIZE WC_SHA_BLOCK_SIZE
110#elif !defined(NO_MD5)
111 #define WC_MAX_DIGEST_SIZE WC_MD5_DIGEST_SIZE
112 #define WC_MAX_BLOCK_SIZE WC_MD5_BLOCK_SIZE
113#else
114 #define WC_MAX_DIGEST_SIZE 64 /* default to max size of 64 */
115 #define WC_MAX_BLOCK_SIZE 128
116#endif
117
118#if !defined(NO_ASN) || !defined(NO_DH) || defined(HAVE_ECC)
119WOLFSSL_API int wc_HashGetOID(enum wc_HashType hash_type);
120WOLFSSL_API enum wc_HashType wc_OidGetHash(int oid);
121#endif
122
123WOLFSSL_API enum wc_HashType wc_HashTypeConvert(int hashType);
124
125WOLFSSL_API int wc_HashGetDigestSize(enum wc_HashType hash_type);
126WOLFSSL_API int wc_HashGetBlockSize(enum wc_HashType hash_type);
127WOLFSSL_API int wc_Hash(enum wc_HashType hash_type,
128 const byte* data, word32 data_len,
129 byte* hash, word32 hash_len);
130
131/* generic hash operation wrappers */
132WOLFSSL_API int wc_HashInit(wc_HashAlg* hash, enum wc_HashType type);
133WOLFSSL_API int wc_HashUpdate(wc_HashAlg* hash, enum wc_HashType type,
134 const byte* data, word32 dataSz);
135WOLFSSL_API int wc_HashFinal(wc_HashAlg* hash, enum wc_HashType type,
136 byte* out);
137WOLFSSL_API int wc_HashFree(wc_HashAlg* hash, enum wc_HashType type);
138
139#ifndef NO_MD5
140#include <wolfssl/wolfcrypt/md5.h>
141WOLFSSL_API int wc_Md5Hash(const byte* data, word32 len, byte* hash);
142#endif
143
144#ifndef NO_SHA
145#include <wolfssl/wolfcrypt/sha.h>
146WOLFSSL_API int wc_ShaHash(const byte*, word32, byte*);
147#endif
148
149#ifdef WOLFSSL_SHA224
150#include <wolfssl/wolfcrypt/sha256.h>
151 WOLFSSL_API int wc_Sha224Hash(const byte*, word32, byte*);
152 #endif /* defined(WOLFSSL_SHA224) */
153
154#ifndef NO_SHA256
155#include <wolfssl/wolfcrypt/sha256.h>
156WOLFSSL_API int wc_Sha256Hash(const byte*, word32, byte*);
157#endif
158
159#ifdef WOLFSSL_SHA384
160#include <wolfssl/wolfcrypt/sha512.h>
161 WOLFSSL_API int wc_Sha384Hash(const byte*, word32, byte*);
162 #endif /* defined(WOLFSSL_SHA384) */
163
164#ifdef WOLFSSL_SHA512
165#include <wolfssl/wolfcrypt/sha512.h>
166WOLFSSL_API int wc_Sha512Hash(const byte*, word32, byte*);
167#endif /* WOLFSSL_SHA512 */
168
169#ifdef __cplusplus
170 } /* extern "C" */
171#endif
172
173#endif /* WOLF_CRYPT_HASH_H */
Note: See TracBrowser for help on using the repository browser.