diff options
author | Steve Holme <steve_holme@hotmail.com> | 2015-01-28 20:59:27 +0000 |
---|---|---|
committer | Steve Holme <steve_holme@hotmail.com> | 2015-01-28 22:34:53 +0000 |
commit | 8cc70db2db5f58e519a1bdfed266ca6514013145 (patch) | |
tree | 59ebffc9c1c38b81f1a4d5df92f56bac46de5266 | |
parent | c469369b865200d751dc9ef8dc18181d185c8e1e (diff) |
ntlm_core: Use own odd parity function when crypto engine doesn't have one
-rw-r--r-- | lib/curl_ntlm_core.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/curl_ntlm_core.c b/lib/curl_ntlm_core.c index 620049256..1bdc82312 100644 --- a/lib/curl_ntlm_core.c +++ b/lib/curl_ntlm_core.c @@ -107,6 +107,7 @@ #include "curl_hmac.h" #include "warnless.h" #include "curl_endian.h" +#include "curl_des.h" #define _MPRINTF_REPLACE /* use our functions only */ #include <curl/mprintf.h> @@ -147,7 +148,11 @@ static void setup_des_key(const unsigned char *key_56, extend_key_56_to_64(key_56, (char *) key); /* Set the key parity to odd */ +#if defined(HAVE_BORINGSSL) + Curl_des_set_odd_parity((unsigned char *) &key, sizeof(key)); +#else DES_set_odd_parity(&key); +#endif /* Set the key */ DES_set_key(&key, ks); @@ -163,6 +168,9 @@ static void setup_des_key(const unsigned char *key_56, /* Expand the 56-bit key to 64-bits */ extend_key_56_to_64(key_56, key); + /* Set the key parity to odd */ + Curl_des_set_odd_parity((unsigned char *) key, sizeof(key)); + /* Set the key */ des_set_key(des, (const uint8_t *) key); } @@ -180,6 +188,9 @@ static void setup_des_key(const unsigned char *key_56, /* Expand the 56-bit key to 64-bits */ extend_key_56_to_64(key_56, key); + /* Set the key parity to odd */ + Curl_des_set_odd_parity((unsigned char *) key, sizeof(key)); + /* Set the key */ gcry_cipher_setkey(*des, key, sizeof(key)); } @@ -212,6 +223,9 @@ static bool encrypt_des(const unsigned char *in, unsigned char *out, /* Expand the 56-bit key to 64-bits */ extend_key_56_to_64(key_56, key); + /* Set the key parity to odd */ + Curl_des_set_odd_parity((unsigned char *) key, sizeof(key)); + /* Import the key */ key_item.data = (unsigned char *)key; key_item.len = sizeof(key); @@ -258,6 +272,9 @@ static bool encrypt_des(const unsigned char *in, unsigned char *out, /* Expand the 56-bit key to 64-bits */ extend_key_56_to_64(key_56, key); + /* Set the key parity to odd */ + Curl_des_set_odd_parity((unsigned char *) key, sizeof(key)); + /* Perform the encryption */ err = CCCrypt(kCCEncrypt, kCCAlgorithmDES, kCCOptionECBMode, key, kCCKeySizeDES, NULL, in, 8 /* inbuflen */, out, @@ -281,6 +298,9 @@ static bool encrypt_des(const unsigned char *in, unsigned char *out, /* Expand the 56-bit key to 64-bits */ extend_key_56_to_64(key_56, ctl.Crypto_Key); + /* Set the key parity to odd */ + Curl_des_set_odd_parity((unsigned char *) ctl.Crypto_Key, ctl.Data_Len); + /* Perform the encryption */ _CIPHER((_SPCPTR *) &out, &ctl, (_SPCPTR *) &in); @@ -316,6 +336,9 @@ static bool encrypt_des(const unsigned char *in, unsigned char *out, /* Expand the 56-bit key to 64-bits */ extend_key_56_to_64(key_56, blob.key); + /* Set the key parity to odd */ + Curl_des_set_odd_parity((unsigned char *) blob.key, sizeof(blob.key)); + /* Import the key */ if(!CryptImportKey(hprov, (BYTE *) &blob, sizeof(blob), 0, 0, &hkey)) { CryptReleaseContext(hprov, 0); |