diff options
author | Sarah Day <sarahday@mit.edu> | 2016-05-02 17:06:35 -0400 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2016-05-23 10:59:07 -0400 |
commit | 09cdb3079508f9d3fcc107a8ee8e7537f70c9d37 (patch) | |
tree | 4d76e9360f2276e86a0efce9fc9a9bd446e5c01b /src/lib/kdb | |
parent | e92dde11a96c23fd68df846260203de4cd09efb4 (diff) | |
download | krb5-09cdb3079508f9d3fcc107a8ee8e7537f70c9d37.zip krb5-09cdb3079508f9d3fcc107a8ee8e7537f70c9d37.tar.gz krb5-09cdb3079508f9d3fcc107a8ee8e7537f70c9d37.tar.bz2 |
Add libkdb function to specialize principal's salt
Add a function krb5_dbe_specialize_salt() to libkdb5 which transforms
a principal entry's salt to KRB5_KDB_SALTTYPE_SPECIAL.
ticket: 8418 (new)
Diffstat (limited to 'src/lib/kdb')
-rw-r--r-- | src/lib/kdb/kdb5.c | 42 | ||||
-rw-r--r-- | src/lib/kdb/libkdb5.exports | 1 |
2 files changed, 43 insertions, 0 deletions
diff --git a/src/lib/kdb/kdb5.c b/src/lib/kdb/kdb5.c index deafed1..68bec6e 100644 --- a/src/lib/kdb/kdb5.c +++ b/src/lib/kdb/kdb5.c @@ -2260,6 +2260,48 @@ krb5_dbe_compute_salt(krb5_context context, const krb5_key_data *key, return 0; } +krb5_error_code +krb5_dbe_specialize_salt(krb5_context context, krb5_db_entry *entry) +{ + krb5_int16 stype, i; + krb5_data *salt = NULL; + krb5_error_code ret = 0; + uint8_t *data; + + if (context == NULL || entry == NULL) + return EINVAL; + + /* + * Store salt values explicitly so that they don't depend on the principal + * name. + */ + for (i = 0; i < entry->n_key_data; i++) { + ret = krb5_dbe_compute_salt(context, &entry->key_data[i], entry->princ, + &stype, &salt); + if (ret) + goto cleanup; + + data = krb5_db_alloc(context, NULL, salt->length); + if (data == NULL) { + ret = ENOMEM; + goto cleanup; + } + memcpy(data, salt->data, salt->length); + + entry->key_data[i].key_data_type[1] = KRB5_KDB_SALTTYPE_SPECIAL; + krb5_db_free(context, entry->key_data[i].key_data_contents[1]); + entry->key_data[i].key_data_contents[1] = data; + entry->key_data[i].key_data_length[1] = salt->length; + entry->key_data[i].key_data_ver = 2; + krb5_free_data(context, salt); + salt = NULL; + } + +cleanup: + krb5_free_data(context, salt); + return ret; +} + /* change password functions */ krb5_error_code krb5_dbe_cpw(krb5_context kcontext, krb5_keyblock *master_key, diff --git a/src/lib/kdb/libkdb5.exports b/src/lib/kdb/libkdb5.exports index 68ac537..60ab4b2 100644 --- a/src/lib/kdb/libkdb5.exports +++ b/src/lib/kdb/libkdb5.exports @@ -58,6 +58,7 @@ krb5_dbe_lookup_mod_princ_data krb5_dbe_lookup_tl_data krb5_dbe_search_enctype krb5_dbe_set_string +krb5_dbe_specialize_salt krb5_dbe_update_actkvno krb5_dbe_update_last_admin_unlock krb5_dbe_update_last_pwd_change |