diff --git a/src/ssl.c b/src/ssl.c index 35ff62a4f..d4491435f 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -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 : diff --git a/wolfcrypt/src/des3.c b/wolfcrypt/src/des3.c index 1bdb9add2..005b03f33 100644 --- a/wolfcrypt/src/des3.c +++ b/wolfcrypt/src/des3.c @@ -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; } diff --git a/wolfssl/wolfcrypt/des3.h b/wolfssl/wolfcrypt/des3.h index db12cc900..409aa81f7 100644 --- a/wolfssl/wolfcrypt/des3.h +++ b/wolfssl/wolfcrypt/des3.h @@ -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);