summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2012-02-12 05:25:22 +0000
committerGreg Hudson <ghudson@mit.edu>2012-02-12 05:25:22 +0000
commit0d975e2701abe3fbcd1bec213fdadc4e09b2b636 (patch)
tree5aae7453648c6c15dd49284c92d8ce7731541483 /src/lib
parent9f23e1a8133c11bff4ef5f41cb44d28041320a76 (diff)
downloadkrb5-0d975e2701abe3fbcd1bec213fdadc4e09b2b636.tar.gz
krb5-0d975e2701abe3fbcd1bec213fdadc4e09b2b636.tar.xz
krb5-0d975e2701abe3fbcd1bec213fdadc4e09b2b636.zip
Convert utility functions to new decoder
Create a special type to plug authdata types from authdata and make krb5int_get_authdata_containee_types use it. Add a test case for it as well. Move krb5_decode_ticket (a trivial wrapper) into asn1_k_encode.c so that krb5_decode.c is empty. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25694 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/krb5/asn.1/asn1_k_encode.c43
-rw-r--r--src/lib/krb5/asn.1/krb5_decode.c6
2 files changed, 44 insertions, 5 deletions
diff --git a/src/lib/krb5/asn.1/asn1_k_encode.c b/src/lib/krb5/asn.1/asn1_k_encode.c
index 6be95f5805..a48db98d02 100644
--- a/src/lib/krb5/asn.1/asn1_k_encode.c
+++ b/src/lib/krb5/asn.1/asn1_k_encode.c
@@ -238,6 +238,22 @@ DEFNONEMPTYNULLTERMSEQOFTYPE(auth_data, authdata_elt_ptr);
DEFPTRTYPE(auth_data_ptr, auth_data);
DEFOPTIONALEMPTYTYPE(opt_auth_data_ptr, auth_data_ptr);
+/* authdata_types retrieves just the types of authdata elements in an array. */
+DEFCTAGGEDTYPE(authdata_elt_type_0, 0, int32);
+static const struct atype_info *authdata_elt_type_fields[] = {
+ &k5_atype_authdata_elt_type_0
+};
+DEFSEQTYPE(authdata_elt_type, krb5_authdatatype, authdata_elt_type_fields);
+DEFPTRTYPE(ptr_authdata_elt_type, authdata_elt_type);
+DEFCOUNTEDSEQOFTYPE(cseqof_authdata_elt_type, unsigned int,
+ ptr_authdata_elt_type);
+struct authdata_types {
+ krb5_authdatatype *types;
+ unsigned int ntypes;
+};
+DEFCOUNTEDTYPE(authdata_types, struct authdata_types, types, ntypes,
+ cseqof_authdata_elt_type);
+
DEFFIELD(keyblock_0, krb5_keyblock, enctype, 0, int32);
DEFCNFIELD(keyblock_1, krb5_keyblock, contents, length, 1, octetstring);
static const struct atype_info *encryption_key_fields[] = {
@@ -1106,6 +1122,12 @@ MAKE_CODEC(krb5_ticket, ticket);
MAKE_CODEC(krb5_encryption_key, encryption_key);
MAKE_CODEC(krb5_enc_tkt_part, enc_tkt_part);
+krb5_error_code KRB5_CALLCONV
+krb5_decode_ticket(const krb5_data *code, krb5_ticket **repptr)
+{
+ return decode_krb5_ticket(code, repptr);
+}
+
/*
* For backwards compatibility, we encode both EncASRepPart and EncTGSRepPart
* with application tag 26. On decode, we accept either app tag and set the
@@ -1251,6 +1273,27 @@ MAKE_CODEC(krb5_ad_signedpath, ad_signedpath);
MAKE_CODEC(krb5_iakerb_header, iakerb_header);
MAKE_CODEC(krb5_iakerb_finished, iakerb_finished);
+krb5_error_code KRB5_CALLCONV
+krb5int_get_authdata_containee_types(krb5_context context,
+ const krb5_authdata *authdata,
+ unsigned int *num_out,
+ krb5_authdatatype **types_out)
+{
+ asn1_error_code ret;
+ struct authdata_types *atypes;
+ void *atypes_ptr;
+ krb5_data d = make_data(authdata->contents, authdata->length);
+
+ ret = k5_asn1_full_decode(&d, &k5_atype_authdata_types, &atypes_ptr);
+ if (ret)
+ return ret;
+ atypes = atypes_ptr;
+ *num_out = atypes->ntypes;
+ *types_out = atypes->types;
+ free(atypes);
+ return 0;
+}
+
/*
* PKINIT
*/
diff --git a/src/lib/krb5/asn.1/krb5_decode.c b/src/lib/krb5/asn.1/krb5_decode.c
index 69d77c1650..2a665f2152 100644
--- a/src/lib/krb5/asn.1/krb5_decode.c
+++ b/src/lib/krb5/asn.1/krb5_decode.c
@@ -31,8 +31,8 @@
#include "asn1_get.h"
#include "krb5_decode_macros.h"
-#ifndef LEAN_CLIENT
#if 0
+#ifndef LEAN_CLIENT
krb5_error_code
decode_krb5_authenticator(const krb5_data *code, krb5_authenticator **repptr)
{
@@ -66,7 +66,6 @@ error_out:
return retval;
}
#endif
-#endif
krb5_error_code KRB5_CALLCONV
krb5_decode_ticket(const krb5_data *code, krb5_ticket **repptr)
@@ -74,7 +73,6 @@ krb5_decode_ticket(const krb5_data *code, krb5_ticket **repptr)
return decode_krb5_ticket(code, repptr);
}
-#if 0
krb5_error_code
decode_krb5_ticket(const krb5_data *code, krb5_ticket **repptr)
{
@@ -815,7 +813,6 @@ decode_krb5_iakerb_finished(const krb5_data *code, krb5_iakerb_finished **repptr
cleanup(free);
}
-#endif
krb5_error_code KRB5_CALLCONV
krb5int_get_authdata_containee_types(krb5_context context,
@@ -841,7 +838,6 @@ krb5int_get_authdata_containee_types(krb5_context context,
assert(0); /* NOTREACHED */
}
-#if 0
#ifndef DISABLE_PKINIT
krb5_error_code