+Mon Aug 28 16:35:22 1995 <tytso@rsts-11.mit.edu>
+
+ * krb5_decode_test.c (main): Add tests for
+ decode_krb5_{etype_info,alt_method}.
+
+ * krb5_encode_test.c (main): Add tests for
+ encode_krb5_{etype_info,alt_method}.
+
+ * ktest_equal.c (ktest_equal_krb5_alt_method,
+ ktest_equal_krb5_etype_info_entry,
+ ktest_equal_krb5_etype_info) New functions to test
+ {encode,decode}_krb5_{etype_info,alt_method}.
+
+ * ktest.c (ktest_make_sample_etype_info_entry,
+ ktest_make_sample_etype_info,
+ ktest_make_sample_alt_method,
+ ktest_destroy_etype_info_entry, ktest_destroy_etype_info):
+ New functions to test
+ {encode,decode}_krb5_{etype_info,alt_method}.
+
Sat Aug 26 12:40:57 1995 Ezra Peisach <epeisach@kangaroo.mit.edu>
* krb5_encode_test.c (encoder_print_results): If trval2 returns
non zero, indicate with error before exiting.
- * trval.c (do_cons): Initialize return value to zero in case of
- zero length data. (instead of random stack value).
-
-
Fri Aug 25 21:50:37 1995 Theodore Y. Ts'o <tytso@dcl>
* krb5_encode_test.c (main): Add tests for
assert(ktest_equal_sequence_of_pa_data(ref,var),"pa_data (empty)\n")
}
+ /****************************************************************/
+ /* decode_pwd_sequence */
+ {
+ setup(krb5_alt_method,"krb5_alt_method",ktest_make_sample_alt_method);
+ decode_run("alt_method","","30 0F A0 03 02 01 2A A1 08 04 06 73 65
+63 72 65 74",decode_krb5_alt_method,ktest_equal_krb5_alt_method);
+ ref.length = 0;
+ decode_run("alt_method (no data)","","30 05 A0 03 02 01 2A",decode_krb5_alt_method,ktest_equal_krb5_alt_method);
+
+ }
+
+ /****************************************************************/
+ /* decode_etype_info */
+ {
+ krb5_etype_info ref, var;
+
+ retval = ktest_make_sample_etype_info(&ref);
+ if (retval) {
+ com_err("krb5_decode_test", retval,
+ "while making sample etype info");
+ exit(1);
+ }
+ retval = krb5_data_hex_parse(&code,"30 33 30 14 A0 03 02 01 00 A1 0D 04 0B 4D 6F 72 74 6F 6E 27 73 20 23 30 30 05 A0 03 02 01 01 30 14 A0 03 02 01 02 A1 0D 04 0B 4D 6F 72 74 6F 6E 27 73 20 23 32");
+ if(retval){
+ com_err("krb5_decode_test", retval, "while parsing etype_info");
+ exit(1);
+ }
+ retval = decode_krb5_etype_info(&code,&var);
+ if(retval){
+ com_err("krb5_decode_test", retval, "while decoding etype_info");
+ }
+ assert(ktest_equal_etype_info(ref,var),"etype_info\n");
+
+ ktest_destroy_etype_info(var);
+ ktest_destroy_etype_info_entry(ref[2]); ref[2] = 0;
+ ktest_destroy_etype_info_entry(ref[1]); ref[1] = 0;
+
+ retval = krb5_data_hex_parse(&code,"30 16 30 14 A0 03 02 01 00 A1 0D 04 0B 4D 6F 72 74 6F 6E 27 73 20 23 30");
+ if(retval){
+ com_err("krb5_decode_test", retval,
+ "while parsing etype_info (only one)");
+ exit(1);
+ }
+ retval = decode_krb5_etype_info(&code,&var);
+ if(retval){
+ com_err("krb5_decode_test", retval,
+ "while decoding etype_info (only one)");
+ }
+ assert(ktest_equal_etype_info(ref,var),"etype_info (only one)\n");
+
+ ktest_destroy_etype_info(var);
+ ktest_destroy_etype_info_entry(ref[0]); ref[0] = 0;
+
+ retval = krb5_data_hex_parse(&code,"30 00");
+ if(retval){
+ com_err("krb5_decode_test", retval,
+ "while parsing etype_info (no info)");
+ exit(1);
+ }
+ retval = decode_krb5_etype_info(&code,&var);
+ if(retval){
+ com_err("krb5_decode_test", retval,
+ "while decoding etype_info (no info)");
+ }
+ assert(ktest_equal_etype_info(ref,var),"etype_info (no info)\n");
+
+ ktest_destroy_etype_info(var);
+ ktest_destroy_etype_info(ref);
+ }
+
+
exit(error_count);
}
+
+
encoder_print_results(code, "padata_sequence(empty)", "");
}
+ /****************************************************************/
+ /* encode_alt_method */
+ {
+ krb5_alt_method am;
+ setup(am,krb5_alt_method,"AltMethod",ktest_make_sample_alt_method);
+ encode_run(am,krb5_alt_method,"alt_method","",encode_krb5_alt_method);
+ am.length = 0;
+ am.data = 0;
+ encode_run(am,krb5_alt_method,"alt_method (no data)","",
+ encode_krb5_alt_method);
+ }
+
+ /****************************************************************/
+ /* encode_etype_info */
+ {
+ krb5_etype_info_entry **info;
+
+ setup(info,krb5_etype_info_entry **,"etype_info",
+ ktest_make_sample_etype_info);
+ retval = encode_krb5_etype_info((const krb5_etype_info_entry **)info,&(code));
+ if(retval) com_err("encoding etype_info",retval,"");
+ encoder_print_results(code, "etype_info", "");
+ ktest_destroy_etype_info_entry(info[2]); info[2] = 0;
+ ktest_destroy_etype_info_entry(info[1]); info[1] = 0;
+
+ retval = encode_krb5_etype_info((const krb5_etype_info_entry **)info,&(code));
+ if(retval) com_err("encoding etype_info (only 1)",retval,"");
+ encoder_print_results(code, "etype_info (only 1)", "");
+
+ ktest_destroy_etype_info_entry(info[0]); info[0] = 0;
+
+ retval = encode_krb5_etype_info((const krb5_etype_info_entry **)info,&(code));
+ if(retval) com_err("encoding etype_info (no info)",retval,"");
+ encoder_print_results(code, "etype_info (no info)", "");
+
+ free(info);
+ }
exit(error_count);
}
+
+
return 0;
}
+krb5_error_code ktest_make_sample_alt_method(p)
+ krb5_alt_method * p;
+{
+ p->method = 42;
+ p->data = "secret";
+ p->length = strlen(p->data);
+ return 0;
+}
+
+krb5_error_code ktest_make_sample_etype_info_entry(p)
+ krb5_etype_info_entry * p;
+{
+ p->etype = 1;
+ p->salt = "Morton";
+ p->length = strlen(p->salt);
+ return 0;
+}
+
+krb5_error_code ktest_make_sample_etype_info(p)
+ krb5_etype_info_entry *** p;
+{
+ krb5_etype_info_entry **info;
+ int i;
+ char buf[80];
+
+ info = malloc(sizeof(krb5_etype_info_entry *) * 4);
+ if (!info)
+ return ENOMEM;
+ memset(info, 0, sizeof(krb5_etype_info_entry *) * 4);
+
+ for (i=0; i < 3; i++) {
+ info[i] = malloc(sizeof(krb5_etype_info_entry));
+ if (info[i] == 0)
+ goto memfail;
+ info[i]->etype = i;
+ sprintf(buf, "Morton's #%d", i);
+ info[i]->length = strlen(buf);
+ info[i]->salt = malloc(info[i]->length+1);
+ if (info[i]->salt == 0)
+ goto memfail;
+ strcpy(info[i]->salt, buf);
+ info[i]->magic = KV5M_ETYPE_INFO_ENTRY;
+ }
+ free(info[1]->salt);
+ info[1]->length = 0;
+ info[1]->salt = 0;
+ *p = info;
+ return 0;
+memfail:
+ ktest_destroy_etype_info(info);
+ return ENOMEM;
+}
/****************************************************************/
/* destructors */
ktest_empty_data(&(ed->ciphertext));
ed->kvno = 0;
}
+
+void ktest_destroy_etype_info_entry(i)
+ krb5_etype_info_entry *i;
+{
+ if (i->salt)
+ free(i->salt);
+ free(i);
+}
+
+void ktest_destroy_etype_info(info)
+ krb5_etype_info_entry **info;
+{
+ int i;
+
+ for(i=0; info[i] != NULL; i++)
+ ktest_destroy_etype_info_entry(info[i]);
+ free(info);
+}
+
+
#ifndef __KTEST_H__
#define __KTEST_H__
-#include "krb5.h"
+#include "k5-int.h"
#define SAMPLE_USEC 123456
#define SAMPLE_TIME 771228197 /* Fri Jun 10 6:03:17 GMT 1994 */
KRB5_PROTOTYPE((passwd_phrase_element *ppe));
krb5_error_code ktest_make_sample_krb5_pwd_data
KRB5_PROTOTYPE((krb5_pwd_data *pd));
+krb5_error_code ktest_make_sample_alt_method
+ KRB5_PROTOTYPE((krb5_alt_method *am));
+
+krb5_error_code ktest_make_sample_etype_info
+ KRB5_PROTOTYPE((krb5_etype_info_entry *** p));
/*----------------------------------------------------------------------*/
void ktest_destroy_enc_data
KRB5_PROTOTYPE((krb5_enc_data *ed));
+void ktest_destroy_etype_info_entry
+ KRB5_PROTOTYPE((krb5_etype_info_entry *i));
+void ktest_destroy_etype_info
+ KRB5_PROTOTYPE((krb5_etype_info_entry **info));
+
#endif
return p;
}
+int ktest_equal_krb5_alt_method(ref, var)
+ krb5_alt_method *ref;
+ krb5_alt_method *var;
+{
+ if (ref->method != var->method)
+ return FALSE;
+ if (ref->length != var->length)
+ return FALSE;
+ if (memcmp(ref->data, var->data, ref->length) != 0)
+ return FALSE;
+ return TRUE;
+}
+
+int ktest_equal_krb5_etype_info_entry(ref, var)
+ krb5_etype_info_entry *ref;
+ krb5_etype_info_entry *var;
+{
+ if (ref->etype != var->etype)
+ return FALSE;
+ if (ref->length != var->length)
+ return FALSE;
+ if (memcmp(ref->salt, var->salt, ref->length) != 0)
+ return FALSE;
+ return TRUE;
+}
+
/**** arrays ****************************************************************/
int ktest_equal_array_of_data(length, ref, var)
{
array_compare(ktest_equal_passwd_phrase_element);
}
+
+int ktest_equal_etype_info(ref, var)
+ krb5_etype_info_entry ** ref;
+ krb5_etype_info_entry ** var;
+{
+ array_compare(ktest_equal_krb5_etype_info_entry);
+}
#ifndef __KTEST_EQUAL_H__
#define __KTEST_EQUAL_H__
-#include "krb5.h"
+#include "k5-int.h"
/* int ktest_equal_structure(krb5_structure *ref, *var) */
/* effects Returns true (non-zero) if ref and var are
generic(ktest_equal_passwd_phrase_element,passwd_phrase_element);
generic(ktest_equal_krb5_pwd_data,krb5_pwd_data);
+generic(ktest_equal_krb5_alt_method,krb5_alt_method);
int ktest_equal_last_req
KRB5_PROTOTYPE((krb5_last_req_entry **ref, krb5_last_req_entry **var));
int ktest_equal_array_of_char
KRB5_PROTOTYPE((const int length, char *ref, char *var));
+int ktest_equal_etype_info
+ KRB5_PROTOTYPE((krb5_etype_info_entry ** ref,
+ krb5_etype_info_entry ** var));
+
+int ktest_equal_etype_info_entry
+ KRB5_PROTOTYPE((krb5_etype_info_entry * ref,
+ krb5_etype_info_entry * var));
+
#endif
encode_krb5_pwd_data: 30 3D A0 03 02 01 02 A1 36 30 34 30 18 A0 0A 04 08 6B 72 62 35 64 61 74 61 A1 0A 04 08 6B 72 62 35 64 61 74 61 30 18 A0 0A 04 08 6B 72 62 35 64 61 74 61 A1 0A 04 08 6B 72 62 35 64 61 74 61
encode_krb5_padata_sequence: 30 24 30 10 A1 03 02 01 0D A2 09 04 07 70 61 2D 64 61 74 61 30 10 A1 03 02 01 0D A2 09 04 07 70 61 2D 64 61 74 61
encode_krb5_padata_sequence(empty): 30 00
+encode_krb5_alt_method: 30 0F A0 03 02 01 2A A1 08 04 06 73 65 63 72 65 74
+encode_krb5_alt_method (no data): 30 05 A0 03 02 01 2A
+encode_krb5_etype_info: 30 33 30 14 A0 03 02 01 00 A1 0D 04 0B 4D 6F 72 74 6F 6E 27 73 20 23 30 30 05 A0 03 02 01 01 30 14 A0 03 02 01 02 A1 0D 04 0B 4D 6F 72 74 6F 6E 27 73 20 23 32
+encode_krb5_etype_info (only 1): 30 16 30 14 A0 03 02 01 00 A1 0D 04 0B 4D 6F 72 74 6F 6E 27 73 20 23 30
+encode_krb5_etype_info (no info): 30 00
[Sequence/Sequence Of]
+encode_krb5_alt_method:
+
+[Sequence/Sequence Of]
+. [0] [Integer] <1>
+ 2a *
+. [1] [Octet String] <6>
+ 73 65 63 72 65 74 secret
+
+encode_krb5_alt_method (no data):
+
+[Sequence/Sequence Of]
+. [0] [Integer] <1>
+ 2a *
+
+encode_krb5_etype_info:
+
+[Sequence/Sequence Of]
+. [Sequence/Sequence Of]
+. . [0] [Integer] <1>
+ 00 .
+. . [1] [Octet String] <11>
+ 4d 6f 72 74 6f 6e 27 73 Morton's
+ 20 23 30 #0
+. [Sequence/Sequence Of]
+. . [0] [Integer] <1>
+ 01 .
+. [Sequence/Sequence Of]
+. . [0] [Integer] <1>
+ 02 .
+. . [1] [Octet String] <11>
+ 4d 6f 72 74 6f 6e 27 73 Morton's
+ 20 23 32 #2
+
+encode_krb5_etype_info (only 1):
+
+[Sequence/Sequence Of]
+. [Sequence/Sequence Of]
+. . [0] [Integer] <1>
+ 00 .
+. . [1] [Octet String] <11>
+ 4d 6f 72 74 6f 6e 27 73 Morton's
+ 20 23 30 #0
+
+encode_krb5_etype_info (no info):
+
+[Sequence/Sequence Of]
+