source: asp3_tinet_ecnl_rx/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/sha.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: 3.3 KB
Line 
1/* sha.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_SHA_H
24#define WOLF_CRYPT_SHA_H
25
26#include <wolfssl/wolfcrypt/types.h>
27
28#ifndef NO_SHA
29
30#ifdef HAVE_FIPS
31#define wc_Sha Sha
32#define WC_SHA SHA
33#define WC_SHA_BLOCK_SIZE SHA_BLOCK_SIZE
34#define WC_SHA_DIGEST_SIZE SHA_DIGEST_SIZE
35#define WC_SHA_PAD_SIZE SHA_PAD_SIZE
36
37/* for fips @wc_fips */
38#include <cyassl/ctaocrypt/sha.h>
39#endif
40
41#ifdef FREESCALE_LTC_SHA
42 #include "fsl_ltc.h"
43#endif
44
45#ifdef __cplusplus
46 extern "C" {
47#endif
48
49#ifndef HAVE_FIPS /* avoid redefining structs */
50
51#ifdef WOLFSSL_MICROCHIP_PIC32MZ
52 #include <wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h>
53#endif
54#ifdef WOLFSSL_ASYNC_CRYPT
55 #include <wolfssl/wolfcrypt/async.h>
56#endif
57
58#ifndef NO_OLD_WC_NAMES
59 #define Sha wc_Sha
60 #define SHA WC_SHA
61 #define SHA_BLOCK_SIZE WC_SHA_BLOCK_SIZE
62 #define SHA_DIGEST_SIZE WC_SHA_DIGEST_SIZE
63 #define SHA_PAD_SIZE WC_SHA_PAD_SIZE
64#endif
65
66/* in bytes */
67enum {
68 WC_SHA = 1, /* hash type unique */
69 WC_SHA_BLOCK_SIZE = 64,
70 WC_SHA_DIGEST_SIZE = 20,
71 WC_SHA_PAD_SIZE = 56
72};
73
74
75#ifndef WOLFSSL_TI_HASH
76/* Sha digest */
77typedef struct wc_Sha {
78 #ifdef FREESCALE_LTC_SHA
79 ltc_hash_ctx_t ctx;
80 #else
81 word32 buffLen; /* in bytes */
82 word32 loLen; /* length in bytes */
83 word32 hiLen; /* length in bytes */
84 word32 buffer[WC_SHA_BLOCK_SIZE / sizeof(word32)];
85 #ifdef WOLFSSL_PIC32MZ_HASH
86 word32 digest[PIC32_DIGEST_SIZE / sizeof(word32)];
87 #else
88 word32 digest[WC_SHA_DIGEST_SIZE / sizeof(word32)];
89 #endif
90 void* heap;
91 #ifdef WOLFSSL_PIC32MZ_HASH
92 hashUpdCache cache; /* cache for updates */
93 #endif
94 #ifdef WOLFSSL_ASYNC_CRYPT
95 WC_ASYNC_DEV asyncDev;
96 #endif /* WOLFSSL_ASYNC_CRYPT */
97#endif /* FREESCALE_LTC_SHA */
98} wc_Sha;
99
100#else
101 #include "wolfssl/wolfcrypt/port/ti/ti-hash.h"
102#endif /* WOLFSSL_TI_HASH */
103
104
105#endif /* HAVE_FIPS */
106
107WOLFSSL_API int wc_InitSha(wc_Sha*);
108WOLFSSL_API int wc_InitSha_ex(wc_Sha* sha, void* heap, int devId);
109WOLFSSL_API int wc_ShaUpdate(wc_Sha*, const byte*, word32);
110WOLFSSL_API int wc_ShaFinal(wc_Sha*, byte*);
111WOLFSSL_API void wc_ShaFree(wc_Sha*);
112
113WOLFSSL_API int wc_ShaGetHash(wc_Sha*, byte*);
114WOLFSSL_API int wc_ShaCopy(wc_Sha*, wc_Sha*);
115
116#ifdef WOLFSSL_PIC32MZ_HASH
117WOLFSSL_API void wc_ShaSizeSet(wc_Sha* sha, word32 len);
118#endif
119
120#ifdef __cplusplus
121 } /* extern "C" */
122#endif
123
124#endif /* NO_SHA */
125#endif /* WOLF_CRYPT_SHA_H */
126
Note: See TracBrowser for help on using the repository browser.