1
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
5
#include "arcfour-int.h"
7
#if TARGET_OS_MAC && !defined(DEPEND)
8
#include <CoreFoundation/CFString.h>
12
krb5int_arcfour_string_to_key(const struct krb5_keytypes *ktp,
13
const krb5_data *string, const krb5_data *salt,
14
const krb5_data *params, krb5_keyblock *key)
16
krb5_error_code err = 0;
17
krb5_MD4_CTX md4_context;
18
unsigned char *copystr;
22
return KRB5_ERR_BAD_S2K_PARAMS;
24
if (key->length != 16)
25
return (KRB5_BAD_MSIZE);
27
/* We ignore salt per the Microsoft spec*/
29
/* compute the space needed for the new string.
30
Since the password must be stored in unicode, we need to increase
34
err = krb5int_utf8cs_to_ucs2les(string->data, string->length, ©str, ©strlen);
38
/* the actual MD4 hash of the data */
39
krb5int_MD4Init(&md4_context);
40
krb5int_MD4Update(&md4_context, copystr, copystrlen);
41
krb5int_MD4Final(&md4_context);
42
memcpy(key->contents, md4_context.digest, 16);
45
/* test the string_to_key function */
49
for(counter=0;counter<16;counter++)
50
printf("%02x", md4_context.digest[counter]);
55
/* Zero out the data behind us */
56
memset(copystr, 0, copystrlen);
57
memset(&md4_context, 0, sizeof(md4_context));