Change LDAP key-sequence encoder to use a single data structure
authorKen Raeburn <raeburn@mit.edu>
Mon, 6 Oct 2008 20:25:45 +0000 (20:25 +0000)
committerKen Raeburn <raeburn@mit.edu>
Mon, 6 Oct 2008 20:25:45 +0000 (20:25 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20829 dc483132-0cff-0310-8789-dd5450dbe970

src/include/k5-int.h
src/lib/krb5/asn.1/ldap_key_seq.c
src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c

index 111b12159d494b1b99bd9fe6240730a1fa7fd97a..f05adecf39424b5afa1d169db5153202364f56e6 100644 (file)
@@ -1595,17 +1595,21 @@ krb5_error_code decode_krb5_sam_key
        (const krb5_data *, krb5_sam_key **);
 
 struct _krb5_key_data;         /* kdb.h */
+
+struct ldap_seqof_key_data {
+    krb5_int32 mkvno;          /* Master key version number */
+    struct _krb5_key_data *key_data;
+    krb5_int16 n_key_data;
+};
+typedef struct ldap_seqof_key_data ldap_seqof_key_data;
+
 krb5_error_code
-krb5int_ldap_encode_sequence_of_keys (struct _krb5_key_data *key_data,
-                                     krb5_int16 n_key_data,
-                                     krb5_int32 mkvno,
+krb5int_ldap_encode_sequence_of_keys (ldap_seqof_key_data *val,
                                      krb5_data **code);
 
 krb5_error_code
 krb5int_ldap_decode_sequence_of_keys (krb5_data *in,
-                                     struct _krb5_key_data **out,
-                                     krb5_int16 *n_key_data,
-                                     int *mkvno);
+                                     ldap_seqof_key_data **rep);
 
 /*************************************************************************
  * End of prototypes for krb5_decode.c
@@ -1864,16 +1868,12 @@ typedef struct _krb5int_access {
 
     /* Used for KDB LDAP back end.  */
     krb5_error_code
-    (*asn1_ldap_encode_sequence_of_keys) (struct _krb5_key_data *key_data,
-                                         krb5_int16 n_key_data,
-                                         krb5_int32 mkvno,
+    (*asn1_ldap_encode_sequence_of_keys) (ldap_seqof_key_data *val,
                                          krb5_data **code);
 
     krb5_error_code
     (*asn1_ldap_decode_sequence_of_keys) (krb5_data *in,
-                                         struct _krb5_key_data **out,
-                                         krb5_int16 *n_key_data,
-                                         int *mkvno);
+                                         ldap_seqof_key_data **);
 
     /*
      * pkinit asn.1 encode/decode functions
index 7f0355d9fdae42559a0511937c83c517bc2d6fdf..1d48f9b5795001063838f11c3af897bc6c0ba690 100644 (file)
@@ -133,11 +133,11 @@ last:
 /* Major version and minor version are both '1' - first version */
 /* asn1_error_code asn1_encode_sequence_of_keys (krb5_key_data *key_data, */
 krb5_error_code
-asn1_encode_sequence_of_keys (krb5_key_data *key_data,
-                              krb5_int16 n_key_data,
-                              krb5_int32 mkvno, /* Master key version number */
-                              krb5_data **code)
+asn1_encode_sequence_of_keys (ldap_seqof_key_data *val, krb5_data **code)
 {
+    krb5_key_data *key_data = val->key_data;
+    krb5_int16 n_key_data = val->n_key_data;
+    krb5_int32 mkvno = val->mkvno;
     asn1_error_code ret = 0;
     asn1buf *buf = NULL;
     unsigned int length, sum = 0;
@@ -392,10 +392,13 @@ last:
 
 /* asn1_error_code asn1_decode_sequence_of_keys (krb5_data *in, */
 krb5_error_code asn1_decode_sequence_of_keys (krb5_data *in,
-                                              krb5_key_data **out,
-                                              krb5_int16 *n_key_data,
-                                              int *mkvno)
+                                              ldap_seqof_key_data **rep)
 {
+    ldap_seqof_key_data *repval;
+    krb5_key_data **out;
+    krb5_int16 *n_key_data;
+    int *mkvno;
+
     asn1_error_code ret;
     asn1buf buf, subbuf;
     int seqindef;
@@ -404,6 +407,12 @@ krb5_error_code asn1_decode_sequence_of_keys (krb5_data *in,
     int kvno, maj, min;
     long lval;
 
+    repval = calloc(1,sizeof(ldap_seqof_key_data));
+    *rep = repval;
+    out = &repval->key_data;
+    n_key_data = &repval->n_key_data;
+    mkvno = &repval->mkvno;
+
     *n_key_data = 0;
     *out = NULL;
 
index 6e7ba33f14109ab8b3c6c8501c71bfae6fe18b9e..12f0dd360c2db974a0ec512d983a7ce555d628d2 100644 (file)
@@ -325,6 +325,7 @@ asn1_encode_sequence_of_keys (krb5_key_data *key_data, krb5_int16 n_key_data,
                              krb5_int32 mkvno, krb5_data **code)
 {
     krb5_error_code err;
+    ldap_seqof_key_data val;
 
     /*
      * This should be pushed back into other library initialization
@@ -334,8 +335,11 @@ asn1_encode_sequence_of_keys (krb5_key_data *key_data, krb5_int16 n_key_data,
     if (err)
        return err;
 
-    return accessor.asn1_ldap_encode_sequence_of_keys(key_data, n_key_data,
-                                                     mkvno, code);
+    val.key_data = key_data;
+    val.n_key_data = n_key_data;
+    val.mkvno = mkvno;
+
+    return accessor.asn1_ldap_encode_sequence_of_keys(&val, code);
 }
 
 static krb5_error_code
@@ -343,6 +347,7 @@ asn1_decode_sequence_of_keys (krb5_data *in, krb5_key_data **out,
                              krb5_int16 *n_key_data, int *mkvno)
 {
     krb5_error_code err;
+    ldap_seqof_key_data *p;
 
     /*
      * This should be pushed back into other library initialization
@@ -352,8 +357,14 @@ asn1_decode_sequence_of_keys (krb5_data *in, krb5_key_data **out,
     if (err)
        return err;
 
-    return accessor.asn1_ldap_decode_sequence_of_keys(in, out, n_key_data,
-                                                     mkvno);
+    err = accessor.asn1_ldap_decode_sequence_of_keys(in, &p);
+    if (err)
+       return err;
+    *out = p->key_data;
+    *n_key_data = p->n_key_data;
+    *mkvno = p->mkvno;
+    free(p);
+    return 0;
 }