DES ECB prototypes

pull/618/head
Jacob Barthelmeh 2016-11-10 16:47:26 -07:00
parent 526b602ebd
commit 6520a77fac
3 changed files with 21 additions and 7 deletions

View File

@ -10486,9 +10486,9 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
#ifdef WOLFSSL_DES_ECB
case DES_ECB_TYPE :
if (ctx->enc)
wc_Des_EbcEncrypt(&ctx->cipher.des, dst, src, len);
ret = wc_Des_EcbEncrypt(&ctx->cipher.des, dst, src, len);
else
wc_Des_EbcDecrypt(&ctx->cipher.des, dst, src, len);
ret = wc_Des_EcbDecrypt(&ctx->cipher.des, dst, src, len);
break;
#endif
case DES_EDE3_CBC_TYPE :

View File

@ -1621,6 +1621,10 @@ int wc_Des_EcbEncrypt(Des* des, byte* out, const byte* in, word32 sz)
{
word32 blocks = sz / DES_BLOCK_SIZE;
if (des == NULL || out == NULL || in == NULL) {
return BAD_FUNC_ARG;
}
while (blocks--) {
DesProcessBlock(des, in, out);
@ -1632,15 +1636,19 @@ int wc_Des_EcbEncrypt(Des* des, byte* out, const byte* in, word32 sz)
int wc_Des3_EcbEncrypt(Des3* des, byte* out, const byte* in, word32 sz)
{
word32 blocks = sz / DES3_BLOCK_SIZE;
printf("wc_Des3_EcbEncrypt(%016x, %016x, %d)\n",
*(unsigned long *)in, *(unsigned long *)out, sz) ;
word32 blocks = sz / DES_BLOCK_SIZE;
/* printf("wc_Des3_EcbEncrypt(%016x, %016x, %d)\n",
*(unsigned long *)in, *(unsigned long *)out, sz) ; */
if (des == NULL || out == NULL || in == NULL) {
return BAD_FUNC_ARG;
}
while (blocks--) {
Des3ProcessBlock(des, in, out);
out += DES3_BLOCK_SIZE;
in += DES3_BLOCK_SIZE;
out += DES_BLOCK_SIZE;
in += DES_BLOCK_SIZE;
}
return 0;
}

View File

@ -94,6 +94,12 @@ WOLFSSL_API int wc_Des_CbcDecrypt(Des* des, byte* out,
const byte* in, word32 sz);
WOLFSSL_API int wc_Des_EcbEncrypt(Des* des, byte* out,
const byte* in, word32 sz);
WOLFSSL_API int wc_Des3_EcbEncrypt(Des3* des, byte* out,
const byte* in, word32 sz);
/* ECB decrypt same process as encrypt but with decrypt key */
#define wc_Des_EcbDecrypt wc_Des_EcbEncrypt
#define wc_Des3_EcbDecrypt wc_Des3_EcbEncrypt
WOLFSSL_API int wc_Des3_SetKey(Des3* des, const byte* key,
const byte* iv,int dir);