MultiTech / CyaSSL

Dependents:   HTTPClient-SSL HTTPClient-SSL HTTPClient-SSL HTTPClient-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-2014 wolfSSL Inc.
00004  *
00005  * This file is part of CyaSSL.
00006  *
00007  * CyaSSL 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  * CyaSSL 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-1301, USA
00020  */
00021 
00022 
00023 #ifdef CYASSL_SHA512
00024 
00025 #ifndef CTAO_CRYPT_SHA512_H
00026 #define CTAO_CRYPT_SHA512_H
00027 
00028 #include <cyassl/ctaocrypt/types.h>
00029 
00030 #ifdef __cplusplus
00031     extern "C" {
00032 #endif
00033 
00034 
00035 /* in bytes */
00036 enum {
00037     SHA512              =   4,   /* hash type unique */
00038     SHA512_BLOCK_SIZE   = 128,
00039     SHA512_DIGEST_SIZE  =  64,
00040     SHA512_PAD_SIZE     = 112 
00041 };
00042 
00043 
00044 /* Sha512 digest */
00045 typedef struct Sha512 {
00046     word32  buffLen;   /* in bytes          */
00047     word32  loLen;     /* length in bytes   */
00048     word32  hiLen;     /* length in bytes   */
00049     word64  digest[SHA512_DIGEST_SIZE / sizeof(word64)];
00050     word64  buffer[SHA512_BLOCK_SIZE  / sizeof(word64)];
00051 } Sha512;
00052 
00053 
00054 CYASSL_API int InitSha512(Sha512*);
00055 CYASSL_API int Sha512Update(Sha512*, const byte*, word32);
00056 CYASSL_API int Sha512Final(Sha512*, byte*);
00057 CYASSL_API int Sha512Hash(const byte*, word32, byte*);
00058 
00059 
00060 #if defined(CYASSL_SHA384) || defined(HAVE_AESGCM)
00061 
00062 /* in bytes */
00063 enum {
00064     SHA384              =   5,   /* hash type unique */
00065     SHA384_BLOCK_SIZE   = 128,
00066     SHA384_DIGEST_SIZE  =  48,
00067     SHA384_PAD_SIZE     = 112 
00068 };
00069 
00070 
00071 /* Sha384 digest */
00072 typedef struct Sha384 {
00073     word32  buffLen;   /* in bytes          */
00074     word32  loLen;     /* length in bytes   */
00075     word32  hiLen;     /* length in bytes   */
00076     word64  digest[SHA512_DIGEST_SIZE / sizeof(word64)]; /* for transform 512 */
00077     word64  buffer[SHA384_BLOCK_SIZE  / sizeof(word64)];
00078 } Sha384;
00079 
00080 
00081 CYASSL_API int InitSha384(Sha384*);
00082 CYASSL_API int Sha384Update(Sha384*, const byte*, word32);
00083 CYASSL_API int Sha384Final(Sha384*, byte*);
00084 CYASSL_API int Sha384Hash(const byte*, word32, byte*);
00085 
00086 
00087 #ifdef HAVE_FIPS
00088     /* fips wrapper calls, user can call direct */
00089     CYASSL_API int InitSha512_fips(Sha512*);
00090     CYASSL_API int Sha512Update_fips(Sha512*, const byte*, word32);
00091     CYASSL_API int Sha512Final_fips(Sha512*, byte*);
00092     #ifndef FIPS_NO_WRAPPERS
00093         /* if not impl or fips.c impl wrapper force fips calls if fips build */
00094         #define InitSha512   InitSha512_fips
00095         #define Sha512Update Sha512Update_fips
00096         #define Sha512Final  Sha512Final_fips
00097     #endif /* FIPS_NO_WRAPPERS */
00098 
00099     /* fips wrapper calls, user can call direct */
00100     CYASSL_API int InitSha384_fips(Sha384*);
00101     CYASSL_API int Sha384Update_fips(Sha384*, const byte*, word32);
00102     CYASSL_API int Sha384Final_fips(Sha384*, byte*);
00103     #ifndef FIPS_NO_WRAPPERS
00104         /* if not impl or fips.c impl wrapper force fips calls if fips build */
00105         #define InitSha384   InitSha384_fips
00106         #define Sha384Update Sha384Update_fips
00107         #define Sha384Final  Sha384Final_fips
00108     #endif /* FIPS_NO_WRAPPERS */
00109 
00110 #endif /* HAVE_FIPS */
00111 
00112 
00113 #endif /* CYASSL_SHA384 */
00114 
00115 #ifdef __cplusplus
00116     } /* extern "C" */
00117 #endif
00118 
00119 #endif /* CTAO_CRYPT_SHA512_H */
00120 #endif /* CYASSL_SHA512 */