3 * Copyright (C) 2006-2014 wolfSSL Inc.
5 * This file is part of CyaSSL.
7 * CyaSSL 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.
12 * CyaSSL 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.
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
25 #ifndef CTAO_CRYPT_SHA512_H
26 #define CTAO_CRYPT_SHA512_H
28 #include <cyassl/ctaocrypt/types.h>
37 SHA512 = 4, /* hash type unique */
38 SHA512_BLOCK_SIZE = 128,
39 SHA512_DIGEST_SIZE = 64,
45 typedef struct Sha512 {
46 word32 buffLen; /* in bytes */
47 word32 loLen; /* length in bytes */
48 word32 hiLen; /* length in bytes */
49 word64 digest[SHA512_DIGEST_SIZE / sizeof(word64)];
50 word64 buffer[SHA512_BLOCK_SIZE / sizeof(word64)];
54 CYASSL_API int InitSha512(Sha512*);
55 CYASSL_API int Sha512Update(Sha512*, const byte*, word32);
56 CYASSL_API int Sha512Final(Sha512*, byte*);
57 CYASSL_API int Sha512Hash(const byte*, word32, byte*);
60 #if defined(CYASSL_SHA384) || defined(HAVE_AESGCM)
64 SHA384 = 5, /* hash type unique */
65 SHA384_BLOCK_SIZE = 128,
66 SHA384_DIGEST_SIZE = 48,
72 typedef struct Sha384 {
73 word32 buffLen; /* in bytes */
74 word32 loLen; /* length in bytes */
75 word32 hiLen; /* length in bytes */
76 word64 digest[SHA512_DIGEST_SIZE / sizeof(word64)]; /* for transform 512 */
77 word64 buffer[SHA384_BLOCK_SIZE / sizeof(word64)];
81 CYASSL_API int InitSha384(Sha384*);
82 CYASSL_API int Sha384Update(Sha384*, const byte*, word32);
83 CYASSL_API int Sha384Final(Sha384*, byte*);
84 CYASSL_API int Sha384Hash(const byte*, word32, byte*);
88 /* fips wrapper calls, user can call direct */
89 CYASSL_API int InitSha512_fips(Sha512*);
90 CYASSL_API int Sha512Update_fips(Sha512*, const byte*, word32);
91 CYASSL_API int Sha512Final_fips(Sha512*, byte*);
92 #ifndef FIPS_NO_WRAPPERS
93 /* if not impl or fips.c impl wrapper force fips calls if fips build */
94 #define InitSha512 InitSha512_fips
95 #define Sha512Update Sha512Update_fips
96 #define Sha512Final Sha512Final_fips
97 #endif /* FIPS_NO_WRAPPERS */
99 /* fips wrapper calls, user can call direct */
100 CYASSL_API int InitSha384_fips(Sha384*);
101 CYASSL_API int Sha384Update_fips(Sha384*, const byte*, word32);
102 CYASSL_API int Sha384Final_fips(Sha384*, byte*);
103 #ifndef FIPS_NO_WRAPPERS
104 /* if not impl or fips.c impl wrapper force fips calls if fips build */
105 #define InitSha384 InitSha384_fips
106 #define Sha384Update Sha384Update_fips
107 #define Sha384Final Sha384Final_fips
108 #endif /* FIPS_NO_WRAPPERS */
110 #endif /* HAVE_FIPS */
113 #endif /* CYASSL_SHA384 */
119 #endif /* CTAO_CRYPT_SHA512_H */
120 #endif /* CYASSL_SHA512 */