From 93de8e45707ab834eb9d4e2a442025d109955382 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 26 Apr 2012 16:52:37 -0400 Subject: krb5samba: Add compat code to initialize keyblock contents --- lib/krb5_wrap/krb5_samba.c | 22 ++++++++++++++++++++++ lib/krb5_wrap/krb5_samba.h | 5 +++++ 2 files changed, 27 insertions(+) (limited to 'lib') diff --git a/lib/krb5_wrap/krb5_samba.c b/lib/krb5_wrap/krb5_samba.c index 82c25103e7..482684fc11 100644 --- a/lib/krb5_wrap/krb5_samba.c +++ b/lib/krb5_wrap/krb5_samba.c @@ -1555,6 +1555,28 @@ krb5_error_code smb_krb5_get_creds(const char *server_s, return ret; } + +krb5_error_code smb_krb5_keyblock_init_contents(krb5_context context, + krb5_enctype enctype, + const void *data, + size_t length, + krb5_keyblock *key) +{ +#if defined(HAVE_KRB5_KEYBLOCK_INIT) + return krb5_keyblock_init(context, enctype, data, length, key); +#else + memset(key, 0, sizeof(krb5_keyblock)); + KRB5_KEY_DATA(key) = SMB_MALLOC(length); + if (NULL == KRB5_KEY_DATA(key)) { + return ENOMEM; + } + memcpy(KRB5_KEY_DATA(key), data, length); + KRB5_KEY_LENGTH(key) = length; + KRB5_KEY_TYPE(key) = enctype; + return 0; +#endif +} + /* simulate a kinit, putting the tgt in the given credentials cache. Orignally by remus@snapserver.com diff --git a/lib/krb5_wrap/krb5_samba.h b/lib/krb5_wrap/krb5_samba.h index e2bd634d7a..a60be35a98 100644 --- a/lib/krb5_wrap/krb5_samba.h +++ b/lib/krb5_wrap/krb5_samba.h @@ -198,6 +198,11 @@ krb5_error_code smb_krb5_get_creds(const char *server_s, const char *cc, const char *impersonate_princ_s, krb5_creds **creds_p); +krb5_error_code smb_krb5_keyblock_init_contents(krb5_context context, + krb5_enctype enctype, + const void *data, + size_t length, + krb5_keyblock *key); krb5_error_code kerberos_kinit_keyblock_cc(krb5_context ctx, krb5_ccache cc, krb5_principal principal, krb5_keyblock *keyblock, -- cgit