K5_GEN_MAKEFILE(plugins/kdb/ldap/ldap_util)
K5_GEN_MAKEFILE(plugins/kdb/ldap/libkdb_ldap)
ldap_plugin_dir=plugins/kdb/ldap
+ LDAP=yes
+else
+ LDAP=no
fi
AC_SUBST(ldap_plugin_dir)
+AC_SUBST(LDAP)
AC_CHECK_HEADERS(Python.h python2.3/Python.h)
BUILDTOP=$(REL)..$(S)..
PROG_LIBPATH=-L$(TOPLIBD)
PROG_RPATH=$(KRB5_LIBDIR)
+LDAP=@LDAP@
RUN_SETUP = @KRB5_RUN_ENV@
t_trval: t_trval.o
$(CC) -o t_trval $(ALL_CFLAGS) t_trval.o
-check:: krb5_decode_test krb5_encode_test
+check:: check-encode check-decode
+
+check-decode: krb5_decode_test
KRB5_CONFIG=$(SRCTOP)/config-files/krb5.conf ; \
export KRB5_CONFIG ;\
$(RUN_SETUP) $(VALGRIND) ./krb5_decode_test
+
+expected_encode.out: reference_encode.out ldap_encode.out
+ if test "$(LDAP)" = yes; then \
+ cat $(srcdir)/reference_encode.out $(srcdir)/ldap_encode.out > expected_encode.out; \
+ else \
+ cat $(srcdir)/reference_encode.out > expected_encode.out; \
+ fi
+
+expected_trval.out: trval_reference.out ldap_trval.out
+ if test "$(LDAP)" = yes; then \
+ cat $(srcdir)/trval_reference.out $(srcdir)/ldap_trval.out > expected_trval.out; \
+ else \
+ cat $(srcdir)/trval_reference.out > expected_trval.out; \
+ fi
+
+check-encode: krb5_encode_test expected_encode.out expected_trval.out
$(RM) test.out
KRB5_CONFIG=$(SRCTOP)/config-files/krb5.conf ; \
export KRB5_CONFIG ;\
$(RUN_SETUP) $(VALGRIND) ./krb5_encode_test > test.out
- cmp test.out $(srcdir)/reference_encode.out
+ cmp test.out expected_encode.out
KRB5_CONFIG=$(SRCTOP)/config-files/krb5.conf ; \
export KRB5_CONFIG ;\
$(RUN_SETUP) $(VALGRIND) ./krb5_encode_test -t > test.out
- cmp test.out $(srcdir)/trval_reference.out
+ cmp test.out expected_trval.out
$(RM) test.out
install::
clean::
- rm -f *~ *.o krb5_encode_test krb5_decode_test test.out trval t_trval
+ rm -f *~ *.o krb5_encode_test krb5_decode_test test.out trval t_trval expected_encode.out expected_trval.out
################ Dependencies ################
com_err(argv[0], retval, "while initializing krb5");
exit(1);
}
+ init_access(argv[0]);
#define setup(type,typestring,constructor) \
type ref, *var; \
retval = constructor(&ref); \
- if (retval) { \
+ if (retval) { \
com_err("krb5_decode_test", retval, "while making sample %s", typestring); \
exit(1); \
}
#define decode_run(typestring,description,encoding,decoder,comparator,cleanup) \
retval = krb5_data_hex_parse(&code,encoding); \
- if (retval) { \
+ if (retval) { \
com_err("krb5_decode_test", retval, "while parsing %s", typestring); \
exit(1); \
} \
retval = decoder(&code,&var); \
- if (retval) { \
+ if (retval) { \
com_err("krb5_decode_test", retval, "while decoding %s", typestring); \
error_count++; \
} \
ktest_empty_sam_response(&ref);
}
+#ifdef ENABLE_LDAP
+ /* ldap sequence_of_keys */
+ {
+ setup(ldap_seqof_key_data,"ldap_seqof_key_data",
+ ktest_make_sample_ldap_seqof_key_data);
+ decode_run("ldap_seqof_key_data","","30 81 87 A0 03 02 01 01 A1 03 02 01 01 A2 03 02 01 2A A3 03 02 01 0E A4 71 30 6F 30 23 A0 10 30 0E A0 03 02 01 00 A1 07 04 05 73 61 6C 74 30 A1 0F 30 0D A0 03 02 01 02 A1 06 04 04 6B 65 79 30 30 23 A0 10 30 0E A0 03 02 01 01 A1 07 04 05 73 61 6C 74 31 A1 0F 30 0D A0 03 02 01 02 A1 06 04 04 6B 65 79 31 30 23 A0 10 30 0E A0 03 02 01 02 A1 07 04 05 73 61 6C 74 32 A1 0F 30 0D A0 03 02 01 02 A1 06 04 04 6B 65 79 32",acc.asn1_ldap_decode_sequence_of_keys,ktest_equal_ldap_sequence_of_keys,ktest_empty_ldap_seqof_key_data);
+ }
+#endif
+
krb5_free_context(test_context);
exit(error_count);
return(error_count);
com_err(argv[0], retval, "while initializing krb5");
exit(1);
}
+ init_access(argv[0]);
#define setup(value,type,typestring,constructor) \
retval = constructor(&(value)); \
encode_krb5_predicted_sam_response);
}
#endif
+#ifdef ENABLE_LDAP
+ {
+ ldap_seqof_key_data skd;
+
+ setup(skd, ldap_seqof_key_data, "ldap_seqof_key_data",
+ ktest_make_sample_ldap_seqof_key_data);
+ encode_run(skd, ldap_seqof_key_data, "ldap_seqof_key_data", "",
+ acc.asn1_ldap_encode_sequence_of_keys);
+ ktest_empty_ldap_seqof_key_data(test_context, &skd);
+ }
+#endif
krb5_free_context(test_context);
exit(error_count);
return(error_count);
}
-
-
return 0;
}
+#ifdef ENABLE_LDAP
+static krb5_error_code ktest_make_sample_key_data(krb5_key_data *p, int i)
+{
+ char buf[10];
+ p->key_data_ver = 2;
+ p->key_data_kvno = 42;
+ sprintf(buf, "key%d", i);
+ p->key_data_type[0] = 2;
+ p->key_data_length[0] = strlen(buf);
+ p->key_data_contents[0] = strdup(buf);
+ sprintf(buf, "salt%d", i);
+ p->key_data_type[1] = i;
+ p->key_data_length[1] = strlen(buf);
+ p->key_data_contents[1] = strdup(buf);
+ if (p->key_data_contents[0] == NULL || p->key_data_contents[1] == NULL)
+ return ENOMEM;
+ return 0;
+}
-
+krb5_error_code ktest_make_sample_ldap_seqof_key_data(p)
+ ldap_seqof_key_data *p;
+{
+ int i;
+ p->mkvno = 14;
+ p->n_key_data = 3;
+ p->key_data = calloc(3,sizeof(krb5_key_data));
+ for (i = 0; i < 3; i++) {
+ krb5_error_code ret;
+ ret = ktest_make_sample_key_data(&p->key_data[i], i);
+ if (ret) return ret;
+ }
+ return 0;
+}
+#endif
/****************************************************************/
ktest_empty_data(&(p->sam_enc_key.ciphertext));
ktest_empty_data(&(p->sam_enc_nonce_or_ts.ciphertext));
}
+
+#ifdef ENABLE_LDAP
+void ktest_empty_ldap_seqof_key_data(ctx, p)
+ krb5_context ctx;
+ ldap_seqof_key_data *p;
+{
+ int i;
+ for (i = 0; i < p->n_key_data; i++) {
+ free(p->key_data[i].key_data_contents[0]);
+ free(p->key_data[i].key_data_contents[1]);
+ }
+}
+#endif
#define __KTEST_H__
#include "k5-int.h"
+#include "kdb.h"
#define SAMPLE_USEC 123456
#define SAMPLE_TIME 771228197 /* Fri Jun 10 6:03:17 GMT 1994 */
(krb5_sam_challenge * p);
krb5_error_code ktest_make_sample_sam_response
(krb5_sam_response * p);
-
+#ifdef ENABLE_LDAP
+krb5_error_code ktest_make_sample_ldap_seqof_key_data(ldap_seqof_key_data * p);
+#endif
/*----------------------------------------------------------------------*/
void ktest_empty_authorization_data
(krb5_sam_challenge * p);
void ktest_empty_sam_response
(krb5_sam_response * p);
+#ifdef ENABLE_LDAP
+void ktest_empty_ldap_seqof_key_data(krb5_context, ldap_seqof_key_data *p);
+#endif
extern krb5_context test_context;
extern char *sample_principal_name;
return p;
}
+#ifdef ENABLE_LDAP
+static int equal_key_data(ref, var)
+ krb5_key_data *ref;
+ krb5_key_data *var;
+{
+ int p=TRUE;
+ if (ref==var) return TRUE;
+ else if (ref == NULL || var == NULL) return FALSE;
+ p=p&&scalar_equal(key_data_ver);
+ p=p&&scalar_equal(key_data_kvno);
+ p=p&&scalar_equal(key_data_type[0]);
+ p=p&&scalar_equal(key_data_type[1]);
+ p=p&&len_equal(key_data_length[0],key_data_contents[0],
+ ktest_equal_array_of_octet);
+ p=p&&len_equal(key_data_length[1],key_data_contents[1],
+ ktest_equal_array_of_octet);
+ return p;
+}
+static int equal_key_data_array(int n, krb5_key_data *ref, krb5_key_data *val)
+{
+ int i, p=TRUE;
+ for (i = 0; i < n; i++) {
+ p=p&&equal_key_data(ref+i, val+i);
+ }
+ return p;
+}
+int ktest_equal_ldap_sequence_of_keys(ref, var)
+ ldap_seqof_key_data *ref;
+ ldap_seqof_key_data *var;
+{
+ int p=TRUE;
+ if (ref==var) return TRUE;
+ else if (ref == NULL || var == NULL) return FALSE;
+ p=p&&scalar_equal(mkvno);
+ p=p&&len_equal(n_key_data,key_data,equal_key_data_array);
+ return p;
+}
+#endif
+
/**** arrays ****************************************************************/
int ktest_equal_array_of_data(length, ref, var)
#define __KTEST_EQUAL_H__
#include "k5-int.h"
+#include "kdb.h"
/* int ktest_equal_structure(krb5_structure *ref, *var) */
/* effects Returns true (non-zero) if ref and var are
(krb5_etype_info_entry * ref,
krb5_etype_info_entry * var);
+int ktest_equal_ldap_sequence_of_keys(ldap_seqof_key_data *ref,
+ ldap_seqof_key_data *var);
#endif
--- /dev/null
+encode_krb5_ldap_seqof_key_data: 30 81 87 A0 03 02 01 01 A1 03 02 01 01 A2 03 02 01 2A A3 03 02 01 0E A4 71 30 6F 30 23 A0 10 30 0E A0 03 02 01 00 A1 07 04 05 73 61 6C 74 30 A1 0F 30 0D A0 03 02 01 02 A1 06 04 04 6B 65 79 30 30 23 A0 10 30 0E A0 03 02 01 01 A1 07 04 05 73 61 6C 74 31 A1 0F 30 0D A0 03 02 01 02 A1 06 04 04 6B 65 79 31 30 23 A0 10 30 0E A0 03 02 01 02 A1 07 04 05 73 61 6C 74 32 A1 0F 30 0D A0 03 02 01 02 A1 06 04 04 6B 65 79 32
--- /dev/null
+encode_krb5_ldap_seqof_key_data:
+
+[Sequence/Sequence Of]
+. [0] [Integer] 1
+. [1] [Integer] 1
+. [2] [Integer] 42
+. [3] [Integer] 14
+. [4] [Sequence/Sequence Of]
+. . [Sequence/Sequence Of]
+. . . [0] [Sequence/Sequence Of]
+. . . . [0] [Integer] 0
+. . . . [1] [Octet String] "salt0"
+. . . [1] [Sequence/Sequence Of]
+. . . . [0] [Integer] 2
+. . . . [1] [Octet String] "key0"
+. . [Sequence/Sequence Of]
+. . . [0] [Sequence/Sequence Of]
+. . . . [0] [Integer] 1
+. . . . [1] [Octet String] "salt1"
+. . . [1] [Sequence/Sequence Of]
+. . . . [0] [Integer] 2
+. . . . [1] [Octet String] "key1"
+. . [Sequence/Sequence Of]
+. . . [0] [Sequence/Sequence Of]
+. . . . [0] [Integer] 2
+. . . . [1] [Octet String] "salt2"
+. . . [1] [Sequence/Sequence Of]
+. . . . [0] [Integer] 2
+. . . . [1] [Octet String] "key2"
+
#include <stdio.h>
#include <ctype.h>
+krb5int_access acc;
+
char hexchar (const unsigned int digit);
asn1_error_code asn1_krb5_data_unparse(code, s)
free(s);
}
#endif
+
+void init_access(const char *progname)
+{
+ krb5_error_code ret;
+ ret = krb5int_accessor(&acc, KRB5INT_ACCESS_VERSION);
+ if (ret) {
+ com_err(progname, ret, "while initializing accessor");
+ exit(1);
+ }
+}
#include "krbasn1.h"
#include "asn1buf.h"
+#include "k5-int.h"
asn1_error_code asn1_krb5_data_unparse
(const krb5_data *code, char **s);
void asn1buf_print
(const asn1buf *buf);
+extern krb5int_access acc;
+extern void init_access(const char *progname);
+
#endif