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