From 6b3d9853ce8fb1506eefd7df10637b0413b69ab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Fri, 25 Apr 2014 14:03:35 +0200 Subject: lib/krb5_wrap: add smb_krb5_get_pw_salt(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Guenther Signed-off-by: Günther Deschner Reviewed-by: Andrew Bartlett Pair-Programmed-With: Andreas Schneider --- lib/krb5_wrap/krb5_samba.c | 42 ++++++++++++++++++++++++++++++++++++++++++ lib/krb5_wrap/krb5_samba.h | 3 +++ 2 files changed, 45 insertions(+) (limited to 'lib') diff --git a/lib/krb5_wrap/krb5_samba.c b/lib/krb5_wrap/krb5_samba.c index b218437da0e..ea6b7158ec6 100644 --- a/lib/krb5_wrap/krb5_samba.c +++ b/lib/krb5_wrap/krb5_samba.c @@ -181,6 +181,48 @@ int create_kerberos_key_from_string_direct(krb5_context context, #error UNKNOWN_CREATE_KEY_FUNCTIONS #endif + +/** +* @brief Create a salt for a given principal +* +* @param context The initialized krb5_context +* @param host_princ The krb5_principal to create the salt for +* @param psalt A pointer to a krb5_data struct +* +* caller has to free the contents of psalt with kerberos_free_data_contents +* when function has succeeded +* +* @return krb5_error_code, returns 0 on success, error code otherwise +*/ + +int smb_krb5_get_pw_salt(krb5_context context, + krb5_principal host_princ, + krb5_data *psalt) +#if defined(HAVE_KRB5_GET_PW_SALT) +/* Heimdal */ +{ + int ret; + krb5_salt salt; + + ret = krb5_get_pw_salt(context, host_princ, &salt); + if (ret) { + return ret; + } + + psalt->data = salt.saltvalue.data; + psalt->length = salt.saltvalue.length; + + return ret; +} +#elif defined(HAVE_KRB5_PRINCIPAL2SALT) +/* MIT */ +{ + return krb5_principal2salt(context, host_princ, psalt); +} +#else +#error UNKNOWN_SALT_FUNCTIONS +#endif + #if defined(HAVE_KRB5_GET_PERMITTED_ENCTYPES) krb5_error_code get_kerberos_allowed_etypes(krb5_context context, krb5_enctype **enctypes) diff --git a/lib/krb5_wrap/krb5_samba.h b/lib/krb5_wrap/krb5_samba.h index 73a52a5cb57..b71eebef024 100644 --- a/lib/krb5_wrap/krb5_samba.h +++ b/lib/krb5_wrap/krb5_samba.h @@ -300,6 +300,9 @@ krb5_enctype ms_suptype_to_ietf_enctype(uint32_t enctype_bitmap); krb5_error_code ms_suptypes_to_ietf_enctypes(TALLOC_CTX *mem_ctx, uint32_t enctype_bitmap, krb5_enctype **enctypes); +int smb_krb5_get_pw_salt(krb5_context context, + krb5_principal host_princ, + krb5_data *psalt); #endif /* HAVE_KRB5 */ -- cgit v1.2.1