wolfSSL SSL/TLS library, support up to TLS1.3

Dependents:   CyaSSL-Twitter-OAuth4Tw Example-client-tls-cert TwitterReader TweetTest ... more

Committer:
wolfSSL
Date:
Tue Aug 22 10:48:22 2017 +0000
Revision:
13:f67a6c6013ca
Parent:
11:cee25a834751
wolfSSL3.12.0 with TLS1.3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 11:cee25a834751 1 /* sha512.h
wolfSSL 11:cee25a834751 2 *
wolfSSL 11:cee25a834751 3 * Copyright (C) 2006-2016 wolfSSL Inc.
wolfSSL 11:cee25a834751 4 *
wolfSSL 11:cee25a834751 5 * This file is part of wolfSSL.
wolfSSL 11:cee25a834751 6 *
wolfSSL 11:cee25a834751 7 * wolfSSL is free software; you can redistribute it and/or modify
wolfSSL 11:cee25a834751 8 * it under the terms of the GNU General Public License as published by
wolfSSL 11:cee25a834751 9 * the Free Software Foundation; either version 2 of the License, or
wolfSSL 11:cee25a834751 10 * (at your option) any later version.
wolfSSL 11:cee25a834751 11 *
wolfSSL 11:cee25a834751 12 * wolfSSL is distributed in the hope that it will be useful,
wolfSSL 11:cee25a834751 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wolfSSL 11:cee25a834751 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wolfSSL 11:cee25a834751 15 * GNU General Public License for more details.
wolfSSL 11:cee25a834751 16 *
wolfSSL 11:cee25a834751 17 * You should have received a copy of the GNU General Public License
wolfSSL 11:cee25a834751 18 * along with this program; if not, write to the Free Software
wolfSSL 11:cee25a834751 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
wolfSSL 11:cee25a834751 20 */
wolfSSL 11:cee25a834751 21
wolfSSL 11:cee25a834751 22
wolfSSL 11:cee25a834751 23 #ifndef WOLF_CRYPT_SHA512_H
wolfSSL 11:cee25a834751 24 #define WOLF_CRYPT_SHA512_H
wolfSSL 11:cee25a834751 25
wolfSSL 11:cee25a834751 26 #include <wolfssl/wolfcrypt/types.h>
wolfSSL 11:cee25a834751 27
wolfSSL 11:cee25a834751 28 #ifdef WOLFSSL_SHA512
wolfSSL 11:cee25a834751 29
wolfSSL 11:cee25a834751 30 /* for fips @wc_fips */
wolfSSL 11:cee25a834751 31 #ifdef HAVE_FIPS
wolfSSL 11:cee25a834751 32 #define CYASSL_SHA512
wolfSSL 11:cee25a834751 33 #if defined(WOLFSSL_SHA384)
wolfSSL 11:cee25a834751 34 #define CYASSL_SHA384
wolfSSL 11:cee25a834751 35 #endif
wolfSSL 11:cee25a834751 36 #include <cyassl/ctaocrypt/sha512.h>
wolfSSL 11:cee25a834751 37 #endif
wolfSSL 11:cee25a834751 38
wolfSSL 11:cee25a834751 39 #ifdef __cplusplus
wolfSSL 11:cee25a834751 40 extern "C" {
wolfSSL 11:cee25a834751 41 #endif
wolfSSL 11:cee25a834751 42
wolfSSL 11:cee25a834751 43 #ifndef HAVE_FIPS /* avoid redefinition of structs */
wolfSSL 11:cee25a834751 44
wolfSSL 11:cee25a834751 45 #ifdef WOLFSSL_ASYNC_CRYPT
wolfSSL 11:cee25a834751 46 #include <wolfssl/wolfcrypt/async.h>
wolfSSL 11:cee25a834751 47 #endif
wolfSSL 11:cee25a834751 48
wolfSSL 11:cee25a834751 49 /* in bytes */
wolfSSL 11:cee25a834751 50 enum {
wolfSSL 11:cee25a834751 51 SHA512 = 4, /* hash type unique */
wolfSSL 11:cee25a834751 52 SHA512_BLOCK_SIZE = 128,
wolfSSL 11:cee25a834751 53 SHA512_DIGEST_SIZE = 64,
wolfSSL 11:cee25a834751 54 SHA512_PAD_SIZE = 112
wolfSSL 11:cee25a834751 55 };
wolfSSL 11:cee25a834751 56
wolfSSL 11:cee25a834751 57
wolfSSL 11:cee25a834751 58 /* Sha512 digest */
wolfSSL 11:cee25a834751 59 typedef struct Sha512 {
wolfSSL 11:cee25a834751 60 word32 buffLen; /* in bytes */
wolfSSL 11:cee25a834751 61 word64 loLen; /* length in bytes */
wolfSSL 11:cee25a834751 62 word64 hiLen; /* length in bytes */
wolfSSL 11:cee25a834751 63 word64 digest[SHA512_DIGEST_SIZE / sizeof(word64)];
wolfSSL 11:cee25a834751 64 word64 buffer[SHA512_BLOCK_SIZE / sizeof(word64)];
wolfSSL 11:cee25a834751 65 void* heap;
wolfSSL 11:cee25a834751 66 #ifdef WOLFSSL_ASYNC_CRYPT
wolfSSL 11:cee25a834751 67 WC_ASYNC_DEV asyncDev;
wolfSSL 11:cee25a834751 68 #endif /* WOLFSSL_ASYNC_CRYPT */
wolfSSL 11:cee25a834751 69 } Sha512;
wolfSSL 11:cee25a834751 70
wolfSSL 11:cee25a834751 71 #endif /* HAVE_FIPS */
wolfSSL 11:cee25a834751 72
wolfSSL 11:cee25a834751 73 WOLFSSL_API int wc_InitSha512(Sha512*);
wolfSSL 11:cee25a834751 74 WOLFSSL_API int wc_InitSha512_ex(Sha512*, void*, int);
wolfSSL 11:cee25a834751 75 WOLFSSL_API int wc_Sha512Update(Sha512*, const byte*, word32);
wolfSSL 11:cee25a834751 76 WOLFSSL_API int wc_Sha512Final(Sha512*, byte*);
wolfSSL 11:cee25a834751 77 WOLFSSL_API void wc_Sha512Free(Sha512*);
wolfSSL 11:cee25a834751 78
wolfSSL 11:cee25a834751 79 WOLFSSL_API int wc_Sha512GetHash(Sha512*, byte*);
wolfSSL 11:cee25a834751 80 WOLFSSL_API int wc_Sha512Copy(Sha512* src, Sha512* dst);
wolfSSL 11:cee25a834751 81
wolfSSL 11:cee25a834751 82 #if defined(WOLFSSL_SHA384)
wolfSSL 11:cee25a834751 83
wolfSSL 11:cee25a834751 84 #ifndef HAVE_FIPS /* avoid redefinition of structs */
wolfSSL 11:cee25a834751 85 /* in bytes */
wolfSSL 11:cee25a834751 86 enum {
wolfSSL 11:cee25a834751 87 SHA384 = 5, /* hash type unique */
wolfSSL 11:cee25a834751 88 SHA384_BLOCK_SIZE = SHA512_BLOCK_SIZE,
wolfSSL 11:cee25a834751 89 SHA384_DIGEST_SIZE = 48,
wolfSSL 11:cee25a834751 90 SHA384_PAD_SIZE = SHA512_PAD_SIZE
wolfSSL 11:cee25a834751 91 };
wolfSSL 11:cee25a834751 92
wolfSSL 11:cee25a834751 93 typedef Sha512 Sha384;
wolfSSL 11:cee25a834751 94 #endif /* HAVE_FIPS */
wolfSSL 11:cee25a834751 95
wolfSSL 11:cee25a834751 96 WOLFSSL_API int wc_InitSha384(Sha384*);
wolfSSL 11:cee25a834751 97 WOLFSSL_API int wc_InitSha384_ex(Sha384*, void*, int);
wolfSSL 11:cee25a834751 98 WOLFSSL_API int wc_Sha384Update(Sha384*, const byte*, word32);
wolfSSL 11:cee25a834751 99 WOLFSSL_API int wc_Sha384Final(Sha384*, byte*);
wolfSSL 11:cee25a834751 100 WOLFSSL_API void wc_Sha384Free(Sha384*);
wolfSSL 11:cee25a834751 101
wolfSSL 11:cee25a834751 102 WOLFSSL_API int wc_Sha384GetHash(Sha384*, byte*);
wolfSSL 11:cee25a834751 103 WOLFSSL_API int wc_Sha384Copy(Sha384* src, Sha384* dst);
wolfSSL 11:cee25a834751 104
wolfSSL 11:cee25a834751 105 #endif /* WOLFSSL_SHA384 */
wolfSSL 11:cee25a834751 106
wolfSSL 11:cee25a834751 107 #ifdef __cplusplus
wolfSSL 11:cee25a834751 108 } /* extern "C" */
wolfSSL 11:cee25a834751 109 #endif
wolfSSL 11:cee25a834751 110
wolfSSL 11:cee25a834751 111 #endif /* WOLFSSL_SHA512 */
wolfSSL 11:cee25a834751 112 #endif /* WOLF_CRYPT_SHA512_H */
wolfSSL 11:cee25a834751 113
wolfSSL 11:cee25a834751 114