mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 19:24:42 +02:00
Add wolfSSL_DES_ecb_encrypt() encrypt/decrypt parameter check.
This commit is contained in:
10
src/ssl.c
10
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){
|
||||
|
Reference in New Issue
Block a user