1 | /* sha256.h
|
---|
2 | *
|
---|
3 | * Copyright (C) 2006-2015 wolfSSL Inc.
|
---|
4 | *
|
---|
5 | * This file is part of wolfSSL. (formerly known as CyaSSL)
|
---|
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-1301, USA
|
---|
20 | */
|
---|
21 |
|
---|
22 | /* code submitted by raphael.huck@efixo.com */
|
---|
23 |
|
---|
24 | #ifndef WOLF_CRYPT_SHA256_H
|
---|
25 | #define WOLF_CRYPT_SHA256_H
|
---|
26 |
|
---|
27 | #include <wolfssl/wolfcrypt/types.h>
|
---|
28 |
|
---|
29 | #ifndef NO_SHA256
|
---|
30 |
|
---|
31 | #ifdef HAVE_FIPS
|
---|
32 | /* for fips @wc_fips */
|
---|
33 | #include <cyassl/ctaocrypt/sha256.h>
|
---|
34 | #endif
|
---|
35 |
|
---|
36 |
|
---|
37 | #ifdef __cplusplus
|
---|
38 | extern "C" {
|
---|
39 | #endif
|
---|
40 |
|
---|
41 | #ifndef HAVE_FIPS /* avoid redefinition of structs */
|
---|
42 | #ifdef WOLFSSL_PIC32MZ_HASH
|
---|
43 | #include "port/pic32/pic32mz-crypt.h"
|
---|
44 | #endif
|
---|
45 |
|
---|
46 | /* in bytes */
|
---|
47 | enum {
|
---|
48 | SHA256 = 2, /* hash type unique */
|
---|
49 | SHA256_BLOCK_SIZE = 64,
|
---|
50 | SHA256_DIGEST_SIZE = 32,
|
---|
51 | SHA256_PAD_SIZE = 56
|
---|
52 | };
|
---|
53 |
|
---|
54 | #ifndef WOLFSSL_TI_HASH
|
---|
55 |
|
---|
56 | /* Sha256 digest */
|
---|
57 | typedef struct Sha256 {
|
---|
58 | word32 buffLen; /* in bytes */
|
---|
59 | word32 loLen; /* length in bytes */
|
---|
60 | word32 hiLen; /* length in bytes */
|
---|
61 | word32 digest[SHA256_DIGEST_SIZE / sizeof(word32)];
|
---|
62 | word32 buffer[SHA256_BLOCK_SIZE / sizeof(word32)];
|
---|
63 | #ifdef WOLFSSL_PIC32MZ_HASH
|
---|
64 | pic32mz_desc desc ; /* Crypt Engine descripter */
|
---|
65 | #endif
|
---|
66 | } Sha256;
|
---|
67 |
|
---|
68 | #else /* WOLFSSL_TI_HASH */
|
---|
69 | #include "wolfssl/wolfcrypt/port/ti/ti-hash.h"
|
---|
70 | #endif
|
---|
71 |
|
---|
72 | #endif /* HAVE_FIPS */
|
---|
73 |
|
---|
74 | WOLFSSL_API int wc_InitSha256(Sha256*);
|
---|
75 | WOLFSSL_API int wc_Sha256Update(Sha256*, const byte*, word32);
|
---|
76 | WOLFSSL_API int wc_Sha256Final(Sha256*, byte*);
|
---|
77 |
|
---|
78 | #ifdef __cplusplus
|
---|
79 | } /* extern "C" */
|
---|
80 | #endif
|
---|
81 |
|
---|
82 | #endif /* NO_SHA256 */
|
---|
83 | #endif /* WOLF_CRYPT_SHA256_H */
|
---|
84 |
|
---|