From b17bf61cc05a95491f1cd1b50737aae64e704f55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Thu, 22 Apr 2004 08:00:08 +0000 Subject: [PATCH] (krb5_random_to_key): new function git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13741 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/krb5/crypto.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/krb5/crypto.c b/lib/krb5/crypto.c index 3ed328bf0..16370d49d 100644 --- a/lib/krb5/crypto.c +++ b/lib/krb5/crypto.c @@ -1608,7 +1608,7 @@ struct checksum_type checksum_none = { "none", 1, 0, - 0, + 0, NONE_checksum, NULL }; @@ -3862,6 +3862,39 @@ krb5_get_wrapped_length (krb5_context context, return wrapped_length (context, crypto, data_len); } +krb5_error_code +krb5_random_to_key(krb5_context context, + krb5_enctype type, + const void *data, + size_t size, + krb5_keyblock *key) +{ + krb5_error_code ret; + struct encryption_type *et = _find_enctype(type); + if(et == NULL) { + krb5_set_error_string(context, "encryption type %d not supported", + type); + return KRB5_PROG_ETYPE_NOSUPP; + } + if (et->keytype->size > size) { + krb5_set_error_string(context, "encryption key %s needs %d bytes " + "of random to make an encryption key out of it", + et->name, et->keytype->size); + return KRB5_PROG_ETYPE_NOSUPP; + } + ret = krb5_data_alloc(&key->keyvalue, et->keytype->size); + if(ret) + return ret; + key->keytype = type; + memcpy(key->keyvalue.data, data, et->keytype->size); +#if 0 + if (et->random_to_key) + ret = (*et->random_to_key)(context, key, data, size); +#endif + + return 0; +} + #ifdef CRYPTO_DEBUG static krb5_error_code