1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
23 #include "curl_setup.h"
30 * https://davenport.sourceforge.io/ntlm.html
31 * https://www.innovation.ch/java/ntlm.html
34 #if !defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO)
39 # include <openssl/des.h>
40 # ifndef OPENSSL_NO_MD4
41 # include <openssl/md4.h>
43 # include <openssl/md5.h>
44 # include <openssl/ssl.h>
45 # include <openssl/rand.h>
48 # ifndef OPENSSL_NO_MD4
55 # if (OPENSSL_VERSION_NUMBER < 0x00907001L)
56 # define DES_key_schedule des_key_schedule
57 # define DES_cblock des_cblock
58 # define DES_set_odd_parity des_set_odd_parity
59 # define DES_set_key des_set_key
60 # define DES_ecb_encrypt des_ecb_encrypt
62 # define DESKEYARG(x) x
64 # define DESKEYARG(x) *x
68 #elif defined(USE_GNUTLS_NETTLE)
70 # include <nettle/des.h>
71 # include <nettle/md4.h>
73 #elif defined(USE_GNUTLS)
76 # define MD5_DIGEST_LENGTH 16
77 # define MD4_DIGEST_LENGTH 16
79 #elif defined(USE_MBEDTLS)
81 # include <mbedtls/des.h>
82 # include <mbedtls/md4.h>
84 #elif defined(USE_NSS)
89 # include "curl_md4.h"
90 # define MD5_DIGEST_LENGTH MD5_LENGTH
92 #elif defined(USE_DARWINSSL)
94 # include <CommonCrypto/CommonCryptor.h>
95 # include <CommonCrypto/CommonDigest.h>
97 #elif defined(USE_OS400CRYPTO)
98 # include "cipher.mih" /* mih/cipher */
99 # include "curl_md4.h"
100 #elif defined(USE_WIN32_CRYPTO)
101 # include <wincrypt.h>
103 # error "Can't compile NTLM support without a crypto library."
107 #include "non-ascii.h"
109 #include "curl_ntlm_core.h"
110 #include "curl_md5.h"
111 #include "curl_hmac.h"
112 #include "warnless.h"
113 #include "curl_endian.h"
114 #include "curl_des.h"
115 /* The last 3 #include files should be in this order */
116 #include "curl_printf.h"
117 #include "curl_memory.h"
118 #include "memdebug.h"
120 #define NTLM_HMAC_MD5_LEN (16)
121 #define NTLMv2_BLOB_SIGNATURE "\x01\x01\x00\x00"
122 #define NTLMv2_BLOB_LEN (44 -16 + ntlm->target_info_len + 4)
125 * Turns a 56-bit key into being 64-bit wide.
127 static void extend_key_56_to_64(const unsigned char *key_56, char *key)
130 key[1] = (unsigned char)(((key_56[0] << 7) & 0xFF) | (key_56[1] >> 1));
131 key[2] = (unsigned char)(((key_56[1] << 6) & 0xFF) | (key_56[2] >> 2));
132 key[3] = (unsigned char)(((key_56[2] << 5) & 0xFF) | (key_56[3] >> 3));
133 key[4] = (unsigned char)(((key_56[3] << 4) & 0xFF) | (key_56[4] >> 4));
134 key[5] = (unsigned char)(((key_56[4] << 3) & 0xFF) | (key_56[5] >> 5));
135 key[6] = (unsigned char)(((key_56[5] << 2) & 0xFF) | (key_56[6] >> 6));
136 key[7] = (unsigned char) ((key_56[6] << 1) & 0xFF);
141 * Turns a 56 bit key into the 64 bit, odd parity key and sets the key. The
142 * key schedule ks is also set.
144 static void setup_des_key(const unsigned char *key_56,
145 DES_key_schedule DESKEYARG(ks))
149 /* Expand the 56-bit key to 64-bits */
150 extend_key_56_to_64(key_56, (char *) &key);
152 /* Set the key parity to odd */
153 DES_set_odd_parity(&key);
156 DES_set_key(&key, ks);
159 #elif defined(USE_GNUTLS_NETTLE)
161 static void setup_des_key(const unsigned char *key_56,
166 /* Expand the 56-bit key to 64-bits */
167 extend_key_56_to_64(key_56, key);
169 /* Set the key parity to odd */
170 Curl_des_set_odd_parity((unsigned char *) key, sizeof(key));
173 des_set_key(des, (const uint8_t *) key);
176 #elif defined(USE_GNUTLS)
179 * Turns a 56 bit key into the 64 bit, odd parity key and sets the key.
181 static void setup_des_key(const unsigned char *key_56,
182 gcry_cipher_hd_t *des)
186 /* Expand the 56-bit key to 64-bits */
187 extend_key_56_to_64(key_56, key);
189 /* Set the key parity to odd */
190 Curl_des_set_odd_parity((unsigned char *) key, sizeof(key));
193 gcry_cipher_setkey(*des, key, sizeof(key));
196 #elif defined(USE_MBEDTLS)
198 static bool encrypt_des(const unsigned char *in, unsigned char *out,
199 const unsigned char *key_56)
201 mbedtls_des_context ctx;
204 /* Expand the 56-bit key to 64-bits */
205 extend_key_56_to_64(key_56, key);
207 /* Set the key parity to odd */
208 mbedtls_des_key_set_parity((unsigned char *) key);
210 /* Perform the encryption */
211 mbedtls_des_init(&ctx);
212 mbedtls_des_setkey_enc(&ctx, (unsigned char *) key);
213 return mbedtls_des_crypt_ecb(&ctx, in, out) == 0;
216 #elif defined(USE_NSS)
219 * Expands a 56 bit key KEY_56 to 64 bit and encrypts 64 bit of data, using
220 * the expanded key. The caller is responsible for giving 64 bit of valid
221 * data is IN and (at least) 64 bit large buffer as OUT.
223 static bool encrypt_des(const unsigned char *in, unsigned char *out,
224 const unsigned char *key_56)
226 const CK_MECHANISM_TYPE mech = CKM_DES_ECB; /* DES cipher in ECB mode */
227 PK11SlotInfo *slot = NULL;
228 char key[8]; /* expanded 64 bit key */
230 PK11SymKey *symkey = NULL;
231 SECItem *param = NULL;
232 PK11Context *ctx = NULL;
233 int out_len; /* not used, required by NSS */
236 /* use internal slot for DES encryption (requires NSS to be initialized) */
237 slot = PK11_GetInternalKeySlot();
241 /* Expand the 56-bit key to 64-bits */
242 extend_key_56_to_64(key_56, key);
244 /* Set the key parity to odd */
245 Curl_des_set_odd_parity((unsigned char *) key, sizeof(key));
248 key_item.data = (unsigned char *)key;
249 key_item.len = sizeof(key);
250 symkey = PK11_ImportSymKey(slot, mech, PK11_OriginUnwrap, CKA_ENCRYPT,
255 /* Create the DES encryption context */
256 param = PK11_ParamFromIV(mech, /* no IV in ECB mode */ NULL);
259 ctx = PK11_CreateContextBySymKey(mech, CKA_ENCRYPT, symkey, param);
263 /* Perform the encryption */
264 if(SECSuccess == PK11_CipherOp(ctx, out, &out_len, /* outbuflen */ 8,
265 (unsigned char *)in, /* inbuflen */ 8)
266 && SECSuccess == PK11_Finalize(ctx))
267 rv = /* all OK */ TRUE;
272 PK11_DestroyContext(ctx, PR_TRUE);
274 PK11_FreeSymKey(symkey);
276 SECITEM_FreeItem(param, PR_TRUE);
281 #elif defined(USE_DARWINSSL)
283 static bool encrypt_des(const unsigned char *in, unsigned char *out,
284 const unsigned char *key_56)
290 /* Expand the 56-bit key to 64-bits */
291 extend_key_56_to_64(key_56, key);
293 /* Set the key parity to odd */
294 Curl_des_set_odd_parity((unsigned char *) key, sizeof(key));
296 /* Perform the encryption */
297 err = CCCrypt(kCCEncrypt, kCCAlgorithmDES, kCCOptionECBMode, key,
298 kCCKeySizeDES, NULL, in, 8 /* inbuflen */, out,
299 8 /* outbuflen */, &out_len);
301 return err == kCCSuccess;
304 #elif defined(USE_OS400CRYPTO)
306 static bool encrypt_des(const unsigned char *in, unsigned char *out,
307 const unsigned char *key_56)
310 _CIPHER_Control_T ctl;
312 /* Setup the cipher control structure */
313 ctl.Func_ID = ENCRYPT_ONLY;
314 ctl.Data_Len = sizeof(key);
316 /* Expand the 56-bit key to 64-bits */
317 extend_key_56_to_64(key_56, ctl.Crypto_Key);
319 /* Set the key parity to odd */
320 Curl_des_set_odd_parity((unsigned char *) ctl.Crypto_Key, ctl.Data_Len);
322 /* Perform the encryption */
323 _CIPHER((_SPCPTR *) &out, &ctl, (_SPCPTR *) &in);
328 #elif defined(USE_WIN32_CRYPTO)
330 static bool encrypt_des(const unsigned char *in, unsigned char *out,
331 const unsigned char *key_56)
342 /* Acquire the crypto provider */
343 if(!CryptAcquireContext(&hprov, NULL, NULL, PROV_RSA_FULL,
344 CRYPT_VERIFYCONTEXT))
347 /* Setup the key blob structure */
348 memset(&blob, 0, sizeof(blob));
349 blob.hdr.bType = PLAINTEXTKEYBLOB;
350 blob.hdr.bVersion = 2;
351 blob.hdr.aiKeyAlg = CALG_DES;
352 blob.len = sizeof(blob.key);
354 /* Expand the 56-bit key to 64-bits */
355 extend_key_56_to_64(key_56, blob.key);
357 /* Set the key parity to odd */
358 Curl_des_set_odd_parity((unsigned char *) blob.key, sizeof(blob.key));
361 if(!CryptImportKey(hprov, (BYTE *) &blob, sizeof(blob), 0, 0, &hkey)) {
362 CryptReleaseContext(hprov, 0);
369 /* Perform the encryption */
370 CryptEncrypt(hkey, 0, FALSE, 0, out, &len, len);
372 CryptDestroyKey(hkey);
373 CryptReleaseContext(hprov, 0);
378 #endif /* defined(USE_WIN32_CRYPTO) */
381 * takes a 21 byte array and treats it as 3 56-bit DES keys. The
382 * 8 byte plaintext is encrypted with each key and the resulting 24
383 * bytes are stored in the results array.
385 void Curl_ntlm_core_lm_resp(const unsigned char *keys,
386 const unsigned char *plaintext,
387 unsigned char *results)
392 setup_des_key(keys, DESKEY(ks));
393 DES_ecb_encrypt((DES_cblock*) plaintext, (DES_cblock*) results,
394 DESKEY(ks), DES_ENCRYPT);
396 setup_des_key(keys + 7, DESKEY(ks));
397 DES_ecb_encrypt((DES_cblock*) plaintext, (DES_cblock*) (results + 8),
398 DESKEY(ks), DES_ENCRYPT);
400 setup_des_key(keys + 14, DESKEY(ks));
401 DES_ecb_encrypt((DES_cblock*) plaintext, (DES_cblock*) (results + 16),
402 DESKEY(ks), DES_ENCRYPT);
403 #elif defined(USE_GNUTLS_NETTLE)
405 setup_des_key(keys, &des);
406 des_encrypt(&des, 8, results, plaintext);
407 setup_des_key(keys + 7, &des);
408 des_encrypt(&des, 8, results + 8, plaintext);
409 setup_des_key(keys + 14, &des);
410 des_encrypt(&des, 8, results + 16, plaintext);
411 #elif defined(USE_GNUTLS)
412 gcry_cipher_hd_t des;
414 gcry_cipher_open(&des, GCRY_CIPHER_DES, GCRY_CIPHER_MODE_ECB, 0);
415 setup_des_key(keys, &des);
416 gcry_cipher_encrypt(des, results, 8, plaintext, 8);
417 gcry_cipher_close(des);
419 gcry_cipher_open(&des, GCRY_CIPHER_DES, GCRY_CIPHER_MODE_ECB, 0);
420 setup_des_key(keys + 7, &des);
421 gcry_cipher_encrypt(des, results + 8, 8, plaintext, 8);
422 gcry_cipher_close(des);
424 gcry_cipher_open(&des, GCRY_CIPHER_DES, GCRY_CIPHER_MODE_ECB, 0);
425 setup_des_key(keys + 14, &des);
426 gcry_cipher_encrypt(des, results + 16, 8, plaintext, 8);
427 gcry_cipher_close(des);
428 #elif defined(USE_MBEDTLS) || defined(USE_NSS) || defined(USE_DARWINSSL) \
429 || defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO)
430 encrypt_des(plaintext, results, keys);
431 encrypt_des(plaintext, results + 8, keys + 7);
432 encrypt_des(plaintext, results + 16, keys + 14);
437 * Set up lanmanager hashed password
439 CURLcode Curl_ntlm_core_mk_lm_hash(struct Curl_easy *data,
440 const char *password,
441 unsigned char *lmbuffer /* 21 bytes */)
444 unsigned char pw[14];
445 static const unsigned char magic[] = {
446 0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25 /* i.e. KGS!@#$% */
448 size_t len = CURLMIN(strlen(password), 14);
450 Curl_strntoupper((char *)pw, password, len);
451 memset(&pw[len], 0, 14 - len);
454 * The LanManager hashed password needs to be created using the
455 * password in the network encoding not the host encoding.
457 result = Curl_convert_to_network(data, (char *)pw, 14);
462 /* Create LanManager hashed password. */
467 setup_des_key(pw, DESKEY(ks));
468 DES_ecb_encrypt((DES_cblock *)magic, (DES_cblock *)lmbuffer,
469 DESKEY(ks), DES_ENCRYPT);
471 setup_des_key(pw + 7, DESKEY(ks));
472 DES_ecb_encrypt((DES_cblock *)magic, (DES_cblock *)(lmbuffer + 8),
473 DESKEY(ks), DES_ENCRYPT);
474 #elif defined(USE_GNUTLS_NETTLE)
476 setup_des_key(pw, &des);
477 des_encrypt(&des, 8, lmbuffer, magic);
478 setup_des_key(pw + 7, &des);
479 des_encrypt(&des, 8, lmbuffer + 8, magic);
480 #elif defined(USE_GNUTLS)
481 gcry_cipher_hd_t des;
483 gcry_cipher_open(&des, GCRY_CIPHER_DES, GCRY_CIPHER_MODE_ECB, 0);
484 setup_des_key(pw, &des);
485 gcry_cipher_encrypt(des, lmbuffer, 8, magic, 8);
486 gcry_cipher_close(des);
488 gcry_cipher_open(&des, GCRY_CIPHER_DES, GCRY_CIPHER_MODE_ECB, 0);
489 setup_des_key(pw + 7, &des);
490 gcry_cipher_encrypt(des, lmbuffer + 8, 8, magic, 8);
491 gcry_cipher_close(des);
492 #elif defined(USE_MBEDTLS) || defined(USE_NSS) || defined(USE_DARWINSSL) \
493 || defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO)
494 encrypt_des(magic, lmbuffer, pw);
495 encrypt_des(magic, lmbuffer + 8, pw + 7);
498 memset(lmbuffer + 16, 0, 21 - 16);
505 static void ascii_to_unicode_le(unsigned char *dest, const char *src,
509 for(i = 0; i < srclen; i++) {
510 dest[2 * i] = (unsigned char)src[i];
511 dest[2 * i + 1] = '\0';
515 #if USE_NTLM_V2 && !defined(USE_WINDOWS_SSPI)
517 static void ascii_uppercase_to_unicode_le(unsigned char *dest,
518 const char *src, size_t srclen)
521 for(i = 0; i < srclen; i++) {
522 dest[2 * i] = (unsigned char)(toupper(src[i]));
523 dest[2 * i + 1] = '\0';
527 #endif /* USE_NTLM_V2 && !USE_WINDOWS_SSPI */
530 * Set up nt hashed passwords
533 CURLcode Curl_ntlm_core_mk_nt_hash(struct Curl_easy *data,
534 const char *password,
535 unsigned char *ntbuffer /* 21 bytes */)
537 size_t len = strlen(password);
538 unsigned char *pw = malloc(len * 2);
541 return CURLE_OUT_OF_MEMORY;
543 ascii_to_unicode_le(pw, password, len);
546 * The NT hashed password needs to be created using the password in the
547 * network encoding not the host encoding.
549 result = Curl_convert_to_network(data, (char *)pw, len * 2);
554 /* Create NT hashed password. */
558 MD4_Update(&MD4pw, pw, 2 * len);
559 MD4_Final(ntbuffer, &MD4pw);
560 #elif defined(USE_GNUTLS_NETTLE)
561 struct md4_ctx MD4pw;
563 md4_update(&MD4pw, (unsigned int)(2 * len), pw);
564 md4_digest(&MD4pw, MD4_DIGEST_SIZE, ntbuffer);
565 #elif defined(USE_GNUTLS)
567 gcry_md_open(&MD4pw, GCRY_MD_MD4, 0);
568 gcry_md_write(MD4pw, pw, 2 * len);
569 memcpy(ntbuffer, gcry_md_read(MD4pw, 0), MD4_DIGEST_LENGTH);
570 gcry_md_close(MD4pw);
571 #elif defined(USE_MBEDTLS)
572 mbedtls_md4(pw, 2 * len, ntbuffer);
573 #elif defined(USE_NSS) || defined(USE_OS400CRYPTO)
574 Curl_md4it(ntbuffer, pw, 2 * len);
575 #elif defined(USE_DARWINSSL)
576 (void)CC_MD4(pw, (CC_LONG)(2 * len), ntbuffer);
577 #elif defined(USE_WIN32_CRYPTO)
579 if(CryptAcquireContext(&hprov, NULL, NULL, PROV_RSA_FULL,
580 CRYPT_VERIFYCONTEXT)) {
582 if(CryptCreateHash(hprov, CALG_MD4, 0, 0, &hhash)) {
584 CryptHashData(hhash, pw, (unsigned int)len * 2, 0);
585 CryptGetHashParam(hhash, HP_HASHVAL, ntbuffer, &length, 0);
586 CryptDestroyHash(hhash);
588 CryptReleaseContext(hprov, 0);
592 memset(ntbuffer + 16, 0, 21 - 16);
600 #if USE_NTLM_V2 && !defined(USE_WINDOWS_SSPI)
602 /* This returns the HMAC MD5 digest */
603 CURLcode Curl_hmac_md5(const unsigned char *key, unsigned int keylen,
604 const unsigned char *data, unsigned int datalen,
605 unsigned char *output)
607 HMAC_context *ctxt = Curl_HMAC_init(Curl_HMAC_MD5, key, keylen);
610 return CURLE_OUT_OF_MEMORY;
612 /* Update the digest with the given challenge */
613 Curl_HMAC_update(ctxt, data, datalen);
615 /* Finalise the digest */
616 Curl_HMAC_final(ctxt, output);
621 /* This creates the NTLMv2 hash by using NTLM hash as the key and Unicode
622 * (uppercase UserName + Domain) as the data
624 CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen,
625 const char *domain, size_t domlen,
626 unsigned char *ntlmhash,
627 unsigned char *ntlmv2hash)
629 /* Unicode representation */
630 size_t identity_len = (userlen + domlen) * 2;
631 unsigned char *identity = malloc(identity_len);
632 CURLcode result = CURLE_OK;
635 return CURLE_OUT_OF_MEMORY;
637 ascii_uppercase_to_unicode_le(identity, user, userlen);
638 ascii_to_unicode_le(identity + (userlen << 1), domain, domlen);
640 result = Curl_hmac_md5(ntlmhash, 16, identity, curlx_uztoui(identity_len),
649 * Curl_ntlm_core_mk_ntlmv2_resp()
651 * This creates the NTLMv2 response as set in the ntlm type-3 message.
655 * ntlmv2hash [in] - The ntlmv2 hash (16 bytes)
656 * challenge_client [in] - The client nonce (8 bytes)
657 * ntlm [in] - The ntlm data struct being used to read TargetInfo
658 and Server challenge received in the type-2 message
659 * ntresp [out] - The address where a pointer to newly allocated
660 * memory holding the NTLMv2 response.
661 * ntresp_len [out] - The length of the output message.
663 * Returns CURLE_OK on success.
665 CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
666 unsigned char *challenge_client,
667 struct ntlmdata *ntlm,
668 unsigned char **ntresp,
669 unsigned int *ntresp_len)
671 /* NTLMv2 response structure :
672 ------------------------------------------------------------------------------
674 ------BLOB--------------------------------------------------------------------
675 16 Signature 0x01010000
676 20 Reserved long (0x00000000)
677 24 Timestamp LE, 64-bit signed value representing the number of
678 tenths of a microsecond since January 1, 1601.
679 32 Client Nonce 8 bytes
681 44 Target Info N bytes (from the type-2 message)
683 ------------------------------------------------------------------------------
686 unsigned int len = 0;
687 unsigned char *ptr = NULL;
688 unsigned char hmac_output[NTLM_HMAC_MD5_LEN];
691 CURLcode result = CURLE_OK;
693 #if CURL_SIZEOF_CURL_OFF_T < 8
694 #error "this section needs 64bit support to work"
697 /* Calculate the timestamp */
699 char *force_timestamp = getenv("CURL_FORCETIME");
701 tw = CURL_OFF_T_C(11644473600) * 10000000;
704 tw = ((curl_off_t)time(NULL) + CURL_OFF_T_C(11644473600)) * 10000000;
706 /* Calculate the response len */
707 len = NTLM_HMAC_MD5_LEN + NTLMv2_BLOB_LEN;
709 /* Allocate the response */
712 return CURLE_OUT_OF_MEMORY;
716 /* Create the BLOB structure */
717 snprintf((char *)ptr + NTLM_HMAC_MD5_LEN, NTLMv2_BLOB_LEN,
718 "%c%c%c%c" /* NTLMv2_BLOB_SIGNATURE */
719 "%c%c%c%c", /* Reserved = 0 */
720 NTLMv2_BLOB_SIGNATURE[0], NTLMv2_BLOB_SIGNATURE[1],
721 NTLMv2_BLOB_SIGNATURE[2], NTLMv2_BLOB_SIGNATURE[3],
724 Curl_write64_le(tw, ptr + 24);
725 memcpy(ptr + 32, challenge_client, 8);
726 memcpy(ptr + 44, ntlm->target_info, ntlm->target_info_len);
728 /* Concatenate the Type 2 challenge with the BLOB and do HMAC MD5 */
729 memcpy(ptr + 8, &ntlm->nonce[0], 8);
730 result = Curl_hmac_md5(ntlmv2hash, NTLM_HMAC_MD5_LEN, ptr + 8,
731 NTLMv2_BLOB_LEN + 8, hmac_output);
737 /* Concatenate the HMAC MD5 output with the BLOB */
738 memcpy(ptr, hmac_output, NTLM_HMAC_MD5_LEN);
740 /* Return the response */
748 * Curl_ntlm_core_mk_lmv2_resp()
750 * This creates the LMv2 response as used in the ntlm type-3 message.
754 * ntlmv2hash [in] - The ntlmv2 hash (16 bytes)
755 * challenge_client [in] - The client nonce (8 bytes)
756 * challenge_client [in] - The server challenge (8 bytes)
757 * lmresp [out] - The LMv2 response (24 bytes)
759 * Returns CURLE_OK on success.
761 CURLcode Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash,
762 unsigned char *challenge_client,
763 unsigned char *challenge_server,
764 unsigned char *lmresp)
766 unsigned char data[16];
767 unsigned char hmac_output[16];
768 CURLcode result = CURLE_OK;
770 memcpy(&data[0], challenge_server, 8);
771 memcpy(&data[8], challenge_client, 8);
773 result = Curl_hmac_md5(ntlmv2hash, 16, &data[0], 16, hmac_output);
777 /* Concatenate the HMAC MD5 output with the client nonce */
778 memcpy(lmresp, hmac_output, 16);
779 memcpy(lmresp+16, challenge_client, 8);
784 #endif /* USE_NTLM_V2 && !USE_WINDOWS_SSPI */
786 #endif /* USE_NTRESPONSES */
788 #endif /* !USE_WINDOWS_SSPI || USE_WIN32_CRYPTO */
790 #endif /* USE_NTLM */