bump libheimntlm to the version from OSX 10.9 Mavericks

This commit is contained in:
Love Hörnquist Åstrand
2013-11-17 13:15:55 +01:00
parent 22a5077835
commit cde59c543d
8 changed files with 1436 additions and 348 deletions

View File

@@ -1,36 +1,36 @@
/*
* Copyright (c) 2010 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Portions Copyright (c) 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/types.h>
@@ -55,9 +55,9 @@ heim_generate_challenge(const char *hostname)
hostname = host;
}
t = time(NULL);
t = (uint32_t)time(NULL);
num = rk_random();
asprintf(&str, "<%lu%lu@%s>", (unsigned long)t,
(unsigned long)num, hostname);
@@ -72,8 +72,8 @@ heim_apop_create(const char *challenge, const char *password)
CC_MD5_CTX ctx;
CC_MD5_Init(&ctx);
CC_MD5_Update(&ctx, challenge, strlen(challenge));
CC_MD5_Update(&ctx, password, strlen(password));
CC_MD5_Update(&ctx, challenge, (CC_LONG)strlen(challenge));
CC_MD5_Update(&ctx, password, (CC_LONG)strlen(password));
CC_MD5_Final(hash, &ctx);
@@ -102,7 +102,7 @@ heim_apop_verify(const char *challenge, const char *password, const char *respon
return 0;
}
struct heim_cram_md5 {
struct heim_cram_md5_data {
CC_MD5_CTX ipad;
CC_MD5_CTX opad;
};
@@ -114,13 +114,13 @@ heim_cram_md5_export(const char *password, heim_CRAM_MD5_STATE *state)
size_t keylen = strlen(password);
uint8_t key[CC_MD5_BLOCK_BYTES];
uint8_t pad[CC_MD5_BLOCK_BYTES];
struct heim_cram_md5 ctx;
struct heim_cram_md5_data ctx;
size_t n;
memset(&ctx, 0, sizeof(ctx));
if (keylen > CC_MD5_BLOCK_BYTES) {
CC_MD5(password, keylen, key);
CC_MD5(password, (CC_LONG)keylen, key);
keylen = sizeof(keylen);
} else {
memcpy(key, password, keylen);
@@ -163,8 +163,7 @@ heim_cram_md5_import(void *data, size_t len)
{
heim_CRAM_MD5_STATE state;
heim_cram_md5 ctx;
unsigned n;
if (len != sizeof(state))
return NULL;
@@ -198,7 +197,7 @@ heim_cram_md5_verify_ctx(heim_cram_md5 ctx, const char *challenge, const char *r
char *str = NULL;
int res;
CC_MD5_Update(&ctx->ipad, challenge, strlen(challenge));
CC_MD5_Update(&ctx->ipad, challenge, (CC_LONG)strlen(challenge));
CC_MD5_Final(hash, &ctx->ipad);
CC_MD5_Update(&ctx->opad, hash, sizeof(hash));