wolf SSL / wolfSSL-TLS13-Beta

Fork of wolfSSL by wolf SSL

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sha512.h Source File

sha512.h

00001 /* sha512.h
00002  *
00003  * Copyright (C) 2006-2016 wolfSSL Inc.
00004  *
00005  * This file is part of wolfSSL.
00006  *
00007  * wolfSSL is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * wolfSSL is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
00020  */
00021 
00022 
00023 #ifndef WOLF_CRYPT_SHA512_H
00024 #define WOLF_CRYPT_SHA512_H
00025 
00026 #include <wolfssl/wolfcrypt/types.h>
00027 
00028 #ifdef WOLFSSL_SHA512
00029 
00030 /* for fips @wc_fips */
00031 #ifdef HAVE_FIPS
00032     #define CYASSL_SHA512
00033     #if defined(WOLFSSL_SHA384)
00034         #define CYASSL_SHA384
00035     #endif
00036     #include <cyassl/ctaocrypt/sha512.h>
00037 #endif
00038 
00039 #ifdef __cplusplus
00040     extern "C" {
00041 #endif
00042 
00043 #ifndef HAVE_FIPS /* avoid redefinition of structs */
00044 
00045 #ifdef WOLFSSL_ASYNC_CRYPT
00046     #include <wolfssl/wolfcrypt/async.h>
00047 #endif
00048 
00049 /* in bytes */
00050 enum {
00051     SHA512              =   4,   /* hash type unique */
00052     SHA512_BLOCK_SIZE   = 128,
00053     SHA512_DIGEST_SIZE  =  64,
00054     SHA512_PAD_SIZE     = 112
00055 };
00056 
00057 
00058 /* Sha512 digest */
00059 typedef struct Sha512 {
00060     word32  buffLen;   /* in bytes          */
00061     word64  loLen;     /* length in bytes   */
00062     word64  hiLen;     /* length in bytes   */
00063     word64  digest[SHA512_DIGEST_SIZE / sizeof(word64)];
00064     word64  buffer[SHA512_BLOCK_SIZE  / sizeof(word64)];
00065     void*   heap;
00066 #ifdef WOLFSSL_ASYNC_CRYPT
00067     WC_ASYNC_DEV asyncDev;
00068 #endif /* WOLFSSL_ASYNC_CRYPT */
00069 } Sha512;
00070 
00071 #endif /* HAVE_FIPS */
00072 
00073 WOLFSSL_API int wc_InitSha512(Sha512*);
00074 WOLFSSL_API int wc_InitSha512_ex(Sha512*, void*, int);
00075 WOLFSSL_API int wc_Sha512Update(Sha512*, const byte*, word32);
00076 WOLFSSL_API int wc_Sha512Final(Sha512*, byte*);
00077 WOLFSSL_API void wc_Sha512Free(Sha512*);
00078 
00079 WOLFSSL_API int wc_Sha512GetHash(Sha512*, byte*);
00080 WOLFSSL_API int wc_Sha512Copy(Sha512* src, Sha512* dst);
00081 
00082 #if defined(WOLFSSL_SHA384)
00083 
00084 #ifndef HAVE_FIPS /* avoid redefinition of structs */
00085 /* in bytes */
00086 enum {
00087     SHA384              =   5,   /* hash type unique */
00088     SHA384_BLOCK_SIZE   =   SHA512_BLOCK_SIZE,
00089     SHA384_DIGEST_SIZE  =   48,
00090     SHA384_PAD_SIZE     =   SHA512_PAD_SIZE
00091 };
00092 
00093 typedef Sha512 Sha384;
00094 #endif /* HAVE_FIPS */
00095 
00096 WOLFSSL_API int wc_InitSha384(Sha384*);
00097 WOLFSSL_API int wc_InitSha384_ex(Sha384*, void*, int);
00098 WOLFSSL_API int wc_Sha384Update(Sha384*, const byte*, word32);
00099 WOLFSSL_API int wc_Sha384Final(Sha384*, byte*);
00100 WOLFSSL_API void wc_Sha384Free(Sha384*);
00101 
00102 WOLFSSL_API int wc_Sha384GetHash(Sha384*, byte*);
00103 WOLFSSL_API int wc_Sha384Copy(Sha384* src, Sha384* dst);
00104 
00105 #endif /* WOLFSSL_SHA384 */
00106 
00107 #ifdef __cplusplus
00108     } /* extern "C" */
00109 #endif
00110 
00111 #endif /* WOLFSSL_SHA512 */
00112 #endif /* WOLF_CRYPT_SHA512_H */
00113 
00114