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

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

Committer:
wolfSSL
Date:
Fri Jun 26 00:39:20 2015 +0000
Revision:
0:d92f9d21154c
wolfSSL 3.6.0

Who changed what in which revision?

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