From dccff615d5f90d89979e7d3e13a7c6ccfe5beb52 Mon Sep 17 00:00:00 2001 From: Go Hosohara Date: Mon, 10 Apr 2017 16:19:44 +0900 Subject: [PATCH] Add wolfSSL_DES_ecb_encrypt() encrypt/decrypt parameter check. --- src/ssl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index 392b91b3d..7bc974918 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -15800,10 +15800,16 @@ void wolfSSL_DES_ecb_encrypt(WOLFSSL_DES_cblock* desa, WOLFSSL_ENTER("wolfSSL_DES_ecb_encrypt"); Des3 enc; - if (desa == NULL || key == NULL){ + if (desa == NULL || key == NULL || desb == NULL || (dir != DES_ENCRYPT && dir != DES_DECRYPT)){ WOLFSSL_MSG("Bad argument passed to wolfSSL_DES_ecb_encrypt"); } else { - if (wc_Des3_SetKey(&enc, (const byte*) key, (const byte*) NULL, dir) != 0){ + int cdir; + if (dir == DES_ENCRYPT){ + cdir = DES_ENCRYPTION; + }else if (dir == DES_DECRYPT){ + cdir = DES_DECRYPTION; + } + if (wc_Des3_SetKey(&enc, (const byte*) key, (const byte*) NULL, cdir) != 0){ WOLFSSL_MSG("wc_Des3_SetKey return error."); } if (wc_Des3_EcbEncrypt(&enc, (byte*) desb, (const byte*) desa, sizeof(desb)) != 0){