Renesas / SecureDweet
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 /* in bytes */
00046 enum {
00047     SHA512              =   4,   /* hash type unique */
00048     SHA512_BLOCK_SIZE   = 128,
00049     SHA512_DIGEST_SIZE  =  64,
00050     SHA512_PAD_SIZE     = 112
00051 };
00052 
00053 
00054 /* Sha512 digest */
00055 typedef struct Sha512 {
00056     word32  buffLen;   /* in bytes          */
00057     word32  loLen;     /* length in bytes   */
00058     word32  hiLen;     /* length in bytes   */
00059     word64  digest[SHA512_DIGEST_SIZE / sizeof(word64)];
00060     word64  buffer[SHA512_BLOCK_SIZE  / sizeof(word64)];
00061 } Sha512;
00062 
00063 #endif /* HAVE_FIPS */
00064 
00065 WOLFSSL_API int wc_InitSha512(Sha512*);
00066 WOLFSSL_API int wc_Sha512Update(Sha512*, const byte*, word32);
00067 WOLFSSL_API int wc_Sha512Final(Sha512*, byte*);
00068 
00069 #if defined(WOLFSSL_SHA384)
00070 
00071 #ifndef HAVE_FIPS /* avoid redefinition of structs */
00072 /* in bytes */
00073 enum {
00074     SHA384              =   5,   /* hash type unique */
00075     SHA384_BLOCK_SIZE   = 128,
00076     SHA384_DIGEST_SIZE  =  48,
00077     SHA384_PAD_SIZE     = 112
00078 };
00079 
00080 
00081 /* Sha384 digest */
00082 typedef struct Sha384 {
00083     word32  buffLen;   /* in bytes          */
00084     word32  loLen;     /* length in bytes   */
00085     word32  hiLen;     /* length in bytes   */
00086     word64  digest[SHA512_DIGEST_SIZE / sizeof(word64)]; /* for transform 512 */
00087     word64  buffer[SHA384_BLOCK_SIZE  / sizeof(word64)];
00088 } Sha384;
00089 #endif /* HAVE_FIPS */
00090 
00091 WOLFSSL_API int wc_InitSha384(Sha384*);
00092 WOLFSSL_API int wc_Sha384Update(Sha384*, const byte*, word32);
00093 WOLFSSL_API int wc_Sha384Final(Sha384*, byte*);
00094 
00095 #endif /* WOLFSSL_SHA384 */
00096 
00097 #ifdef __cplusplus
00098     } /* extern "C" */
00099 #endif
00100 
00101 #endif /* WOLFSSL_SHA512 */
00102 #endif /* WOLF_CRYPT_SHA512_H */
00103 
00104