From: Theodore Tso Date: Thu, 24 Mar 1994 05:29:00 +0000 (+0000) Subject: Add krb5_principal_to_salt_norealm() X-Git-Tag: krb5-1.0-beta4~224 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=94712063545ac7c4bcbcc2422375a80385e5584b;p=krb5.git Add krb5_principal_to_salt_norealm() git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@3472 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/krb/pr_to_salt.c b/src/lib/krb5/krb/pr_to_salt.c index 85caa8bc3..e71fda3af 100644 --- a/src/lib/krb5/krb/pr_to_salt.c +++ b/src/lib/krb5/krb/pr_to_salt.c @@ -37,13 +37,13 @@ static char rcsid_pr_to_salt_c[] = /* * Convert a krb5_principal into the default salt for that principal. */ - krb5_error_code -krb5_principal2salt(pr, ret) +krb5_principal2salt_internal(pr, ret, use_realm) register krb5_const_principal pr; krb5_data *ret; +int use_realm; { - int size, offset; + int size = 0, offset = 0; int nelem; register int i; @@ -55,7 +55,8 @@ krb5_data *ret; nelem = krb5_princ_size(pr); - size = krb5_princ_realm(pr)->length; + if (use_realm) + size += krb5_princ_realm(pr)->length; for (i = 0; i < nelem; i++) size += krb5_princ_component(pr, i)->length; @@ -64,8 +65,10 @@ krb5_data *ret; if (!(ret->data = malloc (size))) return ENOMEM; - offset = krb5_princ_realm(pr)->length; - memcpy(ret->data, krb5_princ_realm(pr)->data, offset); + if (use_realm) { + offset = krb5_princ_realm(pr)->length; + memcpy(ret->data, krb5_princ_realm(pr)->data, offset); + } for (i = 0; i < nelem; i++) { memcpy(&ret->data[offset], krb5_princ_component(pr, i)->data, @@ -74,3 +77,21 @@ krb5_data *ret; } return 0; } + +krb5_error_code +krb5_principal2salt(pr, ret) +register krb5_const_principal pr; +krb5_data *ret; +int use_realm; +{ + return krb5_principal2salt_internal(pr, ret, 1); +} + +krb5_error_code +krb5_principal2salt_norealm(pr, ret) +register krb5_const_principal pr; +krb5_data *ret; +int use_realm; +{ + return krb5_principal2salt_internal(pr, ret, 0); +}