forked from wolfSSL/wolfssl
new changes
This commit is contained in:
@@ -181,7 +181,6 @@ void wc_AesFreeCavium(Aes* aes)
|
||||
|
||||
|
||||
#ifdef HAVE_FIPS
|
||||
/* fips wrapper calls, user can call direct */
|
||||
int wc_AesSetKey_fips(Aes* aes, const byte* key, word32 len,
|
||||
const byte* iv, int dir)
|
||||
{
|
||||
@@ -233,17 +232,6 @@ void wc_AesFreeCavium(Aes* aes)
|
||||
return AesGcmDecrypt_fips(aes, out, in, sz, iv, ivSz,
|
||||
authTag, authTagSz, authIn, authInSz);
|
||||
}
|
||||
#ifndef FIPS_NO_WRAPPERS
|
||||
/* if not impl or fips.c impl wrapper force fips calls if fips build */
|
||||
#define AesSetKey AesSetKey_fips
|
||||
#define AesSetIV AesSetIV_fips
|
||||
#define AesCbcEncrypt AesCbcEncrypt_fips
|
||||
#define AesCbcDecrypt AesCbcDecrypt_fips
|
||||
#define AesGcmSetKey AesGcmSetKey_fips
|
||||
#define AesGcmEncrypt AesGcmEncrypt_fips
|
||||
#define AesGcmDecrypt AesGcmDecrypt_fips
|
||||
#endif /* FIPS_NO_WRAPPERS */
|
||||
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
|
||||
|
||||
169
wolfcrypt/src/compress.c
Normal file
169
wolfcrypt/src/compress.c
Normal file
@@ -0,0 +1,169 @@
|
||||
/* compress.c
|
||||
*
|
||||
* Copyright (C) 2006-2014 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||
wc_*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
|
||||
|
||||
#include <wolfssl/wolfcrypt/compress.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
|
||||
/* alloc user allocs to work with zlib */
|
||||
static void* myAlloc(void* opaque, unsigned int item, unsigned int size)
|
||||
{
|
||||
(void)opaque;
|
||||
return XMALLOC(item * size, opaque, DYNAMIC_TYPE_LIBZ);
|
||||
}
|
||||
|
||||
|
||||
static void myFree(void* opaque, void* memory)
|
||||
{
|
||||
(void)opaque;
|
||||
XFREE(memory, opaque, DYNAMIC_TYPE_LIBZ);
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_MCAPI
|
||||
#define DEFLATE_DEFAULT_WINDOWBITS 11
|
||||
#define DEFLATE_DEFAULT_MEMLEVEL 1
|
||||
#else
|
||||
#define DEFLATE_DEFAULT_WINDOWBITS 15
|
||||
#define DEFLATE_DEFAULT_MEMLEVEL 8
|
||||
#endif
|
||||
|
||||
|
||||
int wc_Compress(byte* out, word32 outSz, const byte* in, word32 inSz, word32 flags)
|
||||
/*
|
||||
* out - pointer to destination buffer
|
||||
* outSz - size of destination buffer
|
||||
* in - pointer to source buffer to compress
|
||||
* inSz - size of source to compress
|
||||
* flags - flags to control how compress operates
|
||||
*
|
||||
* return:
|
||||
* negative - error code
|
||||
* positive - bytes stored in out buffer
|
||||
*
|
||||
* Note, the output buffer still needs to be larger than the input buffer.
|
||||
* The right chunk of data won't compress at all, and the lookup table will
|
||||
* add to the size of the output. The libz code says the compressed
|
||||
* buffer should be srcSz + 0.1% + 12.
|
||||
*/
|
||||
{
|
||||
z_stream stream;
|
||||
int result = 0;
|
||||
|
||||
stream.next_in = (Bytef*)in;
|
||||
stream.avail_in = (uInt)inSz;
|
||||
#ifdef MAXSEG_64K
|
||||
/* Check for source > 64K on 16-bit machine: */
|
||||
if ((uLong)stream.avail_in != inSz) return COMPRESS_INIT_E;
|
||||
#endif
|
||||
stream.next_out = out;
|
||||
stream.avail_out = (uInt)outSz;
|
||||
if ((uLong)stream.avail_out != outSz) return COMPRESS_INIT_E;
|
||||
|
||||
stream.zalloc = (alloc_func)myAlloc;
|
||||
stream.zfree = (free_func)myFree;
|
||||
stream.opaque = (voidpf)0;
|
||||
|
||||
if (deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
|
||||
DEFLATE_DEFAULT_WINDOWBITS, DEFLATE_DEFAULT_MEMLEVEL,
|
||||
flags ? Z_FIXED : Z_DEFAULT_STRATEGY) != Z_OK)
|
||||
return COMPRESS_INIT_E;
|
||||
|
||||
if (deflate(&stream, Z_FINISH) != Z_STREAM_END) {
|
||||
deflateEnd(&stream);
|
||||
return COMPRESS_E;
|
||||
}
|
||||
|
||||
result = (int)stream.total_out;
|
||||
|
||||
if (deflateEnd(&stream) != Z_OK)
|
||||
result = COMPRESS_E;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int wc_DeCompress(byte* out, word32 outSz, const byte* in, word32 inSz)
|
||||
/*
|
||||
* out - pointer to destination buffer
|
||||
* outSz - size of destination buffer
|
||||
* in - pointer to source buffer to compress
|
||||
* inSz - size of source to compress
|
||||
* flags - flags to control how compress operates
|
||||
*
|
||||
* return:
|
||||
* negative - error code
|
||||
* positive - bytes stored in out buffer
|
||||
*/
|
||||
{
|
||||
z_stream stream;
|
||||
int result = 0;
|
||||
|
||||
stream.next_in = (Bytef*)in;
|
||||
stream.avail_in = (uInt)inSz;
|
||||
/* Check for source > 64K on 16-bit machine: */
|
||||
if ((uLong)stream.avail_in != inSz) return DECOMPRESS_INIT_E;
|
||||
|
||||
stream.next_out = out;
|
||||
stream.avail_out = (uInt)outSz;
|
||||
if ((uLong)stream.avail_out != outSz) return DECOMPRESS_INIT_E;
|
||||
|
||||
stream.zalloc = (alloc_func)myAlloc;
|
||||
stream.zfree = (free_func)myFree;
|
||||
stream.opaque = (voidpf)0;
|
||||
|
||||
if (inflateInit2(&stream, DEFLATE_DEFAULT_WINDOWBITS) != Z_OK)
|
||||
return DECOMPRESS_INIT_E;
|
||||
|
||||
if (inflate(&stream, Z_FINISH) != Z_STREAM_END) {
|
||||
inflateEnd(&stream);
|
||||
return DECOMPRESS_E;
|
||||
}
|
||||
|
||||
result = (int)stream.total_out;
|
||||
|
||||
if (inflateEnd(&stream) != Z_OK)
|
||||
result = DECOMPRESS_E;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#endif /* HAVE_LIBZ */
|
||||
|
||||
@@ -23,12 +23,12 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <cyassl/ctaocrypt/settings.h>
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifndef NO_DH
|
||||
|
||||
#include <cyassl/ctaocrypt/dh.h>
|
||||
#include <cyassl/ctaocrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/dh.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
|
||||
#ifndef USER_MATH_LIB
|
||||
#include <math.h>
|
||||
@@ -139,7 +139,7 @@ int wc_DhGenerateKeyPair(DhKey* key, RNG* rng, byte* priv, word32* privSz,
|
||||
return (ret != 0) ? ret : GeneratePublic(key, priv, *privSz, pub, pubSz);
|
||||
}
|
||||
|
||||
int DhAgree(DhKey* key, byte* agree, word32* agreeSz, const byte* priv,
|
||||
int wc_DhAgree(DhKey* key, byte* agree, word32* agreeSz, const byte* priv,
|
||||
word32 privSz, const byte* otherPub, word32 pubSz)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@@ -23,19 +23,19 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <cyassl/ctaocrypt/settings.h>
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
/* submitted by eof */
|
||||
|
||||
#include <cyassl/ctaocrypt/logging.h>
|
||||
#include <cyassl/ctaocrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
CYASSL_API int CyaSSL_Debugging_ON(void);
|
||||
CYASSL_API void CyaSSL_Debugging_OFF(void);
|
||||
WOLFSSL_API int wolfSSL_Debugging_ON(void);
|
||||
WOLFSSL_API void wolfSSL_Debugging_OFF(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -44,13 +44,13 @@
|
||||
#ifdef DEBUG_CYASSL
|
||||
|
||||
/* Set these to default values initially. */
|
||||
static CyaSSL_Logging_cb log_function = 0;
|
||||
static wolfSSL_Logging_cb log_function = 0;
|
||||
static int loggingEnabled = 0;
|
||||
|
||||
#endif /* DEBUG_CYASSL */
|
||||
|
||||
|
||||
int CyaSSL_SetLoggingCb(CyaSSL_Logging_cb f)
|
||||
int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb f)
|
||||
{
|
||||
#ifdef DEBUG_CYASSL
|
||||
int res = 0;
|
||||
@@ -68,7 +68,7 @@ int CyaSSL_SetLoggingCb(CyaSSL_Logging_cb f)
|
||||
}
|
||||
|
||||
|
||||
int CyaSSL_Debugging_ON(void)
|
||||
int wolfSSL_Debugging_ON(void)
|
||||
{
|
||||
#ifdef DEBUG_CYASSL
|
||||
loggingEnabled = 1;
|
||||
@@ -79,7 +79,7 @@ int CyaSSL_Debugging_ON(void)
|
||||
}
|
||||
|
||||
|
||||
void CyaSSL_Debugging_OFF(void)
|
||||
void wolfSSL_Debugging_OFF(void)
|
||||
{
|
||||
#ifdef DEBUG_CYASSL
|
||||
loggingEnabled = 0;
|
||||
@@ -123,40 +123,40 @@ static void cyassl_log(const int logLevel, const char *const logMessage)
|
||||
}
|
||||
|
||||
|
||||
void CYASSL_MSG(const char* msg)
|
||||
void WOLFSSL_MSG(const char* msg)
|
||||
{
|
||||
if (loggingEnabled)
|
||||
cyassl_log(INFO_LOG , msg);
|
||||
}
|
||||
|
||||
|
||||
void CYASSL_ENTER(const char* msg)
|
||||
void WOLFSSL_ENTER(const char* msg)
|
||||
{
|
||||
if (loggingEnabled) {
|
||||
char buffer[80];
|
||||
sprintf(buffer, "CyaSSL Entering %s", msg);
|
||||
sprintf(buffer, "wolfSSL Entering %s", msg);
|
||||
cyassl_log(ENTER_LOG , buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CYASSL_LEAVE(const char* msg, int ret)
|
||||
void WOLFSSL_LEAVE(const char* msg, int ret)
|
||||
{
|
||||
if (loggingEnabled) {
|
||||
char buffer[80];
|
||||
sprintf(buffer, "CyaSSL Leaving %s, return %d", msg, ret);
|
||||
sprintf(buffer, "wolfSSL Leaving %s, return %d", msg, ret);
|
||||
cyassl_log(LEAVE_LOG , buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CYASSL_ERROR(int error)
|
||||
void WOLFSSL_ERROR(int error)
|
||||
{
|
||||
if (loggingEnabled) {
|
||||
char buffer[80];
|
||||
sprintf(buffer, "CyaSSL error occured, error = %d", error);
|
||||
sprintf(buffer, "wolfSSL error occured, error = %d", error);
|
||||
cyassl_log(ERROR_LOG , buffer);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* DEBUG_CYASSL */
|
||||
#endif /* DEBUG_WOLFSSL */
|
||||
|
||||
@@ -26,8 +26,7 @@
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
//#ifdef WOLFSSL_MD2
|
||||
//@TODO
|
||||
#ifdef WOLFSSL_MD2
|
||||
|
||||
#include <wolfssl/wolfcrypt/md2.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
@@ -157,5 +156,5 @@ int wc_Md2Hash(const byte* data, word32 len, byte* hash)
|
||||
}
|
||||
|
||||
|
||||
//@TODO
|
||||
//#endif /* WOLFSSL_MD2 */
|
||||
#endif /* WOLFSSL_MD2 */
|
||||
|
||||
|
||||
@@ -23,15 +23,15 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <cyassl/ctaocrypt/settings.h>
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifndef NO_MD4
|
||||
|
||||
#include <cyassl/ctaocrypt/md4.h>
|
||||
#include <wolfssl/wolfcrypt/md4.h>
|
||||
#ifdef NO_INLINE
|
||||
#include <cyassl/ctaocrypt/misc.h>
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#include <ctaocrypt/src/misc.c>
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
*
|
||||
* Copyright (C) 2006-2014 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||
*
|
||||
* CyaSSL is free software; you can redistribute it and/or modify
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* CyaSSL is distributed in the hope that it will be useful,
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
@@ -25,8 +25,15 @@
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
//#ifdef USE_WOLFSSL_MEMORY
|
||||
//@TODO
|
||||
/* check old macros @wc_fips */
|
||||
#if defined(USE_CYASSL_MEMORY) && !defined(USE_WOLFSSL_MEMORY)
|
||||
#define USE_WOLFSSL_MEMORY
|
||||
#endif
|
||||
#if defined(CYASSL_MALLOC_CHECK) && !defined(WOLFSSL_MALLOC_CHECK)
|
||||
#define WOLFSSL_MALLOC_CHECK
|
||||
#endif
|
||||
|
||||
#ifdef USE_WOLFSSL_MEMORY
|
||||
|
||||
#include <wolfssl/wolfcrypt/memory.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
@@ -102,7 +109,7 @@ void* wolfSSL_Realloc(void *ptr, size_t size)
|
||||
return res;
|
||||
}
|
||||
|
||||
//#endif /* USE_WOLFSSL_MEMORY */
|
||||
#endif /* USE_WOLFSSL_MEMORY */
|
||||
|
||||
|
||||
#ifdef HAVE_IO_POOL
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <cyassl/ctaocrypt/settings.h>
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef HAVE_PKCS7
|
||||
|
||||
#include <cyassl/ctaocrypt/pkcs7.h>
|
||||
#include <cyassl/ctaocrypt/error-crypt.h>
|
||||
#include <cyassl/ctaocrypt/logging.h>
|
||||
#include <wolfssl/wolfcrypt/pkcs7.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
|
||||
#ifndef min
|
||||
static INLINE word32 min(word32 a, word32 b)
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
/* placed ASN.1 contentType OID into *output, return idx on success,
|
||||
* 0 upon failure */
|
||||
WOLFSSL_LOCAL int wc_setContentType(int pkcs7TypeOID, byte* output)
|
||||
WOLFSSL_LOCAL int wc_SetContentType(int pkcs7TypeOID, byte* output)
|
||||
{
|
||||
/* PKCS#7 content types, RFC 2315, section 14 */
|
||||
static const byte pkcs7[] = { 0x2A, 0x86, 0x48, 0x86, 0xF7,
|
||||
@@ -147,7 +147,7 @@ int wc_GetContentType(const byte* input, word32* inOutIdx, word32* oid,
|
||||
|
||||
|
||||
/* init PKCS7 struct with recipient cert, decode into DecodedCert */
|
||||
int wc_PKS7_InitWithCert(PKCS7* pkcs7, byte* cert, word32 certSz)
|
||||
int wc_PKCS7_InitWithCert(PKCS7* pkcs7, byte* cert, word32 certSz)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@@ -789,7 +789,7 @@ int wc_PKCS7_VerifySignedData(PKCS7* pkcs7, byte* pkiMsg, word32 pkiMsgSz)
|
||||
cert = &pkiMsg[idx];
|
||||
certSz += (certIdx - idx);
|
||||
}
|
||||
wc_PKS7_InitWithCert(pkcs7, cert, certSz);
|
||||
wc_PKCS7_InitWithCert(pkcs7, cert, certSz);
|
||||
}
|
||||
idx += length;
|
||||
}
|
||||
@@ -1222,7 +1222,7 @@ int wc_PKCS7_EncodeEnvelopedData(PKCS7* pkcs7, byte* output, word32 outputSz)
|
||||
};
|
||||
|
||||
/* outer content type */
|
||||
outerContentTypeSz = wc_setContentType(ENVELOPED_DATA, outerContentType);
|
||||
outerContentTypeSz = wc_SetContentType(ENVELOPED_DATA, outerContentType);
|
||||
|
||||
/* version, defined as 0 in RFC 2315 */
|
||||
verSz = SetMyVersion(0, ver, 0);
|
||||
@@ -1279,7 +1279,7 @@ int wc_PKCS7_EncodeEnvelopedData(PKCS7* pkcs7, byte* output, word32 outputSz)
|
||||
}
|
||||
|
||||
/* EncryptedContentInfo */
|
||||
contentTypeSz = wc_setContentType(pkcs7->contentOID, contentType);
|
||||
contentTypeSz = wc_SetContentType(pkcs7->contentOID, contentType);
|
||||
if (contentTypeSz == 0) {
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(recip, NULL, DYNAMMIC_TYPE_TMP_BUFFER);
|
||||
|
||||
@@ -183,7 +183,7 @@ int wc_RsaFlattenPublicKey(RsaKey* key, byte* a, word32* aSz, byte* b,
|
||||
}
|
||||
|
||||
|
||||
int wc_ RsaSSL_Sign_fips(const byte* in, word32 inLen, byte* out,
|
||||
int wc_RsaSSL_Sign_fips(const byte* in, word32 inLen, byte* out,
|
||||
word32 outLen, RsaKey* key, RNG* rng)
|
||||
{
|
||||
return RsaSSL_Sign_fips(in, inLen, out, outLen, key, rng);
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/* sha.c
|
||||
*
|
||||
* Copyright (C) 2006-2014 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of CyaSSL.
|
||||
*
|
||||
* CyaSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* CyaSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#if !defined(NO_SHA)
|
||||
|
||||
#ifdef HAVE_FIPS
|
||||
/* set NO_WRAPPERS before headers, use direct internal f()s not wrappers */
|
||||
#define FIPS_NO_WRAPPERS
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/sha.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
int wc_InitSha(Sha* sha)
|
||||
{
|
||||
return InitSha(sha);
|
||||
}
|
||||
|
||||
int wc_ShaUpdate(Sha* sha, const byte* data, word32 len)
|
||||
{
|
||||
return ShaUpdate(sha, data, len);
|
||||
}
|
||||
|
||||
int wc_ShaFinal(Sha* sha, byte* hash)
|
||||
{
|
||||
return ShaFinal(sha, hash);
|
||||
}
|
||||
|
||||
|
||||
int wc_ShaHash(const byte* data, word32 len, byte* hash)
|
||||
{
|
||||
return ShaHash(data, len, hash);
|
||||
}
|
||||
|
||||
|
||||
/* fips wrapper calls, user can call direct */
|
||||
#ifdef HAVE_FIPS
|
||||
int wc_InitSha_fips(Sha* sha)
|
||||
{
|
||||
return InitSha_fips(sha);
|
||||
}
|
||||
|
||||
|
||||
int wc_ShaUpdate_fips(Sha* sha, const byte* data, word32 len)
|
||||
{
|
||||
return ShaUpdate_fips(sha, data, len);
|
||||
}
|
||||
|
||||
|
||||
int wc_ShaFinal_fips(Sha* sha, byte* out)
|
||||
{
|
||||
return ShaFinal_fips(sha,out);
|
||||
}
|
||||
#endif /* HAVE_FIPS */
|
||||
#endif /* NO_SHA */
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/* sha256.c
|
||||
*
|
||||
* Copyright (C) 2006-2014 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
|
||||
/* code submitted by raphael.huck@efixo.com */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
#include <wolfssl/wolfcrypt/sha256.h>
|
||||
|
||||
#if !defined(NO_SHA256)
|
||||
|
||||
int wc_InitSha256(Sha256* sha)
|
||||
{
|
||||
return InitSha256(sha);
|
||||
}
|
||||
|
||||
|
||||
int wc_Sha256Update(Sha256* sha, const byte* data, word32 len)
|
||||
{
|
||||
return Sha256Update(sha, data, len);
|
||||
}
|
||||
|
||||
|
||||
int wc_Sha256Final(Sha256* sha, byte* out)
|
||||
{
|
||||
return Sha256Final(sha, out);
|
||||
}
|
||||
|
||||
|
||||
int wc_Sha256Hash(const byte* data, word32 len, byte* out)
|
||||
{
|
||||
return Sha256Hash(data, len, out);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
90
wolfcrypt/src/sha512.c
Normal file
90
wolfcrypt/src/sha512.c
Normal file
@@ -0,0 +1,90 @@
|
||||
/* sha512.c
|
||||
*
|
||||
* Copyright (C) 2006-2014 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
#include <wolfssl/wolfcrypt/sha512.h>
|
||||
|
||||
#ifdef WOLFSSL_SHA512
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int wc_InitSha512(Sha512* sha)
|
||||
{
|
||||
return InitSha512(sha);
|
||||
}
|
||||
|
||||
|
||||
int wc_Sha512Update(Sha512* sha, const byte* data, word32 len)
|
||||
{
|
||||
return Sha512Update(sha, data, len);
|
||||
}
|
||||
|
||||
|
||||
int wc_Sha512Final(Sha512* sha, byte* out)
|
||||
{
|
||||
return Sha512Final(sha, out);
|
||||
}
|
||||
|
||||
|
||||
int wc_Sha512Hash(const byte* data, word32 len, byte* out)
|
||||
{
|
||||
return Sha512Hash(data, len, out);
|
||||
}
|
||||
|
||||
#if defined(WOLFSSL_SHA384) || defined(HAVE_AESGCM)
|
||||
|
||||
int wc_InitSha384(Sha384* sha)
|
||||
{
|
||||
return InitSha384(sha);
|
||||
}
|
||||
|
||||
|
||||
int wc_Sha384Update(Sha384* sha, const byte* data, word32 len)
|
||||
{
|
||||
return Sha384Update(sha, data, len);
|
||||
}
|
||||
|
||||
|
||||
int wc_Sha384Final(Sha384* sha, byte* out)
|
||||
{
|
||||
return Sha384Final(sha, out);
|
||||
}
|
||||
|
||||
|
||||
int wc_Sha384Hash(const byte* data, word32 len, byte* out)
|
||||
{
|
||||
return Sha384Hash(data, len, out);
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_SHA384 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* WOLFSSL_SHA512 */
|
||||
|
||||
Reference in New Issue
Block a user