lib/krb5_wrap: add smb_krb5_get_pw_salt().
authorGünther Deschner <gd@samba.org>
Fri, 25 Apr 2014 12:03:35 +0000 (14:03 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 8 Aug 2014 04:02:34 +0000 (06:02 +0200)
Guenther

Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Pair-Programmed-With: Andreas Schneider <asn@samba.org>

lib/krb5_wrap/krb5_samba.c
lib/krb5_wrap/krb5_samba.h

index b218437da0ef2ec5ab3554b9907b0e1873d3f41b..ea6b7158ec64e27ca72902f9c53805f8374e6b40 100644 (file)
@@ -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)
index 73a52a5cb5748af85aecac118c3a1f49c68495a1..b71eebef0242182a878b07cbc1c3f2ac1b55c4cc 100644 (file)
@@ -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 */