From 9f23e1a8133c11bff4ef5f41cb44d28041320a76 Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Sat, 11 Feb 2012 23:25:25 +0000 Subject: Data-driven ASN.1 decoder Add a general ASN.1 decoder implementation in asn1_encode.c using the same data structures as the encoder (augmented where necessary), and use it to define decoder functions in asn1_k_encode.c. Add a boolean type to atype_info, as it is needed for the pa_pac_req decoder. For the moment, just #if out the old decoder functions; they and their support code can be cleaned up later after a a few remaining utility functions are addressed. Changes to encoder and decoder interfaces are minimized, but there are two small ones. ldap_seqof_key_data has a kvno field added, and some of the decoder logic is pushed up into the caller. The safe_with_body decoder now outputs an allocated krb5_data * instead of a krb5_data with aliases into the input buffer. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25693 dc483132-0cff-0310-8789-dd5450dbe970 --- src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c index 5546ba020..a7101a738 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c +++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c @@ -365,6 +365,7 @@ asn1_encode_sequence_of_keys(krb5_key_data *key_data, krb5_int16 n_key_data, val.key_data = key_data; val.n_key_data = n_key_data; val.mkvno = mkvno; + val.kvno = key_data[0].key_data_kvno; return accessor.asn1_ldap_encode_sequence_of_keys(&val, code); } @@ -375,6 +376,7 @@ asn1_decode_sequence_of_keys(krb5_data *in, krb5_key_data **out, { krb5_error_code err; ldap_seqof_key_data *p; + int i; /* * This should be pushed back into other library initialization @@ -387,6 +389,14 @@ asn1_decode_sequence_of_keys(krb5_data *in, krb5_key_data **out, err = accessor.asn1_ldap_decode_sequence_of_keys(in, &p); if (err) return err; + + /* Set kvno and key_data_ver in each key_data element. */ + for (i = 0; i < p->n_key_data; i++) { + p->key_data[i].key_data_kvno = p->kvno; + p->key_data[i].key_data_ver = + (p->key_data[i].key_data_length[1] == 0) ? 1 : 2; + } + *out = p->key_data; *n_key_data = p->n_key_data; *mkvno = p->mkvno; -- cgit