mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 19:24:42 +02:00
Fix WolfSSL_DES_ecb_encrypt().
This commit is contained in:
28
src/ssl.c
28
src/ssl.c
@@ -15795,27 +15795,27 @@ void wolfSSL_DES_set_odd_parity(WOLFSSL_DES_cblock* myDes)
|
|||||||
|
|
||||||
#ifdef WOLFSSL_DES_ECB
|
#ifdef WOLFSSL_DES_ECB
|
||||||
void wolfSSL_DES_ecb_encrypt(WOLFSSL_DES_cblock* desa,
|
void wolfSSL_DES_ecb_encrypt(WOLFSSL_DES_cblock* desa,
|
||||||
WOLFSSL_DES_cblock* desb, WOLFSSL_DES_key_schedule* key, int dir)
|
WOLFSSL_DES_cblock* desb, WOLFSSL_DES_key_schedule* key, int enc)
|
||||||
{
|
{
|
||||||
WOLFSSL_ENTER("wolfSSL_DES_ecb_encrypt");
|
WOLFSSL_ENTER("wolfSSL_DES_ecb_encrypt");
|
||||||
|
|
||||||
Des3 enc;
|
Des3 myDes;
|
||||||
if (desa == NULL || key == NULL || desb == NULL || (dir != DES_ENCRYPT && dir != DES_DECRYPT)){
|
if (desa == NULL || key == NULL || desb == NULL || (enc != DES_ENCRYPT && enc != DES_DECRYPT)){
|
||||||
WOLFSSL_MSG("Bad argument passed to wolfSSL_DES_ecb_encrypt");
|
WOLFSSL_MSG("Bad argument passed to wolfSSL_DES_ecb_encrypt");
|
||||||
} else {
|
} else {
|
||||||
int cdir;
|
if (wc_Des3_SetKey(&myDes, (const byte*) key, (const byte*) NULL, enc) != 0){
|
||||||
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.");
|
WOLFSSL_MSG("wc_Des3_SetKey return error.");
|
||||||
}
|
}
|
||||||
if (wc_Des3_EcbEncrypt(&enc, (byte*) desb, (const byte*) desa, sizeof(desb)) != 0){
|
if (enc){
|
||||||
WOLFSSL_MSG("wc_Des3_EcbEncrpyt return error.");
|
if (wc_Des3_EcbEncrypt(&myDes, (byte*) desb, (const byte*) desa, sizeof(desa)) != 0){
|
||||||
}
|
WOLFSSL_MSG("wc_Des3_EcbEncrpyt return error.");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (wc_Des3_EcbDecrypt(&myDes, (byte*) desb, (const byte*) desa, sizeof(desa)) != 0){
|
||||||
|
WOLFSSL_MSG("wc_Des3_EcbDecrpyt return error.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user