Blame src/lib/crypto/krb/s2k_rc4.c
|
Packit Service |
99d1c0 |
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
Packit Service |
99d1c0 |
#include "crypto_int.h"
|
|
Packit Service |
99d1c0 |
#include "k5-utf8.h"
|
|
Packit Service |
99d1c0 |
|
|
Packit Service |
99d1c0 |
krb5_error_code
|
|
Packit Service |
99d1c0 |
krb5int_arcfour_string_to_key(const struct krb5_keytypes *ktp,
|
|
Packit Service |
99d1c0 |
const krb5_data *string, const krb5_data *salt,
|
|
Packit Service |
99d1c0 |
const krb5_data *params, krb5_keyblock *key)
|
|
Packit Service |
99d1c0 |
{
|
|
Packit Service |
99d1c0 |
krb5_error_code err = 0;
|
|
Packit Service |
99d1c0 |
krb5_crypto_iov iov;
|
|
Packit Service |
99d1c0 |
krb5_data hash_out;
|
|
Packit Service |
99d1c0 |
char *utf8;
|
|
Packit Service |
99d1c0 |
unsigned char *copystr;
|
|
Packit Service |
99d1c0 |
size_t copystrlen;
|
|
Packit Service |
99d1c0 |
|
|
Packit Service |
99d1c0 |
if (params != NULL)
|
|
Packit Service |
99d1c0 |
return KRB5_ERR_BAD_S2K_PARAMS;
|
|
Packit Service |
99d1c0 |
|
|
Packit Service |
99d1c0 |
if (key->length != 16)
|
|
Packit Service |
99d1c0 |
return (KRB5_BAD_MSIZE);
|
|
Packit Service |
99d1c0 |
|
|
Packit Service |
99d1c0 |
/* We ignore salt per the Microsoft spec. */
|
|
Packit Service |
99d1c0 |
utf8 = k5memdup0(string->data, string->length, &err;;
|
|
Packit Service |
99d1c0 |
if (utf8 == NULL)
|
|
Packit Service |
99d1c0 |
return err;
|
|
Packit Service |
99d1c0 |
err = k5_utf8_to_utf16le(utf8, ©str, ©strlen);
|
|
Packit Service |
99d1c0 |
zapfree(utf8, string->length);
|
|
Packit Service |
99d1c0 |
if (err)
|
|
Packit Service |
99d1c0 |
return err;
|
|
Packit Service |
99d1c0 |
|
|
Packit Service |
99d1c0 |
/* the actual MD4 hash of the data */
|
|
Packit Service |
99d1c0 |
iov.flags = KRB5_CRYPTO_TYPE_DATA;
|
|
Packit Service |
99d1c0 |
iov.data = make_data(copystr, copystrlen);
|
|
Packit Service |
99d1c0 |
hash_out = make_data(key->contents, key->length);
|
|
Packit Service |
99d1c0 |
err = krb5int_hash_md4.hash(&iov, 1, &hash_out);
|
|
Packit Service |
99d1c0 |
|
|
Packit Service |
99d1c0 |
/* Zero out the data behind us */
|
|
Packit Service |
99d1c0 |
zapfree(copystr, copystrlen);
|
|
Packit Service |
99d1c0 |
return err;
|
|
Packit Service |
99d1c0 |
}
|