forked from wolfSSL/wolfssl
move DES oneshot APIs out of des.[hc]
This commit is contained in:
@@ -91,25 +91,12 @@ void wc_Des_SetIV(Des* des, const byte* iv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wc_Des_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
|
|
||||||
const byte* key, const byte* iv)
|
|
||||||
{
|
|
||||||
return Des_CbcDecryptWithKey(out, in, sz, key, iv);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int wc_Des3_SetIV(Des3* des, const byte* iv)
|
int wc_Des3_SetIV(Des3* des, const byte* iv)
|
||||||
{
|
{
|
||||||
return Des3_SetIV_fips(des, iv);
|
return Des3_SetIV_fips(des, iv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wc_Des3_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
|
|
||||||
const byte* key, const byte* iv)
|
|
||||||
{
|
|
||||||
return Des3_CbcDecryptWithKey(out, in, sz, key, iv);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_CAVIUM
|
#ifdef HAVE_CAVIUM
|
||||||
|
|
||||||
/* Initiliaze Des3 for use with Nitrox device */
|
/* Initiliaze Des3 for use with Nitrox device */
|
||||||
@@ -1489,61 +1476,6 @@ void wc_Des_SetIV(Des* des, const byte* iv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wc_Des_CbcEncryptWithKey(byte* out, const byte* in, word32 sz,
|
|
||||||
const byte* key, const byte* iv)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
|
||||||
Des* des = NULL;
|
|
||||||
#else
|
|
||||||
Des des[1];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
|
||||||
des = (Des*)XMALLOC(sizeof(Des), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
||||||
if (des == NULL)
|
|
||||||
return MEMORY_E;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = wc_Des_SetKey(des, key, iv, DES_ENCRYPTION);
|
|
||||||
if (ret == 0)
|
|
||||||
ret = wc_Des_CbcEncrypt(des, out, in, sz);
|
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
|
||||||
XFREE(des, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int wc_Des_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
|
|
||||||
const byte* key, const byte* iv)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
|
||||||
Des* des = NULL;
|
|
||||||
#else
|
|
||||||
Des des[1];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
|
||||||
des = (Des*)XMALLOC(sizeof(Des), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
||||||
if (des == NULL)
|
|
||||||
return MEMORY_E;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = wc_Des_SetKey(des, key, iv, DES_DECRYPTION);
|
|
||||||
if (ret == 0)
|
|
||||||
ret = wc_Des_CbcDecrypt(des, out, in, sz);
|
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
|
||||||
XFREE(des, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int wc_Des3_SetIV(Des3* des, const byte* iv)
|
int wc_Des3_SetIV(Des3* des, const byte* iv)
|
||||||
{
|
{
|
||||||
if (des && iv)
|
if (des && iv)
|
||||||
@@ -1555,61 +1487,6 @@ int wc_Des3_SetIV(Des3* des, const byte* iv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wc_Des3_CbcEncryptWithKey(byte* out, const byte* in, word32 sz,
|
|
||||||
const byte* key, const byte* iv)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
|
||||||
Des3* des3 = NULL;
|
|
||||||
#else
|
|
||||||
Des3 des3[1];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
|
||||||
des3 = (Des3*)XMALLOC(sizeof(Des3), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
||||||
if (des3 == NULL)
|
|
||||||
return MEMORY_E;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = wc_Des3_SetKey(des3, key, iv, DES_ENCRYPTION);
|
|
||||||
if (ret == 0)
|
|
||||||
ret = wc_Des3_CbcEncrypt(des3, out, in, sz);
|
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
|
||||||
XFREE(des3, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int wc_Des3_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
|
|
||||||
const byte* key, const byte* iv)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
|
||||||
Des3* des3 = NULL;
|
|
||||||
#else
|
|
||||||
Des3 des3[1];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
|
||||||
des3 = (Des3*)XMALLOC(sizeof(Des3), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
||||||
if (des3 == NULL)
|
|
||||||
return MEMORY_E;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = wc_Des3_SetKey(des3, key, iv, DES_DECRYPTION);
|
|
||||||
if (ret == 0)
|
|
||||||
ret = wc_Des3_CbcDecrypt(des3, out, in, sz);
|
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
|
||||||
XFREE(des3, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_CAVIUM
|
#ifdef HAVE_CAVIUM
|
||||||
|
|
||||||
#include "cavium_common.h"
|
#include "cavium_common.h"
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include <wolfssl/wolfcrypt/settings.h>
|
#include <wolfssl/wolfcrypt/settings.h>
|
||||||
#include <wolfssl/wolfcrypt/aes.h>
|
#include <wolfssl/wolfcrypt/aes.h>
|
||||||
|
#include <wolfssl/wolfcrypt/des3.h>
|
||||||
#include <wolfssl/wolfcrypt/wc_encrypt.h>
|
#include <wolfssl/wolfcrypt/wc_encrypt.h>
|
||||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||||
|
|
||||||
@@ -85,3 +86,116 @@ int wc_AesCbcEncryptWithKey(byte* out, const byte* in, word32 inSz,
|
|||||||
}
|
}
|
||||||
#endif /* !NO_AES */
|
#endif /* !NO_AES */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_DES3
|
||||||
|
int wc_Des_CbcEncryptWithKey(byte* out, const byte* in, word32 sz,
|
||||||
|
const byte* key, const byte* iv)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
|
Des* des = NULL;
|
||||||
|
#else
|
||||||
|
Des des[1];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
|
des = (Des*)XMALLOC(sizeof(Des), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
if (des == NULL)
|
||||||
|
return MEMORY_E;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ret = wc_Des_SetKey(des, key, iv, DES_ENCRYPTION);
|
||||||
|
if (ret == 0)
|
||||||
|
ret = wc_Des_CbcEncrypt(des, out, in, sz);
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
|
XFREE(des, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wc_Des_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
|
||||||
|
const byte* key, const byte* iv)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
|
Des* des = NULL;
|
||||||
|
#else
|
||||||
|
Des des[1];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
|
des = (Des*)XMALLOC(sizeof(Des), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
if (des == NULL)
|
||||||
|
return MEMORY_E;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ret = wc_Des_SetKey(des, key, iv, DES_DECRYPTION);
|
||||||
|
if (ret == 0)
|
||||||
|
ret = wc_Des_CbcDecrypt(des, out, in, sz);
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
|
XFREE(des, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int wc_Des3_CbcEncryptWithKey(byte* out, const byte* in, word32 sz,
|
||||||
|
const byte* key, const byte* iv)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
|
Des3* des3 = NULL;
|
||||||
|
#else
|
||||||
|
Des3 des3[1];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
|
des3 = (Des3*)XMALLOC(sizeof(Des3), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
if (des3 == NULL)
|
||||||
|
return MEMORY_E;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ret = wc_Des3_SetKey(des3, key, iv, DES_ENCRYPTION);
|
||||||
|
if (ret == 0)
|
||||||
|
ret = wc_Des3_CbcEncrypt(des3, out, in, sz);
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
|
XFREE(des3, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int wc_Des3_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
|
||||||
|
const byte* key, const byte* iv)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
|
Des3* des3 = NULL;
|
||||||
|
#else
|
||||||
|
Des3 des3[1];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
|
des3 = (Des3*)XMALLOC(sizeof(Des3), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
if (des3 == NULL)
|
||||||
|
return MEMORY_E;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ret = wc_Des3_SetKey(des3, key, iv, DES_DECRYPTION);
|
||||||
|
if (ret == 0)
|
||||||
|
ret = wc_Des3_CbcDecrypt(des3, out, in, sz);
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
|
XFREE(des3, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* !NO_DES3 */
|
||||||
|
@@ -92,12 +92,6 @@ WOLFSSL_API int wc_Des_CbcDecrypt(Des* des, byte* out,
|
|||||||
const byte* in, word32 sz);
|
const byte* in, word32 sz);
|
||||||
WOLFSSL_API int wc_Des_EcbEncrypt(Des* des, byte* out,
|
WOLFSSL_API int wc_Des_EcbEncrypt(Des* des, byte* out,
|
||||||
const byte* in, word32 sz);
|
const byte* in, word32 sz);
|
||||||
WOLFSSL_API int wc_Des_CbcDecryptWithKey(byte* out,
|
|
||||||
const byte* in, word32 sz,
|
|
||||||
const byte* key, const byte* iv);
|
|
||||||
WOLFSSL_API int wc_Des_CbcEncryptWithKey(byte* out,
|
|
||||||
const byte* in, word32 sz,
|
|
||||||
const byte* key, const byte* iv);
|
|
||||||
|
|
||||||
WOLFSSL_API int wc_Des3_SetKey(Des3* des, const byte* key,
|
WOLFSSL_API int wc_Des3_SetKey(Des3* des, const byte* key,
|
||||||
const byte* iv,int dir);
|
const byte* iv,int dir);
|
||||||
@@ -106,12 +100,6 @@ WOLFSSL_API int wc_Des3_CbcEncrypt(Des3* des, byte* out,
|
|||||||
const byte* in,word32 sz);
|
const byte* in,word32 sz);
|
||||||
WOLFSSL_API int wc_Des3_CbcDecrypt(Des3* des, byte* out,
|
WOLFSSL_API int wc_Des3_CbcDecrypt(Des3* des, byte* out,
|
||||||
const byte* in,word32 sz);
|
const byte* in,word32 sz);
|
||||||
WOLFSSL_API int wc_Des3_CbcEncryptWithKey(byte* out,
|
|
||||||
const byte* in, word32 sz,
|
|
||||||
const byte* key, const byte* iv);
|
|
||||||
WOLFSSL_API int wc_Des3_CbcDecryptWithKey(byte* out,
|
|
||||||
const byte* in, word32 sz,
|
|
||||||
const byte* key, const byte* iv);
|
|
||||||
|
|
||||||
#ifdef HAVE_CAVIUM
|
#ifdef HAVE_CAVIUM
|
||||||
WOLFSSL_API int wc_Des3_InitCavium(Des3*, int);
|
WOLFSSL_API int wc_Des3_InitCavium(Des3*, int);
|
||||||
|
@@ -36,9 +36,24 @@ WOLFSSL_API int wc_AesCbcEncryptWithKey(byte* out, const byte* in, word32 inSz,
|
|||||||
WOLFSSL_API int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz,
|
WOLFSSL_API int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz,
|
||||||
const byte* key, word32 keySz,
|
const byte* key, word32 keySz,
|
||||||
const byte* iv);
|
const byte* iv);
|
||||||
#endif /* NO_AES */
|
#endif /* !NO_AES */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_DES3
|
||||||
|
WOLFSSL_API int wc_Des_CbcDecryptWithKey(byte* out,
|
||||||
|
const byte* in, word32 sz,
|
||||||
|
const byte* key, const byte* iv);
|
||||||
|
WOLFSSL_API int wc_Des_CbcEncryptWithKey(byte* out,
|
||||||
|
const byte* in, word32 sz,
|
||||||
|
const byte* key, const byte* iv);
|
||||||
|
WOLFSSL_API int wc_Des3_CbcEncryptWithKey(byte* out,
|
||||||
|
const byte* in, word32 sz,
|
||||||
|
const byte* key, const byte* iv);
|
||||||
|
WOLFSSL_API int wc_Des3_CbcDecryptWithKey(byte* out,
|
||||||
|
const byte* in, word32 sz,
|
||||||
|
const byte* key, const byte* iv);
|
||||||
|
#endif /* !NO_DES3 */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user