plugins \
prototype \
slave \
+ tests \
util/support
BSDFILES = \
plugins/preauth/pkinit/pkinit_accessor.h \
plugins/preauth/pkinit/pkinit_crypto.h \
plugins/preauth/pkinit/pkinit.h \
- plugins/preauth/pkinit/pkinit_crypto_openssl.h
+ plugins/preauth/pkinit/pkinit_crypto_openssl.h \
+ tests/asn.1/ktest.h \
+ tests/asn.1/ktest_equal.h \
+ tests/asn.1/utility.h \
+ tests/gss-threads/gss-misc.c \
+ tests/gss-threads/gss-misc.h \
+ tests/hammer/kdc5_hammer.c
EXCLUDES = `for i in $(BSDFILES) $(OTHEREXCLUDES); do echo $$i; done | $(AWK) '{ print "-path", $$1, "-o" }'` -path /dev/null
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#ifndef __DEBUG_H__
#define __DEBUG_H__
/*
- assert utility macro for test programs:
- If the predicate (pred) is true, then
- OK: <message> is printed. Otherwise,
- ERROR: <message> is printed.
+ assert utility macro for test programs:
+ If the predicate (pred) is true, then
+ OK: <message> is printed. Otherwise,
+ ERROR: <message> is printed.
- message should be a printf format string.
+ message should be a printf format string.
*/
#include <stdio.h>
-#define test(pred,message)\
- if(pred) printf("OK: ");\
- else { printf("ERROR: "); error_count++; }\
- printf(message);
+#define test(pred,message) \
+ if(pred) printf("OK: "); \
+ else { printf("ERROR: "); error_count++; } \
+ printf(message);
#endif
-/* -*- mode: c; indent-tabs-mode: nil -*- */
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* This program is intended to help detect memory leaks in the ASN.1
* decoder functions by exercising their failure paths. The setup
}
init_access(argv[0]);
-#define setup(value, typestring, constructor) \
- retval = constructor(&(value)); \
- if (retval) { \
- com_err("krb5_decode_leak", retval, "while making sample %s", \
- typestring); \
- exit(1); \
+#define setup(value, typestring, constructor) \
+ retval = constructor(&(value)); \
+ if (retval) { \
+ com_err("krb5_decode_leak", retval, "while making sample %s", \
+ typestring); \
+ exit(1); \
}
#define encode_run(value,type,typestring,description,encoder)
* sure to define a pointer named "tmp" of the correct type in the
* enclosing block.
*/
-#define leak_test(value, encoder, decoder, freefn) \
- retval = encoder(&(value),&(code)); \
- if (retval) { \
- com_err("krb5_decode_leak", retval, "while encoding"); \
- exit(1); \
- } \
- for (i = 0; i < code->length; i++) { \
- code->data[i] = (char)~((unsigned char)code->data[i]); \
- retval = decoder(code, &tmp); \
- code->data[i] = (char)~((unsigned char)code->data[i]); \
- if (retval == 0) \
- freefn(test_context, tmp); \
- } \
+#define leak_test(value, encoder, decoder, freefn) \
+ retval = encoder(&(value),&(code)); \
+ if (retval) { \
+ com_err("krb5_decode_leak", retval, "while encoding"); \
+ exit(1); \
+ } \
+ for (i = 0; i < code->length; i++) { \
+ code->data[i] = (char)~((unsigned char)code->data[i]); \
+ retval = decoder(code, &tmp); \
+ code->data[i] = (char)~((unsigned char)code->data[i]); \
+ if (retval == 0) \
+ freefn(test_context, tmp); \
+ } \
krb5_free_data(test_context, code);
/****************************************************************/
krb5_free_predicted_sam_response);
ktest_empty_predicted_sam_response(&sam_ch);
}
- /****************************************************************/
- /* encode_krb5_sam_response_2 */
+ /****************************************************************/
+ /* encode_krb5_sam_response_2 */
{
krb5_sam_response_2 sam_ch2, *tmp;
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#include "k5-int.h"
#include "ktest.h"
#include "com_err.h"
void krb5_ktest_free_alt_method(krb5_context context, krb5_alt_method *val);
void krb5_ktest_free_pwd_sequence(krb5_context context,
- passwd_phrase_element *val);
+ passwd_phrase_element *val);
void krb5_ktest_free_enc_data(krb5_context context, krb5_enc_data *val);
int main(argc, argv)
retval = krb5_init_context(&test_context);
if (retval) {
- com_err(argv[0], retval, "while initializing krb5");
- exit(1);
+ 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) { \
- com_err("krb5_decode_test", retval, "while making sample %s", typestring); \
- exit(1); \
+#define setup(type,typestring,constructor) \
+ type ref, *var; \
+ retval = constructor(&ref); \
+ 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) { \
- com_err("krb5_decode_test", retval, "while parsing %s", typestring); \
- exit(1); \
- } \
- retval = decoder(&code,&var); \
- if (retval) { \
- com_err("krb5_decode_test", retval, "while decoding %s", typestring); \
- error_count++; \
- } \
- test(comparator(&ref,var),typestring); \
- printf("%s\n",description); \
- krb5_free_data_contents(test_context, &code); \
+ retval = krb5_data_hex_parse(&code,encoding); \
+ if (retval) { \
+ com_err("krb5_decode_test", retval, "while parsing %s", typestring); \
+ exit(1); \
+ } \
+ retval = decoder(&code,&var); \
+ if (retval) { \
+ com_err("krb5_decode_test", retval, "while decoding %s", typestring); \
+ error_count++; \
+ } \
+ test(comparator(&ref,var),typestring); \
+ printf("%s\n",description); \
+ krb5_free_data_contents(test_context, &code); \
cleanup(test_context, var);
/****************************************************************/
/* decode_krb5_authenticator */
{
- setup(krb5_authenticator,"krb5_authenticator",ktest_make_sample_authenticator);
-
- decode_run("authenticator","","62 81 A1 30 81 9E A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34 A4 05 02 03 01 E2 40 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A7 03 02 01 11 A8 24 30 22 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72",decode_krb5_authenticator,ktest_equal_authenticator,krb5_free_authenticator);
-
- ref.seq_number = 0xffffff80;
- decode_run("authenticator","(80 -> seq-number 0xffffff80)",
- "62 81 A1 30 81 9E"
- " A0 03 02 01 05"
- " A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55"
- " A2 1A 30 18"
- " A0 03 02 01 01"
- " A1 11 30 0F"
- " 1B 06 68 66 74 73 61 69"
- " 1B 05 65 78 74 72 61"
- " A3 0F 30 0D"
- " A0 03 02 01 01"
- " A1 06 04 04 31 32 33 34"
- " A4 05 02 03 01 E2 40"
- " A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A"
- " A6 13 30 11"
- " A0 03 02 01 01"
- " A1 0A 04 08 31 32 33 34 35 36 37 38"
- " A7 03 02 01 80"
- " A8 24 30 22"
- " 30 0F"
- " A0 03 02 01 01"
- " A1 08 04 06 66 6F 6F 62 61 72"
- " 30 0F"
- " A0 03 02 01 01"
- " A1 08 04 06 66 6F 6F 62 61 72"
- ,decode_krb5_authenticator,ktest_equal_authenticator,krb5_free_authenticator);
-
- ref.seq_number = 0xffffffff;
- decode_run("authenticator","(FF -> seq-number 0xffffffff)",
- "62 81 A1 30 81 9E"
- " A0 03 02 01 05"
- " A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55"
- " A2 1A 30 18"
- " A0 03 02 01 01"
- " A1 11 30 0F"
- " 1B 06 68 66 74 73 61 69"
- " 1B 05 65 78 74 72 61"
- " A3 0F 30 0D"
- " A0 03 02 01 01"
- " A1 06 04 04 31 32 33 34"
- " A4 05 02 03 01 E2 40"
- " A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A"
- " A6 13 30 11"
- " A0 03 02 01 01"
- " A1 0A 04 08 31 32 33 34 35 36 37 38"
- " A7 03 02 01 FF"
- " A8 24 30 22"
- " 30 0F"
- " A0 03 02 01 01"
- " A1 08 04 06 66 6F 6F 62 61 72"
- " 30 0F"
- " A0 03 02 01 01"
- " A1 08 04 06 66 6F 6F 62 61 72"
- ,decode_krb5_authenticator,ktest_equal_authenticator,krb5_free_authenticator);
-
- ref.seq_number = 0xff;
- decode_run("authenticator","(00FF -> seq-number 0xff)",
- "62 81 A2 30 81 9F"
- " A0 03 02 01 05"
- " A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55"
- " A2 1A 30 18"
- " A0 03 02 01 01"
- " A1 11 30 0F"
- " 1B 06 68 66 74 73 61 69"
- " 1B 05 65 78 74 72 61"
- " A3 0F 30 0D"
- " A0 03 02 01 01"
- " A1 06 04 04 31 32 33 34"
- " A4 05 02 03 01 E2 40"
- " A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A"
- " A6 13 30 11"
- " A0 03 02 01 01"
- " A1 0A 04 08 31 32 33 34 35 36 37 38"
- " A7 04 02 02 00 FF"
- " A8 24 30 22"
- " 30 0F"
- " A0 03 02 01 01"
- " A1 08 04 06 66 6F 6F 62 61 72"
- " 30 0F"
- " A0 03 02 01 01"
- " A1 08 04 06 66 6F 6F 62 61 72"
- ,decode_krb5_authenticator,ktest_equal_authenticator,krb5_free_authenticator);
-
- ref.seq_number = 0xffffffff;
- decode_run("authenticator","(00FFFFFFFF -> seq-number 0xffffffff)",
- "62 81 A5 30 81 A2"
- " A0 03 02 01 05"
- " A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55"
- " A2 1A 30 18"
- " A0 03 02 01 01"
- " A1 11 30 0F"
- " 1B 06 68 66 74 73 61 69"
- " 1B 05 65 78 74 72 61"
- " A3 0F 30 0D"
- " A0 03 02 01 01"
- " A1 06 04 04 31 32 33 34"
- " A4 05 02 03 01 E2 40"
- " A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A"
- " A6 13 30 11"
- " A0 03 02 01 01"
- " A1 0A 04 08 31 32 33 34 35 36 37 38"
- " A7 07 02 05 00 FF FF FF FF"
- " A8 24 30 22"
- " 30 0F"
- " A0 03 02 01 01"
- " A1 08 04 06 66 6F 6F 62 61 72"
- " 30 0F"
- " A0 03 02 01 01"
- " A1 08 04 06 66 6F 6F 62 61 72"
- ,decode_krb5_authenticator,ktest_equal_authenticator,krb5_free_authenticator);
-
- ref.seq_number = 0x7fffffff;
- decode_run("authenticator","(7FFFFFFF -> seq-number 0x7fffffff)",
- "62 81 A4 30 81 A1"
- " A0 03 02 01 05"
- " A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55"
- " A2 1A 30 18"
- " A0 03 02 01 01"
- " A1 11 30 0F"
- " 1B 06 68 66 74 73 61 69"
- " 1B 05 65 78 74 72 61"
- " A3 0F 30 0D"
- " A0 03 02 01 01"
- " A1 06 04 04 31 32 33 34"
- " A4 05 02 03 01 E2 40"
- " A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A"
- " A6 13 30 11"
- " A0 03 02 01 01"
- " A1 0A 04 08 31 32 33 34 35 36 37 38"
- " A7 06 02 04 7F FF FF FF"
- " A8 24 30 22"
- " 30 0F"
- " A0 03 02 01 01"
- " A1 08 04 06 66 6F 6F 62 61 72"
- " 30 0F"
- " A0 03 02 01 01"
- " A1 08 04 06 66 6F 6F 62 61 72"
- ,decode_krb5_authenticator,ktest_equal_authenticator,krb5_free_authenticator);
-
- ref.seq_number = 0xffffffff;
- decode_run("authenticator","(FFFFFFFF -> seq-number 0xffffffff)",
- "62 81 A4 30 81 A1"
- " A0 03 02 01 05"
- " A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55"
- " A2 1A 30 18"
- " A0 03 02 01 01"
- " A1 11 30 0F"
- " 1B 06 68 66 74 73 61 69"
- " 1B 05 65 78 74 72 61"
- " A3 0F 30 0D"
- " A0 03 02 01 01"
- " A1 06 04 04 31 32 33 34"
- " A4 05 02 03 01 E2 40"
- " A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A"
- " A6 13 30 11"
- " A0 03 02 01 01"
- " A1 0A 04 08 31 32 33 34 35 36 37 38"
- " A7 06 02 04 FF FF FF FF"
- " A8 24 30 22"
- " 30 0F"
- " A0 03 02 01 01"
- " A1 08 04 06 66 6F 6F 62 61 72"
- " 30 0F"
- " A0 03 02 01 01"
- " A1 08 04 06 66 6F 6F 62 61 72"
- ,decode_krb5_authenticator,ktest_equal_authenticator,krb5_free_authenticator);
-
- ktest_destroy_checksum(&(ref.checksum));
- ktest_destroy_keyblock(&(ref.subkey));
- ref.seq_number = 0;
- ktest_empty_authorization_data(ref.authorization_data);
- decode_run("authenticator","(optionals empty)","62 4F 30 4D A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 05 02 03 01 E2 40 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_authenticator,ktest_equal_authenticator,krb5_free_authenticator);
-
- ktest_destroy_authorization_data(&(ref.authorization_data));
-
- decode_run("authenticator","(optionals NULL)","62 4F 30 4D A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 05 02 03 01 E2 40 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_authenticator,ktest_equal_authenticator,krb5_free_authenticator);
-
- ktest_empty_authenticator(&ref);
+ setup(krb5_authenticator,"krb5_authenticator",ktest_make_sample_authenticator);
+
+ decode_run("authenticator","","62 81 A1 30 81 9E A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34 A4 05 02 03 01 E2 40 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A7 03 02 01 11 A8 24 30 22 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72",decode_krb5_authenticator,ktest_equal_authenticator,krb5_free_authenticator);
+
+ ref.seq_number = 0xffffff80;
+ decode_run("authenticator","(80 -> seq-number 0xffffff80)",
+ "62 81 A1 30 81 9E"
+ " A0 03 02 01 05"
+ " A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55"
+ " A2 1A 30 18"
+ " A0 03 02 01 01"
+ " A1 11 30 0F"
+ " 1B 06 68 66 74 73 61 69"
+ " 1B 05 65 78 74 72 61"
+ " A3 0F 30 0D"
+ " A0 03 02 01 01"
+ " A1 06 04 04 31 32 33 34"
+ " A4 05 02 03 01 E2 40"
+ " A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A"
+ " A6 13 30 11"
+ " A0 03 02 01 01"
+ " A1 0A 04 08 31 32 33 34 35 36 37 38"
+ " A7 03 02 01 80"
+ " A8 24 30 22"
+ " 30 0F"
+ " A0 03 02 01 01"
+ " A1 08 04 06 66 6F 6F 62 61 72"
+ " 30 0F"
+ " A0 03 02 01 01"
+ " A1 08 04 06 66 6F 6F 62 61 72"
+ ,decode_krb5_authenticator,ktest_equal_authenticator,krb5_free_authenticator);
+
+ ref.seq_number = 0xffffffff;
+ decode_run("authenticator","(FF -> seq-number 0xffffffff)",
+ "62 81 A1 30 81 9E"
+ " A0 03 02 01 05"
+ " A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55"
+ " A2 1A 30 18"
+ " A0 03 02 01 01"
+ " A1 11 30 0F"
+ " 1B 06 68 66 74 73 61 69"
+ " 1B 05 65 78 74 72 61"
+ " A3 0F 30 0D"
+ " A0 03 02 01 01"
+ " A1 06 04 04 31 32 33 34"
+ " A4 05 02 03 01 E2 40"
+ " A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A"
+ " A6 13 30 11"
+ " A0 03 02 01 01"
+ " A1 0A 04 08 31 32 33 34 35 36 37 38"
+ " A7 03 02 01 FF"
+ " A8 24 30 22"
+ " 30 0F"
+ " A0 03 02 01 01"
+ " A1 08 04 06 66 6F 6F 62 61 72"
+ " 30 0F"
+ " A0 03 02 01 01"
+ " A1 08 04 06 66 6F 6F 62 61 72"
+ ,decode_krb5_authenticator,ktest_equal_authenticator,krb5_free_authenticator);
+
+ ref.seq_number = 0xff;
+ decode_run("authenticator","(00FF -> seq-number 0xff)",
+ "62 81 A2 30 81 9F"
+ " A0 03 02 01 05"
+ " A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55"
+ " A2 1A 30 18"
+ " A0 03 02 01 01"
+ " A1 11 30 0F"
+ " 1B 06 68 66 74 73 61 69"
+ " 1B 05 65 78 74 72 61"
+ " A3 0F 30 0D"
+ " A0 03 02 01 01"
+ " A1 06 04 04 31 32 33 34"
+ " A4 05 02 03 01 E2 40"
+ " A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A"
+ " A6 13 30 11"
+ " A0 03 02 01 01"
+ " A1 0A 04 08 31 32 33 34 35 36 37 38"
+ " A7 04 02 02 00 FF"
+ " A8 24 30 22"
+ " 30 0F"
+ " A0 03 02 01 01"
+ " A1 08 04 06 66 6F 6F 62 61 72"
+ " 30 0F"
+ " A0 03 02 01 01"
+ " A1 08 04 06 66 6F 6F 62 61 72"
+ ,decode_krb5_authenticator,ktest_equal_authenticator,krb5_free_authenticator);
+
+ ref.seq_number = 0xffffffff;
+ decode_run("authenticator","(00FFFFFFFF -> seq-number 0xffffffff)",
+ "62 81 A5 30 81 A2"
+ " A0 03 02 01 05"
+ " A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55"
+ " A2 1A 30 18"
+ " A0 03 02 01 01"
+ " A1 11 30 0F"
+ " 1B 06 68 66 74 73 61 69"
+ " 1B 05 65 78 74 72 61"
+ " A3 0F 30 0D"
+ " A0 03 02 01 01"
+ " A1 06 04 04 31 32 33 34"
+ " A4 05 02 03 01 E2 40"
+ " A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A"
+ " A6 13 30 11"
+ " A0 03 02 01 01"
+ " A1 0A 04 08 31 32 33 34 35 36 37 38"
+ " A7 07 02 05 00 FF FF FF FF"
+ " A8 24 30 22"
+ " 30 0F"
+ " A0 03 02 01 01"
+ " A1 08 04 06 66 6F 6F 62 61 72"
+ " 30 0F"
+ " A0 03 02 01 01"
+ " A1 08 04 06 66 6F 6F 62 61 72"
+ ,decode_krb5_authenticator,ktest_equal_authenticator,krb5_free_authenticator);
+
+ ref.seq_number = 0x7fffffff;
+ decode_run("authenticator","(7FFFFFFF -> seq-number 0x7fffffff)",
+ "62 81 A4 30 81 A1"
+ " A0 03 02 01 05"
+ " A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55"
+ " A2 1A 30 18"
+ " A0 03 02 01 01"
+ " A1 11 30 0F"
+ " 1B 06 68 66 74 73 61 69"
+ " 1B 05 65 78 74 72 61"
+ " A3 0F 30 0D"
+ " A0 03 02 01 01"
+ " A1 06 04 04 31 32 33 34"
+ " A4 05 02 03 01 E2 40"
+ " A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A"
+ " A6 13 30 11"
+ " A0 03 02 01 01"
+ " A1 0A 04 08 31 32 33 34 35 36 37 38"
+ " A7 06 02 04 7F FF FF FF"
+ " A8 24 30 22"
+ " 30 0F"
+ " A0 03 02 01 01"
+ " A1 08 04 06 66 6F 6F 62 61 72"
+ " 30 0F"
+ " A0 03 02 01 01"
+ " A1 08 04 06 66 6F 6F 62 61 72"
+ ,decode_krb5_authenticator,ktest_equal_authenticator,krb5_free_authenticator);
+
+ ref.seq_number = 0xffffffff;
+ decode_run("authenticator","(FFFFFFFF -> seq-number 0xffffffff)",
+ "62 81 A4 30 81 A1"
+ " A0 03 02 01 05"
+ " A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55"
+ " A2 1A 30 18"
+ " A0 03 02 01 01"
+ " A1 11 30 0F"
+ " 1B 06 68 66 74 73 61 69"
+ " 1B 05 65 78 74 72 61"
+ " A3 0F 30 0D"
+ " A0 03 02 01 01"
+ " A1 06 04 04 31 32 33 34"
+ " A4 05 02 03 01 E2 40"
+ " A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A"
+ " A6 13 30 11"
+ " A0 03 02 01 01"
+ " A1 0A 04 08 31 32 33 34 35 36 37 38"
+ " A7 06 02 04 FF FF FF FF"
+ " A8 24 30 22"
+ " 30 0F"
+ " A0 03 02 01 01"
+ " A1 08 04 06 66 6F 6F 62 61 72"
+ " 30 0F"
+ " A0 03 02 01 01"
+ " A1 08 04 06 66 6F 6F 62 61 72"
+ ,decode_krb5_authenticator,ktest_equal_authenticator,krb5_free_authenticator);
+
+ ktest_destroy_checksum(&(ref.checksum));
+ ktest_destroy_keyblock(&(ref.subkey));
+ ref.seq_number = 0;
+ ktest_empty_authorization_data(ref.authorization_data);
+ decode_run("authenticator","(optionals empty)","62 4F 30 4D A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 05 02 03 01 E2 40 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_authenticator,ktest_equal_authenticator,krb5_free_authenticator);
+
+ ktest_destroy_authorization_data(&(ref.authorization_data));
+
+ decode_run("authenticator","(optionals NULL)","62 4F 30 4D A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 05 02 03 01 E2 40 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_authenticator,ktest_equal_authenticator,krb5_free_authenticator);
+
+ ktest_empty_authenticator(&ref);
}
/****************************************************************/
/* decode_krb5_ticket */
{
- setup(krb5_ticket,"krb5_ticket",ktest_make_sample_ticket);
- decode_run("ticket","","61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_ticket,ktest_equal_ticket,krb5_free_ticket);
- decode_run("ticket","(+ trailing [4] INTEGER","61 61 30 5F A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 A4 03 02 01 01",decode_krb5_ticket,ktest_equal_ticket,krb5_free_ticket);
+ setup(krb5_ticket,"krb5_ticket",ktest_make_sample_ticket);
+ decode_run("ticket","","61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_ticket,ktest_equal_ticket,krb5_free_ticket);
+ decode_run("ticket","(+ trailing [4] INTEGER","61 61 30 5F A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 A4 03 02 01 01",decode_krb5_ticket,ktest_equal_ticket,krb5_free_ticket);
/*
"61 80 30 80 "
" 00 00 00 00"
"00 00 00 00"
*/
- decode_run("ticket","(indefinite lengths)", "61 80 30 80 A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 80 30 80 A0 03 02 01 01 A1 80 30 80 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 00 00 00 00 00 00 00 00 A3 80 30 80 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 00 00 00 00 00 00 00 00" ,decode_krb5_ticket,ktest_equal_ticket,krb5_free_ticket);
+ decode_run("ticket","(indefinite lengths)", "61 80 30 80 A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 80 30 80 A0 03 02 01 01 A1 80 30 80 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 00 00 00 00 00 00 00 00 A3 80 30 80 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 00 00 00 00 00 00 00 00" ,decode_krb5_ticket,ktest_equal_ticket,krb5_free_ticket);
/*
"61 80 30 80 "
" A0 03 02 01 05 "
" A4 03 02 01 01 "
"00 00 00 00"
*/
- decode_run("ticket","(indefinite lengths + trailing [4] INTEGER)", "61 80 30 80 A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 80 30 80 A0 03 02 01 01 A1 80 30 80 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 00 00 00 00 00 00 00 00 A3 80 30 80 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 00 00 00 00 A4 03 02 01 01 00 00 00 00",decode_krb5_ticket,ktest_equal_ticket,krb5_free_ticket);
+ decode_run("ticket","(indefinite lengths + trailing [4] INTEGER)", "61 80 30 80 A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 80 30 80 A0 03 02 01 01 A1 80 30 80 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 00 00 00 00 00 00 00 00 A3 80 30 80 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 00 00 00 00 A4 03 02 01 01 00 00 00 00",decode_krb5_ticket,ktest_equal_ticket,krb5_free_ticket);
- ktest_empty_ticket(&ref);
+ ktest_empty_ticket(&ref);
}
/****************************************************************/
/* decode_krb5_encryption_key */
{
- setup(krb5_keyblock,"krb5_keyblock",ktest_make_sample_keyblock);
+ setup(krb5_keyblock,"krb5_keyblock",ktest_make_sample_keyblock);
- decode_run("encryption_key","","30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
+ decode_run("encryption_key","","30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
- decode_run("encryption_key","(+ trailing [2] INTEGER)","30 16 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 03 02 01 01",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
- decode_run("encryption_key","(+ trailing [2] SEQUENCE {[0] INTEGER})","30 1A A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 07 30 05 A0 03 02 01 01",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
- decode_run("encryption_key","(indefinite lengths)","30 80 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 00 00",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
- decode_run("encryption_key","(indefinite lengths + trailing [2] INTEGER)","30 80 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 03 02 01 01 00 00",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
- decode_run("encryption_key","(indefinite lengths + trailing [2] SEQUENCE {[0] INTEGER})","30 80 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 80 30 80 A0 03 02 01 01 00 00 00 00 00 00",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
- decode_run("encryption_key","(indefinite lengths + trailing SEQUENCE {[0] INTEGER})","30 80 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 30 80 A0 03 02 01 01 00 00 00 00",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
- ref.enctype = -1;
- decode_run("encryption_key","(enctype = -1)","30 11 A0 03 02 01 FF A1 0A 04 08 31 32 33 34 35 36 37 38",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
- ref.enctype = -255;
- decode_run("encryption_key","(enctype = -255)","30 12 A0 04 02 02 FF 01 A1 0A 04 08 31 32 33 34 35 36 37 38",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
- ref.enctype = 255;
- decode_run("encryption_key","(enctype = 255)","30 12 A0 04 02 02 00 FF A1 0A 04 08 31 32 33 34 35 36 37 38",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
- ref.enctype = -2147483648U;
- decode_run("encryption_key","(enctype = -2147483648)","30 14 A0 06 02 04 80 00 00 00 A1 0A 04 08 31 32 33 34 35 36 37 38",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
- ref.enctype = 2147483647;
- decode_run("encryption_key","(enctype = 2147483647)","30 14 A0 06 02 04 7F FF FF FF A1 0A 04 08 31 32 33 34 35 36 37 38",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
+ decode_run("encryption_key","(+ trailing [2] INTEGER)","30 16 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 03 02 01 01",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
+ decode_run("encryption_key","(+ trailing [2] SEQUENCE {[0] INTEGER})","30 1A A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 07 30 05 A0 03 02 01 01",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
+ decode_run("encryption_key","(indefinite lengths)","30 80 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 00 00",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
+ decode_run("encryption_key","(indefinite lengths + trailing [2] INTEGER)","30 80 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 03 02 01 01 00 00",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
+ decode_run("encryption_key","(indefinite lengths + trailing [2] SEQUENCE {[0] INTEGER})","30 80 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 80 30 80 A0 03 02 01 01 00 00 00 00 00 00",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
+ decode_run("encryption_key","(indefinite lengths + trailing SEQUENCE {[0] INTEGER})","30 80 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 30 80 A0 03 02 01 01 00 00 00 00",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
+ ref.enctype = -1;
+ decode_run("encryption_key","(enctype = -1)","30 11 A0 03 02 01 FF A1 0A 04 08 31 32 33 34 35 36 37 38",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
+ ref.enctype = -255;
+ decode_run("encryption_key","(enctype = -255)","30 12 A0 04 02 02 FF 01 A1 0A 04 08 31 32 33 34 35 36 37 38",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
+ ref.enctype = 255;
+ decode_run("encryption_key","(enctype = 255)","30 12 A0 04 02 02 00 FF A1 0A 04 08 31 32 33 34 35 36 37 38",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
+ ref.enctype = -2147483648U;
+ decode_run("encryption_key","(enctype = -2147483648)","30 14 A0 06 02 04 80 00 00 00 A1 0A 04 08 31 32 33 34 35 36 37 38",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
+ ref.enctype = 2147483647;
+ decode_run("encryption_key","(enctype = 2147483647)","30 14 A0 06 02 04 7F FF FF FF A1 0A 04 08 31 32 33 34 35 36 37 38",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock);
- ktest_empty_keyblock(&ref);
+ ktest_empty_keyblock(&ref);
}
/****************************************************************/
/* decode_krb5_enc_tkt_part */
{
- setup(krb5_enc_tkt_part,"krb5_enc_tkt_part",ktest_make_sample_enc_tkt_part);
- decode_run("enc_tkt_part","","63 82 01 14 30 82 01 10 A0 07 03 05 00 FE DC BA 98 A1 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 2E 30 2C A0 03 02 01 01 A1 25 04 23 45 44 55 2C 4D 49 54 2E 2C 41 54 48 45 4E 41 2E 2C 57 41 53 48 49 4E 47 54 4F 4E 2E 45 44 55 2C 43 53 2E A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A8 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A9 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 AA 24 30 22 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72",decode_krb5_enc_tkt_part,ktest_equal_enc_tkt_part,krb5_free_enc_tkt_part);
+ setup(krb5_enc_tkt_part,"krb5_enc_tkt_part",ktest_make_sample_enc_tkt_part);
+ decode_run("enc_tkt_part","","63 82 01 14 30 82 01 10 A0 07 03 05 00 FE DC BA 98 A1 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 2E 30 2C A0 03 02 01 01 A1 25 04 23 45 44 55 2C 4D 49 54 2E 2C 41 54 48 45 4E 41 2E 2C 57 41 53 48 49 4E 47 54 4F 4E 2E 45 44 55 2C 43 53 2E A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A8 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A9 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 AA 24 30 22 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72",decode_krb5_enc_tkt_part,ktest_equal_enc_tkt_part,krb5_free_enc_tkt_part);
- /* ref.times.starttime = 0; */
- ref.times.starttime = ref.times.authtime;
- ref.times.renew_till = 0;
- ktest_destroy_address(&(ref.caddrs[1]));
- ktest_destroy_address(&(ref.caddrs[0]));
- ktest_destroy_authdata(&(ref.authorization_data[1]));
- ktest_destroy_authdata(&(ref.authorization_data[0]));
- /* ISODE version fails on the empty caddrs field */
- ktest_destroy_addresses(&(ref.caddrs));
- ktest_destroy_authorization_data(&(ref.authorization_data));
+ /* ref.times.starttime = 0; */
+ ref.times.starttime = ref.times.authtime;
+ ref.times.renew_till = 0;
+ ktest_destroy_address(&(ref.caddrs[1]));
+ ktest_destroy_address(&(ref.caddrs[0]));
+ ktest_destroy_authdata(&(ref.authorization_data[1]));
+ ktest_destroy_authdata(&(ref.authorization_data[0]));
+ /* ISODE version fails on the empty caddrs field */
+ ktest_destroy_addresses(&(ref.caddrs));
+ ktest_destroy_authorization_data(&(ref.authorization_data));
- decode_run("enc_tkt_part","(optionals NULL)","63 81 A5 30 81 A2 A0 07 03 05 00 FE DC BA 98 A1 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 2E 30 2C A0 03 02 01 01 A1 25 04 23 45 44 55 2C 4D 49 54 2E 2C 41 54 48 45 4E 41 2E 2C 57 41 53 48 49 4E 47 54 4F 4E 2E 45 44 55 2C 43 53 2E A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_enc_tkt_part,ktest_equal_enc_tkt_part, krb5_free_enc_tkt_part);
+ decode_run("enc_tkt_part","(optionals NULL)","63 81 A5 30 81 A2 A0 07 03 05 00 FE DC BA 98 A1 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 2E 30 2C A0 03 02 01 01 A1 25 04 23 45 44 55 2C 4D 49 54 2E 2C 41 54 48 45 4E 41 2E 2C 57 41 53 48 49 4E 47 54 4F 4E 2E 45 44 55 2C 43 53 2E A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_enc_tkt_part,ktest_equal_enc_tkt_part, krb5_free_enc_tkt_part);
- decode_run("enc_tkt_part","(optionals NULL + bitstring enlarged to 38 bits)","63 81 A6 30 81 A3 A0 08 03 06 02 FE DC BA 98 DC A1 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 2E 30 2C A0 03 02 01 01 A1 25 04 23 45 44 55 2C 4D 49 54 2E 2C 41 54 48 45 4E 41 2E 2C 57 41 53 48 49 4E 47 54 4F 4E 2E 45 44 55 2C 43 53 2E A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_enc_tkt_part,ktest_equal_enc_tkt_part,krb5_free_enc_tkt_part);
+ decode_run("enc_tkt_part","(optionals NULL + bitstring enlarged to 38 bits)","63 81 A6 30 81 A3 A0 08 03 06 02 FE DC BA 98 DC A1 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 2E 30 2C A0 03 02 01 01 A1 25 04 23 45 44 55 2C 4D 49 54 2E 2C 41 54 48 45 4E 41 2E 2C 57 41 53 48 49 4E 47 54 4F 4E 2E 45 44 55 2C 43 53 2E A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_enc_tkt_part,ktest_equal_enc_tkt_part,krb5_free_enc_tkt_part);
- decode_run("enc_tkt_part","(optionals NULL + bitstring enlarged to 40 bits)","63 81 A6 30 81 A3 A0 08 03 06 00 FE DC BA 98 DE A1 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 2E 30 2C A0 03 02 01 01 A1 25 04 23 45 44 55 2C 4D 49 54 2E 2C 41 54 48 45 4E 41 2E 2C 57 41 53 48 49 4E 47 54 4F 4E 2E 45 44 55 2C 43 53 2E A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_enc_tkt_part,ktest_equal_enc_tkt_part,krb5_free_enc_tkt_part);
+ decode_run("enc_tkt_part","(optionals NULL + bitstring enlarged to 40 bits)","63 81 A6 30 81 A3 A0 08 03 06 00 FE DC BA 98 DE A1 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 2E 30 2C A0 03 02 01 01 A1 25 04 23 45 44 55 2C 4D 49 54 2E 2C 41 54 48 45 4E 41 2E 2C 57 41 53 48 49 4E 47 54 4F 4E 2E 45 44 55 2C 43 53 2E A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_enc_tkt_part,ktest_equal_enc_tkt_part,krb5_free_enc_tkt_part);
- decode_run("enc_tkt_part","(optionals NULL + bitstring reduced to 29 bits)","63 81 A5 30 81 A2 A0 07 03 05 03 FE DC BA 98 A1 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 2E 30 2C A0 03 02 01 01 A1 25 04 23 45 44 55 2C 4D 49 54 2E 2C 41 54 48 45 4E 41 2E 2C 57 41 53 48 49 4E 47 54 4F 4E 2E 45 44 55 2C 43 53 2E A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_enc_tkt_part,ktest_equal_enc_tkt_part,krb5_free_enc_tkt_part);
+ decode_run("enc_tkt_part","(optionals NULL + bitstring reduced to 29 bits)","63 81 A5 30 81 A2 A0 07 03 05 03 FE DC BA 98 A1 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 2E 30 2C A0 03 02 01 01 A1 25 04 23 45 44 55 2C 4D 49 54 2E 2C 41 54 48 45 4E 41 2E 2C 57 41 53 48 49 4E 47 54 4F 4E 2E 45 44 55 2C 43 53 2E A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_enc_tkt_part,ktest_equal_enc_tkt_part,krb5_free_enc_tkt_part);
- ref.flags &= 0xFFFFFF00;
+ ref.flags &= 0xFFFFFF00;
- decode_run("enc_tkt_part","(optionals NULL + bitstring reduced to 24 bits)","63 81 A4 30 81 A1 A0 06 03 04 00 FE DC BA A1 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 2E 30 2C A0 03 02 01 01 A1 25 04 23 45 44 55 2C 4D 49 54 2E 2C 41 54 48 45 4E 41 2E 2C 57 41 53 48 49 4E 47 54 4F 4E 2E 45 44 55 2C 43 53 2E A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_enc_tkt_part,ktest_equal_enc_tkt_part,krb5_free_enc_tkt_part);
+ decode_run("enc_tkt_part","(optionals NULL + bitstring reduced to 24 bits)","63 81 A4 30 81 A1 A0 06 03 04 00 FE DC BA A1 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 2E 30 2C A0 03 02 01 01 A1 25 04 23 45 44 55 2C 4D 49 54 2E 2C 41 54 48 45 4E 41 2E 2C 57 41 53 48 49 4E 47 54 4F 4E 2E 45 44 55 2C 43 53 2E A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_enc_tkt_part,ktest_equal_enc_tkt_part,krb5_free_enc_tkt_part);
- ktest_empty_enc_tkt_part(&ref);
+ ktest_empty_enc_tkt_part(&ref);
}
/****************************************************************/
/* decode_krb5_enc_kdc_rep_part */
{
- setup(krb5_enc_kdc_rep_part,"krb5_enc_kdc_rep_part",ktest_make_sample_enc_kdc_rep_part);
+ setup(krb5_enc_kdc_rep_part,"krb5_enc_kdc_rep_part",ktest_make_sample_enc_kdc_rep_part);
#ifdef KRB5_GENEROUS_LR_TYPE
- decode_run("enc_kdc_rep_part","(compat_lr_type)","7A 82 01 10 30 82 01 0C A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A1 38 30 36 30 19 A0 04 02 02 00 FB A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A 30 19 A0 04 02 02 00 FB A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A2 03 02 01 2A A3 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A4 07 03 05 00 FE DC BA 98 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A8 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A9 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 AA 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 AB 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23",decode_krb5_enc_kdc_rep_part,ktest_equal_enc_kdc_rep_part,krb5_free_enc_kdc_rep_part);
+ decode_run("enc_kdc_rep_part","(compat_lr_type)","7A 82 01 10 30 82 01 0C A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A1 38 30 36 30 19 A0 04 02 02 00 FB A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A 30 19 A0 04 02 02 00 FB A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A2 03 02 01 2A A3 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A4 07 03 05 00 FE DC BA 98 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A8 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A9 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 AA 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 AB 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23",decode_krb5_enc_kdc_rep_part,ktest_equal_enc_kdc_rep_part,krb5_free_enc_kdc_rep_part);
#endif
- decode_run("enc_kdc_rep_part","","7A 82 01 0E 30 82 01 0A A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A1 36 30 34 30 18 A0 03 02 01 FB A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A 30 18 A0 03 02 01 FB A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A2 03 02 01 2A A3 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A4 07 03 05 00 FE DC BA 98 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A8 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A9 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 AA 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 AB 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23",decode_krb5_enc_kdc_rep_part,ktest_equal_enc_kdc_rep_part,krb5_free_enc_kdc_rep_part);
+ decode_run("enc_kdc_rep_part","","7A 82 01 0E 30 82 01 0A A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A1 36 30 34 30 18 A0 03 02 01 FB A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A 30 18 A0 03 02 01 FB A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A2 03 02 01 2A A3 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A4 07 03 05 00 FE DC BA 98 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A8 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A9 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 AA 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 AB 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23",decode_krb5_enc_kdc_rep_part,ktest_equal_enc_kdc_rep_part,krb5_free_enc_kdc_rep_part);
- ref.key_exp = 0;
- /* ref.times.starttime = 0;*/
- ref.times.starttime = ref.times.authtime;
- ref.times.renew_till = 0;
- ref.flags &= ~TKT_FLG_RENEWABLE;
- ktest_destroy_addresses(&(ref.caddrs));
+ ref.key_exp = 0;
+ /* ref.times.starttime = 0;*/
+ ref.times.starttime = ref.times.authtime;
+ ref.times.renew_till = 0;
+ ref.flags &= ~TKT_FLG_RENEWABLE;
+ ktest_destroy_addresses(&(ref.caddrs));
#ifdef KRB5_GENEROUS_LR_TYPE
- decode_run("enc_kdc_rep_part","(optionals NULL)(compat lr_type)","7A 81 B4 30 81 B1 A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A1 38 30 36 30 19 A0 04 02 02 00 FB A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A 30 19 A0 04 02 02 00 FB A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A2 03 02 01 2A A4 07 03 05 00 FE 5C BA 98 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A9 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 AA 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61",decode_krb5_enc_kdc_rep_part,ktest_equal_enc_kdc_rep_part,krb5_free_enc_kdc_rep_part);
+ decode_run("enc_kdc_rep_part","(optionals NULL)(compat lr_type)","7A 81 B4 30 81 B1 A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A1 38 30 36 30 19 A0 04 02 02 00 FB A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A 30 19 A0 04 02 02 00 FB A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A2 03 02 01 2A A4 07 03 05 00 FE 5C BA 98 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A9 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 AA 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61",decode_krb5_enc_kdc_rep_part,ktest_equal_enc_kdc_rep_part,krb5_free_enc_kdc_rep_part);
#endif
- decode_run("enc_kdc_rep_part","(optionals NULL)","7A 81 B2 30 81 AF A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A1 36 30 34 30 18 A0 03 02 01 FB A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A 30 18 A0 03 02 01 FB A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A2 03 02 01 2A A4 07 03 05 00 FE 5C BA 98 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A9 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 AA 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61",decode_krb5_enc_kdc_rep_part,ktest_equal_enc_kdc_rep_part,krb5_free_enc_kdc_rep_part);
+ decode_run("enc_kdc_rep_part","(optionals NULL)","7A 81 B2 30 81 AF A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A1 36 30 34 30 18 A0 03 02 01 FB A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A 30 18 A0 03 02 01 FB A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A2 03 02 01 2A A4 07 03 05 00 FE 5C BA 98 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A9 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 AA 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61",decode_krb5_enc_kdc_rep_part,ktest_equal_enc_kdc_rep_part,krb5_free_enc_kdc_rep_part);
- ktest_empty_enc_kdc_rep_part(&ref);
+ ktest_empty_enc_kdc_rep_part(&ref);
}
/****************************************************************/
/* decode_krb5_as_rep */
{
- setup(krb5_kdc_rep,"krb5_kdc_rep",ktest_make_sample_kdc_rep);
- ref.msg_type = KRB5_AS_REP;
+ setup(krb5_kdc_rep,"krb5_kdc_rep",ktest_make_sample_kdc_rep);
+ ref.msg_type = KRB5_AS_REP;
- decode_run("as_rep","","6B 81 EA 30 81 E7 A0 03 02 01 05 A1 03 02 01 0B A2 26 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 A3 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A4 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A5 5E 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 A6 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_as_rep,ktest_equal_as_rep,krb5_free_kdc_rep);
+ decode_run("as_rep","","6B 81 EA 30 81 E7 A0 03 02 01 05 A1 03 02 01 0B A2 26 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 A3 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A4 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A5 5E 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 A6 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_as_rep,ktest_equal_as_rep,krb5_free_kdc_rep);
/*
6B 80 30 80
00 00 00 00
00 00 00 00
*/
- decode_run("as_rep","(indefinite lengths)","6B 80 30 80 A0 03 02 01 05 A1 03 02 01 0B A2 80 30 80 30 80 A1 03 02 01 0D A2 09 04 07 70 61 2D 64 61 74 61 00 00 30 80 A1 03 02 01 0D A2 09 04 07 70 61 2D 64 61 74 61 00 00 00 00 00 00 A3 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A4 80 30 80 A0 03 02 01 01 A1 80 30 80 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 00 00 00 00 00 00 00 00 A5 80 61 80 30 80 A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 80 30 80 A0 03 02 01 01 A1 80 30 80 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 00 00 00 00 00 00 00 00 A3 80 30 80 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 00 00 00 00 00 00 00 00 00 00 A6 80 30 80 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 00 00 00 00 00 00 00 00",decode_krb5_as_rep,ktest_equal_as_rep,krb5_free_kdc_rep);
- ktest_destroy_pa_data_array(&(ref.padata));
- decode_run("as_rep","(optionals NULL)","6B 81 C2 30 81 BF A0 03 02 01 05 A1 03 02 01 0B A3 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A4 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A5 5E 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 A6 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_as_rep,ktest_equal_as_rep,krb5_free_kdc_rep);
+ decode_run("as_rep","(indefinite lengths)","6B 80 30 80 A0 03 02 01 05 A1 03 02 01 0B A2 80 30 80 30 80 A1 03 02 01 0D A2 09 04 07 70 61 2D 64 61 74 61 00 00 30 80 A1 03 02 01 0D A2 09 04 07 70 61 2D 64 61 74 61 00 00 00 00 00 00 A3 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A4 80 30 80 A0 03 02 01 01 A1 80 30 80 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 00 00 00 00 00 00 00 00 A5 80 61 80 30 80 A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 80 30 80 A0 03 02 01 01 A1 80 30 80 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 00 00 00 00 00 00 00 00 A3 80 30 80 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 00 00 00 00 00 00 00 00 00 00 A6 80 30 80 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 00 00 00 00 00 00 00 00",decode_krb5_as_rep,ktest_equal_as_rep,krb5_free_kdc_rep);
+ ktest_destroy_pa_data_array(&(ref.padata));
+ decode_run("as_rep","(optionals NULL)","6B 81 C2 30 81 BF A0 03 02 01 05 A1 03 02 01 0B A3 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A4 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A5 5E 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 A6 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_as_rep,ktest_equal_as_rep,krb5_free_kdc_rep);
- ktest_empty_kdc_rep(&ref);
+ ktest_empty_kdc_rep(&ref);
}
/****************************************************************/
/* decode_krb5_tgs_rep */
{
- setup(krb5_kdc_rep,"krb5_kdc_rep",ktest_make_sample_kdc_rep);
- ref.msg_type = KRB5_TGS_REP;
+ setup(krb5_kdc_rep,"krb5_kdc_rep",ktest_make_sample_kdc_rep);
+ ref.msg_type = KRB5_TGS_REP;
- decode_run("tgs_rep","","6D 81 EA 30 81 E7 A0 03 02 01 05 A1 03 02 01 0D A2 26 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 A3 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A4 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A5 5E 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 A6 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_tgs_rep,ktest_equal_tgs_rep,krb5_free_kdc_rep);
+ decode_run("tgs_rep","","6D 81 EA 30 81 E7 A0 03 02 01 05 A1 03 02 01 0D A2 26 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 A3 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A4 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A5 5E 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 A6 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_tgs_rep,ktest_equal_tgs_rep,krb5_free_kdc_rep);
- ktest_destroy_pa_data_array(&(ref.padata));
- decode_run("tgs_rep","(optionals NULL)","6D 81 C2 30 81 BF A0 03 02 01 05 A1 03 02 01 0D A3 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A4 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A5 5E 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 A6 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_tgs_rep,ktest_equal_tgs_rep,krb5_free_kdc_rep);
+ ktest_destroy_pa_data_array(&(ref.padata));
+ decode_run("tgs_rep","(optionals NULL)","6D 81 C2 30 81 BF A0 03 02 01 05 A1 03 02 01 0D A3 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A4 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A5 5E 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 A6 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_tgs_rep,ktest_equal_tgs_rep,krb5_free_kdc_rep);
- ktest_empty_kdc_rep(&ref);
+ ktest_empty_kdc_rep(&ref);
}
/****************************************************************/
/* decode_krb5_ap_req */
{
- setup(krb5_ap_req,"krb5_ap_req",ktest_make_sample_ap_req);
- decode_run("ap_req","","6E 81 9D 30 81 9A A0 03 02 01 05 A1 03 02 01 0E A2 07 03 05 00 FE DC BA 98 A3 5E 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 A4 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_ap_req,ktest_equal_ap_req,krb5_free_ap_req);
- ktest_empty_ap_req(&ref);
+ setup(krb5_ap_req,"krb5_ap_req",ktest_make_sample_ap_req);
+ decode_run("ap_req","","6E 81 9D 30 81 9A A0 03 02 01 05 A1 03 02 01 0E A2 07 03 05 00 FE DC BA 98 A3 5E 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 A4 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_ap_req,ktest_equal_ap_req,krb5_free_ap_req);
+ ktest_empty_ap_req(&ref);
}
/****************************************************************/
/* decode_krb5_ap_rep */
{
- setup(krb5_ap_rep,"krb5_ap_rep",ktest_make_sample_ap_rep);
- decode_run("ap_rep","","6F 33 30 31 A0 03 02 01 05 A1 03 02 01 0F A2 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_ap_rep,ktest_equal_ap_rep,krb5_free_ap_rep);
- ktest_empty_ap_rep(&ref);
+ setup(krb5_ap_rep,"krb5_ap_rep",ktest_make_sample_ap_rep);
+ decode_run("ap_rep","","6F 33 30 31 A0 03 02 01 05 A1 03 02 01 0F A2 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_ap_rep,ktest_equal_ap_rep,krb5_free_ap_rep);
+ ktest_empty_ap_rep(&ref);
}
/****************************************************************/
/* decode_krb5_ap_rep_enc_part */
{
- setup(krb5_ap_rep_enc_part,"krb5_ap_rep_enc_part",ktest_make_sample_ap_rep_enc_part);
+ setup(krb5_ap_rep_enc_part,"krb5_ap_rep_enc_part",ktest_make_sample_ap_rep_enc_part);
- decode_run("ap_rep_enc_part","","7B 36 30 34 A0 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A1 05 02 03 01 E2 40 A2 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A3 03 02 01 11",decode_krb5_ap_rep_enc_part,ktest_equal_ap_rep_enc_part,krb5_free_ap_rep_enc_part);
+ decode_run("ap_rep_enc_part","","7B 36 30 34 A0 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A1 05 02 03 01 E2 40 A2 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A3 03 02 01 11",decode_krb5_ap_rep_enc_part,ktest_equal_ap_rep_enc_part,krb5_free_ap_rep_enc_part);
- ktest_destroy_keyblock(&(ref.subkey));
- ref.seq_number = 0;
- decode_run("ap_rep_enc_part","(optionals NULL)","7B 1C 30 1A A0 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A1 05 02 03 01 E2 40",decode_krb5_ap_rep_enc_part,ktest_equal_ap_rep_enc_part,krb5_free_ap_rep_enc_part);
+ ktest_destroy_keyblock(&(ref.subkey));
+ ref.seq_number = 0;
+ decode_run("ap_rep_enc_part","(optionals NULL)","7B 1C 30 1A A0 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A1 05 02 03 01 E2 40",decode_krb5_ap_rep_enc_part,ktest_equal_ap_rep_enc_part,krb5_free_ap_rep_enc_part);
- retval = krb5_data_hex_parse(&code, "7B 06 30 04 A0 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A1 05 02 03 01 E2 40");
- if (retval) {
- com_err("krb5_decode_test", retval, "while parsing");
- exit(1);
- }
- retval = decode_krb5_ap_rep_enc_part(&code, &var);
- if (retval != ASN1_OVERRUN) {
- printf("ERROR: ");
- } else {
- printf("OK: ");
- }
- printf("ap_rep_enc_part(optionals NULL + expect ASN1_OVERRUN for inconsistent length of timestamp)\n");
- krb5_free_data_contents(test_context, &code);
- krb5_free_ap_rep_enc_part(test_context, var);
+ retval = krb5_data_hex_parse(&code, "7B 06 30 04 A0 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A1 05 02 03 01 E2 40");
+ if (retval) {
+ com_err("krb5_decode_test", retval, "while parsing");
+ exit(1);
+ }
+ retval = decode_krb5_ap_rep_enc_part(&code, &var);
+ if (retval != ASN1_OVERRUN) {
+ printf("ERROR: ");
+ } else {
+ printf("OK: ");
+ }
+ printf("ap_rep_enc_part(optionals NULL + expect ASN1_OVERRUN for inconsistent length of timestamp)\n");
+ krb5_free_data_contents(test_context, &code);
+ krb5_free_ap_rep_enc_part(test_context, var);
- ktest_empty_ap_rep_enc_part(&ref);
+ ktest_empty_ap_rep_enc_part(&ref);
}
/****************************************************************/
/* decode_krb5_as_req */
{
- setup(krb5_kdc_req,"krb5_kdc_req",ktest_make_sample_kdc_req);
- ref.msg_type = KRB5_AS_REQ;
+ setup(krb5_kdc_req,"krb5_kdc_req",ktest_make_sample_kdc_req);
+ ref.msg_type = KRB5_AS_REQ;
- ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
- decode_run("as_req","","6A 82 01 E4 30 82 01 E0 A1 03 02 01 05 A2 03 02 01 0A A3 26 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 A4 82 01 AA 30 82 01 A6 A0 07 03 05 00 FE DC BA 90 A1 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 08 30 06 02 01 00 02 01 01 A9 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 AA 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 AB 81 BF 30 81 BC 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_as_req,ktest_equal_as_req,krb5_free_kdc_req);
+ ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
+ decode_run("as_req","","6A 82 01 E4 30 82 01 E0 A1 03 02 01 05 A2 03 02 01 0A A3 26 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 A4 82 01 AA 30 82 01 A6 A0 07 03 05 00 FE DC BA 90 A1 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 08 30 06 02 01 00 02 01 01 A9 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 AA 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 AB 81 BF 30 81 BC 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_as_req,ktest_equal_as_req,krb5_free_kdc_req);
- ktest_destroy_pa_data_array(&(ref.padata));
- ktest_destroy_principal(&(ref.client));
+ ktest_destroy_pa_data_array(&(ref.padata));
+ ktest_destroy_principal(&(ref.client));
#ifndef ISODE_SUCKS
- ktest_destroy_principal(&(ref.server));
+ ktest_destroy_principal(&(ref.server));
#endif
- ref.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY;
- ref.from = 0;
- ref.rtime = 0;
- ktest_destroy_addresses(&(ref.addresses));
- ktest_destroy_enc_data(&(ref.authorization_data));
- decode_run("as_req","(optionals NULL except second_ticket)","6A 82 01 14 30 82 01 10 A1 03 02 01 05 A2 03 02 01 0A A4 82 01 02 30 81 FF A0 07 03 05 00 FE DC BA 98 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 08 30 06 02 01 00 02 01 01 AB 81 BF 30 81 BC 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_as_req,ktest_equal_as_req,krb5_free_kdc_req);
- ktest_destroy_sequence_of_ticket(&(ref.second_ticket));
+ ref.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY;
+ ref.from = 0;
+ ref.rtime = 0;
+ ktest_destroy_addresses(&(ref.addresses));
+ ktest_destroy_enc_data(&(ref.authorization_data));
+ decode_run("as_req","(optionals NULL except second_ticket)","6A 82 01 14 30 82 01 10 A1 03 02 01 05 A2 03 02 01 0A A4 82 01 02 30 81 FF A0 07 03 05 00 FE DC BA 98 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 08 30 06 02 01 00 02 01 01 AB 81 BF 30 81 BC 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_as_req,ktest_equal_as_req,krb5_free_kdc_req);
+ ktest_destroy_sequence_of_ticket(&(ref.second_ticket));
#ifndef ISODE_SUCKS
- ktest_make_sample_principal(&(ref.server));
+ ktest_make_sample_principal(&(ref.server));
#endif
- ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
- decode_run("as_req","(optionals NULL except server)","6A 69 30 67 A1 03 02 01 05 A2 03 02 01 0A A4 5B 30 59 A0 07 03 05 00 FE DC BA 90 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 08 30 06 02 01 00 02 01 01",decode_krb5_as_req,ktest_equal_as_req,krb5_free_kdc_req);
+ ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
+ decode_run("as_req","(optionals NULL except server)","6A 69 30 67 A1 03 02 01 05 A2 03 02 01 0A A4 5B 30 59 A0 07 03 05 00 FE DC BA 90 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 08 30 06 02 01 00 02 01 01",decode_krb5_as_req,ktest_equal_as_req,krb5_free_kdc_req);
- ktest_empty_kdc_req(&ref);
+ ktest_empty_kdc_req(&ref);
}
/****************************************************************/
/* decode_krb5_tgs_req */
{
- setup(krb5_kdc_req,"krb5_kdc_req",ktest_make_sample_kdc_req);
- ref.msg_type = KRB5_TGS_REQ;
+ setup(krb5_kdc_req,"krb5_kdc_req",ktest_make_sample_kdc_req);
+ ref.msg_type = KRB5_TGS_REQ;
- ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
- decode_run("tgs_req","","6C 82 01 E4 30 82 01 E0 A1 03 02 01 05 A2 03 02 01 0C A3 26 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 A4 82 01 AA 30 82 01 A6 A0 07 03 05 00 FE DC BA 90 A1 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 08 30 06 02 01 00 02 01 01 A9 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 AA 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 AB 81 BF 30 81 BC 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_tgs_req,ktest_equal_tgs_req,krb5_free_kdc_req);
+ ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
+ decode_run("tgs_req","","6C 82 01 E4 30 82 01 E0 A1 03 02 01 05 A2 03 02 01 0C A3 26 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 A4 82 01 AA 30 82 01 A6 A0 07 03 05 00 FE DC BA 90 A1 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 08 30 06 02 01 00 02 01 01 A9 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 AA 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 AB 81 BF 30 81 BC 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_tgs_req,ktest_equal_tgs_req,krb5_free_kdc_req);
- ktest_destroy_pa_data_array(&(ref.padata));
- ktest_destroy_principal(&(ref.client));
+ ktest_destroy_pa_data_array(&(ref.padata));
+ ktest_destroy_principal(&(ref.client));
#ifndef ISODE_SUCKS
- ktest_destroy_principal(&(ref.server));
+ ktest_destroy_principal(&(ref.server));
#endif
- ref.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY;
- ref.from = 0;
- ref.rtime = 0;
- ktest_destroy_addresses(&(ref.addresses));
- ktest_destroy_enc_data(&(ref.authorization_data));
- decode_run("tgs_req","(optionals NULL except second_ticket)","6C 82 01 14 30 82 01 10 A1 03 02 01 05 A2 03 02 01 0C A4 82 01 02 30 81 FF A0 07 03 05 00 FE DC BA 98 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 08 30 06 02 01 00 02 01 01 AB 81 BF 30 81 BC 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_tgs_req,ktest_equal_tgs_req,krb5_free_kdc_req);
-
- ktest_destroy_sequence_of_ticket(&(ref.second_ticket));
+ ref.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY;
+ ref.from = 0;
+ ref.rtime = 0;
+ ktest_destroy_addresses(&(ref.addresses));
+ ktest_destroy_enc_data(&(ref.authorization_data));
+ decode_run("tgs_req","(optionals NULL except second_ticket)","6C 82 01 14 30 82 01 10 A1 03 02 01 05 A2 03 02 01 0C A4 82 01 02 30 81 FF A0 07 03 05 00 FE DC BA 98 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 08 30 06 02 01 00 02 01 01 AB 81 BF 30 81 BC 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_tgs_req,ktest_equal_tgs_req,krb5_free_kdc_req);
+
+ ktest_destroy_sequence_of_ticket(&(ref.second_ticket));
#ifndef ISODE_SUCKS
- ktest_make_sample_principal(&(ref.server));
+ ktest_make_sample_principal(&(ref.server));
#endif
- ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
- decode_run("tgs_req","(optionals NULL except server)","6C 69 30 67 A1 03 02 01 05 A2 03 02 01 0C A4 5B 30 59 A0 07 03 05 00 FE DC BA 90 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 08 30 06 02 01 00 02 01 01",decode_krb5_tgs_req,ktest_equal_tgs_req,krb5_free_kdc_req);
+ ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
+ decode_run("tgs_req","(optionals NULL except server)","6C 69 30 67 A1 03 02 01 05 A2 03 02 01 0C A4 5B 30 59 A0 07 03 05 00 FE DC BA 90 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 08 30 06 02 01 00 02 01 01",decode_krb5_tgs_req,ktest_equal_tgs_req,krb5_free_kdc_req);
- ktest_empty_kdc_req(&ref);
+ ktest_empty_kdc_req(&ref);
}
/****************************************************************/
/* decode_krb5_kdc_req_body */
{
- krb5_kdc_req ref, *var;
- memset(&ref, 0, sizeof(krb5_kdc_req));
- retval = ktest_make_sample_kdc_req_body(&ref);
- if (retval) {
- com_err("making sample kdc_req_body",retval,"");
- exit(1);
- }
- ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
- decode_run("kdc_req_body","","30 82 01 A6 A0 07 03 05 00 FE DC BA 90 A1 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 08 30 06 02 01 00 02 01 01 A9 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 AA 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 AB 81 BF 30 81 BC 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_kdc_req_body,ktest_equal_kdc_req_body,krb5_free_kdc_req);
-
- ktest_destroy_principal(&(ref.client));
+ krb5_kdc_req ref, *var;
+ memset(&ref, 0, sizeof(krb5_kdc_req));
+ retval = ktest_make_sample_kdc_req_body(&ref);
+ if (retval) {
+ com_err("making sample kdc_req_body",retval,"");
+ exit(1);
+ }
+ ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
+ decode_run("kdc_req_body","","30 82 01 A6 A0 07 03 05 00 FE DC BA 90 A1 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 08 30 06 02 01 00 02 01 01 A9 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 AA 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 AB 81 BF 30 81 BC 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_kdc_req_body,ktest_equal_kdc_req_body,krb5_free_kdc_req);
+
+ ktest_destroy_principal(&(ref.client));
#ifndef ISODE_SUCKS
- ktest_destroy_principal(&(ref.server));
+ ktest_destroy_principal(&(ref.server));
#endif
- ref.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY;
- ref.from = 0;
- ref.rtime = 0;
- ktest_destroy_addresses(&(ref.addresses));
- ktest_destroy_enc_data(&(ref.authorization_data));
- decode_run("kdc_req_body","(optionals NULL except second_ticket)","30 81 FF A0 07 03 05 00 FE DC BA 98 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 08 30 06 02 01 00 02 01 01 AB 81 BF 30 81 BC 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_kdc_req_body,ktest_equal_kdc_req_body,krb5_free_kdc_req);
-
- ktest_destroy_sequence_of_ticket(&(ref.second_ticket));
+ ref.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY;
+ ref.from = 0;
+ ref.rtime = 0;
+ ktest_destroy_addresses(&(ref.addresses));
+ ktest_destroy_enc_data(&(ref.authorization_data));
+ decode_run("kdc_req_body","(optionals NULL except second_ticket)","30 81 FF A0 07 03 05 00 FE DC BA 98 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 08 30 06 02 01 00 02 01 01 AB 81 BF 30 81 BC 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_kdc_req_body,ktest_equal_kdc_req_body,krb5_free_kdc_req);
+
+ ktest_destroy_sequence_of_ticket(&(ref.second_ticket));
#ifndef ISODE_SUCKS
- ktest_make_sample_principal(&(ref.server));
+ ktest_make_sample_principal(&(ref.server));
#endif
- ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
- decode_run("kdc_req_body","(optionals NULL except server)","30 59 A0 07 03 05 00 FE DC BA 90 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 08 30 06 02 01 00 02 01 01",decode_krb5_kdc_req_body,ktest_equal_kdc_req_body,krb5_free_kdc_req);
- ref.nktypes = 0;
- free(ref.ktype);
- ref.ktype = NULL;
- decode_run("kdc_req_body","(optionals NULL except server; zero-length etypes)","30 53 A0 07 03 05 00 FE DC BA 90 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 02 30 00",decode_krb5_kdc_req_body,ktest_equal_kdc_req_body,krb5_free_kdc_req);
+ ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
+ decode_run("kdc_req_body","(optionals NULL except server)","30 59 A0 07 03 05 00 FE DC BA 90 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 08 30 06 02 01 00 02 01 01",decode_krb5_kdc_req_body,ktest_equal_kdc_req_body,krb5_free_kdc_req);
+ ref.nktypes = 0;
+ free(ref.ktype);
+ ref.ktype = NULL;
+ decode_run("kdc_req_body","(optionals NULL except server; zero-length etypes)","30 53 A0 07 03 05 00 FE DC BA 90 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 02 30 00",decode_krb5_kdc_req_body,ktest_equal_kdc_req_body,krb5_free_kdc_req);
- ktest_empty_kdc_req(&ref);
+ ktest_empty_kdc_req(&ref);
}
/****************************************************************/
/* decode_krb5_safe */
{
- setup(krb5_safe,"krb5_safe",ktest_make_sample_safe);
- decode_run("safe","","74 6E 30 6C A0 03 02 01 05 A1 03 02 01 14 A2 4F 30 4D A0 0A 04 08 6B 72 62 35 64 61 74 61 A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A2 05 02 03 01 E2 40 A3 03 02 01 11 A4 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 A5 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 A3 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34",decode_krb5_safe,ktest_equal_safe,krb5_free_safe);
+ setup(krb5_safe,"krb5_safe",ktest_make_sample_safe);
+ decode_run("safe","","74 6E 30 6C A0 03 02 01 05 A1 03 02 01 14 A2 4F 30 4D A0 0A 04 08 6B 72 62 35 64 61 74 61 A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A2 05 02 03 01 E2 40 A3 03 02 01 11 A4 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 A5 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 A3 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34",decode_krb5_safe,ktest_equal_safe,krb5_free_safe);
- ref.timestamp = 0;
- ref.usec = 0;
- ref.seq_number = 0;
- ktest_destroy_address(&(ref.r_address));
- decode_run("safe","(optionals NULL)","74 3E 30 3C A0 03 02 01 05 A1 03 02 01 14 A2 1F 30 1D A0 0A 04 08 6B 72 62 35 64 61 74 61 A4 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 A3 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34",decode_krb5_safe,ktest_equal_safe,krb5_free_safe);
+ ref.timestamp = 0;
+ ref.usec = 0;
+ ref.seq_number = 0;
+ ktest_destroy_address(&(ref.r_address));
+ decode_run("safe","(optionals NULL)","74 3E 30 3C A0 03 02 01 05 A1 03 02 01 14 A2 1F 30 1D A0 0A 04 08 6B 72 62 35 64 61 74 61 A4 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 A3 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34",decode_krb5_safe,ktest_equal_safe,krb5_free_safe);
- ktest_empty_safe(&ref);
+ ktest_empty_safe(&ref);
}
/****************************************************************/
/* decode_krb5_priv */
{
- setup(krb5_priv,"krb5_priv",ktest_make_sample_priv);
- decode_run("priv","","75 33 30 31 A0 03 02 01 05 A1 03 02 01 15 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_priv,ktest_equal_priv,krb5_free_priv);
- ktest_empty_priv(&ref);
+ setup(krb5_priv,"krb5_priv",ktest_make_sample_priv);
+ decode_run("priv","","75 33 30 31 A0 03 02 01 05 A1 03 02 01 15 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_priv,ktest_equal_priv,krb5_free_priv);
+ ktest_empty_priv(&ref);
}
/****************************************************************/
/* decode_krb5_enc_priv_part */
{
- setup(krb5_priv_enc_part,"krb5_priv_enc_part",ktest_make_sample_priv_enc_part);
- decode_run("enc_priv_part","","7C 4F 30 4D A0 0A 04 08 6B 72 62 35 64 61 74 61 A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A2 05 02 03 01 E2 40 A3 03 02 01 11 A4 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 A5 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23",decode_krb5_enc_priv_part,ktest_equal_enc_priv_part,krb5_free_priv_enc_part);
+ setup(krb5_priv_enc_part,"krb5_priv_enc_part",ktest_make_sample_priv_enc_part);
+ decode_run("enc_priv_part","","7C 4F 30 4D A0 0A 04 08 6B 72 62 35 64 61 74 61 A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A2 05 02 03 01 E2 40 A3 03 02 01 11 A4 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 A5 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23",decode_krb5_enc_priv_part,ktest_equal_enc_priv_part,krb5_free_priv_enc_part);
- ref.timestamp = 0;
- ref.usec = 0;
- ref.seq_number = 0;
- ktest_destroy_address(&(ref.r_address));
- decode_run("enc_priv_part","(optionals NULL)","7C 1F 30 1D A0 0A 04 08 6B 72 62 35 64 61 74 61 A4 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23",decode_krb5_enc_priv_part,ktest_equal_enc_priv_part,krb5_free_priv_enc_part);
- ktest_empty_priv_enc_part(&ref);
+ ref.timestamp = 0;
+ ref.usec = 0;
+ ref.seq_number = 0;
+ ktest_destroy_address(&(ref.r_address));
+ decode_run("enc_priv_part","(optionals NULL)","7C 1F 30 1D A0 0A 04 08 6B 72 62 35 64 61 74 61 A4 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23",decode_krb5_enc_priv_part,ktest_equal_enc_priv_part,krb5_free_priv_enc_part);
+ ktest_empty_priv_enc_part(&ref);
}
/****************************************************************/
/* decode_krb5_cred */
{
- setup(krb5_cred,"krb5_cred",ktest_make_sample_cred);
- decode_run("cred","","76 81 F6 30 81 F3 A0 03 02 01 05 A1 03 02 01 16 A2 81 BF 30 81 BC 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_cred,ktest_equal_cred,krb5_free_cred);
- ktest_empty_cred(&ref);
+ setup(krb5_cred,"krb5_cred",ktest_make_sample_cred);
+ decode_run("cred","","76 81 F6 30 81 F3 A0 03 02 01 05 A1 03 02 01 16 A2 81 BF 30 81 BC 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_cred,ktest_equal_cred,krb5_free_cred);
+ ktest_empty_cred(&ref);
}
/****************************************************************/
/* decode_krb5_enc_cred_part */
{
- setup(krb5_cred_enc_part,"krb5_cred_enc_part",ktest_make_sample_cred_enc_part);
- decode_run("enc_cred_part","","7D 82 02 23 30 82 02 1F A0 82 01 DA 30 82 01 D6 30 81 E8 A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 07 03 05 00 FE DC BA 98 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A8 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A9 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 AA 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 81 E8 A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 07 03 05 00 FE DC BA 98 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A8 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A9 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 AA 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 A1 03 02 01 2A A2 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A3 05 02 03 01 E2 40 A4 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 A5 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23",decode_krb5_enc_cred_part,ktest_equal_enc_cred_part,krb5_free_cred_enc_part);
- /* free_cred_enc_part does not free the pointer */
- free(var);
- ktest_destroy_principal(&(ref.ticket_info[0]->client));
- ktest_destroy_principal(&(ref.ticket_info[0]->server));
- ref.ticket_info[0]->flags = 0;
- ref.ticket_info[0]->times.authtime = 0;
- ref.ticket_info[0]->times.starttime = 0;
- ref.ticket_info[0]->times.endtime = 0;
- ref.ticket_info[0]->times.renew_till = 0;
- ktest_destroy_addresses(&(ref.ticket_info[0]->caddrs));
- ref.nonce = 0;
- ref.timestamp = 0;
- ref.usec = 0;
- ktest_destroy_address(&(ref.s_address));
- ktest_destroy_address(&(ref.r_address));
- decode_run("enc_cred_part","(optionals NULL)","7D 82 01 0E 30 82 01 0A A0 82 01 06 30 82 01 02 30 15 A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 30 81 E8 A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 07 03 05 00 FE DC BA 98 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A8 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A9 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 AA 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23",decode_krb5_enc_cred_part,ktest_equal_enc_cred_part,krb5_free_cred_enc_part);
- /* free_cred_enc_part does not free the pointer */
- free(var);
-
- ktest_empty_cred_enc_part(&ref);
+ setup(krb5_cred_enc_part,"krb5_cred_enc_part",ktest_make_sample_cred_enc_part);
+ decode_run("enc_cred_part","","7D 82 02 23 30 82 02 1F A0 82 01 DA 30 82 01 D6 30 81 E8 A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 07 03 05 00 FE DC BA 98 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A8 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A9 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 AA 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 81 E8 A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 07 03 05 00 FE DC BA 98 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A8 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A9 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 AA 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 A1 03 02 01 2A A2 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A3 05 02 03 01 E2 40 A4 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 A5 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23",decode_krb5_enc_cred_part,ktest_equal_enc_cred_part,krb5_free_cred_enc_part);
+ /* free_cred_enc_part does not free the pointer */
+ free(var);
+ ktest_destroy_principal(&(ref.ticket_info[0]->client));
+ ktest_destroy_principal(&(ref.ticket_info[0]->server));
+ ref.ticket_info[0]->flags = 0;
+ ref.ticket_info[0]->times.authtime = 0;
+ ref.ticket_info[0]->times.starttime = 0;
+ ref.ticket_info[0]->times.endtime = 0;
+ ref.ticket_info[0]->times.renew_till = 0;
+ ktest_destroy_addresses(&(ref.ticket_info[0]->caddrs));
+ ref.nonce = 0;
+ ref.timestamp = 0;
+ ref.usec = 0;
+ ktest_destroy_address(&(ref.s_address));
+ ktest_destroy_address(&(ref.r_address));
+ decode_run("enc_cred_part","(optionals NULL)","7D 82 01 0E 30 82 01 0A A0 82 01 06 30 82 01 02 30 15 A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 30 81 E8 A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 07 03 05 00 FE DC BA 98 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A8 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A9 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 AA 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23",decode_krb5_enc_cred_part,ktest_equal_enc_cred_part,krb5_free_cred_enc_part);
+ /* free_cred_enc_part does not free the pointer */
+ free(var);
+
+ ktest_empty_cred_enc_part(&ref);
}
/****************************************************************/
/* decode_krb5_error */
{
- setup(krb5_error,"krb5_error",ktest_make_sample_error);
- decode_run("error","","7E 81 BA 30 81 B7 A0 03 02 01 05 A1 03 02 01 1E A2 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A3 05 02 03 01 E2 40 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 05 02 03 01 E2 40 A6 03 02 01 3C A7 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A8 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A9 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 AA 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 AB 0A 1B 08 6B 72 62 35 64 61 74 61 AC 0A 04 08 6B 72 62 35 64 61 74 61",decode_krb5_error,ktest_equal_error,krb5_free_error);
+ setup(krb5_error,"krb5_error",ktest_make_sample_error);
+ decode_run("error","","7E 81 BA 30 81 B7 A0 03 02 01 05 A1 03 02 01 1E A2 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A3 05 02 03 01 E2 40 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 05 02 03 01 E2 40 A6 03 02 01 3C A7 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A8 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A9 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 AA 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 AB 0A 1B 08 6B 72 62 35 64 61 74 61 AC 0A 04 08 6B 72 62 35 64 61 74 61",decode_krb5_error,ktest_equal_error,krb5_free_error);
- ref.ctime = 0;
- ktest_destroy_principal(&(ref.client));
- ktest_empty_data(&(ref.text));
- ktest_empty_data(&(ref.e_data));
- decode_run("error","(optionals NULL)","7E 60 30 5E A0 03 02 01 05 A1 03 02 01 1E A3 05 02 03 01 E2 40 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 05 02 03 01 E2 40 A6 03 02 01 3C A9 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 AA 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61",decode_krb5_error,ktest_equal_error,krb5_free_error);
+ ref.ctime = 0;
+ ktest_destroy_principal(&(ref.client));
+ ktest_empty_data(&(ref.text));
+ ktest_empty_data(&(ref.e_data));
+ decode_run("error","(optionals NULL)","7E 60 30 5E A0 03 02 01 05 A1 03 02 01 1E A3 05 02 03 01 E2 40 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 05 02 03 01 E2 40 A6 03 02 01 3C A9 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 AA 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61",decode_krb5_error,ktest_equal_error,krb5_free_error);
- ktest_empty_error(&ref);
+ ktest_empty_error(&ref);
}
/****************************************************************/
/* decode_krb5_authdata */
{
- krb5_authdata **ref, **var;
- retval = ktest_make_sample_authorization_data(&ref);
- if (retval) {
- com_err("making sample authorization_data",retval,"");
- exit(1);
- }
- retval = krb5_data_hex_parse(&code,"30 22 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72");
- if (retval) {
- com_err("parsing authorization_data",retval,"");
- exit(1);
- }
- retval = decode_krb5_authdata(&code,&var);
- if (retval) com_err("decoding authorization_data",retval,"");
- test(ktest_equal_authorization_data(ref,var),"authorization_data\n")
- krb5_free_data_contents(test_context, &code);
- krb5_free_authdata(test_context, var);
- ktest_destroy_authorization_data(&ref);
+ krb5_authdata **ref, **var;
+ retval = ktest_make_sample_authorization_data(&ref);
+ if (retval) {
+ com_err("making sample authorization_data",retval,"");
+ exit(1);
+ }
+ retval = krb5_data_hex_parse(&code,"30 22 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72");
+ if (retval) {
+ com_err("parsing authorization_data",retval,"");
+ exit(1);
+ }
+ retval = decode_krb5_authdata(&code,&var);
+ if (retval) com_err("decoding authorization_data",retval,"");
+ test(ktest_equal_authorization_data(ref,var),"authorization_data\n")
+ krb5_free_data_contents(test_context, &code);
+ krb5_free_authdata(test_context, var);
+ ktest_destroy_authorization_data(&ref);
}
/****************************************************************/
/* decode_pwd_sequence */
{
- setup(passwd_phrase_element,"passwd_phrase_element",ktest_make_sample_passwd_phrase_element);
- decode_run("PasswdSequence","","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",decode_krb5_pwd_sequence,ktest_equal_passwd_phrase_element,krb5_ktest_free_pwd_sequence);
- ktest_empty_passwd_phrase_element(&ref);
+ setup(passwd_phrase_element,"passwd_phrase_element",ktest_make_sample_passwd_phrase_element);
+ decode_run("PasswdSequence","","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",decode_krb5_pwd_sequence,ktest_equal_passwd_phrase_element,krb5_ktest_free_pwd_sequence);
+ ktest_empty_passwd_phrase_element(&ref);
}
/****************************************************************/
/* decode_passwd_data */
{
- setup(krb5_pwd_data,"krb5_pwd_data",ktest_make_sample_krb5_pwd_data);
- decode_run("PasswdData","","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",decode_krb5_pwd_data,ktest_equal_krb5_pwd_data,krb5_free_pwd_data);
- ktest_empty_pwd_data(&ref);
+ setup(krb5_pwd_data,"krb5_pwd_data",ktest_make_sample_krb5_pwd_data);
+ decode_run("PasswdData","","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",decode_krb5_pwd_data,ktest_equal_krb5_pwd_data,krb5_free_pwd_data);
+ ktest_empty_pwd_data(&ref);
}
/****************************************************************/
/* decode_krb5_padata_sequence */
{
- krb5_pa_data **ref, **var;
- retval = ktest_make_sample_pa_data_array(&ref);
- if (retval) {
- com_err("making sample pa_data array",retval,"");
- exit(1);
- }
- retval = krb5_data_hex_parse(&code,"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");
- if (retval) {
- com_err("parsing padata_sequence",retval,"");
- exit(1);
- }
- retval = decode_krb5_padata_sequence(&code,&var);
- if (retval) com_err("decoding padata_sequence",retval,"");
- test(ktest_equal_sequence_of_pa_data(ref,var),"pa_data\n");
- krb5_free_pa_data(test_context, var);
- krb5_free_data_contents(test_context, &code);
- ktest_destroy_pa_data_array(&ref);
+ krb5_pa_data **ref, **var;
+ retval = ktest_make_sample_pa_data_array(&ref);
+ if (retval) {
+ com_err("making sample pa_data array",retval,"");
+ exit(1);
+ }
+ retval = krb5_data_hex_parse(&code,"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");
+ if (retval) {
+ com_err("parsing padata_sequence",retval,"");
+ exit(1);
+ }
+ retval = decode_krb5_padata_sequence(&code,&var);
+ if (retval) com_err("decoding padata_sequence",retval,"");
+ test(ktest_equal_sequence_of_pa_data(ref,var),"pa_data\n");
+ krb5_free_pa_data(test_context, var);
+ krb5_free_data_contents(test_context, &code);
+ ktest_destroy_pa_data_array(&ref);
}
/****************************************************************/
/* decode_krb5_padata_sequence (empty) */
{
- krb5_pa_data **ref, **var;
- retval = ktest_make_sample_empty_pa_data_array(&ref);
- if (retval) {
- com_err("making sample empty pa_data array",retval,"");
- exit(1);
- }
- retval = krb5_data_hex_parse(&code,"30 00");
- if (retval) {
- com_err("parsing padata_sequence (empty)",retval,"");
- exit(1);
- }
- retval = decode_krb5_padata_sequence(&code,&var);
- if (retval) com_err("decoding padata_sequence (empty)",retval,"");
- test(ktest_equal_sequence_of_pa_data(ref,var),"pa_data (empty)\n");
- krb5_free_pa_data(test_context, var);
- krb5_free_data_contents(test_context, &code);
- ktest_destroy_pa_data_array(&ref);
+ krb5_pa_data **ref, **var;
+ retval = ktest_make_sample_empty_pa_data_array(&ref);
+ if (retval) {
+ com_err("making sample empty pa_data array",retval,"");
+ exit(1);
+ }
+ retval = krb5_data_hex_parse(&code,"30 00");
+ if (retval) {
+ com_err("parsing padata_sequence (empty)",retval,"");
+ exit(1);
+ }
+ retval = decode_krb5_padata_sequence(&code,&var);
+ if (retval) com_err("decoding padata_sequence (empty)",retval,"");
+ test(ktest_equal_sequence_of_pa_data(ref,var),"pa_data (empty)\n");
+ krb5_free_pa_data(test_context, var);
+ krb5_free_data_contents(test_context, &code);
+ ktest_destroy_pa_data_array(&ref);
}
/****************************************************************/
/* 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,krb5_ktest_free_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,krb5_ktest_free_alt_method);
- ktest_empty_alt_method(&ref);
+ 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,krb5_ktest_free_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,krb5_ktest_free_alt_method);
+ ktest_empty_alt_method(&ref);
}
/****************************************************************/
/* 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");
- }
- test(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;
- krb5_free_data_contents(test_context, &code);
-
- 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)");
- }
- test(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;
- krb5_free_data_contents(test_context, &code);
-
- 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)");
- }
- test(ktest_equal_etype_info(ref,var),"etype_info (no info)\n");
-
- krb5_free_data_contents(test_context, &code);
- ktest_destroy_etype_info(var);
- ktest_destroy_etype_info(ref);
+ 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");
+ }
+ test(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;
+ krb5_free_data_contents(test_context, &code);
+
+ 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)");
+ }
+ test(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;
+ krb5_free_data_contents(test_context, &code);
+
+ 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)");
+ }
+ test(ktest_equal_etype_info(ref,var),"etype_info (no info)\n");
+
+ krb5_free_data_contents(test_context, &code);
+ ktest_destroy_etype_info(var);
+ ktest_destroy_etype_info(ref);
}
/****************************************************************/
/* decode_pa_enc_ts */
{
- setup(krb5_pa_enc_ts,"krb5_pa_enc_ts",ktest_make_sample_pa_enc_ts);
- decode_run("pa_enc_ts","","30 1A A0 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A1 05 02 03 01 E2 40",decode_krb5_pa_enc_ts,ktest_equal_krb5_pa_enc_ts,krb5_free_pa_enc_ts);
- ref.pausec = 0;
- decode_run("pa_enc_ts (no usec)","","30 13 A0 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_pa_enc_ts,ktest_equal_krb5_pa_enc_ts,krb5_free_pa_enc_ts);
+ setup(krb5_pa_enc_ts,"krb5_pa_enc_ts",ktest_make_sample_pa_enc_ts);
+ decode_run("pa_enc_ts","","30 1A A0 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A1 05 02 03 01 E2 40",decode_krb5_pa_enc_ts,ktest_equal_krb5_pa_enc_ts,krb5_free_pa_enc_ts);
+ ref.pausec = 0;
+ decode_run("pa_enc_ts (no usec)","","30 13 A0 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_pa_enc_ts,ktest_equal_krb5_pa_enc_ts,krb5_free_pa_enc_ts);
}
/****************************************************************/
/* decode_enc_data */
{
- setup(krb5_enc_data,"krb5_enc_data",ktest_make_sample_enc_data);
- decode_run("enc_data","","30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_enc_data,ktest_equal_enc_data,krb5_ktest_free_enc_data);
- ktest_destroy_enc_data(&ref);
+ setup(krb5_enc_data,"krb5_enc_data",ktest_make_sample_enc_data);
+ decode_run("enc_data","","30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_enc_data,ktest_equal_enc_data,krb5_ktest_free_enc_data);
+ ktest_destroy_enc_data(&ref);
}
/****************************************************************/
/* decode_sam_challenge */
{
- setup(krb5_sam_challenge,"krb5_sam_challenge",ktest_make_sample_sam_challenge);
- decode_run("sam_challenge","","30 78 A0 03 02 01 2A A1 07 03 05 00 80 00 00 00 A2 0B 04 09 74 79 70 65 20 6E 61 6D 65 A3 02 04 00 A4 11 04 0F 63 68 61 6C 6C 65 6E 67 65 20 6C 61 62 65 6C A5 10 04 0E 63 68 61 6C 6C 65 6E 67 65 20 69 70 73 65 A6 16 04 14 72 65 73 70 6F 6E 73 65 5F 70 72 6F 6D 70 74 20 69 70 73 65 A7 02 04 00 A8 05 02 03 54 32 10 A9 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34",decode_krb5_sam_challenge,ktest_equal_sam_challenge,krb5_free_sam_challenge);
- ktest_empty_sam_challenge(&ref);
+ setup(krb5_sam_challenge,"krb5_sam_challenge",ktest_make_sample_sam_challenge);
+ decode_run("sam_challenge","","30 78 A0 03 02 01 2A A1 07 03 05 00 80 00 00 00 A2 0B 04 09 74 79 70 65 20 6E 61 6D 65 A3 02 04 00 A4 11 04 0F 63 68 61 6C 6C 65 6E 67 65 20 6C 61 62 65 6C A5 10 04 0E 63 68 61 6C 6C 65 6E 67 65 20 69 70 73 65 A6 16 04 14 72 65 73 70 6F 6E 73 65 5F 70 72 6F 6D 70 74 20 69 70 73 65 A7 02 04 00 A8 05 02 03 54 32 10 A9 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34",decode_krb5_sam_challenge,ktest_equal_sam_challenge,krb5_free_sam_challenge);
+ ktest_empty_sam_challenge(&ref);
}
/****************************************************************/
/* decode_sam_challenge */
{
- setup(krb5_sam_challenge,"krb5_sam_challenge - no optionals",ktest_make_sample_sam_challenge);
- decode_run("sam_challenge","","30 70 A0 03 02 01 2A A1 07 03 05 00 80 00 00 00 A2 0B 04 09 74 79 70 65 20 6E 61 6D 65 A4 11 04 0F 63 68 61 6C 6C 65 6E 67 65 20 6C 61 62 65 6C A5 10 04 0E 63 68 61 6C 6C 65 6E 67 65 20 69 70 73 65 A6 16 04 14 72 65 73 70 6F 6E 73 65 5F 70 72 6F 6D 70 74 20 69 70 73 65 A8 05 02 03 54 32 10 A9 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34",decode_krb5_sam_challenge,ktest_equal_sam_challenge,krb5_free_sam_challenge);
- ktest_empty_sam_challenge(&ref);
+ setup(krb5_sam_challenge,"krb5_sam_challenge - no optionals",ktest_make_sample_sam_challenge);
+ decode_run("sam_challenge","","30 70 A0 03 02 01 2A A1 07 03 05 00 80 00 00 00 A2 0B 04 09 74 79 70 65 20 6E 61 6D 65 A4 11 04 0F 63 68 61 6C 6C 65 6E 67 65 20 6C 61 62 65 6C A5 10 04 0E 63 68 61 6C 6C 65 6E 67 65 20 69 70 73 65 A6 16 04 14 72 65 73 70 6F 6E 73 65 5F 70 72 6F 6D 70 74 20 69 70 73 65 A8 05 02 03 54 32 10 A9 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34",decode_krb5_sam_challenge,ktest_equal_sam_challenge,krb5_free_sam_challenge);
+ ktest_empty_sam_challenge(&ref);
}
/****************************************************************/
/* decode_sam_response */
{
- setup(krb5_sam_response,"krb5_sam_response",ktest_make_sample_sam_response);
- decode_run("sam_response","","30 6A A0 03 02 01 2A A1 07 03 05 00 80 00 00 00 A2 0C 04 0A 74 72 61 63 6B 20 64 61 74 61 A3 14 30 12 A0 03 02 01 01 A1 04 02 02 07 96 A2 05 04 03 6B 65 79 A4 1C 30 1A A0 03 02 01 01 A1 04 02 02 0D 36 A2 0D 04 0B 6E 6F 6E 63 65 20 6F 72 20 74 73 A5 05 02 03 54 32 10 A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_sam_response,ktest_equal_sam_response,krb5_free_sam_response);
+ setup(krb5_sam_response,"krb5_sam_response",ktest_make_sample_sam_response);
+ decode_run("sam_response","","30 6A A0 03 02 01 2A A1 07 03 05 00 80 00 00 00 A2 0C 04 0A 74 72 61 63 6B 20 64 61 74 61 A3 14 30 12 A0 03 02 01 01 A1 04 02 02 07 96 A2 05 04 03 6B 65 79 A4 1C 30 1A A0 03 02 01 01 A1 04 02 02 0D 36 A2 0D 04 0B 6E 6F 6E 63 65 20 6F 72 20 74 73 A5 05 02 03 54 32 10 A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_sam_response,ktest_equal_sam_response,krb5_free_sam_response);
- ktest_empty_sam_response(&ref);
+ ktest_empty_sam_response(&ref);
}
/****************************************************************/
/* decode_pa_s4u_x509_user */
{
- setup(krb5_pa_s4u_x509_user,"krb5_pa_s4u_x509_user",ktest_make_sample_pa_s4u_x509_user);
- decode_run("pa_s4u_x509_user","","30 68 A0 55 30 53 A0 06 02 04 00 CA 14 9A A1 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 12 04 10 70 61 5F 73 34 75 5F 78 35 30 39 5F 75 73 65 72 A4 07 03 05 00 80 00 00 00 A1 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34",decode_krb5_pa_s4u_x509_user,ktest_equal_pa_s4u_x509_user,krb5_free_pa_s4u_x509_user);
- ktest_empty_pa_s4u_x509_user(&ref);
+ setup(krb5_pa_s4u_x509_user,"krb5_pa_s4u_x509_user",ktest_make_sample_pa_s4u_x509_user);
+ decode_run("pa_s4u_x509_user","","30 68 A0 55 30 53 A0 06 02 04 00 CA 14 9A A1 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 12 04 10 70 61 5F 73 34 75 5F 78 35 30 39 5F 75 73 65 72 A4 07 03 05 00 80 00 00 00 A1 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34",decode_krb5_pa_s4u_x509_user,ktest_equal_pa_s4u_x509_user,krb5_free_pa_s4u_x509_user);
+ ktest_empty_pa_s4u_x509_user(&ref);
}
/****************************************************************/
/* decode_ad_kdcissued */
{
- setup(krb5_ad_kdcissued,"krb5_ad_kdcissued",ktest_make_sample_ad_kdcissued);
- decode_run("ad_kdcissued","","30 65 A0 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 24 30 22 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72",decode_krb5_ad_kdcissued,ktest_equal_ad_kdcissued,krb5_free_ad_kdcissued);
- ktest_empty_ad_kdcissued(&ref);
+ setup(krb5_ad_kdcissued,"krb5_ad_kdcissued",ktest_make_sample_ad_kdcissued);
+ decode_run("ad_kdcissued","","30 65 A0 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 24 30 22 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72",decode_krb5_ad_kdcissued,ktest_equal_ad_kdcissued,krb5_free_ad_kdcissued);
+ ktest_empty_ad_kdcissued(&ref);
}
/****************************************************************/
/* decode_ad_signedpath */
{
- setup(krb5_ad_signedpath,"krb5_ad_signedpath",ktest_make_sample_ad_signedpath);
- decode_run("ad_signedpath","","30 3E A0 03 02 01 01 A1 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34 A3 26 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",decode_krb5_ad_signedpath,ktest_equal_ad_signedpath,krb5_free_ad_signedpath);
- ktest_empty_ad_signedpath(&ref);
+ setup(krb5_ad_signedpath,"krb5_ad_signedpath",ktest_make_sample_ad_signedpath);
+ decode_run("ad_signedpath","","30 3E A0 03 02 01 01 A1 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34 A3 26 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",decode_krb5_ad_signedpath,ktest_equal_ad_signedpath,krb5_free_ad_signedpath);
+ ktest_empty_ad_signedpath(&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);
- ktest_empty_ldap_seqof_key_data(test_context, &ref);
+ 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);
+ ktest_empty_ldap_seqof_key_data(test_context, &ref);
}
#endif
void krb5_ktest_free_alt_method(krb5_context context, krb5_alt_method *val)
{
if (val->data)
- free(val->data);
+ free(val->data);
free(val);
}
void krb5_ktest_free_pwd_sequence(krb5_context context,
- passwd_phrase_element *val)
+ passwd_phrase_element *val)
{
krb5_free_data(context, val->passwd);
krb5_free_data(context, val->phrase);
void krb5_ktest_free_enc_data(krb5_context context, krb5_enc_data *val)
{
if (val) {
- krb5_free_data_contents(context, &(val->ciphertext));
- free(val);
+ krb5_free_data_contents(context, &(val->ciphertext));
+ free(val);
}
}
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#include <stdio.h>
#include "k5-int.h"
#include "com_err.h"
static void encoder_print_results(code, typestring, description)
krb5_data *code;
- char *typestring;
- char *description;
+ char *typestring;
+ char *description;
{
- char *code_string = NULL;
- krb5_error_code retval;
+ char *code_string = NULL;
+ krb5_error_code retval;
int r, rlen;
if (do_trval) {
- printf("encode_krb5_%s%s:\n", typestring, description);
- r = trval2(stdout, code->data, code->length, 0, &rlen);
- printf("\n\n");
- if (rlen < 0 || (unsigned int) rlen != code->length) {
- printf("Error: length mismatch: was %d, parsed %d\n",
- code->length, rlen);
- exit(1);
- }
- if (r != 0) {
- printf("Error: Return from trval2 is %d.\n", r);
- exit(1);
- }
- current_appl_type = -1; /* Reset type */
+ printf("encode_krb5_%s%s:\n", typestring, description);
+ r = trval2(stdout, code->data, code->length, 0, &rlen);
+ printf("\n\n");
+ if (rlen < 0 || (unsigned int) rlen != code->length) {
+ printf("Error: length mismatch: was %d, parsed %d\n",
+ code->length, rlen);
+ exit(1);
+ }
+ if (r != 0) {
+ printf("Error: Return from trval2 is %d.\n", r);
+ exit(1);
+ }
+ current_appl_type = -1; /* Reset type */
} else {
- retval = asn1_krb5_data_unparse(code,&(code_string));
- if (retval) {
- com_err("krb5_encode_test", retval ,
- "while unparsing %s", typestring);
- exit(1);
- }
- printf("encode_krb5_%s%s: %s\n", typestring, description,
- code_string);
- free(code_string);
+ retval = asn1_krb5_data_unparse(code,&(code_string));
+ if (retval) {
+ com_err("krb5_encode_test", retval ,
+ "while unparsing %s", typestring);
+ exit(1);
+ }
+ printf("encode_krb5_%s%s: %s\n", typestring, description,
+ code_string);
+ free(code_string);
}
ktest_destroy_data(&code);
}
static void PRS(argc, argv)
- int argc;
- char **argv;
+ int argc;
+ char **argv;
{
extern char *optarg;
int optchar;
extern int print_types, print_krb5_types, print_id_and_len,
- print_constructed_length, print_skip_context,
- print_skip_tagnum, print_context_shortcut;
+ print_constructed_length, print_skip_context,
+ print_skip_tagnum, print_context_shortcut;
while ((optchar = getopt(argc, argv, "tp:")) != -1) {
- switch(optchar) {
- case 't':
- do_trval = 1;
- break;
- case 'p':
- sample_principal_name = optarg;
- break;
- case '?':
- default:
- fprintf(stderr, "Usage: %s [-t] [-p principal]\n",
- argv[0]);
- exit(1);
- }
+ switch(optchar) {
+ case 't':
+ do_trval = 1;
+ break;
+ case 'p':
+ sample_principal_name = optarg;
+ break;
+ case '?':
+ default:
+ fprintf(stderr, "Usage: %s [-t] [-p principal]\n",
+ argv[0]);
+ exit(1);
+ }
}
print_types = 1;
print_krb5_types = 1;
int
main(argc, argv)
- int argc;
- char **argv;
+ int argc;
+ char **argv;
{
krb5_data *code;
krb5_error_code retval;
retval = krb5_init_context(&test_context);
if (retval) {
- com_err(argv[0], retval, "while initializing krb5");
- exit(1);
+ com_err(argv[0], retval, "while initializing krb5");
+ exit(1);
}
init_access(argv[0]);
-#define setup(value,type,typestring,constructor) \
- retval = constructor(&(value)); \
- if (retval) { \
- com_err("krb5_encode_test", retval, "while making sample %s", typestring); \
- exit(1); \
+#define setup(value,type,typestring,constructor) \
+ retval = constructor(&(value)); \
+ if (retval) { \
+ com_err("krb5_encode_test", retval, "while making sample %s", typestring); \
+ exit(1); \
}
-#define encode_run(value,type,typestring,description,encoder) \
- retval = encoder(&(value),&(code)); \
- if (retval) { \
- com_err("krb5_encode_test", retval,"while encoding %s", typestring); \
- exit(1); \
- } \
+#define encode_run(value,type,typestring,description,encoder) \
+ retval = encoder(&(value),&(code)); \
+ if (retval) { \
+ com_err("krb5_encode_test", retval,"while encoding %s", typestring); \
+ exit(1); \
+ } \
encoder_print_results(code, typestring, description);
/****************************************************************/
/* encode_krb5_authenticator */
{
- krb5_authenticator authent;
- setup(authent,authenticator,"authenticator",ktest_make_sample_authenticator);
+ krb5_authenticator authent;
+ setup(authent,authenticator,"authenticator",ktest_make_sample_authenticator);
- encode_run(authent,authenticator,"authenticator","",encode_krb5_authenticator);
+ encode_run(authent,authenticator,"authenticator","",encode_krb5_authenticator);
- ktest_destroy_checksum(&(authent.checksum));
- ktest_destroy_keyblock(&(authent.subkey));
- authent.seq_number = 0;
- ktest_empty_authorization_data(authent.authorization_data);
- encode_run(authent,authenticator,"authenticator","(optionals empty)",encode_krb5_authenticator);
+ ktest_destroy_checksum(&(authent.checksum));
+ ktest_destroy_keyblock(&(authent.subkey));
+ authent.seq_number = 0;
+ ktest_empty_authorization_data(authent.authorization_data);
+ encode_run(authent,authenticator,"authenticator","(optionals empty)",encode_krb5_authenticator);
- ktest_destroy_authorization_data(&(authent.authorization_data));
- encode_run(authent,authenticator,"authenticator","(optionals NULL)",encode_krb5_authenticator);
- ktest_empty_authenticator(&authent);
+ ktest_destroy_authorization_data(&(authent.authorization_data));
+ encode_run(authent,authenticator,"authenticator","(optionals NULL)",encode_krb5_authenticator);
+ ktest_empty_authenticator(&authent);
}
/****************************************************************/
/* encode_krb5_ticket */
{
- krb5_ticket tkt;
- setup(tkt,ticket,"ticket",ktest_make_sample_ticket);
- encode_run(tkt,ticket,"ticket","",encode_krb5_ticket);
- ktest_empty_ticket(&tkt);
+ krb5_ticket tkt;
+ setup(tkt,ticket,"ticket",ktest_make_sample_ticket);
+ encode_run(tkt,ticket,"ticket","",encode_krb5_ticket);
+ ktest_empty_ticket(&tkt);
}
/****************************************************************/
/* encode_krb5_encryption_key */
{
- krb5_keyblock keyblk;
- setup(keyblk,keyblock,"keyblock",ktest_make_sample_keyblock);
- current_appl_type = 1005;
- encode_run(keyblk,keyblock,"keyblock","",encode_krb5_encryption_key);
- ktest_empty_keyblock(&keyblk);
+ krb5_keyblock keyblk;
+ setup(keyblk,keyblock,"keyblock",ktest_make_sample_keyblock);
+ current_appl_type = 1005;
+ encode_run(keyblk,keyblock,"keyblock","",encode_krb5_encryption_key);
+ ktest_empty_keyblock(&keyblk);
}
/****************************************************************/
/* encode_krb5_enc_tkt_part */
{
- krb5_ticket tkt;
- memset(&tkt, 0, sizeof(krb5_ticket));
- tkt.enc_part2 = (krb5_enc_tkt_part*)calloc(1,sizeof(krb5_enc_tkt_part));
- if (tkt.enc_part2 == NULL) com_err("allocating enc_tkt_part",errno,"");
- setup(*(tkt.enc_part2),enc_tkt_part,"enc_tkt_part",ktest_make_sample_enc_tkt_part);
+ krb5_ticket tkt;
+ memset(&tkt, 0, sizeof(krb5_ticket));
+ tkt.enc_part2 = (krb5_enc_tkt_part*)calloc(1,sizeof(krb5_enc_tkt_part));
+ if (tkt.enc_part2 == NULL) com_err("allocating enc_tkt_part",errno,"");
+ setup(*(tkt.enc_part2),enc_tkt_part,"enc_tkt_part",ktest_make_sample_enc_tkt_part);
- encode_run(*(tkt.enc_part2),enc_tkt_part,"enc_tkt_part","",encode_krb5_enc_tkt_part);
+ encode_run(*(tkt.enc_part2),enc_tkt_part,"enc_tkt_part","",encode_krb5_enc_tkt_part);
- tkt.enc_part2->times.starttime = 0;
- tkt.enc_part2->times.renew_till = 0;
- ktest_destroy_address(&(tkt.enc_part2->caddrs[1]));
- ktest_destroy_address(&(tkt.enc_part2->caddrs[0]));
- ktest_destroy_authdata(&(tkt.enc_part2->authorization_data[1]));
- ktest_destroy_authdata(&(tkt.enc_part2->authorization_data[0]));
+ tkt.enc_part2->times.starttime = 0;
+ tkt.enc_part2->times.renew_till = 0;
+ ktest_destroy_address(&(tkt.enc_part2->caddrs[1]));
+ ktest_destroy_address(&(tkt.enc_part2->caddrs[0]));
+ ktest_destroy_authdata(&(tkt.enc_part2->authorization_data[1]));
+ ktest_destroy_authdata(&(tkt.enc_part2->authorization_data[0]));
- /* ISODE version fails on the empty caddrs field */
- ktest_destroy_addresses(&(tkt.enc_part2->caddrs));
- ktest_destroy_authorization_data(&(tkt.enc_part2->authorization_data));
+ /* ISODE version fails on the empty caddrs field */
+ ktest_destroy_addresses(&(tkt.enc_part2->caddrs));
+ ktest_destroy_authorization_data(&(tkt.enc_part2->authorization_data));
- encode_run(*(tkt.enc_part2),enc_tkt_part,"enc_tkt_part","(optionals NULL)",encode_krb5_enc_tkt_part);
- ktest_empty_ticket(&tkt);
+ encode_run(*(tkt.enc_part2),enc_tkt_part,"enc_tkt_part","(optionals NULL)",encode_krb5_enc_tkt_part);
+ ktest_empty_ticket(&tkt);
}
/****************************************************************/
/* encode_krb5_enc_kdc_rep_part */
{
- krb5_kdc_rep kdcr;
+ krb5_kdc_rep kdcr;
- memset(&kdcr, 0, sizeof(kdcr));
+ memset(&kdcr, 0, sizeof(kdcr));
- kdcr.enc_part2 = (krb5_enc_kdc_rep_part*)
- calloc(1,sizeof(krb5_enc_kdc_rep_part));
- if (kdcr.enc_part2 == NULL) com_err("allocating enc_kdc_rep_part",errno,"");
- setup(*(kdcr.enc_part2),enc_kdc_rep_part,"enc_kdc_rep_part",ktest_make_sample_enc_kdc_rep_part);
+ kdcr.enc_part2 = (krb5_enc_kdc_rep_part*)
+ calloc(1,sizeof(krb5_enc_kdc_rep_part));
+ if (kdcr.enc_part2 == NULL) com_err("allocating enc_kdc_rep_part",errno,"");
+ setup(*(kdcr.enc_part2),enc_kdc_rep_part,"enc_kdc_rep_part",ktest_make_sample_enc_kdc_rep_part);
- encode_run(*(kdcr.enc_part2),enc_kdc_rep_part,"enc_kdc_rep_part","",encode_krb5_enc_kdc_rep_part);
+ encode_run(*(kdcr.enc_part2),enc_kdc_rep_part,"enc_kdc_rep_part","",encode_krb5_enc_kdc_rep_part);
- kdcr.enc_part2->key_exp = 0;
- kdcr.enc_part2->times.starttime = 0;
- kdcr.enc_part2->flags &= ~TKT_FLG_RENEWABLE;
- ktest_destroy_addresses(&(kdcr.enc_part2->caddrs));
+ kdcr.enc_part2->key_exp = 0;
+ kdcr.enc_part2->times.starttime = 0;
+ kdcr.enc_part2->flags &= ~TKT_FLG_RENEWABLE;
+ ktest_destroy_addresses(&(kdcr.enc_part2->caddrs));
- encode_run(*(kdcr.enc_part2),enc_kdc_rep_part,"enc_kdc_rep_part","(optionals NULL)",encode_krb5_enc_kdc_rep_part);
+ encode_run(*(kdcr.enc_part2),enc_kdc_rep_part,"enc_kdc_rep_part","(optionals NULL)",encode_krb5_enc_kdc_rep_part);
- ktest_empty_kdc_rep(&kdcr);
+ ktest_empty_kdc_rep(&kdcr);
}
/****************************************************************/
/* encode_krb5_as_rep */
{
- krb5_kdc_rep kdcr;
- setup(kdcr,kdc_rep,"kdc_rep",ktest_make_sample_kdc_rep);
+ krb5_kdc_rep kdcr;
+ setup(kdcr,kdc_rep,"kdc_rep",ktest_make_sample_kdc_rep);
/* kdcr.msg_type = KRB5_TGS_REP;
test(encode_krb5_as_rep(&kdcr,&code) == KRB5_BADMSGTYPE,
"encode_krb5_as_rep type check\n");
ktest_destroy_data(&code);*/
- kdcr.msg_type = KRB5_AS_REP;
- encode_run(kdcr,as_rep,"as_rep","",encode_krb5_as_rep);
+ kdcr.msg_type = KRB5_AS_REP;
+ encode_run(kdcr,as_rep,"as_rep","",encode_krb5_as_rep);
- ktest_destroy_pa_data_array(&(kdcr.padata));
- encode_run(kdcr,as_rep,"as_rep","(optionals NULL)",encode_krb5_as_rep);
+ ktest_destroy_pa_data_array(&(kdcr.padata));
+ encode_run(kdcr,as_rep,"as_rep","(optionals NULL)",encode_krb5_as_rep);
- ktest_empty_kdc_rep(&kdcr);
+ ktest_empty_kdc_rep(&kdcr);
}
/****************************************************************/
/* encode_krb5_tgs_rep */
{
- krb5_kdc_rep kdcr;
- setup(kdcr,kdc_rep,"kdc_rep",ktest_make_sample_kdc_rep);
+ krb5_kdc_rep kdcr;
+ setup(kdcr,kdc_rep,"kdc_rep",ktest_make_sample_kdc_rep);
/* kdcr.msg_type = KRB5_AS_REP;
test(encode_krb5_tgs_rep(&kdcr,&code) == KRB5_BADMSGTYPE,
"encode_krb5_tgs_rep type check\n");*/
- kdcr.msg_type = KRB5_TGS_REP;
- encode_run(kdcr,tgs_rep,"tgs_rep","",encode_krb5_tgs_rep);
+ kdcr.msg_type = KRB5_TGS_REP;
+ encode_run(kdcr,tgs_rep,"tgs_rep","",encode_krb5_tgs_rep);
- ktest_destroy_pa_data_array(&(kdcr.padata));
- encode_run(kdcr,tgs_rep,"tgs_rep","(optionals NULL)",encode_krb5_tgs_rep);
+ ktest_destroy_pa_data_array(&(kdcr.padata));
+ encode_run(kdcr,tgs_rep,"tgs_rep","(optionals NULL)",encode_krb5_tgs_rep);
- ktest_empty_kdc_rep(&kdcr);
+ ktest_empty_kdc_rep(&kdcr);
}
/****************************************************************/
/* encode_krb5_ap_req */
{
- krb5_ap_req apreq;
- setup(apreq,ap_req,"ap_req",ktest_make_sample_ap_req);
- encode_run(apreq,ap_req,"ap_req","",encode_krb5_ap_req);
- ktest_empty_ap_req(&apreq);
+ krb5_ap_req apreq;
+ setup(apreq,ap_req,"ap_req",ktest_make_sample_ap_req);
+ encode_run(apreq,ap_req,"ap_req","",encode_krb5_ap_req);
+ ktest_empty_ap_req(&apreq);
}
/****************************************************************/
/* encode_krb5_ap_rep */
{
- krb5_ap_rep aprep;
- setup(aprep,ap_rep,"ap_rep",ktest_make_sample_ap_rep);
- encode_run(aprep,ap_rep,"ap_rep","",encode_krb5_ap_rep);
- ktest_empty_ap_rep(&aprep);
+ krb5_ap_rep aprep;
+ setup(aprep,ap_rep,"ap_rep",ktest_make_sample_ap_rep);
+ encode_run(aprep,ap_rep,"ap_rep","",encode_krb5_ap_rep);
+ ktest_empty_ap_rep(&aprep);
}
/****************************************************************/
/* encode_krb5_ap_rep_enc_part */
{
- krb5_ap_rep_enc_part apenc;
- setup(apenc,ap_rep_enc_part,"ap_rep_enc_part",ktest_make_sample_ap_rep_enc_part);
- encode_run(apenc,ap_rep_enc_part,"ap_rep_enc_part","",encode_krb5_ap_rep_enc_part);
+ krb5_ap_rep_enc_part apenc;
+ setup(apenc,ap_rep_enc_part,"ap_rep_enc_part",ktest_make_sample_ap_rep_enc_part);
+ encode_run(apenc,ap_rep_enc_part,"ap_rep_enc_part","",encode_krb5_ap_rep_enc_part);
- ktest_destroy_keyblock(&(apenc.subkey));
- apenc.seq_number = 0;
- encode_run(apenc,ap_rep_enc_part,"ap_rep_enc_part","(optionals NULL)",encode_krb5_ap_rep_enc_part);
- ktest_empty_ap_rep_enc_part(&apenc);
+ ktest_destroy_keyblock(&(apenc.subkey));
+ apenc.seq_number = 0;
+ encode_run(apenc,ap_rep_enc_part,"ap_rep_enc_part","(optionals NULL)",encode_krb5_ap_rep_enc_part);
+ ktest_empty_ap_rep_enc_part(&apenc);
}
/****************************************************************/
/* encode_krb5_as_req */
{
- krb5_kdc_req asreq;
- setup(asreq,kdc_req,"kdc_req",ktest_make_sample_kdc_req);
- asreq.msg_type = KRB5_AS_REQ;
- asreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
- encode_run(asreq,as_req,"as_req","",encode_krb5_as_req);
+ krb5_kdc_req asreq;
+ setup(asreq,kdc_req,"kdc_req",ktest_make_sample_kdc_req);
+ asreq.msg_type = KRB5_AS_REQ;
+ asreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
+ encode_run(asreq,as_req,"as_req","",encode_krb5_as_req);
- ktest_destroy_pa_data_array(&(asreq.padata));
- ktest_destroy_principal(&(asreq.client));
+ ktest_destroy_pa_data_array(&(asreq.padata));
+ ktest_destroy_principal(&(asreq.client));
#ifndef ISODE_SUCKS
- ktest_destroy_principal(&(asreq.server));
+ ktest_destroy_principal(&(asreq.server));
#endif
- asreq.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY;
- asreq.from = 0;
- asreq.rtime = 0;
- ktest_destroy_addresses(&(asreq.addresses));
- ktest_destroy_enc_data(&(asreq.authorization_data));
- encode_run(asreq,as_req,"as_req","(optionals NULL except second_ticket)",encode_krb5_as_req);
- ktest_destroy_sequence_of_ticket(&(asreq.second_ticket));
+ asreq.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY;
+ asreq.from = 0;
+ asreq.rtime = 0;
+ ktest_destroy_addresses(&(asreq.addresses));
+ ktest_destroy_enc_data(&(asreq.authorization_data));
+ encode_run(asreq,as_req,"as_req","(optionals NULL except second_ticket)",encode_krb5_as_req);
+ ktest_destroy_sequence_of_ticket(&(asreq.second_ticket));
#ifndef ISODE_SUCKS
- ktest_make_sample_principal(&(asreq.server));
+ ktest_make_sample_principal(&(asreq.server));
#endif
- asreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
- encode_run(asreq,as_req,"as_req","(optionals NULL except server)",encode_krb5_as_req);
- ktest_empty_kdc_req(&asreq);
+ asreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
+ encode_run(asreq,as_req,"as_req","(optionals NULL except server)",encode_krb5_as_req);
+ ktest_empty_kdc_req(&asreq);
}
/****************************************************************/
/* encode_krb5_tgs_req */
{
- krb5_kdc_req tgsreq;
- setup(tgsreq,kdc_req,"kdc_req",ktest_make_sample_kdc_req);
- tgsreq.msg_type = KRB5_TGS_REQ;
- tgsreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
- encode_run(tgsreq,tgs_req,"tgs_req","",encode_krb5_tgs_req);
+ krb5_kdc_req tgsreq;
+ setup(tgsreq,kdc_req,"kdc_req",ktest_make_sample_kdc_req);
+ tgsreq.msg_type = KRB5_TGS_REQ;
+ tgsreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
+ encode_run(tgsreq,tgs_req,"tgs_req","",encode_krb5_tgs_req);
- ktest_destroy_pa_data_array(&(tgsreq.padata));
- ktest_destroy_principal(&(tgsreq.client));
+ ktest_destroy_pa_data_array(&(tgsreq.padata));
+ ktest_destroy_principal(&(tgsreq.client));
#ifndef ISODE_SUCKS
- ktest_destroy_principal(&(tgsreq.server));
+ ktest_destroy_principal(&(tgsreq.server));
#endif
- tgsreq.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY;
- tgsreq.from = 0;
- tgsreq.rtime = 0;
- ktest_destroy_addresses(&(tgsreq.addresses));
- ktest_destroy_enc_data(&(tgsreq.authorization_data));
- encode_run(tgsreq,tgs_req,"tgs_req","(optionals NULL except second_ticket)",encode_krb5_tgs_req);
-
- ktest_destroy_sequence_of_ticket(&(tgsreq.second_ticket));
+ tgsreq.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY;
+ tgsreq.from = 0;
+ tgsreq.rtime = 0;
+ ktest_destroy_addresses(&(tgsreq.addresses));
+ ktest_destroy_enc_data(&(tgsreq.authorization_data));
+ encode_run(tgsreq,tgs_req,"tgs_req","(optionals NULL except second_ticket)",encode_krb5_tgs_req);
+
+ ktest_destroy_sequence_of_ticket(&(tgsreq.second_ticket));
#ifndef ISODE_SUCKS
- ktest_make_sample_principal(&(tgsreq.server));
+ ktest_make_sample_principal(&(tgsreq.server));
#endif
- tgsreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
- encode_run(tgsreq,tgs_req,"tgs_req","(optionals NULL except server)",encode_krb5_tgs_req);
+ tgsreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
+ encode_run(tgsreq,tgs_req,"tgs_req","(optionals NULL except server)",encode_krb5_tgs_req);
- ktest_empty_kdc_req(&tgsreq);
+ ktest_empty_kdc_req(&tgsreq);
}
/****************************************************************/
/* encode_krb5_kdc_req_body */
{
- krb5_kdc_req kdcrb;
- memset(&kdcrb, 0, sizeof(kdcrb));
- setup(kdcrb,kdc_req_body,"kdc_req_body",ktest_make_sample_kdc_req_body);
- kdcrb.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
- current_appl_type = 1007; /* Force interpretation as kdc-req-body */
- encode_run(kdcrb,kdc_req_body,"kdc_req_body","",encode_krb5_kdc_req_body);
+ krb5_kdc_req kdcrb;
+ memset(&kdcrb, 0, sizeof(kdcrb));
+ setup(kdcrb,kdc_req_body,"kdc_req_body",ktest_make_sample_kdc_req_body);
+ kdcrb.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
+ current_appl_type = 1007; /* Force interpretation as kdc-req-body */
+ encode_run(kdcrb,kdc_req_body,"kdc_req_body","",encode_krb5_kdc_req_body);
- ktest_destroy_principal(&(kdcrb.client));
+ ktest_destroy_principal(&(kdcrb.client));
#ifndef ISODE_SUCKS
- ktest_destroy_principal(&(kdcrb.server));
+ ktest_destroy_principal(&(kdcrb.server));
#endif
- kdcrb.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY;
- kdcrb.from = 0;
- kdcrb.rtime = 0;
- ktest_destroy_addresses(&(kdcrb.addresses));
- ktest_destroy_enc_data(&(kdcrb.authorization_data));
- current_appl_type = 1007; /* Force interpretation as kdc-req-body */
- encode_run(kdcrb,kdc_req_body,"kdc_req_body","(optionals NULL except second_ticket)",encode_krb5_kdc_req_body);
-
- ktest_destroy_sequence_of_ticket(&(kdcrb.second_ticket));
+ kdcrb.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY;
+ kdcrb.from = 0;
+ kdcrb.rtime = 0;
+ ktest_destroy_addresses(&(kdcrb.addresses));
+ ktest_destroy_enc_data(&(kdcrb.authorization_data));
+ current_appl_type = 1007; /* Force interpretation as kdc-req-body */
+ encode_run(kdcrb,kdc_req_body,"kdc_req_body","(optionals NULL except second_ticket)",encode_krb5_kdc_req_body);
+
+ ktest_destroy_sequence_of_ticket(&(kdcrb.second_ticket));
#ifndef ISODE_SUCKS
- ktest_make_sample_principal(&(kdcrb.server));
+ ktest_make_sample_principal(&(kdcrb.server));
#endif
- kdcrb.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
- current_appl_type = 1007; /* Force interpretation as kdc-req-body */
- encode_run(kdcrb,kdc_req_body,"kdc_req_body","(optionals NULL except server)",encode_krb5_kdc_req_body);
+ kdcrb.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
+ current_appl_type = 1007; /* Force interpretation as kdc-req-body */
+ encode_run(kdcrb,kdc_req_body,"kdc_req_body","(optionals NULL except server)",encode_krb5_kdc_req_body);
- ktest_empty_kdc_req(&kdcrb);
+ ktest_empty_kdc_req(&kdcrb);
}
/****************************************************************/
/* encode_krb5_safe */
{
- krb5_safe s;
- setup(s,safe,"safe",ktest_make_sample_safe);
- encode_run(s,safe,"safe","",encode_krb5_safe);
+ krb5_safe s;
+ setup(s,safe,"safe",ktest_make_sample_safe);
+ encode_run(s,safe,"safe","",encode_krb5_safe);
- s.timestamp = 0;
- /* s.usec should be opted out by the timestamp */
- s.seq_number = 0;
- ktest_destroy_address(&(s.r_address));
- encode_run(s,safe,"safe","(optionals NULL)",encode_krb5_safe);
+ s.timestamp = 0;
+ /* s.usec should be opted out by the timestamp */
+ s.seq_number = 0;
+ ktest_destroy_address(&(s.r_address));
+ encode_run(s,safe,"safe","(optionals NULL)",encode_krb5_safe);
- ktest_empty_safe(&s);
+ ktest_empty_safe(&s);
}
/****************************************************************/
/* encode_krb5_priv */
{
- krb5_priv p;
- setup(p,priv,"priv",ktest_make_sample_priv);
- encode_run(p,priv,"priv","",encode_krb5_priv);
- ktest_empty_priv(&p);
+ krb5_priv p;
+ setup(p,priv,"priv",ktest_make_sample_priv);
+ encode_run(p,priv,"priv","",encode_krb5_priv);
+ ktest_empty_priv(&p);
}
/****************************************************************/
/* encode_krb5_enc_priv_part */
{
- krb5_priv_enc_part ep;
- setup(ep,priv_enc_part,"priv_enc_part",ktest_make_sample_priv_enc_part);
- encode_run(ep,enc_priv_part,"enc_priv_part","",encode_krb5_enc_priv_part);
+ krb5_priv_enc_part ep;
+ setup(ep,priv_enc_part,"priv_enc_part",ktest_make_sample_priv_enc_part);
+ encode_run(ep,enc_priv_part,"enc_priv_part","",encode_krb5_enc_priv_part);
- ep.timestamp = 0;
- /* ep.usec should be opted out along with timestamp */
- ep.seq_number = 0;
- ktest_destroy_address(&(ep.r_address));
- encode_run(ep,enc_priv_part,"enc_priv_part","(optionals NULL)",encode_krb5_enc_priv_part);
+ ep.timestamp = 0;
+ /* ep.usec should be opted out along with timestamp */
+ ep.seq_number = 0;
+ ktest_destroy_address(&(ep.r_address));
+ encode_run(ep,enc_priv_part,"enc_priv_part","(optionals NULL)",encode_krb5_enc_priv_part);
- ktest_empty_priv_enc_part(&ep);
+ ktest_empty_priv_enc_part(&ep);
}
/****************************************************************/
/* encode_krb5_cred */
{
- krb5_cred c;
- setup(c,cred,"cred",ktest_make_sample_cred);
- encode_run(c,cred,"cred","",encode_krb5_cred);
- ktest_empty_cred(&c);
+ krb5_cred c;
+ setup(c,cred,"cred",ktest_make_sample_cred);
+ encode_run(c,cred,"cred","",encode_krb5_cred);
+ ktest_empty_cred(&c);
}
/****************************************************************/
/* encode_krb5_enc_cred_part */
{
- krb5_cred_enc_part cep;
- setup(cep,cred_enc_part,"cred_enc_part",ktest_make_sample_cred_enc_part);
- encode_run(cep,enc_cred_part,"enc_cred_part","",encode_krb5_enc_cred_part);
+ krb5_cred_enc_part cep;
+ setup(cep,cred_enc_part,"cred_enc_part",ktest_make_sample_cred_enc_part);
+ encode_run(cep,enc_cred_part,"enc_cred_part","",encode_krb5_enc_cred_part);
- ktest_destroy_principal(&(cep.ticket_info[0]->client));
- ktest_destroy_principal(&(cep.ticket_info[0]->server));
- cep.ticket_info[0]->flags = 0;
- cep.ticket_info[0]->times.authtime = 0;
- cep.ticket_info[0]->times.starttime = 0;
- cep.ticket_info[0]->times.endtime = 0;
- cep.ticket_info[0]->times.renew_till = 0;
- ktest_destroy_addresses(&(cep.ticket_info[0]->caddrs));
- cep.nonce = 0;
- cep.timestamp = 0;
- ktest_destroy_address(&(cep.s_address));
- ktest_destroy_address(&(cep.r_address));
- encode_run(cep,enc_cred_part,"enc_cred_part","(optionals NULL)",encode_krb5_enc_cred_part);
+ ktest_destroy_principal(&(cep.ticket_info[0]->client));
+ ktest_destroy_principal(&(cep.ticket_info[0]->server));
+ cep.ticket_info[0]->flags = 0;
+ cep.ticket_info[0]->times.authtime = 0;
+ cep.ticket_info[0]->times.starttime = 0;
+ cep.ticket_info[0]->times.endtime = 0;
+ cep.ticket_info[0]->times.renew_till = 0;
+ ktest_destroy_addresses(&(cep.ticket_info[0]->caddrs));
+ cep.nonce = 0;
+ cep.timestamp = 0;
+ ktest_destroy_address(&(cep.s_address));
+ ktest_destroy_address(&(cep.r_address));
+ encode_run(cep,enc_cred_part,"enc_cred_part","(optionals NULL)",encode_krb5_enc_cred_part);
- ktest_empty_cred_enc_part(&cep);
+ ktest_empty_cred_enc_part(&cep);
}
/****************************************************************/
/* encode_krb5_error */
{
- krb5_error kerr;
- setup(kerr,error,"error",ktest_make_sample_error);
- encode_run(kerr,error,"error","",encode_krb5_error);
+ krb5_error kerr;
+ setup(kerr,error,"error",ktest_make_sample_error);
+ encode_run(kerr,error,"error","",encode_krb5_error);
- kerr.ctime = 0;
- ktest_destroy_principal(&(kerr.client));
- ktest_empty_data(&(kerr.text));
- ktest_empty_data(&(kerr.e_data));
- encode_run(kerr,error,"error","(optionals NULL)",encode_krb5_error);
+ kerr.ctime = 0;
+ ktest_destroy_principal(&(kerr.client));
+ ktest_empty_data(&(kerr.text));
+ ktest_empty_data(&(kerr.e_data));
+ encode_run(kerr,error,"error","(optionals NULL)",encode_krb5_error);
- ktest_empty_error(&kerr);
+ ktest_empty_error(&kerr);
}
/****************************************************************/
/* encode_krb5_authdata */
{
- krb5_authdata **ad;
- setup(ad,authorization_data,"authorization_data",ktest_make_sample_authorization_data);
+ krb5_authdata **ad;
+ setup(ad,authorization_data,"authorization_data",ktest_make_sample_authorization_data);
- retval = encode_krb5_authdata(ad,&(code));
- if (retval) {
- com_err("encoding authorization_data",retval,"");
- exit(1);
- }
- current_appl_type = 1004; /* Force type to be authdata */
- encoder_print_results(code, "authorization_data", "");
+ retval = encode_krb5_authdata(ad,&(code));
+ if (retval) {
+ com_err("encoding authorization_data",retval,"");
+ exit(1);
+ }
+ current_appl_type = 1004; /* Force type to be authdata */
+ encoder_print_results(code, "authorization_data", "");
- ktest_destroy_authorization_data(&ad);
+ ktest_destroy_authorization_data(&ad);
}
/****************************************************************/
/* encode_pwd_sequence */
{
- passwd_phrase_element ppe;
- setup(ppe,passwd_phrase_element,"PasswdSequence",ktest_make_sample_passwd_phrase_element);
- encode_run(ppe,passwd_phrase_element,"pwd_sequence","",encode_krb5_pwd_sequence);
- ktest_empty_passwd_phrase_element(&ppe);
+ passwd_phrase_element ppe;
+ setup(ppe,passwd_phrase_element,"PasswdSequence",ktest_make_sample_passwd_phrase_element);
+ encode_run(ppe,passwd_phrase_element,"pwd_sequence","",encode_krb5_pwd_sequence);
+ ktest_empty_passwd_phrase_element(&ppe);
}
/****************************************************************/
/* encode_passwd_data */
{
- krb5_pwd_data pd;
- setup(pd,krb5_pwd_data,"PasswdData",ktest_make_sample_krb5_pwd_data);
- encode_run(pd,krb5_pwd_data,"pwd_data","",encode_krb5_pwd_data);
- ktest_empty_pwd_data(&pd);
+ krb5_pwd_data pd;
+ setup(pd,krb5_pwd_data,"PasswdData",ktest_make_sample_krb5_pwd_data);
+ encode_run(pd,krb5_pwd_data,"pwd_data","",encode_krb5_pwd_data);
+ ktest_empty_pwd_data(&pd);
}
/****************************************************************/
/* encode_padata_sequence */
{
- krb5_pa_data **pa;
+ krb5_pa_data **pa;
- setup(pa,krb5_pa_data,"PreauthData",ktest_make_sample_pa_data_array);
- retval = encode_krb5_padata_sequence(pa,&(code));
- if (retval) {
- com_err("encoding padata_sequence",retval,"");
- exit(1);
- }
- encoder_print_results(code, "padata_sequence", "");
+ setup(pa,krb5_pa_data,"PreauthData",ktest_make_sample_pa_data_array);
+ retval = encode_krb5_padata_sequence(pa,&(code));
+ if (retval) {
+ com_err("encoding padata_sequence",retval,"");
+ exit(1);
+ }
+ encoder_print_results(code, "padata_sequence", "");
- ktest_destroy_pa_data_array(&pa);
+ ktest_destroy_pa_data_array(&pa);
}
/****************************************************************/
/* encode_padata_sequence (empty) */
{
- krb5_pa_data **pa;
+ krb5_pa_data **pa;
- setup(pa,krb5_pa_data,"EmptyPreauthData",ktest_make_sample_empty_pa_data_array);
- retval = encode_krb5_padata_sequence(pa,&(code));
- if (retval) {
- com_err("encoding padata_sequence(empty)",retval,"");
- exit(1);
- }
- encoder_print_results(code, "padata_sequence(empty)", "");
+ setup(pa,krb5_pa_data,"EmptyPreauthData",ktest_make_sample_empty_pa_data_array);
+ retval = encode_krb5_padata_sequence(pa,&(code));
+ if (retval) {
+ com_err("encoding padata_sequence(empty)",retval,"");
+ exit(1);
+ }
+ encoder_print_results(code, "padata_sequence(empty)", "");
- ktest_destroy_pa_data_array(&pa);
+ ktest_destroy_pa_data_array(&pa);
}
/****************************************************************/
/* 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;
- if (am.data)
- free(am.data);
- am.data = 0;
- encode_run(am,krb5_alt_method,"alt_method (no data)","",
- encode_krb5_alt_method);
- ktest_empty_alt_method(&am);
+ 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;
+ if (am.data)
+ free(am.data);
+ am.data = 0;
+ encode_run(am,krb5_alt_method,"alt_method (no data)","",
+ encode_krb5_alt_method);
+ ktest_empty_alt_method(&am);
}
/****************************************************************/
/* encode_etype_info */
{
- krb5_etype_info_entry **info;
+ krb5_etype_info_entry **info;
- setup(info,krb5_etype_info_entry **,"etype_info",
- ktest_make_sample_etype_info);
- retval = encode_krb5_etype_info(info,&(code));
- if (retval) {
- com_err("encoding etype_info",retval,"");
- exit(1);
- }
- 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;
+ setup(info,krb5_etype_info_entry **,"etype_info",
+ ktest_make_sample_etype_info);
+ retval = encode_krb5_etype_info(info,&(code));
+ if (retval) {
+ com_err("encoding etype_info",retval,"");
+ exit(1);
+ }
+ 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(info,&(code));
- if (retval) {
- com_err("encoding etype_info (only 1)",retval,"");
- exit(1);
- }
- encoder_print_results(code, "etype_info (only 1)", "");
+ retval = encode_krb5_etype_info(info,&(code));
+ if (retval) {
+ com_err("encoding etype_info (only 1)",retval,"");
+ exit(1);
+ }
+ encoder_print_results(code, "etype_info (only 1)", "");
- ktest_destroy_etype_info_entry(info[0]); info[0] = 0;
+ ktest_destroy_etype_info_entry(info[0]); info[0] = 0;
- retval = encode_krb5_etype_info(info,&(code));
- if (retval) {
- com_err("encoding etype_info (no info)",retval,"");
- exit(1);
- }
- encoder_print_results(code, "etype_info (no info)", "");
+ retval = encode_krb5_etype_info(info,&(code));
+ if (retval) {
+ com_err("encoding etype_info (no info)",retval,"");
+ exit(1);
+ }
+ encoder_print_results(code, "etype_info (no info)", "");
- ktest_destroy_etype_info(info);
+ ktest_destroy_etype_info(info);
}
/* encode_etype_info 2*/
{
- krb5_etype_info_entry **info;
-
- setup(info,krb5_etype_info_entry **,"etype_info2",
- ktest_make_sample_etype_info2);
- retval = encode_krb5_etype_info2(info,&(code));
- if (retval) {
- com_err("encoding etype_info",retval,"");
- exit(1);
- }
- encoder_print_results(code, "etype_info2", "");
- ktest_destroy_etype_info_entry(info[2]); info[2] = 0;
- ktest_destroy_etype_info_entry(info[1]); info[1] = 0;
-
- retval = encode_krb5_etype_info2(info,&(code));
- if (retval) {
- com_err("encoding etype_info (only 1)",retval,"");
- exit(1);
- }
- encoder_print_results(code, "etype_info2 (only 1)", "");
-
- ktest_destroy_etype_info(info);
+ krb5_etype_info_entry **info;
+
+ setup(info,krb5_etype_info_entry **,"etype_info2",
+ ktest_make_sample_etype_info2);
+ retval = encode_krb5_etype_info2(info,&(code));
+ if (retval) {
+ com_err("encoding etype_info",retval,"");
+ exit(1);
+ }
+ encoder_print_results(code, "etype_info2", "");
+ ktest_destroy_etype_info_entry(info[2]); info[2] = 0;
+ ktest_destroy_etype_info_entry(info[1]); info[1] = 0;
+
+ retval = encode_krb5_etype_info2(info,&(code));
+ if (retval) {
+ com_err("encoding etype_info (only 1)",retval,"");
+ exit(1);
+ }
+ encoder_print_results(code, "etype_info2 (only 1)", "");
+
+ ktest_destroy_etype_info(info);
/* ktest_destroy_etype_info_entry(info[0]); info[0] = 0;*/
}
/****************************************************************/
/* encode_pa_enc_ts */
{
- krb5_pa_enc_ts pa_enc;
- setup(pa_enc,krb5_pa_enc_ts,"pa_enc_ts",ktest_make_sample_pa_enc_ts);
- encode_run(pa_enc,krb5_pa_enc_ts,"pa_enc_ts","",encode_krb5_pa_enc_ts);
- pa_enc.pausec = 0;
- encode_run(pa_enc,krb5_pa_enc_ts,"pa_enc_ts (no usec)","",encode_krb5_pa_enc_ts);
+ krb5_pa_enc_ts pa_enc;
+ setup(pa_enc,krb5_pa_enc_ts,"pa_enc_ts",ktest_make_sample_pa_enc_ts);
+ encode_run(pa_enc,krb5_pa_enc_ts,"pa_enc_ts","",encode_krb5_pa_enc_ts);
+ pa_enc.pausec = 0;
+ encode_run(pa_enc,krb5_pa_enc_ts,"pa_enc_ts (no usec)","",encode_krb5_pa_enc_ts);
}
/****************************************************************/
/* encode_enc_data */
{
- krb5_enc_data enc_data;
- setup(enc_data,krb5_enc_data,"enc_data",ktest_make_sample_enc_data);
- current_appl_type = 1001;
- encode_run(enc_data,krb5_enc_data,"enc_data","",encode_krb5_enc_data);
- ktest_destroy_enc_data(&enc_data);
+ krb5_enc_data enc_data;
+ setup(enc_data,krb5_enc_data,"enc_data",ktest_make_sample_enc_data);
+ current_appl_type = 1001;
+ encode_run(enc_data,krb5_enc_data,"enc_data","",encode_krb5_enc_data);
+ ktest_destroy_enc_data(&enc_data);
}
/****************************************************************/
/* encode_krb5_sam_challenge */
{
- krb5_sam_challenge sam_ch;
- setup(sam_ch,krb5_sam_challenge,"sam_challenge",
- ktest_make_sample_sam_challenge);
- encode_run(sam_ch,krb5_sam_challenge,"sam_challenge","",
- encode_krb5_sam_challenge);
- ktest_empty_sam_challenge(&sam_ch);
+ krb5_sam_challenge sam_ch;
+ setup(sam_ch,krb5_sam_challenge,"sam_challenge",
+ ktest_make_sample_sam_challenge);
+ encode_run(sam_ch,krb5_sam_challenge,"sam_challenge","",
+ encode_krb5_sam_challenge);
+ ktest_empty_sam_challenge(&sam_ch);
}
/****************************************************************/
/* encode_krb5_sam_response */
{
- krb5_sam_response sam_ch;
- setup(sam_ch,krb5_sam_response,"sam_response",
- ktest_make_sample_sam_response);
- encode_run(sam_ch,krb5_sam_response,"sam_response","",
- encode_krb5_sam_response);
- ktest_empty_sam_response(&sam_ch);
+ krb5_sam_response sam_ch;
+ setup(sam_ch,krb5_sam_response,"sam_response",
+ ktest_make_sample_sam_response);
+ encode_run(sam_ch,krb5_sam_response,"sam_response","",
+ encode_krb5_sam_response);
+ ktest_empty_sam_response(&sam_ch);
}
/****************************************************************/
/* encode_krb5_sam_key */
{
- krb5_sam_key sam_ch;
- setup(sam_ch,krb5_sam_key,"sam_key",
- ktest_make_sample_sam_key);
- encode_run(sam_ch,krb5_sam_key,"sam_key","",
- encode_krb5_sam_key);
- ktest_empty_sam_key(&sam_ch);
+ krb5_sam_key sam_ch;
+ setup(sam_ch,krb5_sam_key,"sam_key",
+ ktest_make_sample_sam_key);
+ encode_run(sam_ch,krb5_sam_key,"sam_key","",
+ encode_krb5_sam_key);
+ ktest_empty_sam_key(&sam_ch);
}
/****************************************************************/
/* encode_krb5_enc_sam_response_enc */
{
- krb5_enc_sam_response_enc sam_ch;
- setup(sam_ch,krb5_enc_sam_response_enc,"enc_sam_response_enc",
- ktest_make_sample_enc_sam_response_enc);
- encode_run(sam_ch,krb5_enc_sam_response_enc,"enc_sam_response_enc","",
- encode_krb5_enc_sam_response_enc);
- ktest_empty_enc_sam_response_enc(&sam_ch);
+ krb5_enc_sam_response_enc sam_ch;
+ setup(sam_ch,krb5_enc_sam_response_enc,"enc_sam_response_enc",
+ ktest_make_sample_enc_sam_response_enc);
+ encode_run(sam_ch,krb5_enc_sam_response_enc,"enc_sam_response_enc","",
+ encode_krb5_enc_sam_response_enc);
+ ktest_empty_enc_sam_response_enc(&sam_ch);
}
/****************************************************************/
/* encode_krb5_predicted_sam_response */
{
- krb5_predicted_sam_response sam_ch;
- setup(sam_ch,krb5_predicted_sam_response,"predicted_sam_response",
- ktest_make_sample_predicted_sam_response);
- encode_run(sam_ch,krb5_predicted_sam_response,"predicted_sam_response","",
- encode_krb5_predicted_sam_response);
- ktest_empty_predicted_sam_response(&sam_ch);
+ krb5_predicted_sam_response sam_ch;
+ setup(sam_ch,krb5_predicted_sam_response,"predicted_sam_response",
+ ktest_make_sample_predicted_sam_response);
+ encode_run(sam_ch,krb5_predicted_sam_response,"predicted_sam_response","",
+ encode_krb5_predicted_sam_response);
+ ktest_empty_predicted_sam_response(&sam_ch);
}
- /****************************************************************/
- /* encode_krb5_sam_response_2 */
+ /****************************************************************/
+ /* encode_krb5_sam_response_2 */
{
- krb5_sam_response_2 sam_ch2;
- setup(sam_ch2,krb5_sam_response_2,"sam_response_2",
- ktest_make_sample_sam_response_2);
- encode_run(sam_ch2,krb5_sam_response_2,"sam_response_2","",
- acc.encode_krb5_sam_response_2);
- ktest_empty_sam_response_2(&sam_ch2);
+ krb5_sam_response_2 sam_ch2;
+ setup(sam_ch2,krb5_sam_response_2,"sam_response_2",
+ ktest_make_sample_sam_response_2);
+ encode_run(sam_ch2,krb5_sam_response_2,"sam_response_2","",
+ acc.encode_krb5_sam_response_2);
+ ktest_empty_sam_response_2(&sam_ch2);
}
/****************************************************************/
/* encode_krb5_sam_response_enc_2 */
{
- krb5_enc_sam_response_enc_2 sam_ch2;
- setup(sam_ch2,krb5_enc_sam_response_enc_2,"enc_sam_response_enc_2",
- ktest_make_sample_enc_sam_response_enc_2);
- encode_run(sam_ch2,krb5_enc_sam_response_enc_2,
- "enc_sam_response_enc_2","",
- acc.encode_krb5_enc_sam_response_enc_2);
- ktest_empty_enc_sam_response_enc_2(&sam_ch2);
+ krb5_enc_sam_response_enc_2 sam_ch2;
+ setup(sam_ch2,krb5_enc_sam_response_enc_2,"enc_sam_response_enc_2",
+ ktest_make_sample_enc_sam_response_enc_2);
+ encode_run(sam_ch2,krb5_enc_sam_response_enc_2,
+ "enc_sam_response_enc_2","",
+ acc.encode_krb5_enc_sam_response_enc_2);
+ ktest_empty_enc_sam_response_enc_2(&sam_ch2);
}
/****************************************************************/
/* encode_krb5_pa_s4u_x509_user */
{
- krb5_pa_s4u_x509_user s4u;
- setup(s4u,krb5_pa_s4u_x509_user,"pa_s4u_x509_user",
- ktest_make_sample_pa_s4u_x509_user);
- encode_run(s4u,krb5_pa_s4u_x509_user,
- "pa_s4u_x509_user","",
- encode_krb5_pa_s4u_x509_user);
- ktest_empty_pa_s4u_x509_user(&s4u);
+ krb5_pa_s4u_x509_user s4u;
+ setup(s4u,krb5_pa_s4u_x509_user,"pa_s4u_x509_user",
+ ktest_make_sample_pa_s4u_x509_user);
+ encode_run(s4u,krb5_pa_s4u_x509_user,
+ "pa_s4u_x509_user","",
+ encode_krb5_pa_s4u_x509_user);
+ ktest_empty_pa_s4u_x509_user(&s4u);
}
/****************************************************************/
/* encode_krb5_ad_kdcissued */
{
- krb5_ad_kdcissued kdci;
- setup(kdci,krb5_ad_kdcissued,"ad_kdcissued",
- ktest_make_sample_ad_kdcissued);
- encode_run(kdci,krb5_ad_kdcissued,
- "ad_kdcissued","",
- encode_krb5_ad_kdcissued);
- ktest_empty_ad_kdcissued(&kdci);
+ krb5_ad_kdcissued kdci;
+ setup(kdci,krb5_ad_kdcissued,"ad_kdcissued",
+ ktest_make_sample_ad_kdcissued);
+ encode_run(kdci,krb5_ad_kdcissued,
+ "ad_kdcissued","",
+ encode_krb5_ad_kdcissued);
+ ktest_empty_ad_kdcissued(&kdci);
}
/****************************************************************/
/* encode_krb5_ad_signedpath_data */
{
- krb5_ad_signedpath_data spd;
- setup(spd,krb5_ad_signedpath_data,"ad_signedpath_data",
- ktest_make_sample_ad_signedpath_data);
- encode_run(spd,krb5_ad_signedpath_data,
- "ad_signedpath_data","",
- encode_krb5_ad_signedpath_data);
- ktest_empty_ad_signedpath_data(&spd);
+ krb5_ad_signedpath_data spd;
+ setup(spd,krb5_ad_signedpath_data,"ad_signedpath_data",
+ ktest_make_sample_ad_signedpath_data);
+ encode_run(spd,krb5_ad_signedpath_data,
+ "ad_signedpath_data","",
+ encode_krb5_ad_signedpath_data);
+ ktest_empty_ad_signedpath_data(&spd);
}
/****************************************************************/
/* encode_krb5_ad_signedpath */
{
- krb5_ad_signedpath sp;
- setup(sp,krb5_ad_signedpath,"ad_signedpath",
- ktest_make_sample_ad_signedpath);
- encode_run(sp,krb5_ad_signedpath,
- "ad_signedpath","",
- encode_krb5_ad_signedpath);
- ktest_empty_ad_signedpath(&sp);
+ krb5_ad_signedpath sp;
+ setup(sp,krb5_ad_signedpath,"ad_signedpath",
+ ktest_make_sample_ad_signedpath);
+ encode_run(sp,krb5_ad_signedpath,
+ "ad_signedpath","",
+ encode_krb5_ad_signedpath);
+ ktest_empty_ad_signedpath(&sp);
}
#ifdef ENABLE_LDAP
{
- ldap_seqof_key_data skd;
+ 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);
+ 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
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#include "ktest.h"
#include "utility.h"
#include <stdlib.h>
*caddrs = (krb5_address**)calloc(3,sizeof(krb5_address*));
if (*caddrs == NULL) return ENOMEM;
for (i=0; i<2; i++) {
- (*caddrs)[i] = (krb5_address*)calloc(1,sizeof(krb5_address));
- if ((*caddrs)[i] == NULL) return ENOMEM;
- retval = ktest_make_sample_address((*caddrs)[i]);
- if (retval) return retval;
+ (*caddrs)[i] = (krb5_address*)calloc(1,sizeof(krb5_address));
+ if ((*caddrs)[i] == NULL) return ENOMEM;
+ retval = ktest_make_sample_address((*caddrs)[i]);
+ if (retval) return retval;
}
(*caddrs)[2] = NULL;
return 0;
if (*ad == NULL) return ENOMEM;
for (i=0; i<=1; i++) {
- (*ad)[i] = (krb5_authdata*)calloc(1,sizeof(krb5_authdata));
- if ((*ad)[i] == NULL) return ENOMEM;
- retval = ktest_make_sample_authdata((*ad)[i]);
- if (retval) return retval;
+ (*ad)[i] = (krb5_authdata*)calloc(1,sizeof(krb5_authdata));
+ if ((*ad)[i] == NULL) return ENOMEM;
+ retval = ktest_make_sample_authdata((*ad)[i]);
+ if (retval) return retval;
}
(*ad)[2] = NULL;
{
t->tr_type = 1;
return krb5_data_parse(&(t->tr_contents),
- "EDU,MIT.,ATHENA.,WASHINGTON.EDU,CS.");
+ "EDU,MIT.,ATHENA.,WASHINGTON.EDU,CS.");
}
krb5_error_code ktest_make_sample_ticket_times(tt)
*lr = (krb5_last_req_entry**)calloc(3,sizeof(krb5_last_req_entry*));
if (*lr == NULL) return ENOMEM;
for (i=0; i<=1; i++) {
- retval = ktest_make_sample_last_req_entry(&((*lr)[i]));
- if (retval) return retval;
+ retval = ktest_make_sample_last_req_entry(&((*lr)[i]));
+ if (retval) return retval;
}
(*lr)[2] = NULL;
return 0;
if (*pad == NULL) return ENOMEM;
for (i=0; i<=1; i++) {
- (*pad)[i] = (krb5_pa_data*)calloc(1,sizeof(krb5_pa_data));
- if ((*pad)[i] == NULL) return ENOMEM;
- retval = ktest_make_sample_pa_data((*pad)[i]);
- if (retval) return retval;
+ (*pad)[i] = (krb5_pa_data*)calloc(1,sizeof(krb5_pa_data));
+ if ((*pad)[i] == NULL) return ENOMEM;
+ retval = ktest_make_sample_pa_data((*pad)[i]);
+ if (retval) return retval;
}
(*pad)[2] = NULL;
*sot = (krb5_ticket**)calloc(3,sizeof(krb5_ticket*));
if (*sot == NULL) return ENOMEM;
for (i=0; i<2; i++) {
- (*sot)[i] = (krb5_ticket*)calloc(1,sizeof(krb5_ticket));
- if ((*sot)[i] == NULL) return ENOMEM;
- retval = ktest_make_sample_ticket((*sot)[i]);
- if (retval) return retval;
+ (*sot)[i] = (krb5_ticket*)calloc(1,sizeof(krb5_ticket));
+ if ((*sot)[i] == NULL) return ENOMEM;
+ retval = ktest_make_sample_ticket((*sot)[i]);
+ if (retval) return retval;
}
(*sot)[2] = NULL;
*soci = (krb5_cred_info**)calloc(3,sizeof(krb5_cred_info*));
if (*soci == NULL) return ENOMEM;
for (i=0; i<2; i++) {
- (*soci)[i] = (krb5_cred_info*)calloc(1,sizeof(krb5_cred_info));
- if ((*soci)[i] == NULL) return ENOMEM;
- retval = ktest_make_sample_cred_info((*soci)[i]);
- if (retval) return retval;
+ (*soci)[i] = (krb5_cred_info*)calloc(1,sizeof(krb5_cred_info));
+ if ((*soci)[i] == NULL) return ENOMEM;
+ retval = ktest_make_sample_cred_info((*soci)[i]);
+ if (retval) return retval;
}
(*soci)[2] = NULL;
if (pd->element == NULL) return ENOMEM;
for (i=0; i<=1; i++) {
- pd->element[i] = (passwd_phrase_element*)calloc(1,sizeof(passwd_phrase_element));
- if (pd->element[i] == NULL) return ENOMEM;
- retval = ktest_make_sample_passwd_phrase_element(pd->element[i]);
- if (retval) return retval;
+ pd->element[i] = (passwd_phrase_element*)calloc(1,sizeof(passwd_phrase_element));
+ if (pd->element[i] == NULL) return ENOMEM;
+ retval = ktest_make_sample_passwd_phrase_element(pd->element[i]);
+ if (retval) return retval;
}
pd->element[2] = NULL;
krb5_etype_info_entry *** p;
{
krb5_etype_info_entry **info;
- int i, len;
+ int i, len;
char *str;
info = malloc(sizeof(krb5_etype_info_entry *) * 4);
if (!info)
- return ENOMEM;
+ 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;
- len = asprintf(&str, "Morton's #%d", i);
- if (len < 0)
- goto memfail;
- info[i]->salt = (krb5_octet *) str;
- info[i]->length = len;
- info[i]->s2kparams.data = NULL;
- info[i]->s2kparams.length = 0;
- info[i]->magic = KV5M_ETYPE_INFO_ENTRY;
+ info[i] = malloc(sizeof(krb5_etype_info_entry));
+ if (info[i] == 0)
+ goto memfail;
+ info[i]->etype = i;
+ len = asprintf(&str, "Morton's #%d", i);
+ if (len < 0)
+ goto memfail;
+ info[i]->salt = (krb5_octet *) str;
+ info[i]->length = len;
+ info[i]->s2kparams.data = NULL;
+ info[i]->s2kparams.length = 0;
+ info[i]->magic = KV5M_ETYPE_INFO_ENTRY;
}
free(info[1]->salt);
info[1]->length = KRB5_ETYPE_NO_SALT;
krb5_etype_info_entry *** p;
{
krb5_etype_info_entry **info;
- int i, len;
+ int i, len;
char *str;
info = malloc(sizeof(krb5_etype_info_entry *) * 4);
if (!info)
- return ENOMEM;
+ 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;
- len = asprintf(&str, "Morton's #%d", i);
- if (len < 0)
- goto memfail;
- info[i]->salt = (krb5_octet *) str;
- info[i]->length = (unsigned int) len;
- len = asprintf(&info[i]->s2kparams.data, "s2k: %d", i);
- if (len < 0)
- goto memfail;
- info[i]->s2kparams.length = (unsigned int) len;
- info[i]->magic = KV5M_ETYPE_INFO_ENTRY;
+ info[i] = malloc(sizeof(krb5_etype_info_entry));
+ if (info[i] == 0)
+ goto memfail;
+ info[i]->etype = i;
+ len = asprintf(&str, "Morton's #%d", i);
+ if (len < 0)
+ goto memfail;
+ info[i]->salt = (krb5_octet *) str;
+ info[i]->length = (unsigned int) len;
+ len = asprintf(&info[i]->s2kparams.data, "s2k: %d", i);
+ if (len < 0)
+ goto memfail;
+ info[i]->s2kparams.length = (unsigned int) len;
+ info[i]->magic = KV5M_ETYPE_INFO_ENTRY;
}
free(info[1]->salt);
info[1]->length = KRB5_ETYPE_NO_SALT;
p->sam_enc_nonce_or_ts.ciphertext.data = strdup("nonce or ts");
if (p->sam_enc_nonce_or_ts.ciphertext.data == NULL) return ENOMEM;
p->sam_enc_nonce_or_ts.ciphertext.length =
- strlen(p->sam_enc_nonce_or_ts.ciphertext.data);
+ strlen(p->sam_enc_nonce_or_ts.ciphertext.data);
p->sam_enc_nonce_or_ts.enctype = ENCTYPE_DES_CBC_CRC;
p->sam_enc_nonce_or_ts.kvno = 3382;
p->sam_nonce = 0x543210;
p->sam_enc_nonce_or_sad.ciphertext.data = strdup("nonce or sad");
if (p->sam_enc_nonce_or_sad.ciphertext.data == NULL) return ENOMEM;
p->sam_enc_nonce_or_sad.ciphertext.length =
- strlen(p->sam_enc_nonce_or_sad.ciphertext.data);
+ strlen(p->sam_enc_nonce_or_sad.ciphertext.data);
p->sam_enc_nonce_or_sad.enctype = ENCTYPE_DES_CBC_CRC;
p->sam_enc_nonce_or_sad.kvno = 3382;
p->sam_nonce = 0x543210;
p->key_data_length[1] = (unsigned int) len;
p->key_data_contents[1] = (krb5_octet *) str;
if (p->key_data_contents[0] == NULL || p->key_data_contents[1] == NULL)
- return ENOMEM;
+ return ENOMEM;
return 0;
}
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;
+ krb5_error_code ret;
+ ret = ktest_make_sample_key_data(&p->key_data[i], i);
+ if (ret) return ret;
}
return 0;
}
krb5_data ** d;
{
if (*d != NULL) {
- if ((*d)->data != NULL) free((*d)->data);
- free(*d);
- *d = NULL;
+ if ((*d)->data != NULL) free((*d)->data);
+ free(*d);
+ *d = NULL;
}
}
krb5_data * d;
{
if (d->data != NULL) {
- free(d->data);
- d->data = NULL;
- d->length = 0;
+ free(d->data);
+ d->data = NULL;
+ d->length = 0;
}
}
krb5_checksum ** cs;
{
if (*cs != NULL) {
- if ((*cs)->contents != NULL) free((*cs)->contents);
- free(*cs);
- *cs = NULL;
+ if ((*cs)->contents != NULL) free((*cs)->contents);
+ free(*cs);
+ *cs = NULL;
}
}
krb5_keyblock * kb;
{
if (kb != NULL) {
- if (kb->contents) {
- free (kb->contents);
- kb->contents = NULL;
- }
+ if (kb->contents) {
+ free (kb->contents);
+ kb->contents = NULL;
+ }
}
}
krb5_keyblock ** kb;
{
if (*kb != NULL) {
- if ((*kb)->contents != NULL) free((*kb)->contents);
- free(*kb);
- *kb = NULL;
+ if ((*kb)->contents != NULL) free((*kb)->contents);
+ free(*kb);
+ *kb = NULL;
}
}
int i;
if (*ad != NULL) {
- for (i=0; ad[i] != NULL; i++)
- ktest_destroy_authdata(&(ad[i]));
+ for (i=0; ad[i] != NULL; i++)
+ ktest_destroy_authdata(&(ad[i]));
}
}
krb5_authdata ** ad;
{
if (*ad != NULL) {
- if ((*ad)->contents != NULL) free((*ad)->contents);
- free(*ad);
- *ad = NULL;
+ if ((*ad)->contents != NULL) free((*ad)->contents);
+ free(*ad);
+ *ad = NULL;
}
}
int i;
for (i=0; pad[i] != NULL; i++)
- ktest_destroy_pa_data(&(pad[i]));
+ ktest_destroy_pa_data(&(pad[i]));
}
void ktest_destroy_pa_data_array(pad)
krb5_pa_data ** pad;
{
if (*pad != NULL) {
- if ((*pad)->contents != NULL) free((*pad)->contents);
- free(*pad);
- *pad = NULL;
+ if ((*pad)->contents != NULL) free((*pad)->contents);
+ free(*pad);
+ *pad = NULL;
}
}
krb5_address ** a;
{
if (*a != NULL) {
- if ((*a)->contents != NULL) free((*a)->contents);
- free(*a);
- *a = NULL;
+ if ((*a)->contents != NULL) free((*a)->contents);
+ free(*a);
+ *a = NULL;
}
}
int i;
for (i=0; a[i] != NULL; i++)
- ktest_destroy_address(&(a[i]));
+ ktest_destroy_address(&(a[i]));
}
void ktest_destroy_addresses(a)
int i;
for (i=0; i<(*p)->length; i++)
- ktest_empty_data(&(((*p)->data)[i]));
+ ktest_empty_data(&(((*p)->data)[i]));
ktest_empty_data(&((*p)->realm));
free((*p)->data);
free(*p);
int i;
for (i=0; (*sot)[i] != NULL; i++)
- ktest_destroy_ticket(&((*sot)[i]));
+ ktest_destroy_ticket(&((*sot)[i]));
free(*sot);
*sot = NULL;
}
krb5_ticket * tkt;
{
if (tkt->server)
- ktest_destroy_principal(&((tkt)->server));
+ ktest_destroy_principal(&((tkt)->server));
ktest_destroy_enc_data(&((tkt)->enc_part));
if (tkt->enc_part2) {
- ktest_destroy_enc_tkt_part(&(tkt->enc_part2));
+ ktest_destroy_enc_tkt_part(&(tkt->enc_part2));
}
}
krb5_etype_info_entry *i;
{
if (i->salt)
- free(i->salt);
+ free(i->salt);
ktest_empty_data(&(i->s2kparams));
free(i);
}
int i;
for (i=0; info[i] != NULL; i++)
- ktest_destroy_etype_info_entry(info[i]);
+ ktest_destroy_etype_info_entry(info[i]);
free(info);
}
krb5_kdc_req *kr;
{
if (kr->padata)
- ktest_destroy_pa_data_array(&(kr->padata));
+ ktest_destroy_pa_data_array(&(kr->padata));
if (kr->client)
- ktest_destroy_principal(&(kr->client));
+ ktest_destroy_principal(&(kr->client));
if (kr->server)
- ktest_destroy_principal(&(kr->server));
+ ktest_destroy_principal(&(kr->server));
if (kr->ktype)
- free(kr->ktype);
+ free(kr->ktype);
if (kr->addresses)
- ktest_destroy_addresses(&(kr->addresses));
+ ktest_destroy_addresses(&(kr->addresses));
ktest_destroy_enc_data(&(kr->authorization_data));
if (kr->unenc_authdata)
- ktest_destroy_authorization_data(&(kr->unenc_authdata));
+ ktest_destroy_authorization_data(&(kr->unenc_authdata));
if (kr->second_ticket)
- ktest_destroy_sequence_of_ticket(&(kr->second_ticket));
+ ktest_destroy_sequence_of_ticket(&(kr->second_ticket));
}
krb5_kdc_rep *kr;
{
if (kr->padata)
- ktest_destroy_pa_data_array(&(kr->padata));
+ ktest_destroy_pa_data_array(&(kr->padata));
if (kr->client)
- ktest_destroy_principal(&(kr->client));
+ ktest_destroy_principal(&(kr->client));
if (kr->ticket)
- ktest_destroy_ticket(&(kr->ticket));
+ ktest_destroy_ticket(&(kr->ticket));
ktest_destroy_enc_data(&kr->enc_part);
if (kr->enc_part2) {
- ktest_empty_enc_kdc_rep_part(kr->enc_part2);
- free(kr->enc_part2);
- kr->enc_part2 = NULL;
+ ktest_empty_enc_kdc_rep_part(kr->enc_part2);
+ free(kr->enc_part2);
+ kr->enc_part2 = NULL;
}
}
{
if (a->client)
- ktest_destroy_principal(&(a->client));
+ ktest_destroy_principal(&(a->client));
if (a->checksum)
- ktest_destroy_checksum(&(a->checksum));
+ ktest_destroy_checksum(&(a->checksum));
if (a->subkey)
- ktest_destroy_keyblock(&(a->subkey));
+ ktest_destroy_keyblock(&(a->subkey));
if (a->authorization_data)
- ktest_destroy_authorization_data(&(a->authorization_data));
+ ktest_destroy_authorization_data(&(a->authorization_data));
}
void ktest_empty_enc_tkt_part(etp)
{
if (etp->session)
- ktest_destroy_keyblock(&(etp->session));
+ ktest_destroy_keyblock(&(etp->session));
if (etp->client)
- ktest_destroy_principal(&(etp->client));
+ ktest_destroy_principal(&(etp->client));
if (etp->caddrs)
- ktest_destroy_addresses(&(etp->caddrs));
+ ktest_destroy_addresses(&(etp->caddrs));
if (etp->authorization_data)
- ktest_destroy_authorization_data(&(etp->authorization_data));
+ ktest_destroy_authorization_data(&(etp->authorization_data));
ktest_destroy_transited(&(etp->transited));
}
krb5_enc_tkt_part ** etp;
{
if (*etp) {
- ktest_empty_enc_tkt_part(*etp);
- free(*etp);
- *etp = NULL;
+ ktest_empty_enc_tkt_part(*etp);
+ free(*etp);
+ *etp = NULL;
}
}
{
if (ekr->session)
- ktest_destroy_keyblock(&(ekr->session));
+ ktest_destroy_keyblock(&(ekr->session));
if (ekr->server)
- ktest_destroy_principal(&(ekr->server));
+ ktest_destroy_principal(&(ekr->server));
if (ekr->caddrs)
- ktest_destroy_addresses(&(ekr->caddrs));
+ ktest_destroy_addresses(&(ekr->caddrs));
ktest_destroy_last_req(&(ekr->last_req));
}
krb5_transited * t;
{
if (t->tr_contents.data)
- ktest_empty_data(&(t->tr_contents));
+ ktest_empty_data(&(t->tr_contents));
}
{
if (ar->ticket)
- ktest_destroy_ticket(&(ar->ticket));
+ ktest_destroy_ticket(&(ar->ticket));
ktest_destroy_enc_data(&(ar->authenticator));
}
krb5_cred_enc_part * cep;
{
if (cep->s_address)
- ktest_destroy_address(&(cep->s_address));
+ ktest_destroy_address(&(cep->s_address));
if (cep->r_address)
- ktest_destroy_address(&(cep->r_address));
+ ktest_destroy_address(&(cep->r_address));
if (cep->ticket_info)
- ktest_destroy_sequence_of_cred_info(&(cep->ticket_info));
+ ktest_destroy_sequence_of_cred_info(&(cep->ticket_info));
}
void ktest_destroy_cred_info(ci)
krb5_cred_info ** ci;
{
if ((*ci)->session)
- ktest_destroy_keyblock(&((*ci)->session));
+ ktest_destroy_keyblock(&((*ci)->session));
if ((*ci)->client)
- ktest_destroy_principal(&((*ci)->client));
+ ktest_destroy_principal(&((*ci)->client));
if ((*ci)->server)
- ktest_destroy_principal(&((*ci)->server));
+ ktest_destroy_principal(&((*ci)->server));
if ((*ci)->caddrs)
- ktest_destroy_addresses(&((*ci)->caddrs));
+ ktest_destroy_addresses(&((*ci)->caddrs));
free(*ci);
*ci = NULL;
}
int i;
for (i=0; (*soci)[i] != NULL; i++)
- ktest_destroy_cred_info(&((*soci)[i]));
+ ktest_destroy_cred_info(&((*soci)[i]));
free(*soci);
*soci = NULL;
}
int i;
if (*lr) {
- for (i=0; (*lr)[i] != NULL; i++) {
- free((*lr)[i]);
- }
- free(*lr);
+ for (i=0; (*lr)[i] != NULL; i++) {
+ free((*lr)[i]);
+ }
+ free(*lr);
}
}
krb5_error * kerr;
{
if (kerr->client)
- ktest_destroy_principal(&(kerr->client));
+ ktest_destroy_principal(&(kerr->client));
if (kerr->server)
- ktest_destroy_principal(&(kerr->server));
+ ktest_destroy_principal(&(kerr->server));
ktest_empty_data(&(kerr->text));
ktest_empty_data(&(kerr->e_data));
}
int i;
for (i=0; i <= pd->sequence_count; i++) {
- if (pd->element[i]) {
- ktest_empty_passwd_phrase_element(pd->element[i]);
- free(pd->element[i]);
- pd->element[i] = NULL;
- }
+ if (pd->element[i]) {
+ ktest_empty_passwd_phrase_element(pd->element[i]);
+ free(pd->element[i]);
+ pd->element[i] = NULL;
+ }
}
free(pd->element);
krb5_alt_method *am;
{
if (am->data) {
- free(am->data);
- am->data = NULL;
+ free(am->data);
+ am->data = NULL;
}
}
ktest_empty_data(&(p->sam_pk_for_sad));
if (p->sam_cksum.contents != NULL) {
- free(p->sam_cksum.contents);
- p->sam_cksum.contents = NULL;
+ free(p->sam_cksum.contents);
+ p->sam_cksum.contents = NULL;
}
}
krb5_sam_key *p;
{
if (p->sam_key.contents)
- free(p->sam_key.contents);
+ free(p->sam_key.contents);
}
void ktest_empty_predicted_sam_response(p)
void ktest_empty_enc_sam_response_enc(p)
krb5_enc_sam_response_enc *p;
{
- ktest_empty_data(&p->sam_sad);
+ ktest_empty_data(&p->sam_sad);
}
void ktest_empty_sam_response_2(p)
krb5_sam_response_2 *p;
{
- ktest_empty_data(&p->sam_track_id);
- ktest_empty_data(&p->sam_enc_nonce_or_sad.ciphertext);
+ ktest_empty_data(&p->sam_track_id);
+ ktest_empty_data(&p->sam_enc_nonce_or_sad.ciphertext);
}
void ktest_empty_enc_sam_response_enc_2(p)
krb5_enc_sam_response_enc_2 *p;
{
- ktest_empty_data(&p->sam_sad);
+ ktest_empty_data(&p->sam_sad);
}
void ktest_empty_pa_s4u_x509_user(p)
ktest_destroy_principal(&p->client);
if (p->delegated != NULL) {
for (i = 0; p->delegated[i] != NULL; i++) {
- krb5_principal princ = p->delegated[i];
+ krb5_principal princ = p->delegated[i];
ktest_destroy_principal(&princ);
- }
+ }
free(p->delegated);
}
ktest_destroy_pa_data_array(&p->method_data);
if (p->checksum.contents) free(p->checksum.contents);
if (p->delegated != NULL) {
for (i = 0; p->delegated[i] != NULL; i++) {
- krb5_principal princ = p->delegated[i];
+ krb5_principal princ = p->delegated[i];
ktest_destroy_principal(&princ);
- }
+ }
free(p->delegated);
}
ktest_destroy_pa_data_array(&p->method_data);
{
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]);
+ free(p->key_data[i].key_data_contents[0]);
+ free(p->key_data[i].key_data_contents[1]);
}
free(p->key_data);
}
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#include <stdlib.h>
#include <stdio.h>
#include "ktest_equal.h"
#define FALSE 0
#define TRUE 1
-#define struct_equal(field,comparator) \
+#define struct_equal(field,comparator) \
comparator(&(ref->field),&(var->field))
-#define ptr_equal(field,comparator) \
+#define ptr_equal(field,comparator) \
comparator(ref->field,var->field)
-#define scalar_equal(field) \
+#define scalar_equal(field) \
((ref->field) == (var->field))
-#define len_equal(length,field,comparator) \
- ((ref->length == var->length) && \
+#define len_equal(length,field,comparator) \
+ ((ref->length == var->length) && \
comparator(ref->length,ref->field,var->field))
int ktest_equal_authenticator(ref, var)
if (ref==var) return TRUE;
else if (ref == NULL || var == NULL) return FALSE;
return(struct_equal(realm,ktest_equal_data) &&
- len_equal(length,data,ktest_equal_array_of_data) &&
- scalar_equal(type));
+ len_equal(length,data,ktest_equal_array_of_data) &&
+ scalar_equal(type));
}
int ktest_equal_authdata(ref, var)
if (ref==var) return TRUE;
else if (ref == NULL || var == NULL) return FALSE;
return(scalar_equal(ad_type) &&
- len_equal(length,contents,ktest_equal_array_of_octet));
+ len_equal(length,contents,ktest_equal_array_of_octet));
}
int ktest_equal_checksum(ref, var)
krb5_alt_method *var;
{
if (ref->method != var->method)
- return FALSE;
+ return FALSE;
if (ref->length != var->length)
- return FALSE;
+ return FALSE;
if (memcmp(ref->data, var->data, ref->length) != 0)
- return FALSE;
+ return FALSE;
return TRUE;
}
krb5_etype_info_entry *var;
{
if (ref->etype != var->etype)
- return FALSE;
+ return FALSE;
if (ref->length != var->length)
- return FALSE;
+ return FALSE;
if (ref->length > 0 && ref->length != KRB5_ETYPE_NO_SALT)
- if (memcmp(ref->salt, var->salt, ref->length) != 0)
- return FALSE;
+ if (memcmp(ref->salt, var->salt, ref->length) != 0)
+ return FALSE;
return TRUE;
}
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);
+ ktest_equal_array_of_octet);
p=p&&len_equal(key_data_length[1],key_data_contents[1],
- ktest_equal_array_of_octet);
+ 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);
+ p=p&&equal_key_data(ref+i, val+i);
}
return p;
}
if (ref==var) return TRUE;
else if (ref == NULL || var == NULL) return FALSE;
for (i=0; i<(length); i++) {
- p = p && ktest_equal_data(&(ref[i]),&(var[i]));
+ p = p && ktest_equal_data(&(ref[i]),&(var[i]));
}
return p;
}
if (ref==var) return TRUE;
else if (ref == NULL || var == NULL) return FALSE;
for (i=0; i<length; i++)
- p = p && (ref[i] == var[i]);
+ p = p && (ref[i] == var[i]);
return p;
}
if (ref==var) return TRUE;
else if (ref == NULL || var == NULL) return FALSE;
for (i=0; i<length; i++)
- p = p && (ref[i] == var[i]);
+ p = p && (ref[i] == var[i]);
return p;
}
if (ref==var) return TRUE;
else if (ref == NULL || var == NULL) return FALSE;
for (i=0; i<length; i++)
- p = p && (ref[i] == var[i]);
+ p = p && (ref[i] == var[i]);
return p;
}
-#define array_compare(comparator) \
- int i,p=TRUE; \
- if (ref==var) return TRUE; \
- if (!ref || !ref[0]) \
- return (!var || !var[0]); \
- if (!var || !var[0]) return FALSE; \
- for (i=0; ref[i] != NULL && var[i] != NULL; i++) \
- p = p && comparator(ref[i],var[i]); \
- if (ref[i] == NULL && var[i] == NULL) return p; \
+#define array_compare(comparator) \
+ int i,p=TRUE; \
+ if (ref==var) return TRUE; \
+ if (!ref || !ref[0]) \
+ return (!var || !var[0]); \
+ if (!var || !var[0]) return FALSE; \
+ for (i=0; ref[i] != NULL && var[i] != NULL; i++) \
+ p = p && comparator(ref[i],var[i]); \
+ if (ref[i] == NULL && var[i] == NULL) return p; \
else return FALSE
int ktest_equal_authorization_data(ref, var)
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright (C) 1992,1993 Trusted Information Systems, Inc.
*
char *option;
{
if (word[0] != '-')
- return 0;
+ return 0;
if (word[1] == '-')
- word++;
+ word++;
if (strcmp(word+1, option))
- return 0;
+ return 0;
return 1;
}
int r = 0;
while (--argc > 0) {
- argv++;
- if (optflg && *(argv)[0] == '-') {
- if (check_option(*argv, "help"))
- usage();
- else if (check_option(*argv, "types"))
- print_types = 1;
- else if (check_option(*argv, "notypes"))
- print_types = 0;
- else if (check_option(*argv, "krb5"))
- print_krb5_types = 1;
- else if (check_option(*argv, "hex"))
- do_hex = 1;
- else if (check_option(*argv, "notypebytes"))
- print_id_and_len = 0;
- else if (check_option(*argv, "krb5decode")) {
- print_id_and_len = 0;
- print_krb5_types = 1;
- print_types = 1;
- } else {
- fprintf(stderr,"trval: unknown option: %s\n", *argv);
- usage();
- }
- } else {
- optflg = 0;
- if ((fp = fopen(*argv,"r")) == NULL) {
- fprintf(stderr,"trval: unable to open %s\n", *argv);
- continue;
- }
- r = trval(fp, stdout);
- fclose(fp);
- }
+ argv++;
+ if (optflg && *(argv)[0] == '-') {
+ if (check_option(*argv, "help"))
+ usage();
+ else if (check_option(*argv, "types"))
+ print_types = 1;
+ else if (check_option(*argv, "notypes"))
+ print_types = 0;
+ else if (check_option(*argv, "krb5"))
+ print_krb5_types = 1;
+ else if (check_option(*argv, "hex"))
+ do_hex = 1;
+ else if (check_option(*argv, "notypebytes"))
+ print_id_and_len = 0;
+ else if (check_option(*argv, "krb5decode")) {
+ print_id_and_len = 0;
+ print_krb5_types = 1;
+ print_types = 1;
+ } else {
+ fprintf(stderr,"trval: unknown option: %s\n", *argv);
+ usage();
+ }
+ } else {
+ optflg = 0;
+ if ((fp = fopen(*argv,"r")) == NULL) {
+ fprintf(stderr,"trval: unable to open %s\n", *argv);
+ continue;
+ }
+ r = trval(fp, stdout);
+ fclose(fp);
+ }
}
if (optflg) r = trval(stdin, stdout);
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright (C) 1992,1993 Trusted Information Systems, Inc.
*
/* IDENTIFIER OCTET = TAG CLASS | FORM OF ENCODING | TAG NUMBER */
/* TAG CLASSES */
-#define ID_CLASS 0xc0 /* bits 8 and 7 */
-#define CLASS_UNIV 0x00 /* 0 = universal */
-#define CLASS_APPL 0x40 /* 1 = application */
-#define CLASS_CONT 0x80 /* 2 = context-specific */
-#define CLASS_PRIV 0xc0 /* 3 = private */
+#define ID_CLASS 0xc0 /* bits 8 and 7 */
+#define CLASS_UNIV 0x00 /* 0 = universal */
+#define CLASS_APPL 0x40 /* 1 = application */
+#define CLASS_CONT 0x80 /* 2 = context-specific */
+#define CLASS_PRIV 0xc0 /* 3 = private */
/* FORM OF ENCODING */
-#define ID_FORM 0x20 /* bit 6 */
-#define FORM_PRIM 0x00 /* 0 = primitive */
-#define FORM_CONS 0x20 /* 1 = constructed */
+#define ID_FORM 0x20 /* bit 6 */
+#define FORM_PRIM 0x00 /* 0 = primitive */
+#define FORM_CONS 0x20 /* 1 = constructed */
/* TAG NUMBERS */
-#define ID_TAG 0x1f /* bits 5-1 */
-#define PRIM_BOOL 0x01 /* Boolean */
-#define PRIM_INT 0x02 /* Integer */
-#define PRIM_BITS 0x03 /* Bit String */
-#define PRIM_OCTS 0x04 /* Octet String */
-#define PRIM_NULL 0x05 /* Null */
-#define PRIM_OID 0x06 /* Object Identifier */
-#define PRIM_ODE 0x07 /* Object Descriptor */
-#define CONS_EXTN 0x08 /* External */
-#define PRIM_REAL 0x09 /* Real */
-#define PRIM_ENUM 0x0a /* Enumerated type */
-#define PRIM_ENCR 0x0b /* Encrypted */
-#define CONS_SEQ 0x10 /* SEQUENCE/SEQUENCE OF */
-#define CONS_SET 0x11 /* SET/SET OF */
-#define DEFN_NUMS 0x12 /* Numeric String */
-#define DEFN_PRTS 0x13 /* Printable String */
-#define DEFN_T61S 0x14 /* T.61 String */
-#define DEFN_VTXS 0x15 /* Videotex String */
-#define DEFN_IA5S 0x16 /* IA5 String */
-#define DEFN_UTCT 0x17 /* UTCTime */
-#define DEFN_GENT 0x18 /* Generalized Time */
-#define DEFN_GFXS 0x19 /* Graphics string (ISO2375) */
-#define DEFN_VISS 0x1a /* Visible string */
-#define DEFN_GENS 0x1b /* General string */
-#define DEFN_CHRS 0x1c /* Character string */
-
-#define LEN_XTND 0x80 /* long or indefinite form */
-#define LEN_SMAX 127 /* largest short form */
-#define LEN_MASK 0x7f /* mask to get number of bytes in length */
-#define LEN_INDF (-1) /* indefinite length */
-
-#define KRB5 /* Do krb5 application types */
+#define ID_TAG 0x1f /* bits 5-1 */
+#define PRIM_BOOL 0x01 /* Boolean */
+#define PRIM_INT 0x02 /* Integer */
+#define PRIM_BITS 0x03 /* Bit String */
+#define PRIM_OCTS 0x04 /* Octet String */
+#define PRIM_NULL 0x05 /* Null */
+#define PRIM_OID 0x06 /* Object Identifier */
+#define PRIM_ODE 0x07 /* Object Descriptor */
+#define CONS_EXTN 0x08 /* External */
+#define PRIM_REAL 0x09 /* Real */
+#define PRIM_ENUM 0x0a /* Enumerated type */
+#define PRIM_ENCR 0x0b /* Encrypted */
+#define CONS_SEQ 0x10 /* SEQUENCE/SEQUENCE OF */
+#define CONS_SET 0x11 /* SET/SET OF */
+#define DEFN_NUMS 0x12 /* Numeric String */
+#define DEFN_PRTS 0x13 /* Printable String */
+#define DEFN_T61S 0x14 /* T.61 String */
+#define DEFN_VTXS 0x15 /* Videotex String */
+#define DEFN_IA5S 0x16 /* IA5 String */
+#define DEFN_UTCT 0x17 /* UTCTime */
+#define DEFN_GENT 0x18 /* Generalized Time */
+#define DEFN_GFXS 0x19 /* Graphics string (ISO2375) */
+#define DEFN_VISS 0x1a /* Visible string */
+#define DEFN_GENS 0x1b /* General string */
+#define DEFN_CHRS 0x1c /* Character string */
+
+#define LEN_XTND 0x80 /* long or indefinite form */
+#define LEN_SMAX 127 /* largest short form */
+#define LEN_MASK 0x7f /* mask to get number of bytes in length */
+#define LEN_INDF (-1) /* indefinite length */
+
+#define KRB5 /* Do krb5 application types */
int print_types = 0;
int print_id_and_len = 1;
static int convert_nibble(int ch)
{
if (isdigit(ch))
- return (ch - '0');
+ return (ch - '0');
if (ch >= 'a' && ch <= 'f')
- return (ch - 'a' + 10);
+ return (ch - 'a' + 10);
if (ch >= 'A' && ch <= 'F')
- return (ch - 'A' + 10);
+ return (ch - 'A' + 10);
return -1;
}
int trval(fin, fout)
- FILE *fin;
- FILE *fout;
+ FILE *fin;
+ FILE *fout;
{
unsigned char *p;
unsigned int maxlen;
p = (unsigned char *)malloc(maxlen);
len = 0;
while ((cc = fgetc(fin)) != EOF) {
- if ((unsigned int) len == maxlen) {
- maxlen += BUFSIZ;
- p = (unsigned char *)realloc(p, maxlen);
- }
- if (do_hex) {
- if (cc == ' ' || cc == '\n' || cc == '\t')
- continue;
- cc2 = fgetc(fin);
- if (cc2 == EOF)
- break;
- n1 = convert_nibble(cc);
- n2 = convert_nibble(cc2);
- cc = (n1 << 4) + n2;
- }
- p[len++] = cc;
+ if ((unsigned int) len == maxlen) {
+ maxlen += BUFSIZ;
+ p = (unsigned char *)realloc(p, maxlen);
+ }
+ if (do_hex) {
+ if (cc == ' ' || cc == '\n' || cc == '\t')
+ continue;
+ cc2 = fgetc(fin);
+ if (cc2 == EOF)
+ break;
+ n1 = convert_nibble(cc);
+ n2 = convert_nibble(cc2);
+ cc = (n1 << 4) + n2;
+ }
+ p[len++] = cc;
}
fprintf(fout, "<%d>", len);
r = trval2(fout, p, len, 0, &rlen);
r = OK;
if (len < 2) {
- fprintf(fp, "missing id and length octets (%d)\n", len);
- return(NOTOK);
+ fprintf(fp, "missing id and length octets (%d)\n", len);
+ return(NOTOK);
}
fprintf(fp, "\n");
elen = enc[1];
if (print_id_and_len) {
- fprintf(fp, "%02x ", eid);
- fprintf(fp, "%02x ", elen);
+ fprintf(fp, "%02x ", eid);
+ fprintf(fp, "%02x ", elen);
}
if (elen == LEN_XTND) {
- fprintf(fp,
- "indefinite length encoding not implemented (0x%02x)\n", elen);
- return(NOTOK);
+ fprintf(fp,
+ "indefinite length encoding not implemented (0x%02x)\n", elen);
+ return(NOTOK);
}
xlen = 0;
if (elen & LEN_XTND) {
- xlen = elen & LEN_MASK;
- if (xlen > len - 2) {
- fprintf(fp, "extended length too long (%d > %d - 2)\n", xlen, len);
- return(NOTOK);
- }
- elen = decode_len(fp, enc+2, xlen);
+ xlen = elen & LEN_MASK;
+ if (xlen > len - 2) {
+ fprintf(fp, "extended length too long (%d > %d - 2)\n", xlen, len);
+ return(NOTOK);
+ }
+ elen = decode_len(fp, enc+2, xlen);
}
if (elen > len - 2 - xlen) {
- fprintf(fp, "length too long (%d > %d - 2 - %d)\n", elen, len, xlen);
- return(NOTOK);
+ fprintf(fp, "length too long (%d > %d - 2 - %d)\n", elen, len, xlen);
+ return(NOTOK);
}
print_tag_type(fp, eid, lev);
if (print_context_shortcut &&
- ((eid & ID_CLASS) == CLASS_CONT) && (lev > 0)) {
- rlen_ext += 2 + xlen;
- enc += 2 + xlen;
- goto context_restart;
+ ((eid & ID_CLASS) == CLASS_CONT) && (lev > 0)) {
+ rlen_ext += 2 + xlen;
+ enc += 2 + xlen;
+ goto context_restart;
}
switch(eid & ID_FORM) {
case FORM_PRIM:
- r = do_prim(fp, eid & ID_TAG, enc+2+xlen, elen, lev+1);
- *rlen = 2 + xlen + elen + rlen_ext;
- break;
+ r = do_prim(fp, eid & ID_TAG, enc+2+xlen, elen, lev+1);
+ *rlen = 2 + xlen + elen + rlen_ext;
+ break;
case FORM_CONS:
- if (print_constructed_length) {
- fprintf(fp, "constr ");
- fprintf(fp, "<%d>", elen);
- }
- r = do_cons(fp, enc+2+xlen, elen, lev+1, &rlen2);
- *rlen = 2 + xlen + rlen2 + rlen_ext;
- break;
+ if (print_constructed_length) {
+ fprintf(fp, "constr ");
+ fprintf(fp, "<%d>", elen);
+ }
+ r = do_cons(fp, enc+2+xlen, elen, lev+1, &rlen2);
+ *rlen = 2 + xlen + rlen2 + rlen_ext;
+ break;
}
return(r);
int i;
if (print_id_and_len)
- fprintf(fp, "%02x ", enc[0]);
+ fprintf(fp, "%02x ", enc[0]);
rlen = enc[0];
for (i=1; i<len; i++) {
- if (print_id_and_len)
- fprintf(fp, "%02x ", enc[i]);
- rlen = (rlen * 0x100) + enc[i];
+ if (print_id_and_len)
+ fprintf(fp, "%02x ", enc[i]);
+ rlen = (rlen * 0x100) + enc[i];
}
return(rlen);
}
int len;
int lev;
{
- int i;
- long num = 0;
+ int i;
+ long num = 0;
if (tag != PRIM_BITS || len > 5)
- return 0;
+ return 0;
for (i=1; i < len; i++) {
- num = num << 8;
- num += enc[i];
+ num = num << 8;
+ num += enc[i];
}
fprintf(fp, "0x%lx", num);
if (enc[0])
- fprintf(fp, " (%d unused bits)", enc[0]);
+ fprintf(fp, " (%d unused bits)", enc[0]);
return 1;
}
int len;
int lev;
{
- int i;
- long num = 0;
+ int i;
+ long num = 0;
if (tag != PRIM_INT || len > 4)
- return 0;
+ return 0;
if (enc[0] & 0x80)
- num = -1;
+ num = -1;
for (i=0; i < len; i++) {
- num = num << 8;
- num += enc[i];
+ num = num << 8;
+ num += enc[i];
}
fprintf(fp, "%ld", num);
int len;
int lev;
{
- int i;
+ int i;
/*
* Only try this printing function with "reasonable" types
*/
if ((tag < DEFN_NUMS) && (tag != PRIM_OCTS))
- return 0;
+ return 0;
for (i=0; i < len; i++)
- if (!isprint(enc[i]))
- return 0;
+ if (!isprint(enc[i]))
+ return 0;
fprintf(fp, "\"%.*s\"", len, enc);
return 1;
}
int width;
if (do_prim_string(fp, tag, enc, len, lev))
- return OK;
+ return OK;
if (do_prim_int(fp, tag, enc, len, lev))
- return OK;
+ return OK;
if (do_prim_bitstring(fp, tag, enc, len, lev))
- return OK;
+ return OK;
if (print_primitive_length)
- fprintf(fp, "<%d>", len);
+ fprintf(fp, "<%d>", len);
width = (80 - (lev * 3) - 8) / 4;
for (n = 0; n < len; n++) {
- if ((n % width) == 0) {
- fprintf(fp, "\n");
- for (i=0; i<lev; i++) fprintf(fp, " ");
- }
- fprintf(fp, "%02x ", enc[n]);
- if ((n % width) == (width-1)) {
- fprintf(fp, " ");
- for (i=n-(width-1); i<=n; i++)
- if (isprint(enc[i])) fprintf(fp, "%c", enc[i]);
- else fprintf(fp, ".");
- }
+ if ((n % width) == 0) {
+ fprintf(fp, "\n");
+ for (i=0; i<lev; i++) fprintf(fp, " ");
+ }
+ fprintf(fp, "%02x ", enc[n]);
+ if ((n % width) == (width-1)) {
+ fprintf(fp, " ");
+ for (i=n-(width-1); i<=n; i++)
+ if (isprint(enc[i])) fprintf(fp, "%c", enc[i]);
+ else fprintf(fp, ".");
+ }
}
if ((j = (n % width)) != 0) {
- fprintf(fp, " ");
- for (i=0; i<width-j; i++) fprintf(fp, " ");
- for (i=n-j; i<n; i++)
- if (isprint(enc[i])) fprintf(fp, "%c", enc[i]);
- else fprintf(fp, ".");
+ fprintf(fp, " ");
+ for (i=0; i<width-j; i++) fprintf(fp, " ");
+ for (i=n-j; i<n; i++)
+ if (isprint(enc[i])) fprintf(fp, "%c", enc[i]);
+ else fprintf(fp, ".");
}
return(OK);
}
save_appl = current_appl_type;
for (n = 0, rlent = 0; n < len; n+=rlen2, rlent+=rlen2) {
- r = trval2(fp, enc+n, len-n, lev, &rlen2);
- current_appl_type = save_appl;
- if (r != OK) return(r);
+ r = trval2(fp, enc+n, len-n, lev, &rlen2);
+ current_appl_type = save_appl;
+ if (r != OK) return(r);
}
if (rlent != len) {
- fprintf(fp, "inconsistent constructed lengths (%d != %d)\n",
- rlent, len);
- return(NOTOK);
+ fprintf(fp, "inconsistent constructed lengths (%d != %d)\n",
+ rlent, len);
+ return(NOTOK);
}
*rlen = rlent;
return(r);
}
struct typestring_table {
- int k1, k2;
- char *str;
- int new_appl;
+ int k1, k2;
+ char *str;
+ int new_appl;
};
static char *lookup_typestring(table, key1, key2)
struct typestring_table *table;
- int key1, key2;
+ int key1, key2;
{
struct typestring_table *ent;
for (ent = table; ent->k1 > 0; ent++) {
- if ((ent->k1 == key1) &&
- (ent->k2 == key2)) {
- if (ent->new_appl)
- current_appl_type = ent->new_appl;
- return ent->str;
- }
+ if ((ent->k1 == key1) &&
+ (ent->k2 == key2)) {
+ if (ent->new_appl)
+ current_appl_type = ent->new_appl;
+ return ent->str;
+ }
}
return 0;
}
{ 1000, 0, "name-type"}, /* PrincipalName */
{ 1000, 1, "name-string"},
- { 1001, 0, "etype"}, /* Encrypted data */
+ { 1001, 0, "etype"}, /* Encrypted data */
{ 1001, 1, "kvno"},
{ 1001, 2, "cipher"},
- { 1002, 0, "addr-type"}, /* HostAddress */
+ { 1002, 0, "addr-type"}, /* HostAddress */
{ 1002, 1, "address"},
- { 1003, 0, "addr-type"}, /* HostAddresses */
+ { 1003, 0, "addr-type"}, /* HostAddresses */
{ 1003, 1, "address"},
- { 1004, 0, "ad-type"}, /* AuthorizationData */
+ { 1004, 0, "ad-type"}, /* AuthorizationData */
{ 1004, 1, "ad-data"},
- { 1005, 0, "keytype"}, /* EncryptionKey */
+ { 1005, 0, "keytype"}, /* EncryptionKey */
{ 1005, 1, "keyvalue"},
- { 1006, 0, "cksumtype"}, /* Checksum */
+ { 1006, 0, "cksumtype"}, /* Checksum */
{ 1006, 1, "checksum"},
- { 1007, 0, "kdc-options"}, /* KDC-REQ-BODY */
+ { 1007, 0, "kdc-options"}, /* KDC-REQ-BODY */
{ 1007, 1, "cname", 1000},
{ 1007, 2, "realm"},
{ 1007, 3, "sname", 1000},
{ 1007, 10, "enc-authorization-data", 1001},
{ 1007, 11, "additional-tickets"},
- { 1008, 1, "padata-type"}, /* PA-DATA */
+ { 1008, 1, "padata-type"}, /* PA-DATA */
{ 1008, 2, "pa-data"},
- { 1009, 0, "user-data"}, /* KRB-SAFE-BODY */
+ { 1009, 0, "user-data"}, /* KRB-SAFE-BODY */
{ 1009, 1, "timestamp"},
{ 1009, 2, "usec"},
{ 1009, 3, "seq-number"},
{ 1009, 4, "s-address", 1002},
{ 1009, 5, "r-address", 1002},
- { 1010, 0, "lr-type"}, /* LastReq */
+ { 1010, 0, "lr-type"}, /* LastReq */
{ 1010, 1, "lr-value"},
- { 1011, 0, "key", 1005}, /* KRB-CRED-INFO */
+ { 1011, 0, "key", 1005}, /* KRB-CRED-INFO */
{ 1011, 1, "prealm"},
{ 1011, 2, "pname", 1000},
{ 1011, 3, "flags"},
{ 1011, 9, "sname", 1000},
{ 1011, 10, "caddr", 1002},
- { 1, 0, "tkt-vno"}, /* Ticket */
+ { 1, 0, "tkt-vno"}, /* Ticket */
{ 1, 1, "realm"},
{ 1, 2, "sname", 1000},
{ 1, 3, "tkt-enc-part", 1001},
{ 3, 9, "caddr", 1003},
{ 3, 10, "authorization-data", 1004},
- { 10, 1, "pvno"}, /* AS-REQ */
+ { 10, 1, "pvno"}, /* AS-REQ */
{ 10, 2, "msg-type"},
{ 10, 3, "padata", 1008},
{ 10, 4, "req-body", 1007},
- { 11, 0, "pvno"}, /* AS-REP */
+ { 11, 0, "pvno"}, /* AS-REP */
{ 11, 1, "msg-type"},
{ 11, 2, "padata", 1008},
{ 11, 3, "crealm"},
{ 11, 5, "ticket"},
{ 11, 6, "enc-part", 1001},
- { 12, 1, "pvno"}, /* TGS-REQ */
+ { 12, 1, "pvno"}, /* TGS-REQ */
{ 12, 2, "msg-type"},
{ 12, 3, "padata", 1008},
{ 12, 4, "req-body", 1007},
- { 13, 0, "pvno"}, /* TGS-REP */
+ { 13, 0, "pvno"}, /* TGS-REP */
{ 13, 1, "msg-type"},
{ 13, 2, "padata", 1008},
{ 13, 3, "crealm"},
{ 13, 5, "ticket"},
{ 13, 6, "enc-part", 1001},
- { 14, 0, "pvno"}, /* AP-REQ */
+ { 14, 0, "pvno"}, /* AP-REQ */
{ 14, 1, "msg-type"},
{ 14, 2, "ap-options"},
{ 14, 3, "ticket"},
{ 14, 4, "authenticator", 1001},
- { 15, 0, "pvno"}, /* AP-REP */
+ { 15, 0, "pvno"}, /* AP-REP */
{ 15, 1, "msg-type"},
{ 15, 2, "enc-part", 1001},
- { 20, 0, "pvno"}, /* KRB-SAFE */
+ { 20, 0, "pvno"}, /* KRB-SAFE */
{ 20, 1, "msg-type"},
{ 20, 2, "safe-body", 1009},
{ 20, 3, "cksum", 1006},
- { 21, 0, "pvno"}, /* KRB-PRIV */
+ { 21, 0, "pvno"}, /* KRB-PRIV */
{ 21, 1, "msg-type"},
{ 21, 2, "enc-part", 1001},
- { 22, 0, "pvno"}, /* KRB-CRED */
+ { 22, 0, "pvno"}, /* KRB-CRED */
{ 22, 1, "msg-type"},
{ 22, 2, "tickets"},
{ 22, 3, "enc-part", 1001},
- { 25, 0, "key", 1005}, /* EncASRepPart */
+ { 25, 0, "key", 1005}, /* EncASRepPart */
{ 25, 1, "last-req", 1010},
{ 25, 2, "nonce"},
{ 25, 3, "key-expiration"},
{ 25, 10, "sname", 1000},
{ 25, 11, "caddr", 1003},
- { 26, 0, "key", 1005}, /* EncTGSRepPart */
+ { 26, 0, "key", 1005}, /* EncTGSRepPart */
{ 26, 1, "last-req", 1010},
{ 26, 2, "nonce"},
{ 26, 3, "key-expiration"},
{ 26, 10, "sname", 1000},
{ 26, 11, "caddr", 1003},
- { 27, 0, "ctime"}, /* EncApRepPart */
+ { 27, 0, "ctime"}, /* EncApRepPart */
{ 27, 1, "cusec"},
{ 27, 2, "subkey", 1005},
{ 27, 3, "seq-number"},
- { 28, 0, "user-data"}, /* EncKrbPrivPart */
+ { 28, 0, "user-data"}, /* EncKrbPrivPart */
{ 28, 1, "timestamp"},
{ 28, 2, "usec"},
{ 28, 3, "seq-number"},
{ 28, 4, "s-address", 1002},
{ 28, 5, "r-address", 1002},
- { 29, 0, "ticket-info", 1011}, /* EncKrbCredPart */
+ { 29, 0, "ticket-info", 1011}, /* EncKrbCredPart */
{ 29, 1, "nonce"},
{ 29, 2, "timestamp"},
{ 29, 3, "usec"},
{ 29, 4, "s-address", 1002},
{ 29, 5, "r-address", 1002},
- { 30, 0, "pvno"}, /* KRB-ERROR */
+ { 30, 0, "pvno"}, /* KRB-ERROR */
{ 30, 1, "msg-type"},
{ 30, 2, "ctime"},
{ 30, 3, "cusec"},
int eid;
int lev;
{
- int tag = eid & ID_TAG;
- int do_space = 1;
- char *str;
+ int tag = eid & ID_TAG;
+ int do_space = 1;
+ char *str;
fprintf(fp, "[");
switch(eid & ID_CLASS) {
case CLASS_UNIV:
- if (print_types && print_skip_tagnum)
- do_space = 0;
- else
- fprintf(fp, "UNIV %d", tag);
- break;
+ if (print_types && print_skip_tagnum)
+ do_space = 0;
+ else
+ fprintf(fp, "UNIV %d", tag);
+ break;
case CLASS_APPL:
- current_appl_type = tag;
+ current_appl_type = tag;
#ifdef KRB5
- if (print_krb5_types) {
- str = lookup_typestring(krb5_types, tag, -1);
- if (str) {
- fputs(str, fp);
- break;
- }
- }
+ if (print_krb5_types) {
+ str = lookup_typestring(krb5_types, tag, -1);
+ if (str) {
+ fputs(str, fp);
+ break;
+ }
+ }
#endif
- fprintf(fp, "APPL %d", tag);
- break;
+ fprintf(fp, "APPL %d", tag);
+ break;
case CLASS_CONT:
#ifdef KRB5
- if (print_krb5_types && current_appl_type) {
- str = lookup_typestring(krb5_fields,
- current_appl_type, tag);
- if (str) {
- fputs(str, fp);
- break;
- }
- }
+ if (print_krb5_types && current_appl_type) {
+ str = lookup_typestring(krb5_fields,
+ current_appl_type, tag);
+ if (str) {
+ fputs(str, fp);
+ break;
+ }
+ }
#endif
- if (print_skip_context && lev)
- fprintf(fp, "%d", tag);
- else
- fprintf(fp, "CONT %d", tag);
- break;
+ if (print_skip_context && lev)
+ fprintf(fp, "%d", tag);
+ else
+ fprintf(fp, "CONT %d", tag);
+ break;
case CLASS_PRIV:
- fprintf(fp, "PRIV %d", tag);
- break;
+ fprintf(fp, "PRIV %d", tag);
+ break;
}
if (print_types && ((eid & ID_CLASS) == CLASS_UNIV)) {
- if (do_space)
- fputs(" ", fp);
- str = lookup_typestring(univ_types, eid & ID_TAG, -1);
- if (str)
- fputs(str, fp);
- else
- fprintf(fp, "UNIV %d???", eid & ID_TAG);
+ if (do_space)
+ fputs(" ", fp);
+ str = lookup_typestring(univ_types, eid & ID_TAG, -1);
+ if (str)
+ fputs(str, fp);
+ else
+ fprintf(fp, "UNIV %d???", eid & ID_TAG);
}
fprintf(fp, "] ");
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#include "utility.h"
#include "krb5.h"
#include <stdlib.h>
if (*s != NULL) free(*s);
if (code==NULL) {
- *s = strdup("<NULL>");
- if (*s == NULL) return ENOMEM;
+ *s = strdup("<NULL>");
+ if (*s == NULL) return ENOMEM;
} else if (code->data == NULL || ((int) code->length) <= 0) {
- *s = strdup("<EMPTY>");
- if (*s==NULL) return ENOMEM;
+ *s = strdup("<EMPTY>");
+ if (*s==NULL) return ENOMEM;
} else {
- unsigned int i;
+ unsigned int i;
- *s = (char*)calloc((size_t) 3*(code->length), sizeof(char));
- if (*s == NULL) return ENOMEM;
- for (i = 0; i < code->length; i++) {
- (*s)[3*i] = hexchar((unsigned char) (((code->data)[i]&0xF0)>>4));
- (*s)[3*i+1] = hexchar((unsigned char) ((code->data)[i]&0x0F));
- (*s)[3*i+2] = ' ';
- }
- (*s)[3*(code->length)-1] = '\0';
+ *s = (char*)calloc((size_t) 3*(code->length), sizeof(char));
+ if (*s == NULL) return ENOMEM;
+ for (i = 0; i < code->length; i++) {
+ (*s)[3*i] = hexchar((unsigned char) (((code->data)[i]&0xF0)>>4));
+ (*s)[3*i+1] = hexchar((unsigned char) ((code->data)[i]&0x0F));
+ (*s)[3*i+2] = ' ';
+ }
+ (*s)[3*(code->length)-1] = '\0';
}
return 0;
}
const unsigned int digit;
{
if (digit<=9)
- return '0'+digit;
+ return '0'+digit;
else if (digit<=15)
- return 'A'+digit-10;
+ return 'A'+digit-10;
else
- return 'X';
+ return 'X';
}
krb5_error_code krb5_data_parse(d, s)
d->data = calloc((strlen(s) / 2 + 1), 1);
if (d->data == NULL)
- return ENOMEM;
+ return ENOMEM;
d->length = 0;
buf[1] = '\0';
for (lo = 0, dp = d->data, cp = s; *cp; cp++) {
- if (*cp < 0)
- return ASN1_PARSE_ERROR;
- else if (isspace((unsigned char) *cp))
- continue;
- else if (isxdigit((unsigned char) *cp)) {
- buf[0] = *cp;
- v = strtol(buf, NULL, 16);
- } else
- return ASN1_PARSE_ERROR;
- if (lo) {
- *dp++ |= v;
- lo = 0;
- } else {
- *dp = v << 4;
- lo = 1;
- }
+ if (*cp < 0)
+ return ASN1_PARSE_ERROR;
+ else if (isspace((unsigned char) *cp))
+ continue;
+ else if (isxdigit((unsigned char) *cp)) {
+ buf[0] = *cp;
+ v = strtol(buf, NULL, 16);
+ } else
+ return ASN1_PARSE_ERROR;
+ if (lo) {
+ *dp++ |= v;
+ lo = 0;
+ } else {
+ *dp = v << 4;
+ lo = 1;
+ }
}
d->length = dp - d->data;
s = calloc(3*length, sizeof(char));
if (s == NULL) return;
for (i=0; i<length; i++) {
- s[3*i] = hexchar(((bufcopy.base)[i]&0xF0)>>4);
- s[3*i+1] = hexchar((bufcopy.base)[i]&0x0F);
- s[3*i+2] = ' ';
+ s[3*i] = hexchar(((bufcopy.base)[i]&0xF0)>>4);
+ s[3*i+1] = hexchar((bufcopy.base)[i]&0x0F);
+ s[3*i+2] = ' ';
}
s[3*length-1] = '\0';
krb5_error_code ret;
ret = krb5int_accessor(&acc, KRB5INT_ACCESS_VERSION);
if (ret) {
- com_err(progname, ret, "while initializing accessor");
- exit(1);
+ com_err(progname, ret, "while initializing accessor");
+ exit(1);
}
}
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* tests/create/kdb5_mkdums.c
*
#include <stdio.h>
-#define REALM_SEP '@'
-#define REALM_SEP_STR "@"
+#define REALM_SEP '@'
+#define REALM_SEP_STR "@"
struct mblock {
krb5_deltat max_life;
krb5_timestamp expiration;
krb5_flags flags;
krb5_kvno mkvno;
-} mblock = { /* XXX */
+} mblock = { /* XXX */
KRB5_KDB_MAX_LIFE,
KRB5_KDB_MAX_RLIFE,
KRB5_KDB_EXPIRATION,
static void
usage(who, status)
-char *who;
-int status;
+ char *who;
+ int status;
{
fprintf(stderr,
- "usage: %s -p prefix -n num_to_create [-d dbpathname] [-r realmname]\n",
- who);
+ "usage: %s -p prefix -n num_to_create [-d dbpathname] [-r realmname]\n",
+ who);
fprintf(stderr, "\t [-D depth] [-k enctype] [-M mkeyname]\n");
exit(status);
krb5_init_context(&test_context);
if (strrchr(argv[0], '/'))
- argv[0] = strrchr(argv[0], '/')+1;
+ argv[0] = strrchr(argv[0], '/')+1;
progname = argv[0];
depth = 1;
while ((optchar = getopt(argc, argv, "D:P:p:n:d:r:k:M:e:m")) != -1) {
- switch(optchar) {
- case 'D':
- depth = atoi(optarg); /* how deep to go */
- break;
- case 'P': /* Only used for testing!!! */
- mkey_password = optarg;
- break;
- case 'p': /* prefix name to create */
- strncpy(principal_string, optarg, sizeof(principal_string) - 1);
- principal_string[sizeof(principal_string) - 1] = '\0';
- suffix = principal_string + strlen(principal_string);
- suffix_size = sizeof(principal_string) -
- (suffix - principal_string);
- break;
- case 'n': /* how many to create */
- num_to_create = atoi(optarg);
- break;
- case 'd': /* set db name */
- dbname = optarg;
- break;
- case 'r':
- cur_realm = optarg;
- break;
- case 'k':
- master_keyblock.enctype = atoi(optarg);
- enctypedone++;
- break;
- case 'M': /* master key name in DB */
- mkey_name = optarg;
- break;
- case 'm':
- manual_mkey = TRUE;
- break;
- case '?':
- default:
- usage(progname, 1);
- /*NOTREACHED*/
- }
+ switch(optchar) {
+ case 'D':
+ depth = atoi(optarg); /* how deep to go */
+ break;
+ case 'P': /* Only used for testing!!! */
+ mkey_password = optarg;
+ break;
+ case 'p': /* prefix name to create */
+ strncpy(principal_string, optarg, sizeof(principal_string) - 1);
+ principal_string[sizeof(principal_string) - 1] = '\0';
+ suffix = principal_string + strlen(principal_string);
+ suffix_size = sizeof(principal_string) -
+ (suffix - principal_string);
+ break;
+ case 'n': /* how many to create */
+ num_to_create = atoi(optarg);
+ break;
+ case 'd': /* set db name */
+ dbname = optarg;
+ break;
+ case 'r':
+ cur_realm = optarg;
+ break;
+ case 'k':
+ master_keyblock.enctype = atoi(optarg);
+ enctypedone++;
+ break;
+ case 'M': /* master key name in DB */
+ mkey_name = optarg;
+ break;
+ case 'm':
+ manual_mkey = TRUE;
+ break;
+ case '?':
+ default:
+ usage(progname, 1);
+ /*NOTREACHED*/
+ }
}
if (!(num_to_create && suffix)) usage(progname, 1);
if (!enctypedone)
- master_keyblock.enctype = DEFAULT_KDC_ENCTYPE;
+ master_keyblock.enctype = DEFAULT_KDC_ENCTYPE;
if (!krb5_c_valid_enctype(master_keyblock.enctype)) {
- com_err(progname, KRB5_PROG_ETYPE_NOSUPP,
- "while setting up enctype %d", master_keyblock.enctype);
- exit(1);
+ com_err(progname, KRB5_PROG_ETYPE_NOSUPP,
+ "while setting up enctype %d", master_keyblock.enctype);
+ exit(1);
}
if (!dbname)
- dbname = DEFAULT_KDB_FILE; /* XXX? */
+ dbname = DEFAULT_KDB_FILE; /* XXX? */
if (!cur_realm) {
- if ((retval = krb5_get_default_realm(test_context, &cur_realm))) {
- com_err(progname, retval, "while retrieving default realm name");
- exit(1);
- }
+ if ((retval = krb5_get_default_realm(test_context, &cur_realm))) {
+ com_err(progname, retval, "while retrieving default realm name");
+ exit(1);
+ }
}
if ((retval = set_dbname_help(progname, dbname)))
- exit(retval);
+ exit(retval);
for (n = 1; n <= num_to_create; n++) {
- /* build the new principal name */
- /* we can't pick random names because we need to generate all the names
- again given a prefix and count to test the db lib and kdb */
- (void) snprintf(suffix, suffix_size, "%d", n);
- (void) snprintf(tmp, sizeof(tmp), "%s-DEPTH-1", principal_string);
- tmp[sizeof(tmp) - 1] = '\0';
- str_newprinc = tmp;
- add_princ(test_context, str_newprinc);
-
- for (i = 2; i <= depth; i++) {
- (void) snprintf(tmp2, sizeof(tmp2), "/%s-DEPTH-%d",
- principal_string, i);
- tmp2[sizeof(tmp2) - 1] = '\0';
- strncat(tmp, tmp2, sizeof(tmp) - 1 - strlen(tmp));
- str_newprinc = tmp;
- add_princ(test_context, str_newprinc);
- }
+ /* build the new principal name */
+ /* we can't pick random names because we need to generate all the names
+ again given a prefix and count to test the db lib and kdb */
+ (void) snprintf(suffix, suffix_size, "%d", n);
+ (void) snprintf(tmp, sizeof(tmp), "%s-DEPTH-1", principal_string);
+ tmp[sizeof(tmp) - 1] = '\0';
+ str_newprinc = tmp;
+ add_princ(test_context, str_newprinc);
+
+ for (i = 2; i <= depth; i++) {
+ (void) snprintf(tmp2, sizeof(tmp2), "/%s-DEPTH-%d",
+ principal_string, i);
+ tmp2[sizeof(tmp2) - 1] = '\0';
+ strncat(tmp, tmp2, sizeof(tmp) - 1 - strlen(tmp));
+ str_newprinc = tmp;
+ add_princ(test_context, str_newprinc);
+ }
}
retval = krb5_db_fini(test_context);
memset(master_keyblock.contents, 0,
- (size_t) master_keyblock.length);
+ (size_t) master_keyblock.length);
if (retval && retval != KRB5_KDB_DBNOTINITED) {
- com_err(progname, retval, "while closing database");
- exit(1);
+ com_err(progname, retval, "while closing database");
+ exit(1);
}
if (master_princ_set) {
- krb5_free_principal(test_context, master_princ);
+ krb5_free_principal(test_context, master_princ);
}
krb5_free_context(test_context);
exit(0);
void
add_princ(context, str_newprinc)
- krb5_context context;
- char * str_newprinc;
+ krb5_context context;
+ char * str_newprinc;
{
- krb5_error_code retval;
- krb5_principal newprinc;
- krb5_db_entry newentry;
- char princ_name[4096];
+ krb5_error_code retval;
+ krb5_principal newprinc;
+ krb5_db_entry newentry;
+ char princ_name[4096];
memset(&newentry, 0, sizeof(newentry));
snprintf(princ_name, sizeof(princ_name), "%s@%s", str_newprinc, cur_realm);
if ((retval = krb5_parse_name(context, princ_name, &newprinc))) {
- com_err(progname, retval, "while parsing '%s'", princ_name);
- return;
+ com_err(progname, retval, "while parsing '%s'", princ_name);
+ return;
}
/* Add basic data */
/* Add princ to db entry */
if ((retval = krb5_copy_principal(context, newprinc, &newentry.princ))) {
- com_err(progname, retval, "while encoding princ to db entry for '%s'",
- princ_name);
- krb5_free_principal(context, newprinc);
- goto error;
+ com_err(progname, retval, "while encoding princ to db entry for '%s'",
+ princ_name);
+ krb5_free_principal(context, newprinc);
+ goto error;
}
{
- /* Add mod princ to db entry */
- krb5_int32 now;
-
- retval = krb5_timeofday(context, &now);
- if (retval) {
- com_err(progname, retval, "while fetching date");
- krb5_free_principal(context, newprinc);
- goto error;
- }
- retval = krb5_dbe_update_mod_princ_data(context, &newentry, now,
- master_princ);
- if (retval) {
- com_err(progname, retval, "while encoding mod_princ data");
- krb5_free_principal(context, newprinc);
- goto error;
- }
+ /* Add mod princ to db entry */
+ krb5_int32 now;
+
+ retval = krb5_timeofday(context, &now);
+ if (retval) {
+ com_err(progname, retval, "while fetching date");
+ krb5_free_principal(context, newprinc);
+ goto error;
+ }
+ retval = krb5_dbe_update_mod_princ_data(context, &newentry, now,
+ master_princ);
+ if (retval) {
+ com_err(progname, retval, "while encoding mod_princ data");
+ krb5_free_principal(context, newprinc);
+ goto error;
+ }
}
{ /* Add key and salt data to db entry */
krb5_keyblock key;
if ((retval = krb5_principal2salt(context, newprinc, &salt))) {
- com_err(progname, retval, "while converting princ to salt for '%s'",
- princ_name);
- krb5_free_principal(context, newprinc);
- goto error;
+ com_err(progname, retval, "while converting princ to salt for '%s'",
+ princ_name);
+ krb5_free_principal(context, newprinc);
+ goto error;
+ }
+
+ krb5_free_principal(context, newprinc);
+
+ pwd.length = strlen(princ_name);
+ pwd.data = princ_name; /* must be able to regenerate */
+ if ((retval = krb5_c_string_to_key(context, master_keyblock.enctype,
+ &pwd, &salt, &key))) {
+ com_err(progname,retval,"while converting password to key for '%s'",
+ princ_name);
+ krb5_free_data_contents(context, &salt);
+ goto error;
}
+ krb5_free_data_contents(context, &salt);
- krb5_free_principal(context, newprinc);
-
- pwd.length = strlen(princ_name);
- pwd.data = princ_name; /* must be able to regenerate */
- if ((retval = krb5_c_string_to_key(context, master_keyblock.enctype,
- &pwd, &salt, &key))) {
- com_err(progname,retval,"while converting password to key for '%s'",
- princ_name);
- krb5_free_data_contents(context, &salt);
- goto error;
- }
- krb5_free_data_contents(context, &salt);
-
- if ((retval = krb5_dbe_create_key_data(context, &newentry))) {
- com_err(progname, retval, "while creating key_data for '%s'",
- princ_name);
+ if ((retval = krb5_dbe_create_key_data(context, &newentry))) {
+ com_err(progname, retval, "while creating key_data for '%s'",
+ princ_name);
free(key.contents);
- goto error;
+ goto error;
}
if ((retval = krb5_dbekd_encrypt_key_data(context,&master_keyblock,
- &key, NULL, 1,
- newentry.key_data))) {
- com_err(progname, retval, "while encrypting key for '%s'",
- princ_name);
+ &key, NULL, 1,
+ newentry.key_data))) {
+ com_err(progname, retval, "while encrypting key for '%s'",
+ princ_name);
free(key.contents);
- goto error;
+ goto error;
}
free(key.contents);
}
{
- int one = 1;
-
- if ((retval = krb5_db_put_principal(context, &newentry, &one))) {
- com_err(progname, retval, "while storing principal date");
- goto error;
- }
- if (one != 1) {
- com_err(progname,0,"entry not stored in database (unknown failure)");
- goto error;
- }
+ int one = 1;
+
+ if ((retval = krb5_db_put_principal(context, &newentry, &one))) {
+ com_err(progname, retval, "while storing principal date");
+ goto error;
+ }
+ if (one != 1) {
+ com_err(progname,0,"entry not stored in database (unknown failure)");
+ goto error;
+ }
}
fprintf(stdout, "Added %s to database\n", princ_name);
int
set_dbname_help(pname, dbname)
-char *pname;
-char *dbname;
+ char *pname;
+ char *dbname;
{
krb5_error_code retval;
int nentries;
/* assemble & parse the master key name */
if ((retval = krb5_db_setup_mkey_name(test_context, mkey_name, cur_realm,
- 0, &master_princ))) {
- com_err(pname, retval, "while setting up master key name");
- return(1);
+ 0, &master_princ))) {
+ com_err(pname, retval, "while setting up master key name");
+ return(1);
}
master_princ_set = 1;
if (mkey_password) {
- pwd.data = mkey_password;
- pwd.length = strlen(mkey_password);
- retval = krb5_principal2salt(test_context, master_princ, &scratch);
- if (retval) {
- com_err(pname, retval, "while calculated master key salt");
- return(1);
- }
- if ((retval = krb5_c_string_to_key(test_context,
- master_keyblock.enctype,
- &pwd, &scratch,
- &master_keyblock))) {
- com_err(pname, retval,
- "while transforming master key from password");
- return(1);
- }
- free(scratch.data);
+ pwd.data = mkey_password;
+ pwd.length = strlen(mkey_password);
+ retval = krb5_principal2salt(test_context, master_princ, &scratch);
+ if (retval) {
+ com_err(pname, retval, "while calculated master key salt");
+ return(1);
+ }
+ if ((retval = krb5_c_string_to_key(test_context,
+ master_keyblock.enctype,
+ &pwd, &scratch,
+ &master_keyblock))) {
+ com_err(pname, retval,
+ "while transforming master key from password");
+ return(1);
+ }
+ free(scratch.data);
} else {
- if ((retval = krb5_db_fetch_mkey(test_context, master_princ,
- master_keyblock.enctype, manual_mkey,
- FALSE, 0, NULL, NULL,
- &master_keyblock))) {
- com_err(pname, retval, "while reading master key");
- return(1);
- }
+ if ((retval = krb5_db_fetch_mkey(test_context, master_princ,
+ master_keyblock.enctype, manual_mkey,
+ FALSE, 0, NULL, NULL,
+ &master_keyblock))) {
+ com_err(pname, retval, "while reading master key");
+ return(1);
+ }
}
/* Ick! Current DAL interface requires that the default_realm
field be set in the krb5_context. */
if ((retval = krb5_set_default_realm(test_context, cur_realm))) {
- com_err(pname, retval, "setting default realm");
- return 1;
+ com_err(pname, retval, "setting default realm");
+ return 1;
}
/* Pathname is passed to db2 via 'args' parameter. */
args[1] = NULL;
if (asprintf(&args[0], "dbname=%s", dbname) < 0) {
- com_err(pname, errno, "while setting up db parameters");
- return 1;
+ com_err(pname, errno, "while setting up db parameters");
+ return 1;
}
if ((retval = krb5_db_open(test_context, args, KRB5_KDB_OPEN_RO))) {
- com_err(pname, retval, "while initializing database");
- return(1);
+ com_err(pname, retval, "while initializing database");
+ return(1);
}
/* Done with args */
free(args[0]);
if ((retval = krb5_db_verify_master_key(test_context, master_princ,
- IGNORE_VNO, &master_keyblock))){
- com_err(pname, retval, "while verifying master key");
- (void) krb5_db_fini(test_context);
- return(1);
+ IGNORE_VNO, &master_keyblock))){
+ com_err(pname, retval, "while verifying master key");
+ (void) krb5_db_fini(test_context);
+ return(1);
}
nentries = 1;
if ((retval = krb5_db_get_principal(test_context, master_princ,
- &master_entry, &nentries, &more))) {
- com_err(pname, retval, "while retrieving master entry");
- (void) krb5_db_fini(test_context);
- return(1);
+ &master_entry, &nentries, &more))) {
+ com_err(pname, retval, "while retrieving master entry");
+ (void) krb5_db_fini(test_context);
+ return(1);
} else if (more) {
- com_err(pname, KRB5KDC_ERR_PRINCIPAL_NOT_UNIQUE,
- "while retrieving master entry");
- (void) krb5_db_fini(test_context);
- return(1);
+ com_err(pname, KRB5KDC_ERR_PRINCIPAL_NOT_UNIQUE,
+ "while retrieving master entry");
+ (void) krb5_db_fini(test_context);
+ return(1);
} else if (!nentries) {
- com_err(pname, KRB5_KDB_NOENTRY, "while retrieving master entry");
- (void) krb5_db_fini(test_context);
- return(1);
+ com_err(pname, KRB5_KDB_NOENTRY, "while retrieving master entry");
+ (void) krb5_db_fini(test_context);
+ return(1);
}
mblock.max_life = master_entry.max_life;
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* tests/dejagnu/t_inetd.c
*
static void usage()
{
- fprintf(stderr, "%s: port program argv0 argv1 ...\n", progname);
- exit(1);
+ fprintf(stderr, "%s: port program argv0 argv1 ...\n", progname);
+ exit(1);
}
int
int argc;
char **argv;
{
- unsigned short port;
- char *path;
- int sock, acc;
- int one = 1;
- struct sockaddr_in l_inaddr, f_inaddr; /* local, foreign address */
- int namelen = sizeof(f_inaddr);
+ unsigned short port;
+ char *path;
+ int sock, acc;
+ int one = 1;
+ struct sockaddr_in l_inaddr, f_inaddr; /* local, foreign address */
+ int namelen = sizeof(f_inaddr);
#ifdef POSIX_SIGNALS
- struct sigaction csig;
+ struct sigaction csig;
#endif
- progname = argv[0];
+ progname = argv[0];
- if(argc <= 3) usage();
+ if(argc <= 3) usage();
- if(atoi(argv[1]) == 0) usage();
+ if(atoi(argv[1]) == 0) usage();
- port = htons(atoi(argv[1]));
- path = argv[2];
+ port = htons(atoi(argv[1]));
+ path = argv[2];
- if ((sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
- com_err(progname, errno, "creating socket");
- exit(3);
- }
+ if ((sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
+ com_err(progname, errno, "creating socket");
+ exit(3);
+ }
- (void) setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&one,
- sizeof (one));
+ (void) setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&one,
+ sizeof (one));
- l_inaddr.sin_family = AF_INET;
- l_inaddr.sin_addr.s_addr = 0;
- l_inaddr.sin_port = port;
+ l_inaddr.sin_family = AF_INET;
+ l_inaddr.sin_addr.s_addr = 0;
+ l_inaddr.sin_port = port;
- if (bind(sock, (struct sockaddr *)&l_inaddr, sizeof(l_inaddr))) {
- com_err(progname, errno, "binding socket");
- exit(3);
- }
+ if (bind(sock, (struct sockaddr *)&l_inaddr, sizeof(l_inaddr))) {
+ com_err(progname, errno, "binding socket");
+ exit(3);
+ }
- if (listen(sock, 1) == -1) {
- com_err(progname, errno, "listening");
- exit(3);
- }
+ if (listen(sock, 1) == -1) {
+ com_err(progname, errno, "listening");
+ exit(3);
+ }
- printf("Ready!\n");
- if ((acc = accept(sock, (struct sockaddr *)&f_inaddr,
- &namelen)) == -1) {
- com_err(progname, errno, "accepting");
- exit(3);
- }
+ printf("Ready!\n");
+ if ((acc = accept(sock, (struct sockaddr *)&f_inaddr,
+ &namelen)) == -1) {
+ com_err(progname, errno, "accepting");
+ exit(3);
+ }
- dup2(acc, 0);
- dup2(acc, 1);
- dup2(acc, 2);
- close(sock);
- sock = 0;
+ dup2(acc, 0);
+ dup2(acc, 1);
+ dup2(acc, 2);
+ close(sock);
+ sock = 0;
- /* Don't wait for a child signal... Otherwise dejagnu gets confused */
+ /* Don't wait for a child signal... Otherwise dejagnu gets confused */
#ifdef POSIX_SIGNALS
- csig.sa_handler = (RETSIGTYPE (*)())0;
- sigemptyset(&csig.sa_mask);
- csig.sa_flags = 0;
- sigaction(SIGCHLD, &csig, (struct sigaction *)0);
+ csig.sa_handler = (RETSIGTYPE (*)())0;
+ sigemptyset(&csig.sa_mask);
+ csig.sa_flags = 0;
+ sigaction(SIGCHLD, &csig, (struct sigaction *)0);
#else
- signal(SIGCHLD, SIG_IGN);
+ signal(SIGCHLD, SIG_IGN);
#endif
- if(execv(path, &argv[3]))
- fprintf(stderr, "t_inetd: Could not exec %s\n", path);
- exit(1);
+ if(execv(path, &argv[3]))
+ fprintf(stderr, "t_inetd: Could not exec %s\n", path);
+ exit(1);
}
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* tests/dump.c
*
unsigned char *ptr = (unsigned char *)data->data;
int i;
for (i=0; i<data->length; i++) {
- fprintf(stderr, "%02x ", ptr[i]);
- if ((i % 16) == 15) fprintf(stderr, "\n");
+ fprintf(stderr, "%02x ", ptr[i]);
+ if ((i % 16) == 15) fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
}
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 1994 by OpenVision Technologies, Inc.
*
static void usage()
{
- fprintf(stderr, "Usage: gss-client [-port port] [-mech mechanism] [-d]\n");
- fprintf(stderr, " [-seq] [-noreplay] [-nomutual]");
- fprintf(stderr, " [-threads num]");
- fprintf(stderr, "\n");
- fprintf(stderr, " [-f] [-q] [-ccount count] [-mcount count]\n");
- fprintf(stderr, " [-v1] [-na] [-nw] [-nx] [-nm] host service msg\n");
- exit(1);
+ fprintf(stderr, "Usage: gss-client [-port port] [-mech mechanism] [-d]\n");
+ fprintf(stderr, " [-seq] [-noreplay] [-nomutual]");
+ fprintf(stderr, " [-threads num]");
+ fprintf(stderr, "\n");
+ fprintf(stderr, " [-f] [-q] [-ccount count] [-mcount count]\n");
+ fprintf(stderr, " [-v1] [-na] [-nw] [-nx] [-nm] host service msg\n");
+ exit(1);
}
/*
*
* Arguments:
*
- * host (r) the target host name
- * port (r) the target port, in host byte order
+ * host (r) the target host name
+ * port (r) the target port, in host byte order
*
* Returns: 0 on success, or -1 on failure
*
char *host;
u_short port;
{
- struct hostent *hp;
+ struct hostent *hp;
- if ((hp = gethostbyname(host)) == NULL) {
- fprintf(stderr, "Unknown host: %s\n", host);
- return -1;
- }
+ if ((hp = gethostbyname(host)) == NULL) {
+ fprintf(stderr, "Unknown host: %s\n", host);
+ return -1;
+ }
- saddr.sin_family = hp->h_addrtype;
- memcpy(&saddr.sin_addr, hp->h_addr, sizeof(saddr.sin_addr));
- saddr.sin_port = htons(port);
- return 0;
+ saddr.sin_family = hp->h_addrtype;
+ memcpy(&saddr.sin_addr, hp->h_addr, sizeof(saddr.sin_addr));
+ saddr.sin_port = htons(port);
+ return 0;
}
/*
*
* Arguments:
*
- * host (r) the target host name
- * port (r) the target port, in host byte order
+ * host (r) the target host name
+ * port (r) the target port, in host byte order
*
* Returns: the established socket file desciptor, or -1 on failure
*
{
int s;
- if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- perror("creating socket");
- return -1;
- }
- if (connect(s, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
- perror("connecting to server");
- (void) closesocket(s);
- return -1;
- }
- return s;
+ if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+ perror("creating socket");
+ return -1;
+ }
+ if (connect(s, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
+ perror("connecting to server");
+ (void) closesocket(s);
+ return -1;
+ }
+ return s;
}
/*
*
* Arguments:
*
- * s (r) an established TCP connection to the service
- * service_name(r) the ASCII service name of the service
- * gss_flags (r) GSS-API delegation flag (if any)
- * auth_flag (r) whether to actually do authentication
+ * s (r) an established TCP connection to the service
+ * service_name(r) the ASCII service name of the service
+ * gss_flags (r) GSS-API delegation flag (if any)
+ * auth_flag (r) whether to actually do authentication
* v1_format (r) whether the v1 sample protocol should be used
- * oid (r) OID of the mechanism to use
- * context (w) the established GSS-API context
- * ret_flags (w) the returned flags from init_sec_context
+ * oid (r) OID of the mechanism to use
+ * context (w) the established GSS-API context
+ * ret_flags (w) the returned flags from init_sec_context
*
* Returns: 0 on success, -1 on failure
*
* and -1 is returned.
*/
static int client_establish_context(s, service_name, gss_flags, auth_flag,
- v1_format, oid, gss_context, ret_flags)
- int s;
- char *service_name;
- gss_OID oid;
- OM_uint32 gss_flags;
- int auth_flag;
- int v1_format;
- gss_ctx_id_t *gss_context;
- OM_uint32 *ret_flags;
+ v1_format, oid, gss_context, ret_flags)
+ int s;
+ char *service_name;
+ gss_OID oid;
+ OM_uint32 gss_flags;
+ int auth_flag;
+ int v1_format;
+ gss_ctx_id_t *gss_context;
+ OM_uint32 *ret_flags;
{
- if (auth_flag) {
- gss_buffer_desc send_tok, recv_tok, *token_ptr;
- gss_name_t target_name;
- OM_uint32 maj_stat, min_stat, init_sec_min_stat;
- int token_flags;
-
- /*
- * Import the name into target_name. Use send_tok to save
- * local variable space.
- */
- send_tok.value = service_name;
- send_tok.length = strlen(service_name) ;
- maj_stat = gss_import_name(&min_stat, &send_tok,
- (gss_OID) gss_nt_service_name, &target_name);
- if (maj_stat != GSS_S_COMPLETE) {
- display_status("parsing name", maj_stat, min_stat);
- return -1;
- }
-
- if (!v1_format) {
- if (send_token(s, TOKEN_NOOP|TOKEN_CONTEXT_NEXT, empty_token) < 0) {
- (void) gss_release_name(&min_stat, &target_name);
- return -1;
- }
- }
-
- /*
- * Perform the context-establishement loop.
- *
- * On each pass through the loop, token_ptr points to the token
- * to send to the server (or GSS_C_NO_BUFFER on the first pass).
- * Every generated token is stored in send_tok which is then
- * transmitted to the server; every received token is stored in
- * recv_tok, which token_ptr is then set to, to be processed by
- * the next call to gss_init_sec_context.
- *
- * GSS-API guarantees that send_tok's length will be non-zero
- * if and only if the server is expecting another token from us,
- * and that gss_init_sec_context returns GSS_S_CONTINUE_NEEDED if
- * and only if the server has another token to send us.
- */
-
- token_ptr = GSS_C_NO_BUFFER;
- *gss_context = GSS_C_NO_CONTEXT;
-
- do {
- maj_stat =
- gss_init_sec_context(&init_sec_min_stat,
- GSS_C_NO_CREDENTIAL,
- gss_context,
- target_name,
- oid,
- gss_flags,
- 0,
- NULL, /* no channel bindings */
- token_ptr,
- NULL, /* ignore mech type */
- &send_tok,
- ret_flags,
- NULL); /* ignore time_rec */
-
- if (token_ptr != GSS_C_NO_BUFFER)
- free (recv_tok.value);
-
- if (send_tok.length != 0) {
- if (verbose)
- printf("Sending init_sec_context token (size=%d)...",
- (int) send_tok.length);
- if (send_token(s, v1_format?0:TOKEN_CONTEXT, &send_tok) < 0) {
- (void) gss_release_buffer(&min_stat, &send_tok);
- (void) gss_release_name(&min_stat, &target_name);
- if (*gss_context != GSS_C_NO_CONTEXT) {
- gss_delete_sec_context(&min_stat, gss_context,
- GSS_C_NO_BUFFER);
- *gss_context = GSS_C_NO_CONTEXT;
- }
- return -1;
- }
- }
- (void) gss_release_buffer(&min_stat, &send_tok);
-
- if (maj_stat!=GSS_S_COMPLETE && maj_stat!=GSS_S_CONTINUE_NEEDED) {
- display_status("initializing context", maj_stat,
- init_sec_min_stat);
- (void) gss_release_name(&min_stat, &target_name);
- if (*gss_context != GSS_C_NO_CONTEXT)
- gss_delete_sec_context(&min_stat, gss_context,
- GSS_C_NO_BUFFER);
- return -1;
- }
-
- if (maj_stat == GSS_S_CONTINUE_NEEDED) {
- if (verbose)
- printf("continue needed...");
- if (recv_token(s, &token_flags, &recv_tok) < 0) {
- (void) gss_release_name(&min_stat, &target_name);
- return -1;
- }
- token_ptr = &recv_tok;
- }
- if (verbose)
- printf("\n");
- } while (maj_stat == GSS_S_CONTINUE_NEEDED);
-
- (void) gss_release_name(&min_stat, &target_name);
- }
- else {
- if (send_token(s, TOKEN_NOOP, empty_token) < 0)
- return -1;
- }
-
- return 0;
+ if (auth_flag) {
+ gss_buffer_desc send_tok, recv_tok, *token_ptr;
+ gss_name_t target_name;
+ OM_uint32 maj_stat, min_stat, init_sec_min_stat;
+ int token_flags;
+
+ /*
+ * Import the name into target_name. Use send_tok to save
+ * local variable space.
+ */
+ send_tok.value = service_name;
+ send_tok.length = strlen(service_name) ;
+ maj_stat = gss_import_name(&min_stat, &send_tok,
+ (gss_OID) gss_nt_service_name, &target_name);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("parsing name", maj_stat, min_stat);
+ return -1;
+ }
+
+ if (!v1_format) {
+ if (send_token(s, TOKEN_NOOP|TOKEN_CONTEXT_NEXT, empty_token) < 0) {
+ (void) gss_release_name(&min_stat, &target_name);
+ return -1;
+ }
+ }
+
+ /*
+ * Perform the context-establishement loop.
+ *
+ * On each pass through the loop, token_ptr points to the token
+ * to send to the server (or GSS_C_NO_BUFFER on the first pass).
+ * Every generated token is stored in send_tok which is then
+ * transmitted to the server; every received token is stored in
+ * recv_tok, which token_ptr is then set to, to be processed by
+ * the next call to gss_init_sec_context.
+ *
+ * GSS-API guarantees that send_tok's length will be non-zero
+ * if and only if the server is expecting another token from us,
+ * and that gss_init_sec_context returns GSS_S_CONTINUE_NEEDED if
+ * and only if the server has another token to send us.
+ */
+
+ token_ptr = GSS_C_NO_BUFFER;
+ *gss_context = GSS_C_NO_CONTEXT;
+
+ do {
+ maj_stat =
+ gss_init_sec_context(&init_sec_min_stat,
+ GSS_C_NO_CREDENTIAL,
+ gss_context,
+ target_name,
+ oid,
+ gss_flags,
+ 0,
+ NULL, /* no channel bindings */
+ token_ptr,
+ NULL, /* ignore mech type */
+ &send_tok,
+ ret_flags,
+ NULL); /* ignore time_rec */
+
+ if (token_ptr != GSS_C_NO_BUFFER)
+ free (recv_tok.value);
+
+ if (send_tok.length != 0) {
+ if (verbose)
+ printf("Sending init_sec_context token (size=%d)...",
+ (int) send_tok.length);
+ if (send_token(s, v1_format?0:TOKEN_CONTEXT, &send_tok) < 0) {
+ (void) gss_release_buffer(&min_stat, &send_tok);
+ (void) gss_release_name(&min_stat, &target_name);
+ if (*gss_context != GSS_C_NO_CONTEXT) {
+ gss_delete_sec_context(&min_stat, gss_context,
+ GSS_C_NO_BUFFER);
+ *gss_context = GSS_C_NO_CONTEXT;
+ }
+ return -1;
+ }
+ }
+ (void) gss_release_buffer(&min_stat, &send_tok);
+
+ if (maj_stat!=GSS_S_COMPLETE && maj_stat!=GSS_S_CONTINUE_NEEDED) {
+ display_status("initializing context", maj_stat,
+ init_sec_min_stat);
+ (void) gss_release_name(&min_stat, &target_name);
+ if (*gss_context != GSS_C_NO_CONTEXT)
+ gss_delete_sec_context(&min_stat, gss_context,
+ GSS_C_NO_BUFFER);
+ return -1;
+ }
+
+ if (maj_stat == GSS_S_CONTINUE_NEEDED) {
+ if (verbose)
+ printf("continue needed...");
+ if (recv_token(s, &token_flags, &recv_tok) < 0) {
+ (void) gss_release_name(&min_stat, &target_name);
+ return -1;
+ }
+ token_ptr = &recv_tok;
+ }
+ if (verbose)
+ printf("\n");
+ } while (maj_stat == GSS_S_CONTINUE_NEEDED);
+
+ (void) gss_release_name(&min_stat, &target_name);
+ }
+ else {
+ if (send_token(s, TOKEN_NOOP, empty_token) < 0)
+ return -1;
+ }
+
+ return 0;
}
static void read_file(file_name, in_buf)
- char *file_name;
- gss_buffer_t in_buf;
+ char *file_name;
+ gss_buffer_t in_buf;
{
int fd, count;
struct stat stat_buf;
if ((fd = open(file_name, O_RDONLY, 0)) < 0) {
- perror("open");
- fprintf(stderr, "Couldn't open file %s\n", file_name);
- exit(2);
+ perror("open");
+ fprintf(stderr, "Couldn't open file %s\n", file_name);
+ exit(2);
}
if (fstat(fd, &stat_buf) < 0) {
- perror("fstat");
- exit(3);
+ perror("fstat");
+ exit(3);
}
in_buf->length = stat_buf.st_size;
if (in_buf->length == 0) {
- in_buf->value = NULL;
- return;
+ in_buf->value = NULL;
+ return;
}
if ((in_buf->value = malloc(in_buf->length)) == 0) {
- fprintf(stderr, "Couldn't allocate %d byte buffer for reading file\n",
- (int) in_buf->length);
- exit(4);
+ fprintf(stderr, "Couldn't allocate %d byte buffer for reading file\n",
+ (int) in_buf->length);
+ exit(4);
}
/* this code used to check for incomplete reads, but you can't get
count = read(fd, in_buf->value, in_buf->length);
if (count < 0) {
- perror("read");
- exit(5);
+ perror("read");
+ exit(5);
}
if (count < in_buf->length)
- fprintf(stderr, "Warning, only read in %d bytes, expected %d\n",
- count, (int) in_buf->length);
+ fprintf(stderr, "Warning, only read in %d bytes, expected %d\n",
+ count, (int) in_buf->length);
}
/*
*
* Arguments:
*
- * host (r) the host providing the service
- * port (r) the port to connect to on host
- * service_name (r) the GSS-API service name to authenticate to
- * gss_flags (r) GSS-API delegation flag (if any)
- * auth_flag (r) whether to do authentication
- * wrap_flag (r) whether to do message wrapping at all
- * encrypt_flag (r) whether to do encryption while wrapping
- * mic_flag (r) whether to request a MIC from the server
- * msg (r) the message to have "signed"
- * use_file (r) whether to treat msg as an input file name
- * mcount (r) the number of times to send the message
+ * host (r) the host providing the service
+ * port (r) the port to connect to on host
+ * service_name (r) the GSS-API service name to authenticate to
+ * gss_flags (r) GSS-API delegation flag (if any)
+ * auth_flag (r) whether to do authentication
+ * wrap_flag (r) whether to do message wrapping at all
+ * encrypt_flag (r) whether to do encryption while wrapping
+ * mic_flag (r) whether to request a MIC from the server
+ * msg (r) the message to have "signed"
+ * use_file (r) whether to treat msg as an input file name
+ * mcount (r) the number of times to send the message
*
* Returns: 0 on success, -1 on failure
*
* verifies it with gss_verify. -1 is returned if any step fails,
* otherwise 0 is returned. */
static int call_server(host, port, oid, service_name, gss_flags, auth_flag,
- wrap_flag, encrypt_flag, mic_flag, v1_format, msg, use_file,
- mcount)
- char *host;
- u_short port;
- gss_OID oid;
- char *service_name;
- OM_uint32 gss_flags;
- int auth_flag, wrap_flag, encrypt_flag, mic_flag;
- int v1_format;
- char *msg;
- int use_file;
- int mcount;
+ wrap_flag, encrypt_flag, mic_flag, v1_format, msg, use_file,
+ mcount)
+ char *host;
+ u_short port;
+ gss_OID oid;
+ char *service_name;
+ OM_uint32 gss_flags;
+ int auth_flag, wrap_flag, encrypt_flag, mic_flag;
+ int v1_format;
+ char *msg;
+ int use_file;
+ int mcount;
{
- gss_ctx_id_t context;
- gss_buffer_desc in_buf, out_buf;
- int s, state;
- OM_uint32 ret_flags;
- OM_uint32 maj_stat, min_stat;
- gss_name_t src_name, targ_name;
- gss_buffer_desc sname, tname;
- OM_uint32 lifetime;
- gss_OID mechanism, name_type;
- int is_local;
- OM_uint32 context_flags;
- int is_open;
- gss_qop_t qop_state;
- gss_OID_set mech_names;
- gss_buffer_desc oid_name;
- size_t i;
- int token_flags;
-
- /* Open connection */
- if ((s = connect_to_server()) < 0)
- return -1;
-
- /* Establish context */
- if (client_establish_context(s, service_name, gss_flags, auth_flag,
- v1_format, oid, &context,
- &ret_flags) < 0) {
- (void) closesocket(s);
- return -1;
- }
-
- if (auth_flag && verbose) {
- /* display the flags */
- display_ctx_flags(ret_flags);
-
- /* Get context information */
- maj_stat = gss_inquire_context( &min_stat, context,
- &src_name, &targ_name, &lifetime,
- &mechanism, &context_flags,
- &is_local,
- &is_open);
- if (maj_stat != GSS_S_COMPLETE) {
- display_status("inquiring context", maj_stat, min_stat);
- return -1;
- }
-
- maj_stat = gss_display_name(&min_stat, src_name, &sname,
- &name_type);
- if (maj_stat != GSS_S_COMPLETE) {
- display_status("displaying source name", maj_stat, min_stat);
- return -1;
- }
- maj_stat = gss_display_name(&min_stat, targ_name, &tname,
- (gss_OID *) NULL);
- if (maj_stat != GSS_S_COMPLETE) {
- display_status("displaying target name", maj_stat, min_stat);
- return -1;
- }
- printf("\"%.*s\" to \"%.*s\", lifetime %d, flags %x, %s, %s\n",
- (int) sname.length, (char *) sname.value,
- (int) tname.length, (char *) tname.value, lifetime,
- context_flags,
- (is_local) ? "locally initiated" : "remotely initiated",
- (is_open) ? "open" : "closed");
-
- (void) gss_release_name(&min_stat, &src_name);
- (void) gss_release_name(&min_stat, &targ_name);
- (void) gss_release_buffer(&min_stat, &sname);
- (void) gss_release_buffer(&min_stat, &tname);
-
- maj_stat = gss_oid_to_str(&min_stat,
- name_type,
- &oid_name);
- if (maj_stat != GSS_S_COMPLETE) {
- display_status("converting oid->string", maj_stat, min_stat);
- return -1;
- }
- printf("Name type of source name is %.*s.\n",
- (int) oid_name.length, (char *) oid_name.value);
- (void) gss_release_buffer(&min_stat, &oid_name);
-
- /* Now get the names supported by the mechanism */
- maj_stat = gss_inquire_names_for_mech(&min_stat,
- mechanism,
- &mech_names);
- if (maj_stat != GSS_S_COMPLETE) {
- display_status("inquiring mech names", maj_stat, min_stat);
- return -1;
- }
-
- maj_stat = gss_oid_to_str(&min_stat,
- mechanism,
- &oid_name);
- if (maj_stat != GSS_S_COMPLETE) {
- display_status("converting oid->string", maj_stat, min_stat);
- return -1;
- }
- printf("Mechanism %.*s supports %d names\n",
- (int) oid_name.length, (char *) oid_name.value,
- (int) mech_names->count);
- (void) gss_release_buffer(&min_stat, &oid_name);
-
- for (i=0; i<mech_names->count; i++) {
- maj_stat = gss_oid_to_str(&min_stat,
- &mech_names->elements[i],
- &oid_name);
- if (maj_stat != GSS_S_COMPLETE) {
- display_status("converting oid->string", maj_stat, min_stat);
- return -1;
- }
- printf(" %d: %.*s\n", (int) i,
- (int) oid_name.length, (char *) oid_name.value);
-
- (void) gss_release_buffer(&min_stat, &oid_name);
- }
- (void) gss_release_oid_set(&min_stat, &mech_names);
- }
+ gss_ctx_id_t context;
+ gss_buffer_desc in_buf, out_buf;
+ int s, state;
+ OM_uint32 ret_flags;
+ OM_uint32 maj_stat, min_stat;
+ gss_name_t src_name, targ_name;
+ gss_buffer_desc sname, tname;
+ OM_uint32 lifetime;
+ gss_OID mechanism, name_type;
+ int is_local;
+ OM_uint32 context_flags;
+ int is_open;
+ gss_qop_t qop_state;
+ gss_OID_set mech_names;
+ gss_buffer_desc oid_name;
+ size_t i;
+ int token_flags;
+
+ /* Open connection */
+ if ((s = connect_to_server()) < 0)
+ return -1;
+
+ /* Establish context */
+ if (client_establish_context(s, service_name, gss_flags, auth_flag,
+ v1_format, oid, &context,
+ &ret_flags) < 0) {
+ (void) closesocket(s);
+ return -1;
+ }
+
+ if (auth_flag && verbose) {
+ /* display the flags */
+ display_ctx_flags(ret_flags);
+
+ /* Get context information */
+ maj_stat = gss_inquire_context( &min_stat, context,
+ &src_name, &targ_name, &lifetime,
+ &mechanism, &context_flags,
+ &is_local,
+ &is_open);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("inquiring context", maj_stat, min_stat);
+ return -1;
+ }
+
+ maj_stat = gss_display_name(&min_stat, src_name, &sname,
+ &name_type);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("displaying source name", maj_stat, min_stat);
+ return -1;
+ }
+ maj_stat = gss_display_name(&min_stat, targ_name, &tname,
+ (gss_OID *) NULL);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("displaying target name", maj_stat, min_stat);
+ return -1;
+ }
+ printf("\"%.*s\" to \"%.*s\", lifetime %d, flags %x, %s, %s\n",
+ (int) sname.length, (char *) sname.value,
+ (int) tname.length, (char *) tname.value, lifetime,
+ context_flags,
+ (is_local) ? "locally initiated" : "remotely initiated",
+ (is_open) ? "open" : "closed");
+
+ (void) gss_release_name(&min_stat, &src_name);
+ (void) gss_release_name(&min_stat, &targ_name);
+ (void) gss_release_buffer(&min_stat, &sname);
+ (void) gss_release_buffer(&min_stat, &tname);
+
+ maj_stat = gss_oid_to_str(&min_stat,
+ name_type,
+ &oid_name);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("converting oid->string", maj_stat, min_stat);
+ return -1;
+ }
+ printf("Name type of source name is %.*s.\n",
+ (int) oid_name.length, (char *) oid_name.value);
+ (void) gss_release_buffer(&min_stat, &oid_name);
+
+ /* Now get the names supported by the mechanism */
+ maj_stat = gss_inquire_names_for_mech(&min_stat,
+ mechanism,
+ &mech_names);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("inquiring mech names", maj_stat, min_stat);
+ return -1;
+ }
+
+ maj_stat = gss_oid_to_str(&min_stat,
+ mechanism,
+ &oid_name);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("converting oid->string", maj_stat, min_stat);
+ return -1;
+ }
+ printf("Mechanism %.*s supports %d names\n",
+ (int) oid_name.length, (char *) oid_name.value,
+ (int) mech_names->count);
+ (void) gss_release_buffer(&min_stat, &oid_name);
+
+ for (i=0; i<mech_names->count; i++) {
+ maj_stat = gss_oid_to_str(&min_stat,
+ &mech_names->elements[i],
+ &oid_name);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("converting oid->string", maj_stat, min_stat);
+ return -1;
+ }
+ printf(" %d: %.*s\n", (int) i,
+ (int) oid_name.length, (char *) oid_name.value);
+
+ (void) gss_release_buffer(&min_stat, &oid_name);
+ }
+ (void) gss_release_oid_set(&min_stat, &mech_names);
+ }
if (use_file) {
read_file(msg, &in_buf);
for (i = 0; i < mcount; i++) {
if (wrap_flag) {
maj_stat = gss_wrap(&min_stat, context, encrypt_flag, GSS_C_QOP_DEFAULT,
- &in_buf, &state, &out_buf);
+ &in_buf, &state, &out_buf);
if (maj_stat != GSS_S_COMPLETE) {
display_status("wrapping message", maj_stat, min_stat);
(void) closesocket(s);
/* Send to server */
if (send_token(s, (v1_format?0
- :(TOKEN_DATA |
- (wrap_flag ? TOKEN_WRAPPED : 0) |
- (encrypt_flag ? TOKEN_ENCRYPTED : 0) |
- (mic_flag ? TOKEN_SEND_MIC : 0))), &out_buf) < 0) {
+ :(TOKEN_DATA |
+ (wrap_flag ? TOKEN_WRAPPED : 0) |
+ (encrypt_flag ? TOKEN_ENCRYPTED : 0) |
+ (mic_flag ? TOKEN_SEND_MIC : 0))), &out_buf) < 0) {
(void) closesocket(s);
(void) gss_delete_sec_context(&min_stat, &context, GSS_C_NO_BUFFER);
return -1;
if (mic_flag) {
/* Verify signature block */
maj_stat = gss_verify_mic(&min_stat, context, &in_buf,
- &out_buf, &qop_state);
+ &out_buf, &qop_state);
if (maj_stat != GSS_S_COMPLETE) {
display_status("verifying signature", maj_stat, min_stat);
(void) closesocket(s);
static void parse_oid(char *mechanism, gss_OID *oid)
{
- char *mechstr = 0, *cp;
+ char *mechstr = 0, *cp;
gss_buffer_desc tok;
OM_uint32 maj_stat, min_stat;
if (isdigit((int) mechanism[0])) {
- if (asprintf(&mechstr, "{ %s }", mechanism) < 0) {
- fprintf(stderr, "Couldn't allocate mechanism scratch!\n");
- return;
- }
- for (cp = mechstr; *cp; cp++)
- if (*cp == '.')
- *cp = ' ';
- tok.value = mechstr;
+ if (asprintf(&mechstr, "{ %s }", mechanism) < 0) {
+ fprintf(stderr, "Couldn't allocate mechanism scratch!\n");
+ return;
+ }
+ for (cp = mechstr; *cp; cp++)
+ if (*cp == '.')
+ *cp = ' ';
+ tok.value = mechstr;
} else
- tok.value = mechanism;
+ tok.value = mechanism;
tok.length = strlen(tok.value);
maj_stat = gss_str_to_oid(&min_stat, &tok, oid);
if (maj_stat != GSS_S_COMPLETE) {
- display_status("str_to_oid", maj_stat, min_stat);
- return;
+ display_status("str_to_oid", maj_stat, min_stat);
+ return;
}
if (mechstr)
- free(mechstr);
+ free(mechstr);
}
static int max_threads = 1;
int err;
err = pthread_mutex_lock(&counter_mutex);
if (err) {
- perror("pthread_mutex_lock");
- return 0;
+ perror("pthread_mutex_lock");
+ return 0;
}
if (counter == max_threads) {
- err = pthread_cond_wait(&counter_cond, &counter_mutex);
- if (err) {
- pthread_mutex_unlock(&counter_mutex);
- perror("pthread_cond_wait");
- return 0;
- }
+ err = pthread_cond_wait(&counter_cond, &counter_mutex);
+ if (err) {
+ pthread_mutex_unlock(&counter_mutex);
+ perror("pthread_cond_wait");
+ return 0;
+ }
}
counter++;
pthread_mutex_unlock(&counter_mutex);
sleep(1);
err = pthread_mutex_lock(&counter_mutex);
if (err) {
- perror("pthread_mutex_lock");
- return;
+ perror("pthread_mutex_lock");
+ return;
}
if (counter == max_threads)
- pthread_cond_broadcast(&counter_cond);
+ pthread_cond_broadcast(&counter_cond);
counter--;
pthread_mutex_unlock(&counter_mutex);
}
}
int main(argc, argv)
- int argc;
- char **argv;
+ int argc;
+ char **argv;
{
- int i;
-
- display_file = stdout;
- auth_flag = wrap_flag = encrypt_flag = mic_flag = 1;
- v1_format = 0;
-
- /* Parse arguments. */
- argc--; argv++;
- while (argc) {
- if (strcmp(*argv, "-port") == 0) {
- argc--; argv++;
- if (!argc) usage();
- port = atoi(*argv);
- } else if (strcmp(*argv, "-mech") == 0) {
- argc--; argv++;
- if (!argc) usage();
- mechanism = *argv;
- }
+ int i;
+
+ display_file = stdout;
+ auth_flag = wrap_flag = encrypt_flag = mic_flag = 1;
+ v1_format = 0;
+
+ /* Parse arguments. */
+ argc--; argv++;
+ while (argc) {
+ if (strcmp(*argv, "-port") == 0) {
+ argc--; argv++;
+ if (!argc) usage();
+ port = atoi(*argv);
+ } else if (strcmp(*argv, "-mech") == 0) {
+ argc--; argv++;
+ if (!argc) usage();
+ mechanism = *argv;
+ }
#if defined(_WIN32) || 1
- else if (strcmp(*argv, "-threads") == 0) {
- argc--; argv++;
- if (!argc) usage();
- max_threads = atoi(*argv);
- }
+ else if (strcmp(*argv, "-threads") == 0) {
+ argc--; argv++;
+ if (!argc) usage();
+ max_threads = atoi(*argv);
+ }
#endif
- else if (strcmp(*argv, "-d") == 0) {
- gss_flags |= GSS_C_DELEG_FLAG;
- } else if (strcmp(*argv, "-seq") == 0) {
- gss_flags |= GSS_C_SEQUENCE_FLAG;
- } else if (strcmp(*argv, "-noreplay") == 0) {
- gss_flags &= ~GSS_C_REPLAY_FLAG;
- } else if (strcmp(*argv, "-nomutual") == 0) {
- gss_flags &= ~GSS_C_MUTUAL_FLAG;
- } else if (strcmp(*argv, "-f") == 0) {
- use_file = 1;
- } else if (strcmp(*argv, "-q") == 0) {
- verbose = 0;
- } else if (strcmp(*argv, "-ccount") == 0) {
- argc--; argv++;
- if (!argc) usage();
- ccount = atoi(*argv);
- if (ccount <= 0) usage();
- } else if (strcmp(*argv, "-mcount") == 0) {
- argc--; argv++;
- if (!argc) usage();
- mcount = atoi(*argv);
- if (mcount < 0) usage();
- } else if (strcmp(*argv, "-na") == 0) {
- auth_flag = wrap_flag = encrypt_flag = mic_flag = 0;
- } else if (strcmp(*argv, "-nw") == 0) {
- wrap_flag = 0;
- } else if (strcmp(*argv, "-nx") == 0) {
- encrypt_flag = 0;
- } else if (strcmp(*argv, "-nm") == 0) {
- mic_flag = 0;
- } else if (strcmp(*argv, "-v1") == 0) {
- v1_format = 1;
- } else
- break;
- argc--; argv++;
- }
- if (argc != 3)
- usage();
+ else if (strcmp(*argv, "-d") == 0) {
+ gss_flags |= GSS_C_DELEG_FLAG;
+ } else if (strcmp(*argv, "-seq") == 0) {
+ gss_flags |= GSS_C_SEQUENCE_FLAG;
+ } else if (strcmp(*argv, "-noreplay") == 0) {
+ gss_flags &= ~GSS_C_REPLAY_FLAG;
+ } else if (strcmp(*argv, "-nomutual") == 0) {
+ gss_flags &= ~GSS_C_MUTUAL_FLAG;
+ } else if (strcmp(*argv, "-f") == 0) {
+ use_file = 1;
+ } else if (strcmp(*argv, "-q") == 0) {
+ verbose = 0;
+ } else if (strcmp(*argv, "-ccount") == 0) {
+ argc--; argv++;
+ if (!argc) usage();
+ ccount = atoi(*argv);
+ if (ccount <= 0) usage();
+ } else if (strcmp(*argv, "-mcount") == 0) {
+ argc--; argv++;
+ if (!argc) usage();
+ mcount = atoi(*argv);
+ if (mcount < 0) usage();
+ } else if (strcmp(*argv, "-na") == 0) {
+ auth_flag = wrap_flag = encrypt_flag = mic_flag = 0;
+ } else if (strcmp(*argv, "-nw") == 0) {
+ wrap_flag = 0;
+ } else if (strcmp(*argv, "-nx") == 0) {
+ encrypt_flag = 0;
+ } else if (strcmp(*argv, "-nm") == 0) {
+ mic_flag = 0;
+ } else if (strcmp(*argv, "-v1") == 0) {
+ v1_format = 1;
+ } else
+ break;
+ argc--; argv++;
+ }
+ if (argc != 3)
+ usage();
#ifdef _WIN32
if (max_threads < 1) {
SetEnvironmentVariable("KERBEROSLOGIN_NEVER_PROMPT","1");
#endif
- server_host = *argv++;
- service_name = *argv++;
- msg = *argv++;
+ server_host = *argv++;
+ service_name = *argv++;
+ msg = *argv++;
- if (mechanism)
- parse_oid(mechanism, &oid);
+ if (mechanism)
+ parse_oid(mechanism, &oid);
- if (get_server_info(server_host, port) < 0) {
- exit(1);
- }
+ if (get_server_info(server_host, port) < 0) {
+ exit(1);
+ }
if ( max_threads == 1 ) {
for (i = 0; i < ccount; i++) {
exit(7);
}
#else
- int err;
- pthread_t thr;
- err = pthread_create(&thr, 0, (void *(*)(void *))worker_bee, malloc(12));
- if (err) {
- perror("pthread_create");
- exit(7);
- }
- (void) pthread_detach(thr);
+ int err;
+ pthread_t thr;
+ err = pthread_create(&thr, 0, (void *(*)(void *))worker_bee, malloc(12));
+ if (err) {
+ perror("pthread_create");
+ exit(7);
+ }
+ (void) pthread_detach(thr);
#endif
} else {
exit(8);
CleanupHandles();
#else
if (max_threads > 1)
- sleep(10);
+ sleep(10);
#endif
return 0;
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 1994 by OpenVision Technologies, Inc.
*
static void usage()
{
- fprintf(stderr, "Usage: gss-server [-port port] [-verbose] [-once]");
+ fprintf(stderr, "Usage: gss-server [-port port] [-verbose] [-once]");
#ifdef _WIN32
- fprintf(stderr, " [-threads num]");
+ fprintf(stderr, " [-threads num]");
#endif
- fprintf(stderr, "\n");
- fprintf(stderr, " [-inetd] [-export] [-logfile file] service_name\n");
- exit(1);
+ fprintf(stderr, "\n");
+ fprintf(stderr, " [-inetd] [-export] [-logfile file] service_name\n");
+ exit(1);
}
FILE *logfile;
*
* Arguments:
*
- * service_name (r) the ASCII service name
- * server_creds (w) the GSS-API service credentials
+ * service_name (r) the ASCII service name
+ * server_creds (w) the GSS-API service credentials
*
* Returns: 0 on success, -1 on failure
*
* 0 is returned.
*/
static int server_acquire_creds(service_name, server_creds)
- char *service_name;
- gss_cred_id_t *server_creds;
+ char *service_name;
+ gss_cred_id_t *server_creds;
{
- gss_buffer_desc name_buf;
- gss_name_t server_name;
- OM_uint32 maj_stat, min_stat;
-
- name_buf.value = service_name;
- name_buf.length = strlen(name_buf.value) + 1;
- maj_stat = gss_import_name(&min_stat, &name_buf,
- (gss_OID) gss_nt_service_name, &server_name);
- if (maj_stat != GSS_S_COMPLETE) {
- display_status("importing name", maj_stat, min_stat);
- return -1;
- }
-
- maj_stat = gss_acquire_cred(&min_stat, server_name, 0,
- GSS_C_NULL_OID_SET, GSS_C_ACCEPT,
- server_creds, NULL, NULL);
- if (maj_stat != GSS_S_COMPLETE) {
- display_status("acquiring credentials", maj_stat, min_stat);
- return -1;
- }
-
- (void) gss_release_name(&min_stat, &server_name);
-
- return 0;
+ gss_buffer_desc name_buf;
+ gss_name_t server_name;
+ OM_uint32 maj_stat, min_stat;
+
+ name_buf.value = service_name;
+ name_buf.length = strlen(name_buf.value) + 1;
+ maj_stat = gss_import_name(&min_stat, &name_buf,
+ (gss_OID) gss_nt_service_name, &server_name);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("importing name", maj_stat, min_stat);
+ return -1;
+ }
+
+ maj_stat = gss_acquire_cred(&min_stat, server_name, 0,
+ GSS_C_NULL_OID_SET, GSS_C_ACCEPT,
+ server_creds, NULL, NULL);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("acquiring credentials", maj_stat, min_stat);
+ return -1;
+ }
+
+ (void) gss_release_name(&min_stat, &server_name);
+
+ return 0;
}
/*
*
* Arguments:
*
- * s (r) an established TCP connection to the client
- * service_creds (r) server credentials, from gss_acquire_cred
- * context (w) the established GSS-API context
- * client_name (w) the client's ASCII name
+ * s (r) an established TCP connection to the client
+ * service_creds (r) server credentials, from gss_acquire_cred
+ * context (w) the established GSS-API context
+ * client_name (w) the client's ASCII name
*
* Returns: 0 on success, -1 on failure
*
* message is displayed and -1 is returned.
*/
static int server_establish_context(s, server_creds, context, client_name,
- ret_flags)
- int s;
- gss_cred_id_t server_creds;
- gss_ctx_id_t *context;
- gss_buffer_t client_name;
- OM_uint32 *ret_flags;
+ ret_flags)
+ int s;
+ gss_cred_id_t server_creds;
+ gss_ctx_id_t *context;
+ gss_buffer_t client_name;
+ OM_uint32 *ret_flags;
{
- gss_buffer_desc send_tok, recv_tok;
- gss_name_t client;
- gss_OID doid;
- OM_uint32 maj_stat, min_stat, acc_sec_min_stat;
- gss_buffer_desc oid_name;
- int token_flags;
-
- if (recv_token(s, &token_flags, &recv_tok) < 0)
- return -1;
-
- if (recv_tok.value) {
- free (recv_tok.value);
- recv_tok.value = NULL;
- }
-
- if (! (token_flags & TOKEN_NOOP)) {
- if (logfile)
- fprintf(logfile, "Expected NOOP token, got %d token instead\n",
- token_flags);
- return -1;
- }
-
- *context = GSS_C_NO_CONTEXT;
-
- if (token_flags & TOKEN_CONTEXT_NEXT) {
- do {
- if (recv_token(s, &token_flags, &recv_tok) < 0)
- return -1;
-
- if (verbose && logfile) {
- fprintf(logfile, "Received token (size=%d): \n", (int) recv_tok.length);
- print_token(&recv_tok);
- }
-
- maj_stat =
- gss_accept_sec_context(&acc_sec_min_stat,
- context,
- server_creds,
- &recv_tok,
- GSS_C_NO_CHANNEL_BINDINGS,
- &client,
- &doid,
- &send_tok,
- ret_flags,
- NULL, /* ignore time_rec */
- NULL); /* ignore del_cred_handle */
-
- if(recv_tok.value) {
- free(recv_tok.value);
- recv_tok.value = NULL;
- }
-
- if (send_tok.length != 0) {
- if (verbose && logfile) {
- fprintf(logfile,
- "Sending accept_sec_context token (size=%d):\n",
- (int) send_tok.length);
- print_token(&send_tok);
- }
- if (send_token(s, TOKEN_CONTEXT, &send_tok) < 0) {
- if (logfile)
- fprintf(logfile, "failure sending token\n");
- return -1;
- }
-
- (void) gss_release_buffer(&min_stat, &send_tok);
- }
- if (maj_stat!=GSS_S_COMPLETE && maj_stat!=GSS_S_CONTINUE_NEEDED) {
- display_status("accepting context", maj_stat,
- acc_sec_min_stat);
- if (*context != GSS_C_NO_CONTEXT)
- gss_delete_sec_context(&min_stat, context,
- GSS_C_NO_BUFFER);
- return -1;
- }
-
- if (verbose && logfile) {
- if (maj_stat == GSS_S_CONTINUE_NEEDED)
- fprintf(logfile, "continue needed...\n");
- else
- fprintf(logfile, "\n");
- fflush(logfile);
- }
- } while (maj_stat == GSS_S_CONTINUE_NEEDED);
-
- /* display the flags */
- display_ctx_flags(*ret_flags);
-
- if (verbose && logfile) {
- maj_stat = gss_oid_to_str(&min_stat, doid, &oid_name);
- if (maj_stat != GSS_S_COMPLETE) {
- display_status("converting oid->string", maj_stat, min_stat);
- return -1;
- }
- fprintf(logfile, "Accepted connection using mechanism OID %.*s.\n",
- (int) oid_name.length, (char *) oid_name.value);
- (void) gss_release_buffer(&min_stat, &oid_name);
- }
-
- maj_stat = gss_display_name(&min_stat, client, client_name, &doid);
- if (maj_stat != GSS_S_COMPLETE) {
- display_status("displaying name", maj_stat, min_stat);
- return -1;
- }
- maj_stat = gss_release_name(&min_stat, &client);
- if (maj_stat != GSS_S_COMPLETE) {
- display_status("releasing name", maj_stat, min_stat);
- return -1;
- }
- }
- else {
- client_name->length = *ret_flags = 0;
-
- if (logfile)
- fprintf(logfile, "Accepted unauthenticated connection.\n");
- }
-
- return 0;
+ gss_buffer_desc send_tok, recv_tok;
+ gss_name_t client;
+ gss_OID doid;
+ OM_uint32 maj_stat, min_stat, acc_sec_min_stat;
+ gss_buffer_desc oid_name;
+ int token_flags;
+
+ if (recv_token(s, &token_flags, &recv_tok) < 0)
+ return -1;
+
+ if (recv_tok.value) {
+ free (recv_tok.value);
+ recv_tok.value = NULL;
+ }
+
+ if (! (token_flags & TOKEN_NOOP)) {
+ if (logfile)
+ fprintf(logfile, "Expected NOOP token, got %d token instead\n",
+ token_flags);
+ return -1;
+ }
+
+ *context = GSS_C_NO_CONTEXT;
+
+ if (token_flags & TOKEN_CONTEXT_NEXT) {
+ do {
+ if (recv_token(s, &token_flags, &recv_tok) < 0)
+ return -1;
+
+ if (verbose && logfile) {
+ fprintf(logfile, "Received token (size=%d): \n", (int) recv_tok.length);
+ print_token(&recv_tok);
+ }
+
+ maj_stat =
+ gss_accept_sec_context(&acc_sec_min_stat,
+ context,
+ server_creds,
+ &recv_tok,
+ GSS_C_NO_CHANNEL_BINDINGS,
+ &client,
+ &doid,
+ &send_tok,
+ ret_flags,
+ NULL, /* ignore time_rec */
+ NULL); /* ignore del_cred_handle */
+
+ if(recv_tok.value) {
+ free(recv_tok.value);
+ recv_tok.value = NULL;
+ }
+
+ if (send_tok.length != 0) {
+ if (verbose && logfile) {
+ fprintf(logfile,
+ "Sending accept_sec_context token (size=%d):\n",
+ (int) send_tok.length);
+ print_token(&send_tok);
+ }
+ if (send_token(s, TOKEN_CONTEXT, &send_tok) < 0) {
+ if (logfile)
+ fprintf(logfile, "failure sending token\n");
+ return -1;
+ }
+
+ (void) gss_release_buffer(&min_stat, &send_tok);
+ }
+ if (maj_stat!=GSS_S_COMPLETE && maj_stat!=GSS_S_CONTINUE_NEEDED) {
+ display_status("accepting context", maj_stat,
+ acc_sec_min_stat);
+ if (*context != GSS_C_NO_CONTEXT)
+ gss_delete_sec_context(&min_stat, context,
+ GSS_C_NO_BUFFER);
+ return -1;
+ }
+
+ if (verbose && logfile) {
+ if (maj_stat == GSS_S_CONTINUE_NEEDED)
+ fprintf(logfile, "continue needed...\n");
+ else
+ fprintf(logfile, "\n");
+ fflush(logfile);
+ }
+ } while (maj_stat == GSS_S_CONTINUE_NEEDED);
+
+ /* display the flags */
+ display_ctx_flags(*ret_flags);
+
+ if (verbose && logfile) {
+ maj_stat = gss_oid_to_str(&min_stat, doid, &oid_name);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("converting oid->string", maj_stat, min_stat);
+ return -1;
+ }
+ fprintf(logfile, "Accepted connection using mechanism OID %.*s.\n",
+ (int) oid_name.length, (char *) oid_name.value);
+ (void) gss_release_buffer(&min_stat, &oid_name);
+ }
+
+ maj_stat = gss_display_name(&min_stat, client, client_name, &doid);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("displaying name", maj_stat, min_stat);
+ return -1;
+ }
+ maj_stat = gss_release_name(&min_stat, &client);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("releasing name", maj_stat, min_stat);
+ return -1;
+ }
+ }
+ else {
+ client_name->length = *ret_flags = 0;
+
+ if (logfile)
+ fprintf(logfile, "Accepted unauthenticated connection.\n");
+ }
+
+ return 0;
}
/*
*
* Arguments:
*
- * port (r) the port number on which to listen
+ * port (r) the port number on which to listen
*
* Returns: the listening socket file descriptor, or -1 on failure
*
* On error, an error message is displayed and -1 is returned.
*/
static int create_socket(port)
- u_short port;
+ u_short port;
{
- struct sockaddr_in saddr;
- int s;
- int on = 1;
-
- saddr.sin_family = AF_INET;
- saddr.sin_port = htons(port);
- saddr.sin_addr.s_addr = INADDR_ANY;
-
- if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- perror("creating socket");
- return -1;
- }
- /* Let the socket be reused right away */
- (void) setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on));
- if (bind(s, (struct sockaddr *) &saddr, sizeof(saddr)) < 0) {
- perror("binding socket");
- (void) close(s);
- return -1;
- }
- if (listen(s, 5) < 0) {
- perror("listening on socket");
- (void) close(s);
- return -1;
- }
- return s;
+ struct sockaddr_in saddr;
+ int s;
+ int on = 1;
+
+ saddr.sin_family = AF_INET;
+ saddr.sin_port = htons(port);
+ saddr.sin_addr.s_addr = INADDR_ANY;
+
+ if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+ perror("creating socket");
+ return -1;
+ }
+ /* Let the socket be reused right away */
+ (void) setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on));
+ if (bind(s, (struct sockaddr *) &saddr, sizeof(saddr)) < 0) {
+ perror("binding socket");
+ (void) close(s);
+ return -1;
+ }
+ if (listen(s, 5) < 0) {
+ perror("listening on socket");
+ (void) close(s);
+ return -1;
+ }
+ return s;
}
static float timeval_subtract(tv1, tv2)
- struct timeval *tv1, *tv2;
+ struct timeval *tv1, *tv2;
{
- return ((tv1->tv_sec - tv2->tv_sec) +
- ((float) (tv1->tv_usec - tv2->tv_usec)) / 1000000);
+ return ((tv1->tv_sec - tv2->tv_sec) +
+ ((float) (tv1->tv_usec - tv2->tv_usec)) / 1000000);
}
/*
* Yes, yes, this isn't the best place for doing this test.
* DO NOT REMOVE THIS UNTIL A BETTER TEST HAS BEEN WRITTEN, THOUGH.
- * -TYT
+ * -TYT
*/
static int test_import_export_context(context)
- gss_ctx_id_t *context;
+ gss_ctx_id_t *context;
{
- OM_uint32 min_stat, maj_stat;
- gss_buffer_desc context_token, copied_token;
- struct timeval tm1, tm2;
-
- /*
- * Attempt to save and then restore the context.
- */
- gettimeofday(&tm1, (struct timezone *)0);
- maj_stat = gss_export_sec_context(&min_stat, context, &context_token);
- if (maj_stat != GSS_S_COMPLETE) {
- display_status("exporting context", maj_stat, min_stat);
- return 1;
- }
- gettimeofday(&tm2, (struct timezone *)0);
- if (verbose && logfile)
- fprintf(logfile, "Exported context: %d bytes, %7.4f seconds\n",
- (int) context_token.length,
- timeval_subtract(&tm2, &tm1));
- copied_token.length = context_token.length;
- copied_token.value = malloc(context_token.length);
- if (copied_token.value == 0) {
- if (logfile)
- fprintf(logfile, "Couldn't allocate memory to copy context token.\n");
- return 1;
- }
- memcpy(copied_token.value, context_token.value, copied_token.length);
- maj_stat = gss_import_sec_context(&min_stat, &copied_token, context);
- if (maj_stat != GSS_S_COMPLETE) {
- display_status("importing context", maj_stat, min_stat);
- return 1;
- }
- free(copied_token.value);
- gettimeofday(&tm1, (struct timezone *)0);
- if (verbose && logfile)
- fprintf(logfile, "Importing context: %7.4f seconds\n",
- timeval_subtract(&tm1, &tm2));
- (void) gss_release_buffer(&min_stat, &context_token);
- return 0;
+ OM_uint32 min_stat, maj_stat;
+ gss_buffer_desc context_token, copied_token;
+ struct timeval tm1, tm2;
+
+ /*
+ * Attempt to save and then restore the context.
+ */
+ gettimeofday(&tm1, (struct timezone *)0);
+ maj_stat = gss_export_sec_context(&min_stat, context, &context_token);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("exporting context", maj_stat, min_stat);
+ return 1;
+ }
+ gettimeofday(&tm2, (struct timezone *)0);
+ if (verbose && logfile)
+ fprintf(logfile, "Exported context: %d bytes, %7.4f seconds\n",
+ (int) context_token.length,
+ timeval_subtract(&tm2, &tm1));
+ copied_token.length = context_token.length;
+ copied_token.value = malloc(context_token.length);
+ if (copied_token.value == 0) {
+ if (logfile)
+ fprintf(logfile, "Couldn't allocate memory to copy context token.\n");
+ return 1;
+ }
+ memcpy(copied_token.value, context_token.value, copied_token.length);
+ maj_stat = gss_import_sec_context(&min_stat, &copied_token, context);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("importing context", maj_stat, min_stat);
+ return 1;
+ }
+ free(copied_token.value);
+ gettimeofday(&tm1, (struct timezone *)0);
+ if (verbose && logfile)
+ fprintf(logfile, "Importing context: %7.4f seconds\n",
+ timeval_subtract(&tm1, &tm2));
+ (void) gss_release_buffer(&min_stat, &context_token);
+ return 0;
}
/*
*
* Arguments:
*
- * s (r) a TCP socket on which a connection has been
- * accept()ed
- * service_name (r) the ASCII name of the GSS-API service to
- * establish a context as
- * export (r) whether to test context exporting
+ * s (r) a TCP socket on which a connection has been
+ * accept()ed
+ * service_name (r) the ASCII name of the GSS-API service to
+ * establish a context as
+ * export (r) whether to test context exporting
*
* Returns: -1 on error
*
* If any error occurs, -1 is returned.
*/
static int sign_server(s, server_creds, export)
- int s;
- gss_cred_id_t server_creds;
- int export;
+ int s;
+ gss_cred_id_t server_creds;
+ int export;
{
gss_buffer_desc client_name, xmit_buf, msg_buf;
gss_ctx_id_t context;
OM_uint32 maj_stat, min_stat;
int i, conf_state, ret_flags;
- char *cp;
+ char *cp;
int token_flags;
/* Establish a context with the client */
if (server_establish_context(s, server_creds, &context,
- &client_name, &ret_flags) < 0)
+ &client_name, &ret_flags) < 0)
return(-1);
if (context == GSS_C_NO_CONTEXT) {
}
else {
printf("Accepted connection: \"%.*s\"\n",
- (int) client_name.length, (char *) client_name.value);
+ (int) client_name.length, (char *) client_name.value);
(void) gss_release_buffer(&min_stat, &client_name);
if (export) {
}
if ((context == GSS_C_NO_CONTEXT) &&
- ( token_flags & (TOKEN_WRAPPED|TOKEN_ENCRYPTED|TOKEN_SEND_MIC))) {
+ ( token_flags & (TOKEN_WRAPPED|TOKEN_ENCRYPTED|TOKEN_SEND_MIC))) {
if (logfile)
fprintf(logfile,
- "Unauthenticated client requested authenticated services!\n");
+ "Unauthenticated client requested authenticated services!\n");
if(xmit_buf.value) {
free (xmit_buf.value);
xmit_buf.value = 0;
if (token_flags & TOKEN_WRAPPED) {
maj_stat = gss_unwrap(&min_stat, context, &xmit_buf, &msg_buf,
- &conf_state, (gss_qop_t *) NULL);
+ &conf_state, (gss_qop_t *) NULL);
if (maj_stat != GSS_S_COMPLETE) {
display_status("unsealing message", maj_stat, min_stat);
if(xmit_buf.value) {
fprintf(logfile, "Received message: ");
cp = msg_buf.value;
if ((isprint((int) cp[0]) || isspace((int) cp[0])) &&
- (isprint((int) cp[1]) || isspace((int) cp[1]))) {
+ (isprint((int) cp[1]) || isspace((int) cp[1]))) {
fprintf(logfile, "\"%.*s\"\n", (int) msg_buf.length,
- (char *) msg_buf.value);
- } else {
- fprintf(logfile, "\n");
- print_token(&msg_buf);
- }
+ (char *) msg_buf.value);
+ } else {
+ fprintf(logfile, "\n");
+ print_token(&msg_buf);
+ }
}
if (token_flags & TOKEN_SEND_MIC) {
/* Produce a signature block for the message */
maj_stat = gss_get_mic(&min_stat, context, GSS_C_QOP_DEFAULT,
- &msg_buf, &xmit_buf);
+ &msg_buf, &xmit_buf);
if (maj_stat != GSS_S_COMPLETE) {
display_status("signing message", maj_stat, min_stat);
return(-1);
int err;
err = pthread_mutex_lock(&counter_mutex);
if (err) {
- perror("pthread_mutex_lock");
- return 0;
+ perror("pthread_mutex_lock");
+ return 0;
}
if (counter == max_threads) {
- err = pthread_cond_wait(&counter_cond, &counter_mutex);
- if (err) {
- pthread_mutex_unlock(&counter_mutex);
- perror("pthread_cond_wait");
- return 0;
- }
+ err = pthread_cond_wait(&counter_cond, &counter_mutex);
+ if (err) {
+ pthread_mutex_unlock(&counter_mutex);
+ perror("pthread_cond_wait");
+ return 0;
+ }
}
counter++;
pthread_mutex_unlock(&counter_mutex);
int err;
err = pthread_mutex_lock(&counter_mutex);
if (err) {
- perror("pthread_mutex_lock");
- return;
+ perror("pthread_mutex_lock");
+ return;
}
if (counter == max_threads)
- pthread_cond_broadcast(&counter_cond);
+ pthread_cond_broadcast(&counter_cond);
counter--;
pthread_mutex_unlock(&counter_mutex);
}
int
main(argc, argv)
- int argc;
- char **argv;
+ int argc;
+ char **argv;
{
- char *service_name;
- gss_cred_id_t server_creds;
- OM_uint32 min_stat;
- u_short port = 4444;
- int once = 0;
- int do_inetd = 0;
- int export = 0;
-
- signal(SIGPIPE, SIG_IGN);
- logfile = stdout;
- display_file = stdout;
- argc--; argv++;
- while (argc) {
- if (strcmp(*argv, "-port") == 0) {
- argc--; argv++;
- if (!argc) usage();
- port = atoi(*argv);
- }
+ char *service_name;
+ gss_cred_id_t server_creds;
+ OM_uint32 min_stat;
+ u_short port = 4444;
+ int once = 0;
+ int do_inetd = 0;
+ int export = 0;
+
+ signal(SIGPIPE, SIG_IGN);
+ logfile = stdout;
+ display_file = stdout;
+ argc--; argv++;
+ while (argc) {
+ if (strcmp(*argv, "-port") == 0) {
+ argc--; argv++;
+ if (!argc) usage();
+ port = atoi(*argv);
+ }
#if defined _WIN32 || 1
- else if (strcmp(*argv, "-threads") == 0) {
- argc--; argv++;
- if (!argc) usage();
- max_threads = atoi(*argv);
- }
+ else if (strcmp(*argv, "-threads") == 0) {
+ argc--; argv++;
+ if (!argc) usage();
+ max_threads = atoi(*argv);
+ }
#endif
- else if (strcmp(*argv, "-verbose") == 0) {
- verbose = 1;
- } else if (strcmp(*argv, "-once") == 0) {
- once = 1;
- } else if (strcmp(*argv, "-inetd") == 0) {
- do_inetd = 1;
- } else if (strcmp(*argv, "-export") == 0) {
- export = 1;
- } else if (strcmp(*argv, "-logfile") == 0) {
- argc--; argv++;
- if (!argc) usage();
- /* Gross hack, but it makes it unnecessary to add an
- extra argument to disable logging, and makes the code
- more efficient because it doesn't actually write data
- to /dev/null. */
- if (! strcmp(*argv, "/dev/null")) {
- logfile = display_file = NULL;
- }
- else {
- logfile = fopen(*argv, "a");
- display_file = logfile;
- if (!logfile) {
- perror(*argv);
- exit(1);
- }
- }
- } else
- break;
- argc--; argv++;
- }
- if (argc != 1)
- usage();
-
- if ((*argv)[0] == '-')
- usage();
+ else if (strcmp(*argv, "-verbose") == 0) {
+ verbose = 1;
+ } else if (strcmp(*argv, "-once") == 0) {
+ once = 1;
+ } else if (strcmp(*argv, "-inetd") == 0) {
+ do_inetd = 1;
+ } else if (strcmp(*argv, "-export") == 0) {
+ export = 1;
+ } else if (strcmp(*argv, "-logfile") == 0) {
+ argc--; argv++;
+ if (!argc) usage();
+ /* Gross hack, but it makes it unnecessary to add an
+ extra argument to disable logging, and makes the code
+ more efficient because it doesn't actually write data
+ to /dev/null. */
+ if (! strcmp(*argv, "/dev/null")) {
+ logfile = display_file = NULL;
+ }
+ else {
+ logfile = fopen(*argv, "a");
+ display_file = logfile;
+ if (!logfile) {
+ perror(*argv);
+ exit(1);
+ }
+ }
+ } else
+ break;
+ argc--; argv++;
+ }
+ if (argc != 1)
+ usage();
+
+ if ((*argv)[0] == '-')
+ usage();
#ifdef _WIN32
if (max_threads < 1) {
InitHandles();
#endif
- service_name = *argv;
+ service_name = *argv;
- if (server_acquire_creds(service_name, &server_creds) < 0)
- return -1;
+ if (server_acquire_creds(service_name, &server_creds) < 0)
+ return -1;
- if (do_inetd) {
- close(1);
- close(2);
+ if (do_inetd) {
+ close(1);
+ close(2);
- sign_server(0, server_creds, export);
- close(0);
- } else {
- int stmp;
+ sign_server(0, server_creds, export);
+ close(0);
+ } else {
+ int stmp;
- if ((stmp = create_socket(port)) >= 0) {
- if (listen(stmp, max_threads == 1 ? 0 : max_threads) < 0)
- perror("listening on socket");
+ if ((stmp = create_socket(port)) >= 0) {
+ if (listen(stmp, max_threads == 1 ? 0 : max_threads) < 0)
+ perror("listening on socket");
- do {
- struct _work_plan * work = malloc(sizeof(struct _work_plan));
+ do {
+ struct _work_plan * work = malloc(sizeof(struct _work_plan));
- if ( work == NULL ) {
- fprintf(stderr, "fatal error: out of memory");
- break;
- }
+ if ( work == NULL ) {
+ fprintf(stderr, "fatal error: out of memory");
+ break;
+ }
- /* Accept a TCP connection */
- if ((work->s = accept(stmp, NULL, 0)) < 0) {
- perror("accepting connection");
- continue;
- }
+ /* Accept a TCP connection */
+ if ((work->s = accept(stmp, NULL, 0)) < 0) {
+ perror("accepting connection");
+ continue;
+ }
- work->server_creds = server_creds;
- work->export = export;
+ work->server_creds = server_creds;
+ work->export = export;
- if (max_threads == 1) {
- worker_bee((void *)work);
- }
+ if (max_threads == 1) {
+ worker_bee((void *)work);
+ }
#if defined _WIN32 || 1
- else {
- if ( WaitAndIncrementThreadCounter() ) {
+ else {
+ if ( WaitAndIncrementThreadCounter() ) {
#ifdef _WIN32
- uintptr_t handle = _beginthread(worker_bee, 0, (void *)work);
- if (handle == (uintptr_t)-1) {
- closesocket(work->s);
- free(work);
- }
+ uintptr_t handle = _beginthread(worker_bee, 0, (void *)work);
+ if (handle == (uintptr_t)-1) {
+ closesocket(work->s);
+ free(work);
+ }
#else
- int err;
- pthread_t thr;
- err = pthread_create(&thr, 0, (void *(*)(void *))worker_bee,
- (void *) work);
- if (err) {
- perror("pthread_create");
- closesocket(work->s);
- free(work);
- }
- (void) pthread_detach(thr);
+ int err;
+ pthread_t thr;
+ err = pthread_create(&thr, 0, (void *(*)(void *))worker_bee,
+ (void *) work);
+ if (err) {
+ perror("pthread_create");
+ closesocket(work->s);
+ free(work);
+ }
+ (void) pthread_detach(thr);
#endif
- } else {
- fprintf(stderr, "fatal error incrementing thread counter");
- closesocket(work->s);
- free(work);
- break;
- }
- }
+ } else {
+ fprintf(stderr, "fatal error incrementing thread counter");
+ closesocket(work->s);
+ free(work);
+ break;
+ }
+ }
#endif
- } while (!once);
+ } while (!once);
- closesocket(stmp);
- }
- }
+ closesocket(stmp);
+ }
+ }
- (void) gss_release_cred(&min_stat, &server_creds);
+ (void) gss_release_cred(&min_stat, &server_creds);
#ifdef _WIN32
CleanupHandles();
#else
if (max_threads > 1)
- while (1)
- sleep (999999);
+ while (1)
+ sleep (999999);
#endif
- return 0;
+ return 0;
}
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 1996, Massachusetts Institute of Technology.
* All Rights Reserved.
FILE *display_file;
int main(argc, argv)
- int argc;
- char **argv;
+ int argc;
+ char **argv;
{
- int retval;
+ int retval;
- display_file = stdout;
+ display_file = stdout;
- retval = test_import_name("host@dcl.mit.edu");
+ retval = test_import_name("host@dcl.mit.edu");
- return retval;
+ return retval;
}
static int test_import_name(name)
- char *name;
+ char *name;
{
- OM_uint32 maj_stat, min_stat;
- gss_name_t gss_name;
- gss_buffer_desc buffer_name;
- gss_OID name_oid;
-
- buffer_name.value = name;
- buffer_name.length = strlen(name) + 1;
- maj_stat = gss_import_name(&min_stat, &buffer_name,
- (gss_OID) gss_nt_service_name,
- &gss_name);
- if (maj_stat != GSS_S_COMPLETE) {
- display_status("parsing name", maj_stat, min_stat);
- return -1;
- }
-
- maj_stat = gss_display_name(&min_stat, gss_name, &buffer_name,
- &name_oid);
- if (maj_stat != GSS_S_COMPLETE) {
- display_status("displaying context", maj_stat, min_stat);
- return -1;
- }
- printf("name is: ");
- display_buffer(buffer_name);
- printf("\n");
- (void) gss_release_buffer(&min_stat, &buffer_name);
-
- gss_oid_to_str(&min_stat, name_oid, &buffer_name);
- printf("name type is: ");
- display_buffer(buffer_name);
- printf("\n");
- (void) gss_release_buffer(&min_stat, &buffer_name);
-#ifdef GSSAPI_V2
- (void) gss_release_oid(&min_stat, &name_oid);
+ OM_uint32 maj_stat, min_stat;
+ gss_name_t gss_name;
+ gss_buffer_desc buffer_name;
+ gss_OID name_oid;
+
+ buffer_name.value = name;
+ buffer_name.length = strlen(name) + 1;
+ maj_stat = gss_import_name(&min_stat, &buffer_name,
+ (gss_OID) gss_nt_service_name,
+ &gss_name);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("parsing name", maj_stat, min_stat);
+ return -1;
+ }
+
+ maj_stat = gss_display_name(&min_stat, gss_name, &buffer_name,
+ &name_oid);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("displaying context", maj_stat, min_stat);
+ return -1;
+ }
+ printf("name is: ");
+ display_buffer(buffer_name);
+ printf("\n");
+ (void) gss_release_buffer(&min_stat, &buffer_name);
+
+ gss_oid_to_str(&min_stat, name_oid, &buffer_name);
+ printf("name type is: ");
+ display_buffer(buffer_name);
+ printf("\n");
+ (void) gss_release_buffer(&min_stat, &buffer_name);
+#ifdef GSSAPI_V2
+ (void) gss_release_oid(&min_stat, &name_oid);
#endif
- (void) gss_release_name(&min_stat, &gss_name);
- return 0;
+ (void) gss_release_name(&min_stat, &gss_name);
+ return 0;
}
static void display_buffer(buffer)
- gss_buffer_desc buffer;
+ gss_buffer_desc buffer;
{
char *namebuf;
namebuf = malloc(buffer.length+1);
if (!namebuf) {
- fprintf(stderr, "display_buffer: couldn't allocate buffer!\n");
- exit(1);
+ fprintf(stderr, "display_buffer: couldn't allocate buffer!\n");
+ exit(1);
}
strncpy(namebuf, buffer.value, buffer.length);
namebuf[buffer.length] = '\0';
}
void display_status(msg, maj_stat, min_stat)
- char *msg;
- OM_uint32 maj_stat;
- OM_uint32 min_stat;
+ char *msg;
+ OM_uint32 maj_stat;
+ OM_uint32 min_stat;
{
- display_status_1(msg, maj_stat, GSS_C_GSS_CODE);
- display_status_1(msg, min_stat, GSS_C_MECH_CODE);
+ display_status_1(msg, maj_stat, GSS_C_GSS_CODE);
+ display_status_1(msg, min_stat, GSS_C_MECH_CODE);
}
static void display_status_1(m, code, type)
- char *m;
- OM_uint32 code;
- int type;
+ char *m;
+ OM_uint32 code;
+ int type;
{
- OM_uint32 min_stat;
- gss_buffer_desc msg;
-#ifdef GSSAPI_V2
- OM_uint32 msg_ctx;
-#else /* GSSAPI_V2 */
- int msg_ctx;
-#endif /* GSSAPI_V2 */
-
- msg_ctx = 0;
- while (1) {
- (void) gss_display_status(&min_stat, code,
- type, GSS_C_NULL_OID,
- &msg_ctx, &msg);
- if (display_file)
- fprintf(display_file, "GSS-API error %s: %s\n", m,
- (char *)msg.value);
- (void) gss_release_buffer(&min_stat, &msg);
-
- if (!msg_ctx)
- break;
- }
+ OM_uint32 min_stat;
+ gss_buffer_desc msg;
+#ifdef GSSAPI_V2
+ OM_uint32 msg_ctx;
+#else /* GSSAPI_V2 */
+ int msg_ctx;
+#endif /* GSSAPI_V2 */
+
+ msg_ctx = 0;
+ while (1) {
+ (void) gss_display_status(&min_stat, code,
+ type, GSS_C_NULL_OID,
+ &msg_ctx, &msg);
+ if (display_file)
+ fprintf(display_file, "GSS-API error %s: %s\n", m,
+ (char *)msg.value);
+ (void) gss_release_buffer(&min_stat, &msg);
+
+ if (!msg_ctx)
+ break;
+ }
}
-/* -*- mode: c; indent-tabs-mode: nil -*- */
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 2009 by the Massachusetts Institute of Technology.
* All Rights Reserved.
static int use_spnego = 0;
static void displayStatus_1(m, code, type)
- char *m;
- OM_uint32 code;
- int type;
+ char *m;
+ OM_uint32 code;
+ int type;
{
- OM_uint32 maj_stat, min_stat;
- gss_buffer_desc msg;
- OM_uint32 msg_ctx;
-
- msg_ctx = 0;
- while (1) {
- maj_stat = gss_display_status(&min_stat, code,
- type, GSS_C_NULL_OID,
- &msg_ctx, &msg);
- fprintf(stderr, "%s: %s\n", m, (char *)msg.value);
- (void) gss_release_buffer(&min_stat, &msg);
-
- if (!msg_ctx)
- break;
- }
+ OM_uint32 maj_stat, min_stat;
+ gss_buffer_desc msg;
+ OM_uint32 msg_ctx;
+
+ msg_ctx = 0;
+ while (1) {
+ maj_stat = gss_display_status(&min_stat, code,
+ type, GSS_C_NULL_OID,
+ &msg_ctx, &msg);
+ fprintf(stderr, "%s: %s\n", m, (char *)msg.value);
+ (void) gss_release_buffer(&min_stat, &msg);
+
+ if (!msg_ctx)
+ break;
+ }
}
static void displayStatus(msg, maj_stat, min_stat)
- char *msg;
- OM_uint32 maj_stat;
- OM_uint32 min_stat;
+ char *msg;
+ OM_uint32 maj_stat;
+ OM_uint32 min_stat;
{
- displayStatus_1(msg, maj_stat, GSS_C_GSS_CODE);
- displayStatus_1(msg, min_stat, GSS_C_MECH_CODE);
+ displayStatus_1(msg, maj_stat, GSS_C_GSS_CODE);
+ displayStatus_1(msg, min_stat, GSS_C_MECH_CODE);
}
static OM_uint32
printf("Attribute %.*s %s %s\n\n%.*s\n",
(int)attribute->length, (char *)attribute->value,
authenticated ? "Authenticated" : "",
- complete ? "Complete" : "",
+ complete ? "Complete" : "",
(int)display_value.length, (char *)display_value.value);
if (noisy) {
&initiator_context,
target_name,
use_spnego ?
- (gss_OID)&spnego_mech :
- (gss_OID)gss_mech_krb5,
+ (gss_OID)&spnego_mech :
+ (gss_OID)gss_mech_krb5,
GSS_C_REPLAY_FLAG | GSS_C_SEQUENCE_FLAG,
GSS_C_INDEFINITE,
GSS_C_NO_CHANNEL_BINDINGS,
mechs.elements = use_spnego ? (gss_OID)&spnego_mech :
- (gss_OID)gss_mech_krb5;
+ (gss_OID)gss_mech_krb5;
mechs.count = 1;
/* get default cred */
-/* -*- mode: c; indent-tabs-mode: nil -*- */
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 2009 by the Massachusetts Institute of Technology.
* All Rights Reserved.
static int use_spnego = 0;
static void displayStatus_1(m, code, type)
- char *m;
- OM_uint32 code;
- int type;
+ char *m;
+ OM_uint32 code;
+ int type;
{
- OM_uint32 maj_stat, min_stat;
- gss_buffer_desc msg;
- OM_uint32 msg_ctx;
-
- msg_ctx = 0;
- while (1) {
- maj_stat = gss_display_status(&min_stat, code,
- type, GSS_C_NULL_OID,
- &msg_ctx, &msg);
- fprintf(stderr, "%s: %s\n", m, (char *)msg.value);
- (void) gss_release_buffer(&min_stat, &msg);
-
- if (!msg_ctx)
- break;
- }
+ OM_uint32 maj_stat, min_stat;
+ gss_buffer_desc msg;
+ OM_uint32 msg_ctx;
+
+ msg_ctx = 0;
+ while (1) {
+ maj_stat = gss_display_status(&min_stat, code,
+ type, GSS_C_NULL_OID,
+ &msg_ctx, &msg);
+ fprintf(stderr, "%s: %s\n", m, (char *)msg.value);
+ (void) gss_release_buffer(&min_stat, &msg);
+
+ if (!msg_ctx)
+ break;
+ }
}
static void displayStatus(msg, maj_stat, min_stat)
- char *msg;
- OM_uint32 maj_stat;
- OM_uint32 min_stat;
+ char *msg;
+ OM_uint32 maj_stat;
+ OM_uint32 min_stat;
{
- displayStatus_1(msg, maj_stat, GSS_C_GSS_CODE);
- displayStatus_1(msg, min_stat, GSS_C_MECH_CODE);
+ displayStatus_1(msg, maj_stat, GSS_C_GSS_CODE);
+ displayStatus_1(msg, min_stat, GSS_C_MECH_CODE);
}
static OM_uint32
printf("Attribute %.*s %s %s\n\n%.*s\n",
(int)attribute->length, (char *)attribute->value,
authenticated ? "Authenticated" : "",
- complete ? "Complete" : "",
+ complete ? "Complete" : "",
(int)display_value.length, (char *)display_value.value);
if (noisy) {
&initiator_context,
target,
mechs ? &mechs->elements[0] :
- (gss_OID)gss_mech_krb5,
+ (gss_OID)gss_mech_krb5,
GSS_C_REPLAY_FLAG | GSS_C_SEQUENCE_FLAG,
GSS_C_INDEFINITE,
GSS_C_NO_CHANNEL_BINDINGS,
if (argc < 2 || argc > 5) {
fprintf(stderr, "Usage: %s [--spnego] [user] "
- "[proxy-target] [keytab]\n", argv[0]);
+ "[proxy-target] [keytab]\n", argv[0]);
fprintf(stderr, " proxy-target and keytab are optional\n");
exit(1);
}
}
mechs.elements = use_spnego ? (gss_OID)&spnego_mech :
- (gss_OID)gss_mech_krb5;
+ (gss_OID)gss_mech_krb5;
mechs.count = 1;
/* get default cred */
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* tests/hammer/pp.c
*
void
print_principal(p)
- krb5_principal p;
+ krb5_principal p;
{
- char *buf;
- krb5_error_code retval;
+ char *buf;
+ krb5_error_code retval;
- if (retval = krb5_unparse_name(p, &buf)) {
- com_err("DEBUG: Print_principal", retval,
- "while unparsing name");
- exit(1);
- }
- printf("%s\n", buf);
- free(buf);
+ if (retval = krb5_unparse_name(p, &buf)) {
+ com_err("DEBUG: Print_principal", retval,
+ "while unparsing name");
+ exit(1);
+ }
+ printf("%s\n", buf);
+ free(buf);
}
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#include "autoconf.h"
#include "k5-platform.h"
#include <stdio.h>
x = k5_getpwuid_r(my_uid, &pwx, pwbuf, sizeof(pwbuf), &pwd);
printf("k5_getpwuid_r returns %d\n", x);
if (x != 0)
- exit(1);
+ exit(1);
printf(" username is '%s'\n", pwd->pw_name);
exit(0);
}
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* test_getsockname.c
*
int sock;
GETSOCKNAME_ARG3_TYPE i;
struct hostent *host;
- struct sockaddr_in s_sock; /* server address */
- struct sockaddr_in c_sock; /* client address */
+ struct sockaddr_in s_sock; /* server address */
+ struct sockaddr_in c_sock; /* client address */
char *hostname;
if (argc == 2) {
- hostname = argv[1];
+ hostname = argv[1];
} else {
- fprintf(stderr, "Usage: %s hostname\n", argv[0]);
- exit(1);
+ fprintf(stderr, "Usage: %s hostname\n", argv[0]);
+ exit(1);
}
/* Look up server host */
if ((host = gethostbyname(hostname)) == (struct hostent *) 0) {
- fprintf(stderr, "%s: unknown host\n", hostname);
- exit(1);
+ fprintf(stderr, "%s: unknown host\n", hostname);
+ exit(1);
}
/* Set server's address */
/* Open a socket */
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
- perror("socket");
- exit(1);
+ perror("socket");
+ exit(1);
}
memset(&c_sock, 0, sizeof(c_sock));
/* Bind it to set the address; kernel will fill in port # */
if (bind(sock, (struct sockaddr *)&c_sock, sizeof(c_sock)) < 0) {
- perror("bind");
- exit(1);
+ perror("bind");
+ exit(1);
}
/* "connect" the datagram socket; this is necessary to get a local address
properly bound for getsockname() below. */
if (connect(sock, (struct sockaddr *)&s_sock, sizeof(s_sock)) == -1) {
- perror("connect");
- exit(1);
+ perror("connect");
+ exit(1);
}
/* Get my address */
memset(&c_sock, 0, sizeof(c_sock));
i = sizeof(c_sock);
if (getsockname(sock, (struct sockaddr *)&c_sock, &i) < 0) {
- perror("getsockname");
- exit(1);
+ perror("getsockname");
+ exit(1);
}
printf("My interface address is: %s\n", inet_ntoa(c_sock.sin_addr));
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright (C) 1998 by the FundsXpress, INC.
*
unsigned char *instr, *outstr;
if (argc != 3) {
- fprintf(stderr, "%s: instr outlen\n", argv[0]);
- exit(1);
+ fprintf(stderr, "%s: instr outlen\n", argv[0]);
+ exit(1);
}
instr = (unsigned char *) argv[1];
inlen = strlen(instr)*8;
outlen = atoi(argv[2]);
if (outlen%8) {
- fprintf(stderr, "outlen must be a multiple of 8\n");
- exit(1);
+ fprintf(stderr, "outlen must be a multiple of 8\n");
+ exit(1);
}
if ((outstr = (unsigned char *) malloc(outlen/8)) == NULL) {
- fprintf(stderr, "ENOMEM\n");
- exit(1);
+ fprintf(stderr, "ENOMEM\n");
+ exit(1);
}
krb5int_nfold(inlen,instr,outlen,outstr);
printf("%d-fold(",outlen);
for (i=0; i<(inlen/8); i++)
- printf("%02x",instr[i]);
+ printf("%02x",instr[i]);
printf(") = ");
for (i=0; i<(outlen/8); i++)
- printf("%02x",outstr[i]);
+ printf("%02x",outstr[i]);
printf("\n");
exit(0);
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#include <stdio.h>
/*
unsigned char *char_array = (unsigned char*)&int_var;
if (char_array[0] == 0)
- return 0; /* big endian */
+ return 0; /* big endian */
else
- return 1; /* little endian */
+ return 1; /* little endian */
}
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* test/resolve/addrinfo-test.c
*
static void usage () {
fprintf(stderr,
- "usage:\n"
- "\t%s [ options ] [host]\n"
- "options:\n"
- "\t-t\tspecify protocol IPPROTO_TCP\n"
- "\t-u\tspecify protocol IPPROTO_UDP\n"
- "\t-R\tspecify protocol IPPROTO_RAW\n"
- "\t-I\tspecify protocol IPPROTO_ICMP\n"
- "\n"
- "\t-d\tspecify socket type SOCK_DGRAM\n"
- "\t-s\tspecify socket type SOCK_STREAM\n"
- "\t-r\tspecify socket type SOCK_RAW\n"
- "\n"
- "\t-4\tspecify address family AF_INET\n"
+ "usage:\n"
+ "\t%s [ options ] [host]\n"
+ "options:\n"
+ "\t-t\tspecify protocol IPPROTO_TCP\n"
+ "\t-u\tspecify protocol IPPROTO_UDP\n"
+ "\t-R\tspecify protocol IPPROTO_RAW\n"
+ "\t-I\tspecify protocol IPPROTO_ICMP\n"
+ "\n"
+ "\t-d\tspecify socket type SOCK_DGRAM\n"
+ "\t-s\tspecify socket type SOCK_STREAM\n"
+ "\t-r\tspecify socket type SOCK_RAW\n"
+ "\n"
+ "\t-4\tspecify address family AF_INET\n"
#ifdef AF_INET6
- "\t-6\tspecify address family AF_INET6\n"
+ "\t-6\tspecify address family AF_INET6\n"
#endif
- "\n"
- "\t-p P\tspecify port P (service name or port number)\n"
- "\t-N\thostname is numeric, skip DNS query\n"
- "\t-n\tservice/port is numeric (sets AI_NUMERICSERV)\n"
- "\t-P\tset AI_PASSIVE\n"
- "\n"
- "default: protocol 0, socket type 0, address family 0, null port\n"
- ,
- whoami);
+ "\n"
+ "\t-p P\tspecify port P (service name or port number)\n"
+ "\t-N\thostname is numeric, skip DNS query\n"
+ "\t-n\tservice/port is numeric (sets AI_NUMERICSERV)\n"
+ "\t-P\tset AI_PASSIVE\n"
+ "\n"
+ "default: protocol 0, socket type 0, address family 0, null port\n"
+ ,
+ whoami);
/* [ -t | -u | -R | -I ] [ -d | -s | -r ] [ -p port ] */
exit (1);
}
static char buf[30];
switch (f) {
default:
- snprintf(buf, sizeof(buf), "AF %d", f);
- return buf;
+ snprintf(buf, sizeof(buf), "AF %d", f);
+ return buf;
case AF_INET: return "AF_INET";
#ifdef AF_INET6
case AF_INET6: return "AF_INET6";
whoami = strrchr(argv[0], '/');
if (whoami == 0)
- whoami = argv[0];
+ whoami = argv[0];
else
- whoami = whoami+1;
+ whoami = whoami+1;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = 0;
hints.ai_family = 0;
if (argc == 1)
- usage ();
+ usage ();
while (++argv, --argc > 0) {
- char *arg;
- arg = *argv;
+ char *arg;
+ arg = *argv;
- if (*arg != '-')
- hname = arg;
- else if (arg[1] == 0 || arg[2] != 0)
- usage ();
- else
- switch (arg[1]) {
- case 'u':
- hints.ai_protocol = IPPROTO_UDP;
- break;
- case 't':
- hints.ai_protocol = IPPROTO_TCP;
- break;
- case 'R':
- hints.ai_protocol = IPPROTO_RAW;
- break;
- case 'I':
- hints.ai_protocol = IPPROTO_ICMP;
- break;
- case 'd':
- hints.ai_socktype = SOCK_DGRAM;
- break;
- case 's':
- hints.ai_socktype = SOCK_STREAM;
- break;
- case 'r':
- hints.ai_socktype = SOCK_RAW;
- break;
- case 'p':
- if (argv[1] == 0 || argv[1][0] == 0 || argv[1][0] == '-')
- usage ();
- port = argv[1];
- argc--, argv++;
- break;
- case '4':
- hints.ai_family = AF_INET;
- break;
+ if (*arg != '-')
+ hname = arg;
+ else if (arg[1] == 0 || arg[2] != 0)
+ usage ();
+ else
+ switch (arg[1]) {
+ case 'u':
+ hints.ai_protocol = IPPROTO_UDP;
+ break;
+ case 't':
+ hints.ai_protocol = IPPROTO_TCP;
+ break;
+ case 'R':
+ hints.ai_protocol = IPPROTO_RAW;
+ break;
+ case 'I':
+ hints.ai_protocol = IPPROTO_ICMP;
+ break;
+ case 'd':
+ hints.ai_socktype = SOCK_DGRAM;
+ break;
+ case 's':
+ hints.ai_socktype = SOCK_STREAM;
+ break;
+ case 'r':
+ hints.ai_socktype = SOCK_RAW;
+ break;
+ case 'p':
+ if (argv[1] == 0 || argv[1][0] == 0 || argv[1][0] == '-')
+ usage ();
+ port = argv[1];
+ argc--, argv++;
+ break;
+ case '4':
+ hints.ai_family = AF_INET;
+ break;
#ifdef AF_INET6
- case '6':
- hints.ai_family = AF_INET6;
- break;
+ case '6':
+ hints.ai_family = AF_INET6;
+ break;
#endif
- case 'N':
- numerichost = 1;
- break;
- case 'n':
- numericserv = 1;
- break;
- case 'P':
- hints.ai_flags |= AI_PASSIVE;
- break;
- default:
- usage ();
- }
+ case 'N':
+ numerichost = 1;
+ break;
+ case 'n':
+ numericserv = 1;
+ break;
+ case 'P':
+ hints.ai_flags |= AI_PASSIVE;
+ break;
+ default:
+ usage ();
+ }
}
if (hname && !numerichost)
- hints.ai_flags |= AI_CANONNAME;
+ hints.ai_flags |= AI_CANONNAME;
if (numerichost) {
#ifdef AI_NUMERICHOST
- hints.ai_flags |= AI_NUMERICHOST;
+ hints.ai_flags |= AI_NUMERICHOST;
#else
- fprintf(stderr, "AI_NUMERICHOST not defined on this platform\n");
- exit(1);
+ fprintf(stderr, "AI_NUMERICHOST not defined on this platform\n");
+ exit(1);
#endif
}
if (numericserv) {
#ifdef AI_NUMERICSERV
- hints.ai_flags |= AI_NUMERICSERV;
+ hints.ai_flags |= AI_NUMERICSERV;
#else
- fprintf(stderr, "AI_NUMERICSERV not defined on this platform\n");
- exit(1);
+ fprintf(stderr, "AI_NUMERICSERV not defined on this platform\n");
+ exit(1);
#endif
}
printf("getaddrinfo(hostname %s, service %s,\n"
- " hints { ",
- hname ? hname : "(null)", port ? port : "(null)");
+ " hints { ",
+ hname ? hname : "(null)", port ? port : "(null)");
sep = "";
#define Z(FLAG) if (hints.ai_flags & AI_##FLAG) printf("%s%s", sep, #FLAG), sep = "|"
Z(CANONNAME);
Z(NUMERICSERV);
#endif
if (sep[0] == 0)
- printf ("no-flags");
+ printf ("no-flags");
if (hints.ai_family)
- printf(" %s", familyname(hints.ai_family));
+ printf(" %s", familyname(hints.ai_family));
if (hints.ai_socktype)
- printf(" SOCK_%s", socktypename(hints.ai_socktype));
+ printf(" SOCK_%s", socktypename(hints.ai_socktype));
if (hints.ai_protocol)
- printf(" IPPROTO_%s", protoname(hints.ai_protocol));
+ printf(" IPPROTO_%s", protoname(hints.ai_protocol));
printf(" }):\n");
err = getaddrinfo(hname, port, &hints, &ap);
if (err) {
- printf("\terror => %s\n", eaistr(err));
- return 1;
+ printf("\terror => %s\n", eaistr(err));
+ return 1;
}
#if defined(SIN6_LEN)
if (ap->ai_addr->sa_len == 0)
- printf ("BAD: sa_len not set!\n");
+ printf ("BAD: sa_len not set!\n");
#endif
for (ap2 = ap; ap2; ap2 = ap2->ai_next) {
- char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
- /* If we don't do this, even AIX's own getnameinfo will reject
- the sockaddr structures. The sa_len field doesn't get set
- either, on AIX, but getnameinfo won't complain. */
- if (ap2->ai_addr->sa_family == 0) {
- printf("BAD: sa_family zero! fixing...\n");
- ap2->ai_addr->sa_family = ap2->ai_family;
- } else if (ap2->ai_addr->sa_family != ap2->ai_family) {
- printf("BAD: sa_family != ai_family! fixing...\n");
- ap2->ai_addr->sa_family = ap2->ai_family;
- }
- if (getnameinfo(ap2->ai_addr, ap2->ai_addrlen, hbuf, sizeof(hbuf),
- pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV)) {
- strlcpy(hbuf, "...", sizeof(hbuf));
- strlcpy(pbuf, "...", sizeof(pbuf));
- }
- printf("%p:\n"
- "\tfamily = %s\tproto = %-4s\tsocktype = %s\n",
- ap2, familyname(ap2->ai_family),
- protoname (ap2->ai_protocol),
- socktypename (ap2->ai_socktype));
- if (ap2->ai_canonname) {
- if (ap2->ai_canonname[0])
- printf("\tcanonname = %s\n", ap2->ai_canonname);
- else
- printf("BAD: ai_canonname is set but empty!\n");
- } else if (ap2 == ap && (hints.ai_flags & AI_CANONNAME)) {
- printf("BAD: first ai_canonname is null!\n");
- }
- printf("\taddr = %-28s\tport = %s\n", hbuf, pbuf);
+ char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
+ /* If we don't do this, even AIX's own getnameinfo will reject
+ the sockaddr structures. The sa_len field doesn't get set
+ either, on AIX, but getnameinfo won't complain. */
+ if (ap2->ai_addr->sa_family == 0) {
+ printf("BAD: sa_family zero! fixing...\n");
+ ap2->ai_addr->sa_family = ap2->ai_family;
+ } else if (ap2->ai_addr->sa_family != ap2->ai_family) {
+ printf("BAD: sa_family != ai_family! fixing...\n");
+ ap2->ai_addr->sa_family = ap2->ai_family;
+ }
+ if (getnameinfo(ap2->ai_addr, ap2->ai_addrlen, hbuf, sizeof(hbuf),
+ pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV)) {
+ strlcpy(hbuf, "...", sizeof(hbuf));
+ strlcpy(pbuf, "...", sizeof(pbuf));
+ }
+ printf("%p:\n"
+ "\tfamily = %s\tproto = %-4s\tsocktype = %s\n",
+ ap2, familyname(ap2->ai_family),
+ protoname (ap2->ai_protocol),
+ socktypename (ap2->ai_socktype));
+ if (ap2->ai_canonname) {
+ if (ap2->ai_canonname[0])
+ printf("\tcanonname = %s\n", ap2->ai_canonname);
+ else
+ printf("BAD: ai_canonname is set but empty!\n");
+ } else if (ap2 == ap && (hints.ai_flags & AI_CANONNAME)) {
+ printf("BAD: first ai_canonname is null!\n");
+ }
+ printf("\taddr = %-28s\tport = %s\n", hbuf, pbuf);
- err = getnameinfo(ap2->ai_addr, ap2->ai_addrlen, hbuf, sizeof (hbuf),
- pbuf, sizeof(pbuf), NI_NAMEREQD);
- if (err)
- printf("\tgetnameinfo(NI_NAMEREQD): %s\n", eaistr(err));
- else
- printf("\tgetnameinfo => %s, %s\n", hbuf, pbuf);
+ err = getnameinfo(ap2->ai_addr, ap2->ai_addrlen, hbuf, sizeof (hbuf),
+ pbuf, sizeof(pbuf), NI_NAMEREQD);
+ if (err)
+ printf("\tgetnameinfo(NI_NAMEREQD): %s\n", eaistr(err));
+ else
+ printf("\tgetnameinfo => %s, %s\n", hbuf, pbuf);
}
freeaddrinfo(ap);
return 0;
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#define USE_FAKE_ADDRINFO
#include "addrinfo-test.c"
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* test/resolve/resolve.c
*
int
main(argc, argv)
- int argc;
- char **argv;
+ int argc;
+ char **argv;
{
- char myname[MAXHOSTNAMELEN+1];
- char *ptr;
- struct in_addr addrcopy;
- struct hostent *host;
- int quiet = 0;
-
- argc--; argv++;
- while (argc) {
- if ((strcmp(*argv, "--quiet") == 0) ||
- (strcmp(*argv, "-q") == 0)) {
- quiet++;
- } else
- break;
- argc--; argv++;
- }
-
- if (argc >= 1) {
- strncpy(myname, *argv, MAXHOSTNAMELEN);
- } else {
- if(gethostname(myname, MAXHOSTNAMELEN)) {
- perror("gethostname failure");
- exit(1);
- }
- }
-
- myname[MAXHOSTNAMELEN] = '\0'; /* for safety */
-
- /* Look up the address... */
- if (!quiet)
- printf("Hostname: %s\n", myname);
-
-
- /* Set the hosts db to close each time - effectively rewinding file */
- sethostent(0);
-
- if((host = gethostbyname (myname)) == NULL) {
- fprintf(stderr,
- "Could not look up address for hostname '%s' - fatal\n",
- myname);
- exit(2);
- }
-
- ptr = host->h_addr_list[0];
+ char myname[MAXHOSTNAMELEN+1];
+ char *ptr;
+ struct in_addr addrcopy;
+ struct hostent *host;
+ int quiet = 0;
+
+ argc--; argv++;
+ while (argc) {
+ if ((strcmp(*argv, "--quiet") == 0) ||
+ (strcmp(*argv, "-q") == 0)) {
+ quiet++;
+ } else
+ break;
+ argc--; argv++;
+ }
+
+ if (argc >= 1) {
+ strncpy(myname, *argv, MAXHOSTNAMELEN);
+ } else {
+ if(gethostname(myname, MAXHOSTNAMELEN)) {
+ perror("gethostname failure");
+ exit(1);
+ }
+ }
+
+ myname[MAXHOSTNAMELEN] = '\0'; /* for safety */
+
+ /* Look up the address... */
+ if (!quiet)
+ printf("Hostname: %s\n", myname);
+
+
+ /* Set the hosts db to close each time - effectively rewinding file */
+ sethostent(0);
+
+ if((host = gethostbyname (myname)) == NULL) {
+ fprintf(stderr,
+ "Could not look up address for hostname '%s' - fatal\n",
+ myname);
+ exit(2);
+ }
+
+ ptr = host->h_addr_list[0];
#define UC(a) (((int)a)&0xff)
- if (!quiet)
- printf("Host address: %d.%d.%d.%d\n",
- UC(ptr[0]), UC(ptr[1]), UC(ptr[2]), UC(ptr[3]));
-
- memcpy(&addrcopy.s_addr, ptr, 4);
-
- /* Convert back to full name */
- if((host = gethostbyaddr(&addrcopy.s_addr, 4, AF_INET)) == NULL) {
- fprintf(stderr, "Error looking up IP address - fatal\n");
- exit(2);
- }
-
- if (quiet)
- printf("%s\n", host->h_name);
- else
- printf("FQDN: %s\n", host->h_name);
-
- /*
- * The host name must have at least one '.' in the name, and
- * if there is only one '.', it must not be at the end of the
- * string. (i.e., "foo." is not a FQDN)
- */
- ptr = strchr(host->h_name, '.');
- if (ptr == NULL || ptr[1] == '\0') {
- fprintf(stderr,
- "\nResolve library did not return a "
- "fully qualified domain name.\n\n"
- "If you are using /etc/hosts before DNS, "
- "e.g. \"files\" is listed first\n"
- "for \"hosts:\" in nsswitch.conf, ensure that "
- "you have listed the FQDN\n"
- "as the first name for the local host.\n\n"
- "If this does not correct the problem, "
- "you may have to reconfigure the kerberos\n"
- "distribution to select a "
- "different set of libraries using \n"
- "--with-netlib[=libs]\n");
- exit(3);
- }
-
- if (!quiet)
- printf("Resolve library appears to have passed the test\n");
-
- /* All ok */
- exit(0);
+ if (!quiet)
+ printf("Host address: %d.%d.%d.%d\n",
+ UC(ptr[0]), UC(ptr[1]), UC(ptr[2]), UC(ptr[3]));
+
+ memcpy(&addrcopy.s_addr, ptr, 4);
+
+ /* Convert back to full name */
+ if((host = gethostbyaddr(&addrcopy.s_addr, 4, AF_INET)) == NULL) {
+ fprintf(stderr, "Error looking up IP address - fatal\n");
+ exit(2);
+ }
+
+ if (quiet)
+ printf("%s\n", host->h_name);
+ else
+ printf("FQDN: %s\n", host->h_name);
+
+ /*
+ * The host name must have at least one '.' in the name, and
+ * if there is only one '.', it must not be at the end of the
+ * string. (i.e., "foo." is not a FQDN)
+ */
+ ptr = strchr(host->h_name, '.');
+ if (ptr == NULL || ptr[1] == '\0') {
+ fprintf(stderr,
+ "\nResolve library did not return a "
+ "fully qualified domain name.\n\n"
+ "If you are using /etc/hosts before DNS, "
+ "e.g. \"files\" is listed first\n"
+ "for \"hosts:\" in nsswitch.conf, ensure that "
+ "you have listed the FQDN\n"
+ "as the first name for the local host.\n\n"
+ "If this does not correct the problem, "
+ "you may have to reconfigure the kerberos\n"
+ "distribution to select a "
+ "different set of libraries using \n"
+ "--with-netlib[=libs]\n");
+ exit(3);
+ }
+
+ if (!quiet)
+ printf("Resolve library appears to have passed the test\n");
+
+ /* All ok */
+ exit(0);
}
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/* foo */
#include <stdio.h>
#include <string.h>
#define HORIZ 25
static void *do_open_1(const char *libname, const char *rev,
- int lazy, int line)
+ int lazy, int line)
{
void *p;
char *namebuf;
int r;
if (verbose)
- printf("from line %d: do_open(%s)...%*s", line, libname,
- HORIZ-strlen(libname), "");
+ printf("from line %d: do_open(%s)...%*s", line, libname,
+ HORIZ-strlen(libname), "");
#ifdef _AIX
r = asprintf(&namebuf, "lib%s%s", libname, SHLIB_SUFFIX);
#else
r = asprintf(&namebuf, "lib%s%s(shr.o.%s)", libname, SHLIB_SUFFIX, rev);
#endif
if (r < 0) {
- perror("asprintf");
- exit(1);
+ perror("asprintf");
+ exit(1);
}
#ifndef RTLD_MEMBER
#endif
p = dlopen(namebuf, (lazy ? RTLD_LAZY : RTLD_NOW) | RTLD_MEMBER);
if (p == 0) {
- fprintf(stderr, "dlopen of %s failed: %s\n", namebuf, dlerror());
- exit(1);
+ fprintf(stderr, "dlopen of %s failed: %s\n", namebuf, dlerror());
+ exit(1);
}
free(namebuf);
if (verbose)
- printf("done: %p\n", p);
+ printf("done: %p\n", p);
return p;
}
assert(strlen(SYM_PREFIX) == 0);
if (verbose)
- printf("from line %d: get_sym(%s)...%*s", line, symname,
- HORIZ-strlen(symname), "");
+ printf("from line %d: get_sym(%s)...%*s", line, symname,
+ HORIZ-strlen(symname), "");
s = dlsym(libhandle, symname);
if (s == 0) {
- fprintf(stderr, "symbol %s not found\n", symname);
- exit(1);
+ fprintf(stderr, "symbol %s not found\n", symname);
+ exit(1);
}
if (verbose)
- printf("done: %p\n", s);
+ printf("done: %p\n", s);
return s;
}
static void do_close_1(void *libhandle, int line)
{
if (verbose) {
- char pbuf[3*sizeof(libhandle)+4];
- snprintf(pbuf, sizeof(pbuf), "%p", libhandle);
- printf("from line %d: do_close(%s)...%*s", line, pbuf,
- HORIZ-1-strlen(pbuf), "");
+ char pbuf[3*sizeof(libhandle)+4];
+ snprintf(pbuf, sizeof(pbuf), "%p", libhandle);
+ printf("from line %d: do_close(%s)...%*s", line, pbuf,
+ HORIZ-1-strlen(pbuf), "");
}
if (dlclose(libhandle) != 0) {
- fprintf(stderr, "dlclose failed: %s\n", dlerror());
- exit(1);
+ fprintf(stderr, "dlclose failed: %s\n", dlerror());
+ exit(1);
}
if (verbose)
- printf("done\n");
+ printf("done\n");
}
#elif defined _WIN32
celib2 = do_open("com_err", "3.0", 0);
do_close(celib2);
{
- typedef krb5_error_code KRB5_CALLCONV (*ict)(krb5_context *);
- typedef void KRB5_CALLCONV (*fct)(krb5_context);
+ typedef krb5_error_code KRB5_CALLCONV (*ict)(krb5_context *);
+ typedef void KRB5_CALLCONV (*fct)(krb5_context);
- ict init_context = (ict) get_sym(k5lib, "krb5_init_context");
- fct free_context = (fct) get_sym(k5lib, "krb5_free_context");
- krb5_context ctx;
- krb5_error_code err;
+ ict init_context = (ict) get_sym(k5lib, "krb5_init_context");
+ fct free_context = (fct) get_sym(k5lib, "krb5_free_context");
+ krb5_context ctx;
+ krb5_error_code err;
#define CALLING(S) (verbose ? printf("at line %d: calling %s...%*s", __LINE__, #S, (int)(HORIZ+1-strlen(#S)), "") : 0)
#define DONE() (verbose ? printf("done\n") : 0)
- CALLING(krb5_init_context);
- err = init_context(&ctx);
- DONE();
- if (err) {
- fprintf(stderr, "error 0x%lx initializing context\n",
- (unsigned long) err);
- exit(1);
- }
- CALLING(krb5_free_context);
- free_context(ctx);
- DONE();
+ CALLING(krb5_init_context);
+ err = init_context(&ctx);
+ DONE();
+ if (err) {
+ fprintf(stderr, "error 0x%lx initializing context\n",
+ (unsigned long) err);
+ exit(1);
+ }
+ CALLING(krb5_free_context);
+ free_context(ctx);
+ DONE();
}
celib2 = do_open("com_err", "3.0", 0);
do_close(celib);
/* Test gssapi_krb5 without having loaded anything else. */
gsslib = do_open("gssapi_krb5", "2.2", 1);
{
- OM_uint32 KRB5_CALLCONV (*init_sec_context)(OM_uint32 *, gss_cred_id_t,
- gss_ctx_id_t *, gss_name_t,
- gss_OID,
- OM_uint32, OM_uint32,
- gss_channel_bindings_t,
- gss_buffer_t, gss_OID *,
- gss_buffer_t,
- OM_uint32 *, OM_uint32 *)
- = get_gfun(gsslib, "gss_init_sec_context");
- OM_uint32 KRB5_CALLCONV (*import_name)(OM_uint32 *, gss_buffer_t,
- gss_OID, gss_name_t *)
- = get_gfun(gsslib, "gss_import_name");
- OM_uint32 KRB5_CALLCONV (*release_buffer)(OM_uint32 *, gss_buffer_t)
- = get_gfun(gsslib, "gss_release_buffer");
- OM_uint32 KRB5_CALLCONV (*release_name)(OM_uint32 *, gss_name_t *)
- = get_gfun(gsslib, "gss_release_name");
- OM_uint32 KRB5_CALLCONV (*delete_sec_context)(OM_uint32 *,
- gss_ctx_id_t *,
- gss_buffer_t)
- = get_gfun(gsslib, "gss_delete_sec_context");
-
- OM_uint32 gmaj, gmin;
- OM_uint32 retflags;
- gss_ctx_id_t gctx = GSS_C_NO_CONTEXT;
- gss_buffer_desc token;
- gss_name_t target;
- static gss_buffer_desc target_name_buf = {
- 9, "x@mit.edu"
- };
- static gss_OID_desc service_name = {
- 10, "\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04"
- };
-
- CALLING(gss_import_name);
- gmaj = import_name(&gmin, &target_name_buf, &service_name, &target);
- DONE();
- if (gmaj != GSS_S_COMPLETE) {
- fprintf(stderr,
- "import_name reports error major 0x%lx minor 0x%lx(%ld)\n",
- (unsigned long) gmaj, (unsigned long) gmin,
- (signed long) gmin);
- exit(1);
- }
- /* This will probably get different errors, depending on
- whether we have tickets at the time. Doesn't matter much,
- we're ignoring the error and testing whether we're doing
- cleanup properly. (Though the internal cleanup needed in
- the two cases might be different.) */
- CALLING(gss_init_sec_context);
- gmaj = init_sec_context(&gmin, GSS_C_NO_CREDENTIAL, &gctx, target,
- GSS_C_NULL_OID, 0, 0, NULL, GSS_C_NO_BUFFER,
- NULL, &token, &retflags, NULL);
- DONE();
- /* Ignore success/failure indication. */
- if (token.length) {
- CALLING(gss_release_buffer);
- release_buffer(&gmin, &token);
- DONE();
- }
- CALLING(gss_release_name);
- release_name(&gmin, &target);
- DONE();
- if (gctx != GSS_C_NO_CONTEXT) {
- CALLING(gss_delete_sec_context);
- delete_sec_context(&gmin, gctx, GSS_C_NO_BUFFER);
- DONE();
- }
+ OM_uint32 KRB5_CALLCONV (*init_sec_context)(OM_uint32 *, gss_cred_id_t,
+ gss_ctx_id_t *, gss_name_t,
+ gss_OID,
+ OM_uint32, OM_uint32,
+ gss_channel_bindings_t,
+ gss_buffer_t, gss_OID *,
+ gss_buffer_t,
+ OM_uint32 *, OM_uint32 *)
+ = get_gfun(gsslib, "gss_init_sec_context");
+ OM_uint32 KRB5_CALLCONV (*import_name)(OM_uint32 *, gss_buffer_t,
+ gss_OID, gss_name_t *)
+ = get_gfun(gsslib, "gss_import_name");
+ OM_uint32 KRB5_CALLCONV (*release_buffer)(OM_uint32 *, gss_buffer_t)
+ = get_gfun(gsslib, "gss_release_buffer");
+ OM_uint32 KRB5_CALLCONV (*release_name)(OM_uint32 *, gss_name_t *)
+ = get_gfun(gsslib, "gss_release_name");
+ OM_uint32 KRB5_CALLCONV (*delete_sec_context)(OM_uint32 *,
+ gss_ctx_id_t *,
+ gss_buffer_t)
+ = get_gfun(gsslib, "gss_delete_sec_context");
+
+ OM_uint32 gmaj, gmin;
+ OM_uint32 retflags;
+ gss_ctx_id_t gctx = GSS_C_NO_CONTEXT;
+ gss_buffer_desc token;
+ gss_name_t target;
+ static gss_buffer_desc target_name_buf = {
+ 9, "x@mit.edu"
+ };
+ static gss_OID_desc service_name = {
+ 10, "\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04"
+ };
+
+ CALLING(gss_import_name);
+ gmaj = import_name(&gmin, &target_name_buf, &service_name, &target);
+ DONE();
+ if (gmaj != GSS_S_COMPLETE) {
+ fprintf(stderr,
+ "import_name reports error major 0x%lx minor 0x%lx(%ld)\n",
+ (unsigned long) gmaj, (unsigned long) gmin,
+ (signed long) gmin);
+ exit(1);
+ }
+ /* This will probably get different errors, depending on
+ whether we have tickets at the time. Doesn't matter much,
+ we're ignoring the error and testing whether we're doing
+ cleanup properly. (Though the internal cleanup needed in
+ the two cases might be different.) */
+ CALLING(gss_init_sec_context);
+ gmaj = init_sec_context(&gmin, GSS_C_NO_CREDENTIAL, &gctx, target,
+ GSS_C_NULL_OID, 0, 0, NULL, GSS_C_NO_BUFFER,
+ NULL, &token, &retflags, NULL);
+ DONE();
+ /* Ignore success/failure indication. */
+ if (token.length) {
+ CALLING(gss_release_buffer);
+ release_buffer(&gmin, &token);
+ DONE();
+ }
+ CALLING(gss_release_name);
+ release_name(&gmin, &target);
+ DONE();
+ if (gctx != GSS_C_NO_CONTEXT) {
+ CALLING(gss_delete_sec_context);
+ delete_sec_context(&gmin, gctx, GSS_C_NO_BUFFER);
+ DONE();
+ }
}
do_close(gsslib);
celib = do_open("com_err", "3.0", 1);
gsslib = do_open("gssapi_krb5", "2.2", 1);
{
- OM_uint32 KRB5_CALLCONV (*init_sec_context)(OM_uint32 *, gss_cred_id_t,
- gss_ctx_id_t *, gss_name_t,
- gss_OID,
- OM_uint32, OM_uint32,
- gss_channel_bindings_t,
- gss_buffer_t, gss_OID *,
- gss_buffer_t,
- OM_uint32 *, OM_uint32 *)
- = get_gfun(gsslib, "gss_init_sec_context");
- OM_uint32 KRB5_CALLCONV (*import_name)(OM_uint32 *, gss_buffer_t,
- gss_OID, gss_name_t *)
- = get_gfun(gsslib, "gss_import_name");
- OM_uint32 KRB5_CALLCONV (*release_buffer)(OM_uint32 *, gss_buffer_t)
- = get_gfun(gsslib, "gss_release_buffer");
- OM_uint32 KRB5_CALLCONV (*release_name)(OM_uint32 *, gss_name_t *)
- = get_gfun(gsslib, "gss_release_name");
- OM_uint32 KRB5_CALLCONV (*delete_sec_context)(OM_uint32 *,
- gss_ctx_id_t *,
- gss_buffer_t)
- = get_gfun(gsslib, "gss_delete_sec_context");
-
- OM_uint32 gmaj, gmin;
- OM_uint32 retflags;
- gss_ctx_id_t gctx = GSS_C_NO_CONTEXT;
- gss_buffer_desc token;
- gss_name_t target;
- static gss_buffer_desc target_name_buf = {
- 9, "x@mit.edu"
- };
- static gss_OID_desc service_name = {
- 10, "\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04"
- };
-
- CALLING(gss_import_name);
- gmaj = import_name(&gmin, &target_name_buf, &service_name, &target);
- DONE();
- if (gmaj != GSS_S_COMPLETE) {
- fprintf(stderr,
- "import_name reports error major 0x%lx minor 0x%lx(%ld)\n",
- (unsigned long) gmaj, (unsigned long) gmin,
- (signed long) gmin);
- exit(1);
- }
- /* This will probably get different errors, depending on
- whether we have tickets at the time. Doesn't matter much,
- we're ignoring the error and testing whether we're doing
- cleanup properly. (Though the internal cleanup needed in
- the two cases might be different.) */
- CALLING(gss_init_sec_context);
- gmaj = init_sec_context(&gmin, GSS_C_NO_CREDENTIAL, &gctx, target,
- GSS_C_NULL_OID, 0, 0, NULL, GSS_C_NO_BUFFER,
- NULL, &token, &retflags, NULL);
- DONE();
- /* Ignore success/failure indication. */
- if (token.length) {
- CALLING(gss_release_buffer);
- release_buffer(&gmin, &token);
- DONE();
- }
- CALLING(gss_release_name);
- release_name(&gmin, &target);
- DONE();
- if (gctx != GSS_C_NO_CONTEXT) {
- CALLING(gss_delete_sec_context);
- delete_sec_context(&gmin, gctx, GSS_C_NO_BUFFER);
- DONE();
- }
+ OM_uint32 KRB5_CALLCONV (*init_sec_context)(OM_uint32 *, gss_cred_id_t,
+ gss_ctx_id_t *, gss_name_t,
+ gss_OID,
+ OM_uint32, OM_uint32,
+ gss_channel_bindings_t,
+ gss_buffer_t, gss_OID *,
+ gss_buffer_t,
+ OM_uint32 *, OM_uint32 *)
+ = get_gfun(gsslib, "gss_init_sec_context");
+ OM_uint32 KRB5_CALLCONV (*import_name)(OM_uint32 *, gss_buffer_t,
+ gss_OID, gss_name_t *)
+ = get_gfun(gsslib, "gss_import_name");
+ OM_uint32 KRB5_CALLCONV (*release_buffer)(OM_uint32 *, gss_buffer_t)
+ = get_gfun(gsslib, "gss_release_buffer");
+ OM_uint32 KRB5_CALLCONV (*release_name)(OM_uint32 *, gss_name_t *)
+ = get_gfun(gsslib, "gss_release_name");
+ OM_uint32 KRB5_CALLCONV (*delete_sec_context)(OM_uint32 *,
+ gss_ctx_id_t *,
+ gss_buffer_t)
+ = get_gfun(gsslib, "gss_delete_sec_context");
+
+ OM_uint32 gmaj, gmin;
+ OM_uint32 retflags;
+ gss_ctx_id_t gctx = GSS_C_NO_CONTEXT;
+ gss_buffer_desc token;
+ gss_name_t target;
+ static gss_buffer_desc target_name_buf = {
+ 9, "x@mit.edu"
+ };
+ static gss_OID_desc service_name = {
+ 10, "\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04"
+ };
+
+ CALLING(gss_import_name);
+ gmaj = import_name(&gmin, &target_name_buf, &service_name, &target);
+ DONE();
+ if (gmaj != GSS_S_COMPLETE) {
+ fprintf(stderr,
+ "import_name reports error major 0x%lx minor 0x%lx(%ld)\n",
+ (unsigned long) gmaj, (unsigned long) gmin,
+ (signed long) gmin);
+ exit(1);
+ }
+ /* This will probably get different errors, depending on
+ whether we have tickets at the time. Doesn't matter much,
+ we're ignoring the error and testing whether we're doing
+ cleanup properly. (Though the internal cleanup needed in
+ the two cases might be different.) */
+ CALLING(gss_init_sec_context);
+ gmaj = init_sec_context(&gmin, GSS_C_NO_CREDENTIAL, &gctx, target,
+ GSS_C_NULL_OID, 0, 0, NULL, GSS_C_NO_BUFFER,
+ NULL, &token, &retflags, NULL);
+ DONE();
+ /* Ignore success/failure indication. */
+ if (token.length) {
+ CALLING(gss_release_buffer);
+ release_buffer(&gmin, &token);
+ DONE();
+ }
+ CALLING(gss_release_name);
+ release_name(&gmin, &target);
+ DONE();
+ if (gctx != GSS_C_NO_CONTEXT) {
+ CALLING(gss_delete_sec_context);
+ delete_sec_context(&gmin, gctx, GSS_C_NO_BUFFER);
+ DONE();
+ }
}
do_close(celib);
do_close(gsslib);
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* tests/test1.c
*
*/
code = krb5_parse_name ("server/test/1@BOGUS.ORG", &tk_in.server);
if (code != 0) {
- com_err("tkt_test_1", code, " parsing server principal");
- return;
+ com_err("tkt_test_1", code, " parsing server principal");
+ return;
}
- serv_k.enctype = 1; /* XXX symbolic constant */
- serv_k.length = 8; /* XXX symbolic constant */
+ serv_k.enctype = 1; /* XXX symbolic constant */
+ serv_k.length = 8; /* XXX symbolic constant */
serv_k.contents = key_one;
- sess_k.enctype = 1; /* XXX symbolic constant */
- sess_k.length = 8; /* XXX symbolic constant */
+ sess_k.enctype = 1; /* XXX symbolic constant */
+ sess_k.length = 8; /* XXX symbolic constant */
sess_k.contents = key_two;
- tk_in.etype = 1; /* XXX symbolic constant here */
+ tk_in.etype = 1; /* XXX symbolic constant here */
tk_in.skvno = 4;
tk_in.enc_part2 = &tk_in_enc;
code = krb5_parse_name ("client/test/1@BOGUS.ORG", &tk_in_enc.client);
if (code != 0) {
- com_err("tkt_test_1", code, " parsing client principal");
- return;
+ com_err("tkt_test_1", code, " parsing client principal");
+ return;
}
tk_in_enc.transited.length = 0;
code = krb5_encrypt_tkt_part(&serv_k, &tk_in);
if (code != 0) {
- com_err ("tkt_test_1", code, " encrypting ticket");
- return;
+ com_err ("tkt_test_1", code, " encrypting ticket");
+ return;
}
data = 0;
code = krb5_encode_ticket (&tk_in, &data);
if (code != 0) {
- com_err ("tkt_test_1", code, " encoding ticket");
- return;
+ com_err ("tkt_test_1", code, " encoding ticket");
+ return;
}
dump_data(data);
tk_out = 0;
code = krb5_decode_ticket (data, &tk_out);
if (code != 0) {
- com_err ("tkt_test_1", code, "decoding ticket");
- return;
+ com_err ("tkt_test_1", code, "decoding ticket");
+ return;
}
/* check the plaintext values */
if (tk_out->etype != 1) {
- com_err ("tkt_test_1", 0, "wrong etype");
- return;
+ com_err ("tkt_test_1", 0, "wrong etype");
+ return;
}
if (tk_out->skvno != 4) {
- com_err ("tkt_test_1", 0, "wrong kvno");
- return;
+ com_err ("tkt_test_1", 0, "wrong kvno");
+ return;
}
code = krb5_unparse_name(tk_out->server, &out);
if (code != 0) {
- com_err ("tkt_test_1", code, "couldn't unparse server principal");
- return;
+ com_err ("tkt_test_1", code, "couldn't unparse server principal");
+ return;
}
if (strcmp (out, "server/test/1@BOGUS.ORG") != 0) {
- com_err("tkt_test_1", 0, "wrong server principal");
- return;
+ com_err("tkt_test_1", 0, "wrong server principal");
+ return;
}
free(out);
out = 0;
/* decode the ciphertext */
code = krb5_decrypt_tkt_part (&serv_k, tk_out);
if (code != 0) {
- com_err ("tkt_test_1", code, "while decrypting ticket");
- return;
+ com_err ("tkt_test_1", code, "while decrypting ticket");
+ return;
}
/* check the contents */
if (tk_out->enc_part2->flags != 0x11) {
- com_err("tkt_test_1", 0, "wrong flags");
- return;
+ com_err("tkt_test_1", 0, "wrong flags");
+ return;
}
nsess = tk_out->enc_part2->session;
if (nsess->enctype != 1) {
- com_err("tkt_test_1", 0, "wrong session key type");
- return;
+ com_err("tkt_test_1", 0, "wrong session key type");
+ return;
}
if (nsess->length != 8) {
- com_err("tkt_test_1", 0, "wrong session key length");
- return;
+ com_err("tkt_test_1", 0, "wrong session key length");
+ return;
}
if (memcmp(nsess->contents, key_two, 8) != 0) {
- com_err("tkt_test_1", 0, "wrong session key contents");
- return;
+ com_err("tkt_test_1", 0, "wrong session key contents");
+ return;
}
code = krb5_unparse_name(tk_out->enc_part2->client, &out);
if (code != 0) {
- com_err ("tkt_test_1", code, "couldn't unparse client principal");
- return;
+ com_err ("tkt_test_1", code, "couldn't unparse client principal");
+ return;
}
if (strcmp (out, "client/test/1@BOGUS.ORG") != 0) {
- com_err("tkt_test_1", 0, "wrong client principal");
- return;
+ com_err("tkt_test_1", 0, "wrong client principal");
+ return;
}
free(out);
out = 0;
if (tk_out->enc_part2->transited.length != 0) {
- com_err("tkt_test_1", 0, "wrong transited length");
- return;
+ com_err("tkt_test_1", 0, "wrong transited length");
+ return;
}
/* XXX should check address here, too */
/* XXX should check times here */
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* test/threads/gss-perf.c
*
fprintf (stderr, "\t-A\ttest gss_accept_sec_context\n");
fprintf (stderr, "\t-k K\tspecify keytab (remember FILE: or other prefix!)\n");
fprintf (stderr, "\t-t N\tspecify number of threads (default %d)\n",
- N_THREADS);
+ N_THREADS);
fprintf (stderr, "\t-i N\tset iteration count (default %d)\n",
- ITER_COUNT);
+ ITER_COUNT);
fprintf (stderr, "\t-m\tenable mutual authentication flag (but don't do the additional calls)\n");
fprintf (stderr, "\t-K\tinitialize a krb5_context for the duration\n");
fprintf (stderr, "\t-P\tpause briefly after starting, to allow attaching dtrace/strace/etc\n");
val = strtol (arg, &end, 10);
if (*arg == 0 || *end != 0) {
- fprintf (stderr, "invalid numeric argument '%s'\n", arg);
- usage ();
+ fprintf (stderr, "invalid numeric argument '%s'\n", arg);
+ usage ();
}
if (val >= 1 && val <= INT_MAX)
- return val;
+ return val;
fprintf (stderr, "out of range numeric value %ld (1..%d)\n",
- val, INT_MAX);
+ val, INT_MAX);
usage ();
}
prog = strrchr (argv[0], '/');
if (prog)
- prog++;
+ prog++;
else
- prog = argv[0];
+ prog = argv[0];
while ((c = getopt (argc, argv, optstring)) != -1) {
- switch (c) {
- case '?':
- case ':':
- usage ();
- break;
-
- case 'k':
- setenv ("KRB5_KTNAME", optarg, 1);
- break;
-
- case 't':
- n_threads = numarg (optarg);
- if (n_threads >= SIZE_MAX / sizeof (struct thread_info)) {
- n_threads = SIZE_MAX / sizeof (struct thread_info);
- fprintf (stderr, "limiting n_threads to %u\n", n_threads);
- }
- break;
-
- case 'i':
- iter_count = numarg (optarg);
- break;
-
- case 'K':
- init_krb5_first = 1;
- break;
-
- case 'P':
- do_pause = 1;
- break;
-
- case 'I':
- test_init = 1;
- break;
- case 'A':
- test_accept = 1;
- break;
- }
+ switch (c) {
+ case '?':
+ case ':':
+ usage ();
+ break;
+
+ case 'k':
+ setenv ("KRB5_KTNAME", optarg, 1);
+ break;
+
+ case 't':
+ n_threads = numarg (optarg);
+ if (n_threads >= SIZE_MAX / sizeof (struct thread_info)) {
+ n_threads = SIZE_MAX / sizeof (struct thread_info);
+ fprintf (stderr, "limiting n_threads to %u\n", n_threads);
+ }
+ break;
+
+ case 'i':
+ iter_count = numarg (optarg);
+ break;
+
+ case 'K':
+ init_krb5_first = 1;
+ break;
+
+ case 'P':
+ do_pause = 1;
+ break;
+
+ case 'I':
+ test_init = 1;
+ break;
+ case 'A':
+ test_accept = 1;
+ break;
+ }
}
if (argc == optind + 1)
- set_target (argv[optind]);
+ set_target (argv[optind]);
else
- usage ();
+ usage ();
if (test_init && test_accept) {
- fprintf (stderr, "-I and -A are mutually exclusive\n");
- usage ();
+ fprintf (stderr, "-I and -A are mutually exclusive\n");
+ usage ();
}
if (test_init == 0 && test_accept == 0)
- test_init = 1;
+ test_init = 1;
}
static void
gss_buffer_desc msg = GSS_C_EMPTY_BUFFER;
do {
- maj_stat = gss_display_status (&min_stat,
- val,
- type,
- GSS_C_NO_OID,
- &mctx,
- &msg);
- if (maj_stat != GSS_S_COMPLETE) {
- fprintf (stderr,
- "error getting display form of %s status code %#lx\n",
- s_type, (unsigned long) val);
- exit (1);
- }
- fprintf (stderr, " %s: %.*s\n", s_type,
- (int) msg.length, (char *) msg.value);
- gss_release_buffer (&min_stat, &msg);
+ maj_stat = gss_display_status (&min_stat,
+ val,
+ type,
+ GSS_C_NO_OID,
+ &mctx,
+ &msg);
+ if (maj_stat != GSS_S_COMPLETE) {
+ fprintf (stderr,
+ "error getting display form of %s status code %#lx\n",
+ s_type, (unsigned long) val);
+ exit (1);
+ }
+ fprintf (stderr, " %s: %.*s\n", s_type,
+ (int) msg.length, (char *) msg.value);
+ gss_release_buffer (&min_stat, &msg);
} while (mctx != 0);
}
reply.value = NULL;
reply.length = 0;
maj_stat = gss_accept_sec_context (&min_stat,
- &ctx,
- GSS_C_NO_CREDENTIAL,
- msg,
- GSS_C_NO_CHANNEL_BINDINGS,
- &client,
- &oid,
- &reply,
- &flags,
- NULL, /* time_rec */
- NULL); /* del_cred_handle */
+ &ctx,
+ GSS_C_NO_CREDENTIAL,
+ msg,
+ GSS_C_NO_CHANNEL_BINDINGS,
+ &client,
+ &oid,
+ &reply,
+ &flags,
+ NULL, /* time_rec */
+ NULL); /* del_cred_handle */
if (maj_stat != GSS_S_COMPLETE && maj_stat != GSS_S_CONTINUE_NEEDED) {
- fprintf (stderr, "pid %lu thread %#lx failing in iteration %d\n",
- (unsigned long) getpid (), (unsigned long) pthread_self (),
- iter);
- gss_error ("accepting context", maj_stat, min_stat);
+ fprintf (stderr, "pid %lu thread %#lx failing in iteration %d\n",
+ (unsigned long) getpid (), (unsigned long) pthread_self (),
+ iter);
+ gss_error ("accepting context", maj_stat, min_stat);
}
gss_release_buffer (&min_stat, &reply);
if (ctx != GSS_C_NO_CONTEXT)
- gss_delete_sec_context (&min_stat, &ctx, GSS_C_NO_BUFFER);
+ gss_delete_sec_context (&min_stat, &ctx, GSS_C_NO_BUFFER);
gss_release_name (&min_stat, &client);
}
gss_buffer_desc msg = GSS_C_EMPTY_BUFFER;
if (do_mutual)
- flags |= GSS_C_MUTUAL_FLAG;
+ flags |= GSS_C_MUTUAL_FLAG;
msg.value = NULL;
msg.length = 0;
maj_stat = gss_init_sec_context (&min_stat,
- GSS_C_NO_CREDENTIAL,
- &ctx,
- target,
- GSS_C_NO_OID,
- flags,
- 0,
- NULL, /* no channel bindings */
- NULL, /* no previous token */
- NULL, /* ignore mech type */
- &msg,
- &ret_flags,
- NULL); /* time_rec */
+ GSS_C_NO_CREDENTIAL,
+ &ctx,
+ target,
+ GSS_C_NO_OID,
+ flags,
+ 0,
+ NULL, /* no channel bindings */
+ NULL, /* no previous token */
+ NULL, /* ignore mech type */
+ &msg,
+ &ret_flags,
+ NULL); /* time_rec */
if (maj_stat != GSS_S_COMPLETE && maj_stat != GSS_S_CONTINUE_NEEDED) {
- gss_error ("initiating", maj_stat, min_stat);
+ gss_error ("initiating", maj_stat, min_stat);
}
if (ctx != GSS_C_NO_CONTEXT)
- gss_delete_sec_context (&min_stat, &ctx, GSS_C_NO_BUFFER);
+ gss_delete_sec_context (&min_stat, &ctx, GSS_C_NO_BUFFER);
return msg;
}
namebuf.value = name;
namebuf.length = strlen (name);
maj_stat = gss_import_name (&min_stat,
- &namebuf,
- GSS_C_NT_HOSTBASED_SERVICE,
- &target);
+ &namebuf,
+ GSS_C_NT_HOSTBASED_SERVICE,
+ &target);
if (maj_stat != GSS_S_COMPLETE)
- gss_error ("importing target name", maj_stat, min_stat);
+ gss_error ("importing target name", maj_stat, min_stat);
}
static long double
{
/* POSIX says .tv_usec is signed. */
return (t1.tv_sec - t2.tv_sec
- + (long double) 1.0e-6 * (t1.tv_usec - t2.tv_usec));
+ + (long double) 1.0e-6 * (t1.tv_usec - t2.tv_usec));
}
static struct timeval
{
struct timeval tv;
if (gettimeofday (&tv, NULL) < 0) {
- perror ("gettimeofday");
- exit (1);
+ perror ("gettimeofday");
+ exit (1);
}
return tv;
}
r->start_time = now ();
for (i = 0; i < iter_count; i++) {
- if (test_init) {
- gss_buffer_desc msg = do_init ();
- gss_release_buffer (&min_stat, &msg);
- } else if (test_accept) {
- do_accept (&init_msg, i);
- } else
- assert (test_init || test_accept);
+ if (test_init) {
+ gss_buffer_desc msg = do_init ();
+ gss_release_buffer (&min_stat, &msg);
+ } else if (test_accept) {
+ do_accept (&init_msg, i);
+ } else
+ assert (test_init || test_accept);
}
r->end_time = now ();
}
* This option allows you to test the effect of that.
*/
if (init_krb5_first && krb5_init_context (&kctx) != 0) {
- fprintf (stderr, "krb5_init_context error\n");
- exit (1);
+ fprintf (stderr, "krb5_init_context error\n");
+ exit (1);
}
tinfo = calloc (n_threads, sizeof (*tinfo));
if (tinfo == NULL) {
- perror ("calloc");
- exit (1);
+ perror ("calloc");
+ exit (1);
}
printf ("Test: %s threads: %d iterations: %d target: %s\n",
- test_init ? "init" : "accept", n_threads, iter_count,
- target_name ? target_name : "(NONE)");
+ test_init ? "init" : "accept", n_threads, iter_count,
+ target_name ? target_name : "(NONE)");
if (do_pause) {
- printf ("pid %lu napping...\n", (unsigned long) getpid ());
- sleep (10);
+ printf ("pid %lu napping...\n", (unsigned long) getpid ());
+ sleep (10);
}
/*
* Some tests use one message and process it over and over. Even
printf ("starting...\n");
/* And *now* we start measuring the performance. */
if (getrusage (RUSAGE_SELF, &start) < 0) {
- perror ("getrusage");
- exit (1);
+ perror ("getrusage");
+ exit (1);
}
start_time = now ();
#define foreach_thread(IDXVAR) for (IDXVAR = 0; IDXVAR < n_threads; IDXVAR++)
foreach_thread (i) {
- int err;
+ int err;
- err = pthread_create (&tinfo[i].tid, NULL, thread_proc, &tinfo[i].r);
- if (err) {
- fprintf (stderr, "pthread_create: %s\n", strerror (err));
- exit (1);
- }
+ err = pthread_create (&tinfo[i].tid, NULL, thread_proc, &tinfo[i].r);
+ if (err) {
+ fprintf (stderr, "pthread_create: %s\n", strerror (err));
+ exit (1);
+ }
}
foreach_thread (i) {
- int err;
- void *val;
-
- err = pthread_join (tinfo[i].tid, &val);
- if (err) {
- fprintf (stderr, "pthread_join: %s\n", strerror (err));
- exit (1);
- }
+ int err;
+ void *val;
+
+ err = pthread_join (tinfo[i].tid, &val);
+ if (err) {
+ fprintf (stderr, "pthread_join: %s\n", strerror (err));
+ exit (1);
+ }
}
finish_time = now ();
if (getrusage (RUSAGE_SELF, &finish) < 0) {
- perror ("getrusage");
- exit (1);
+ perror ("getrusage");
+ exit (1);
}
if (init_krb5_first)
- krb5_free_context (kctx);
+ krb5_free_context (kctx);
foreach_thread (i) {
- printf ("Thread %2d: elapsed time %Lfs\n", i,
- tvsub (tinfo[i].r.end_time, tinfo[i].r.start_time));
+ printf ("Thread %2d: elapsed time %Lfs\n", i,
+ tvsub (tinfo[i].r.end_time, tinfo[i].r.start_time));
}
wallclock = tvsub (finish_time, start_time);
/*
* of particular interest, so report all the info we've got.
*/
printf ("Overall run time with %d threads = %Lfs, %Lfms per iteration.\n",
- n_threads, wallclock, 1000 * wallclock / iter_count);
+ n_threads, wallclock, 1000 * wallclock / iter_count);
user = tvsub (finish.ru_utime, start.ru_utime);
sys = tvsub (finish.ru_stime, start.ru_stime);
total = user + sys;
printf ("CPU usage: user=%Lfs sys=%Lfs total=%Lfs.\n", user, sys, total);
printf ("Utilization: user=%5.1Lf%% sys=%5.1Lf%% total=%5.1Lf%%\n",
- 100 * user / wallclock,
- 100 * sys / wallclock,
- 100 * total / wallclock);
+ 100 * user / wallclock,
+ 100 * sys / wallclock,
+ 100 * total / wallclock);
printf ("Util/thread: user=%5.1Lf%% sys=%5.1Lf%% total=%5.1Lf%%\n",
- 100 * user / wallclock / n_threads,
- 100 * sys / wallclock / n_threads,
- 100 * total / wallclock / n_threads);
+ 100 * user / wallclock / n_threads,
+ 100 * sys / wallclock / n_threads,
+ 100 * total / wallclock / n_threads);
printf ("Total CPU use per iteration per thread: %Lfms\n",
- 1000 * total / n_threads / iter_count);
+ 1000 * total / n_threads / iter_count);
return 0;
}
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
long err;
int i;
const char *const names[] = {
- "one", "two", "three", 0
+ "one", "two", "three", 0
};
char **values;
const char *mypath = (random() & 1) ? path : filename;
while (!done) {
- err = profile_init_path(mypath, &p);
- if (err) {
- com_err(prog, err, "calling profile_init(\"%s\")", mypath);
- exit(1);
- }
- for (i = 0; i < 10; i++) {
- values = 0;
- err = profile_get_values(p, names, &values);
- if (err == 0 && values != 0)
- profile_free_list(values);
- }
- profile_release(p);
+ err = profile_init_path(mypath, &p);
+ if (err) {
+ com_err(prog, err, "calling profile_init(\"%s\")", mypath);
+ exit(1);
+ }
+ for (i = 0; i < 10; i++) {
+ values = 0;
+ err = profile_get_values(p, names, &values);
+ if (err == 0 && values != 0)
+ profile_free_list(values);
+ }
+ profile_release(p);
}
return 0;
}
{
struct timespec req;
while (!done) {
- req.tv_sec = 0;
- req.tv_nsec = random() & 499999999;
- nanosleep(&req, 0);
- utime(filename, 0);
-/* printf("."), fflush(stdout); */
+ req.tv_sec = 0;
+ req.tv_nsec = random() & 499999999;
+ nanosleep(&req, 0);
+ utime(filename, 0);
+/* printf("."), fflush(stdout); */
}
return 0;
}
prog = argv[0];
for (i = 0; i < nthreads; i++) {
- assert(0 == pthread_create(&thr, 0, worker, 0));
+ assert(0 == pthread_create(&thr, 0, worker, 0));
}
sleep(1);
pthread_create(&thr, 0, modifier, 0);
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* test/threads/t_rcache.c
*
time_t now, next;
now = time(0);
do {
- next = time(0);
+ next = time(0);
} while (now == next);
}
krb5_rcache my_rcache;
snprintf(buf, sizeof(buf), "host/all-in-one.mit.edu/%p@ATHENA.MIT.EDU",
- buf);
+ buf);
r.server = buf;
r.client = (t->my_cusec & 7) + "abcdefgh@ATHENA.MIT.EDU";
r.msghash = NULL;
if (t->now != t->my_ctime) {
- if (t->my_ctime != 0) {
- snprintf(buf2, sizeof(buf2), "%3d: %ld %5d\n", t->idx,
- t->my_ctime, t->my_cusec);
- printf("%s", buf2);
- }
- t->my_ctime = t->now;
- t->my_cusec = 1;
+ if (t->my_ctime != 0) {
+ snprintf(buf2, sizeof(buf2), "%3d: %ld %5d\n", t->idx,
+ t->my_ctime, t->my_cusec);
+ printf("%s", buf2);
+ }
+ t->my_ctime = t->now;
+ t->my_cusec = 1;
} else
- t->my_cusec++;
+ t->my_cusec++;
r.ctime = t->my_ctime;
r.cusec = t->my_cusec;
if (!init_once) {
- err = krb5_get_server_rcache(ctx, &piece, &my_rcache);
- if (err) {
- const char *msg = krb5_get_error_message(ctx, err);
- fprintf(stderr, "%s: %s while initializing replay cache\n", prog, msg);
- krb5_free_error_message(ctx, msg);
- exit(1);
- }
+ err = krb5_get_server_rcache(ctx, &piece, &my_rcache);
+ if (err) {
+ const char *msg = krb5_get_error_message(ctx, err);
+ fprintf(stderr, "%s: %s while initializing replay cache\n", prog, msg);
+ krb5_free_error_message(ctx, msg);
+ exit(1);
+ }
} else
- my_rcache = rcache;
+ my_rcache = rcache;
err = krb5_rc_store(ctx, my_rcache, &r);
if (err) {
- com_err(prog, err, "storing in replay cache");
- exit(1);
+ com_err(prog, err, "storing in replay cache");
+ exit(1);
}
if (!init_once)
- krb5_rc_close(ctx, my_rcache);
+ krb5_rc_close(ctx, my_rcache);
}
static void *run_a_loop (void *x)
t.now = time(0);
t.idx = *(int *)x;
while (t.now != time(0))
- ;
+ ;
t.now = time(0);
while (t.now < end_time) {
- t.now = time(0);
- try_one(&t);
- t.total++;
+ t.now = time(0);
+ try_one(&t);
+ t.total++;
#if 0
- printf("%c", chr);
- fflush(stdout);
+ printf("%c", chr);
+ fflush(stdout);
#endif
}
/* printf("thread %u total %u\n", (unsigned) ((int *)x-ip), t.total);*/
prog = argv[0];
while ((c = getopt(argc, argv, optstring)) != -1) {
- switch (c) {
- case '?':
- case ':':
- default:
- usage ();
- case '1':
- init_once = 1;
- break;
- case 't':
- n_threads = atoi (optarg);
- if (n_threads < 1 || n_threads > 10000)
- usage ();
- break;
- case 'i':
- interval = atoi (optarg);
- if (interval < 2 || n_threads > 100000)
- usage ();
- break;
- }
+ switch (c) {
+ case '?':
+ case ':':
+ default:
+ usage ();
+ case '1':
+ init_once = 1;
+ break;
+ case 't':
+ n_threads = atoi (optarg);
+ if (n_threads < 1 || n_threads > 10000)
+ usage ();
+ break;
+ case 'i':
+ interval = atoi (optarg);
+ if (interval < 2 || n_threads > 100000)
+ usage ();
+ break;
+ }
}
}
process_options (argc, argv);
err = krb5_init_context(&ctx);
if (err) {
- com_err(prog, err, "initializing context");
- return 1;
+ com_err(prog, err, "initializing context");
+ return 1;
}
/*
*/
err = krb5_get_server_rcache(ctx, &piece, &rcache);
if (err) {
- const char *msg = krb5_get_error_message(ctx, err);
- fprintf(stderr, "%s: %s while initializing replay cache\n", prog, msg);
- krb5_free_error_message(ctx, msg);
- return 1;
+ const char *msg = krb5_get_error_message(ctx, err);
+ fprintf(stderr, "%s: %s while initializing replay cache\n", prog, msg);
+ krb5_free_error_message(ctx, msg);
+ return 1;
}
err = krb5_rc_destroy(ctx, rcache);
if (err) {
- const char *msg = krb5_get_error_message(ctx, err);
- fprintf(stderr, "%s: %s while destroying old replay cache\n",
- prog, msg);
- krb5_free_error_message(ctx, msg);
- return 1;
+ const char *msg = krb5_get_error_message(ctx, err);
+ fprintf(stderr, "%s: %s while destroying old replay cache\n",
+ prog, msg);
+ krb5_free_error_message(ctx, msg);
+ return 1;
}
rcache = NULL;
if (init_once) {
- err = krb5_get_server_rcache(ctx, &piece, &rcache);
- if (err) {
- const char *msg = krb5_get_error_message(ctx, err);
- fprintf(stderr, "%s: %s while initializing new replay cache\n",
- prog, msg);
- krb5_free_error_message(ctx, msg);
- return 1;
- }
+ err = krb5_get_server_rcache(ctx, &piece, &rcache);
+ if (err) {
+ const char *msg = krb5_get_error_message(ctx, err);
+ fprintf(stderr, "%s: %s while initializing new replay cache\n",
+ prog, msg);
+ krb5_free_error_message(ctx, msg);
+ return 1;
+ }
}
ip = malloc(sizeof(int) * n_threads);
if (ip == 0 && n_threads > 0) {
- perror("malloc");
- exit(1);
+ perror("malloc");
+ exit(1);
}
for (i = 0; i < n_threads; i++)
- ip[i] = i;
+ ip[i] = i;
wait_for_tick ();
end_time = time(0) + interval;
for (i = 0; i < n_threads; i++) {
- pthread_t new_thread;
- int perr;
- perr = pthread_create(&new_thread, 0, run_a_loop, &ip[i]);
- if (perr) {
- errno = perr;
- perror("pthread_create");
- exit(1);
- }
+ pthread_t new_thread;
+ int perr;
+ perr = pthread_create(&new_thread, 0, run_a_loop, &ip[i]);
+ if (perr) {
+ errno = perr;
+ perror("pthread_create");
+ exit(1);
+ }
}
while (time(0) < end_time + 1)
- sleep(1);
+ sleep(1);
sum = 0;
for (i = 0; i < n_threads; i++) {
- sum += ip[i];
- printf("thread %d total %5d, about %.1f per second\n", i, ip[i],
- ((double) ip[i])/interval);
+ sum += ip[i];
+ printf("thread %d total %5d, about %.1f per second\n", i, ip[i],
+ ((double) ip[i])/interval);
}
printf("total %lu in %d seconds, avg ~%.1f/sec, ~%.1f/sec/thread\n",
- sum, interval,
- ((double)sum)/interval, ((double)sum)/interval/n_threads);
+ sum, interval,
+ ((double)sum)/interval, ((double)sum)/interval/n_threads);
free(ip);
if (init_once)
- krb5_rc_close(ctx, rcache);
+ krb5_rc_close(ctx, rcache);
krb5_free_context(ctx);
return 0;
}
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* tests/verify/kdb5_verify.c
*
#include <ss/ss.h>
#include <stdio.h>
-#define REALM_SEP '@'
-#define REALM_SEP_STR "@"
+#define REALM_SEP '@'
+#define REALM_SEP_STR "@"
struct mblock {
krb5_deltat max_life;
krb5_timestamp expiration;
krb5_flags flags;
krb5_kvno mkvno;
-} mblock = { /* XXX */
+} mblock = { /* XXX */
KRB5_KDB_MAX_LIFE,
KRB5_KDB_MAX_RLIFE,
KRB5_KDB_EXPIRATION,
static void
usage(who, status)
-char *who;
-int status;
+ char *who;
+ int status;
{
fprintf(stderr,
- "usage: %s -p prefix -n num_to_check [-d dbpathname] [-r realmname]\n",
- who);
+ "usage: %s -p prefix -n num_to_check [-d dbpathname] [-r realmname]\n",
+ who);
fprintf(stderr, "\t [-D depth] [-k enctype] [-M mkeyname]\n");
exit(status);
krb5_init_context(&context);
if (strrchr(argv[0], '/'))
- argv[0] = strrchr(argv[0], '/')+1;
+ argv[0] = strrchr(argv[0], '/')+1;
progname = argv[0];
depth = 1;
while ((optchar = getopt(argc, argv, "D:P:p:n:d:r:R:k:M:e:m")) != -1) {
- switch(optchar) {
- case 'D':
- depth = atoi(optarg); /* how deep to go */
- break;
- case 'P': /* Only used for testing!!! */
- mkey_password = optarg;
- break;
- case 'p': /* prefix name to check */
- strncpy(principal_string, optarg, sizeof(principal_string) - 1);
- principal_string[sizeof(principal_string) - 1] = '\0';
- suffix = principal_string + strlen(principal_string);
- suffix_size = sizeof(principal_string) -
- (suffix - principal_string);
- break;
- case 'n': /* how many to check */
- num_to_check = atoi(optarg);
- break;
- case 'd': /* set db name */
- dbname = optarg;
- break;
- case 'r':
- cur_realm = optarg;
- break;
- case 'k':
- master_keyblock.enctype = atoi(optarg);
- enctypedone++;
- break;
- case 'M': /* master key name in DB */
- mkey_name = optarg;
- break;
- case 'm':
- manual_mkey = TRUE;
- break;
- case '?':
- default:
- usage(progname, 1);
- /*NOTREACHED*/
- }
+ switch(optchar) {
+ case 'D':
+ depth = atoi(optarg); /* how deep to go */
+ break;
+ case 'P': /* Only used for testing!!! */
+ mkey_password = optarg;
+ break;
+ case 'p': /* prefix name to check */
+ strncpy(principal_string, optarg, sizeof(principal_string) - 1);
+ principal_string[sizeof(principal_string) - 1] = '\0';
+ suffix = principal_string + strlen(principal_string);
+ suffix_size = sizeof(principal_string) -
+ (suffix - principal_string);
+ break;
+ case 'n': /* how many to check */
+ num_to_check = atoi(optarg);
+ break;
+ case 'd': /* set db name */
+ dbname = optarg;
+ break;
+ case 'r':
+ cur_realm = optarg;
+ break;
+ case 'k':
+ master_keyblock.enctype = atoi(optarg);
+ enctypedone++;
+ break;
+ case 'M': /* master key name in DB */
+ mkey_name = optarg;
+ break;
+ case 'm':
+ manual_mkey = TRUE;
+ break;
+ case '?':
+ default:
+ usage(progname, 1);
+ /*NOTREACHED*/
+ }
}
if (!(num_to_check && suffix)) usage(progname, 1);
if (!enctypedone)
- master_keyblock.enctype = DEFAULT_KDC_ENCTYPE;
+ master_keyblock.enctype = DEFAULT_KDC_ENCTYPE;
if (!krb5_c_valid_enctype(master_keyblock.enctype)) {
- com_err(progname, KRB5_PROG_ETYPE_NOSUPP,
- "while setting up enctype %d", master_keyblock.enctype);
- exit(1);
+ com_err(progname, KRB5_PROG_ETYPE_NOSUPP,
+ "while setting up enctype %d", master_keyblock.enctype);
+ exit(1);
}
krb5_use_enctype(context, &master_encblock, master_keyblock.enctype);
if (!dbname)
- dbname = DEFAULT_KDB_FILE; /* XXX? */
+ dbname = DEFAULT_KDB_FILE; /* XXX? */
if (!cur_realm) {
- if ((retval = krb5_get_default_realm(context, &cur_realm))) {
- com_err(progname, retval, "while retrieving default realm name");
- exit(1);
- }
+ if ((retval = krb5_get_default_realm(context, &cur_realm))) {
+ com_err(progname, retval, "while retrieving default realm name");
+ exit(1);
+ }
}
if ((retval = set_dbname_help(context, progname, dbname)))
- exit(retval);
+ exit(retval);
errors = 0;
fprintf(stdout, "\nChecking ");
for (n = 1; n <= num_to_check; n++) {
- /* build the new principal name */
- /* we can't pick random names because we need to generate all the names
- again given a prefix and count to test the db lib and kdb */
- (void) snprintf(suffix, suffix_size, "%d", n);
- (void) snprintf(tmp, sizeof(tmp), "%s-DEPTH-1", principal_string);
- str_princ = tmp;
- if (check_princ(context, str_princ)) errors++;
-
- for (i = 2; i <= depth; i++) {
- (void) snprintf(tmp2, sizeof(tmp2), "/%s-DEPTH-%d",
- principal_string, i);
- tmp2[sizeof(tmp2) - 1] = '\0';
- strncat(tmp, tmp2, sizeof(tmp) - 1 - strlen(tmp));
- str_princ = tmp;
- if (check_princ(context, str_princ)) errors++;
- }
+ /* build the new principal name */
+ /* we can't pick random names because we need to generate all the names
+ again given a prefix and count to test the db lib and kdb */
+ (void) snprintf(suffix, suffix_size, "%d", n);
+ (void) snprintf(tmp, sizeof(tmp), "%s-DEPTH-1", principal_string);
+ str_princ = tmp;
+ if (check_princ(context, str_princ)) errors++;
+
+ for (i = 2; i <= depth; i++) {
+ (void) snprintf(tmp2, sizeof(tmp2), "/%s-DEPTH-%d",
+ principal_string, i);
+ tmp2[sizeof(tmp2) - 1] = '\0';
+ strncat(tmp, tmp2, sizeof(tmp) - 1 - strlen(tmp));
+ str_princ = tmp;
+ if (check_princ(context, str_princ)) errors++;
+ }
}
if (errors)
- fprintf(stdout, "\n%d errors/principals failed.\n", errors);
+ fprintf(stdout, "\n%d errors/principals failed.\n", errors);
else
- fprintf(stdout, "\nNo errors.\n");
+ fprintf(stdout, "\nNo errors.\n");
krb5_finish_random_key(context, &master_encblock, &master_random);
krb5_finish_key(context, &master_encblock);
retval = krb5_db_fini(context);
memset(master_keyblock.contents, 0, (size_t) master_keyblock.length);
if (retval && retval != KRB5_KDB_DBNOTINITED) {
- com_err(progname, retval, "while closing database");
- exit(1);
+ com_err(progname, retval, "while closing database");
+ exit(1);
}
if (str_master_princ) {
- krb5_free_unparsed_name(context, str_master_princ);
+ krb5_free_unparsed_name(context, str_master_princ);
}
krb5_free_principal(context, master_princ);
krb5_free_context(context);
fprintf(stderr, "\t%s ...\n", princ_name);
if ((retval = krb5_parse_name(context, princ_name, &princ))) {
- com_err(progname, retval, "while parsing '%s'", princ_name);
- goto out;
+ com_err(progname, retval, "while parsing '%s'", princ_name);
+ goto out;
}
pwd.data = princ_name; /* must be able to regenerate */
pwd.length = strlen(princ_name);
if ((retval = krb5_principal2salt(context, princ, &salt))) {
- com_err(progname, retval, "while converting principal to salt for '%s'", princ_name);
- krb5_free_principal(context, princ);
- goto out;
+ com_err(progname, retval, "while converting principal to salt for '%s'", princ_name);
+ krb5_free_principal(context, princ);
+ goto out;
}
if ((retval = krb5_string_to_key(context, &master_encblock,
- &pwd_key, &pwd, &salt))) {
- com_err(progname, retval, "while converting password to key for '%s'",
- princ_name);
- krb5_free_data_contents(context, &salt);
- krb5_free_principal(context, princ);
- goto out;
+ &pwd_key, &pwd, &salt))) {
+ com_err(progname, retval, "while converting password to key for '%s'",
+ princ_name);
+ krb5_free_data_contents(context, &salt);
+ krb5_free_principal(context, princ);
+ goto out;
}
krb5_free_data_contents(context, &salt);
if ((retval = krb5_db_get_principal(context, princ, &kdbe,
- &nprincs, &more))) {
- com_err(progname, retval, "while attempting to verify principal's existence");
- krb5_free_principal(context, princ);
- goto out;
+ &nprincs, &more))) {
+ com_err(progname, retval, "while attempting to verify principal's existence");
+ krb5_free_principal(context, princ);
+ goto out;
}
krb5_free_principal(context, princ);
if (nprincs != 1) {
- com_err(progname, 0, "Found %d entries db entry for %s.\n", nprincs,
- princ_name);
- goto errout;
+ com_err(progname, 0, "Found %d entries db entry for %s.\n", nprincs,
+ princ_name);
+ goto errout;
}
if ((retval = krb5_dbekd_decrypt_key_data(context, &master_keyblock,
- kdbe.key_data, &db_key, NULL))) {
- com_err(progname, retval, "while decrypting key for '%s'", princ_name);
- goto errout;
+ kdbe.key_data, &db_key, NULL))) {
+ com_err(progname, retval, "while decrypting key for '%s'", princ_name);
+ goto errout;
}
if ((pwd_key.enctype != db_key.enctype) ||
- (pwd_key.length != db_key.length)) {
- fprintf (stderr, "\tKey types do not agree (%d expected, %d from db)\n",
- pwd_key.enctype, db_key.enctype);
-errout:
- krb5_db_free_principal(context, &kdbe, nprincs);
- return(-1);
+ (pwd_key.length != db_key.length)) {
+ fprintf (stderr, "\tKey types do not agree (%d expected, %d from db)\n",
+ pwd_key.enctype, db_key.enctype);
+ errout:
+ krb5_db_free_principal(context, &kdbe, nprincs);
+ return(-1);
}
else {
- if (memcmp((char *)pwd_key.contents, (char *) db_key.contents,
- (size_t) pwd_key.length)) {
- fprintf(stderr, "\t key did not match stored value for %s\n",
- princ_name);
- goto errout;
- }
+ if (memcmp((char *)pwd_key.contents, (char *) db_key.contents,
+ (size_t) pwd_key.length)) {
+ fprintf(stderr, "\t key did not match stored value for %s\n",
+ princ_name);
+ goto errout;
+ }
}
free(pwd_key.contents);
free(db_key.contents);
if (kdbe.key_data[0].key_data_kvno != 1) {
- fprintf(stderr,"\tkvno did not match stored value for %s.\n", princ_name);
- goto errout;
+ fprintf(stderr,"\tkvno did not match stored value for %s.\n", princ_name);
+ goto errout;
}
if (kdbe.max_life != mblock.max_life) {
- fprintf(stderr, "\tmax life did not match stored value for %s.\n",
- princ_name);
- goto errout;
+ fprintf(stderr, "\tmax life did not match stored value for %s.\n",
+ princ_name);
+ goto errout;
}
if (kdbe.max_renewable_life != mblock.max_rlife) {
- fprintf(stderr,
- "\tmax renewable life did not match stored value for %s.\n",
- princ_name);
- goto errout;
+ fprintf(stderr,
+ "\tmax renewable life did not match stored value for %s.\n",
+ princ_name);
+ goto errout;
}
if (kdbe.expiration != mblock.expiration) {
- fprintf(stderr, "\texpiration time did not match stored value for %s.\n",
- princ_name);
- goto errout;
+ fprintf(stderr, "\texpiration time did not match stored value for %s.\n",
+ princ_name);
+ goto errout;
}
/*
- if ((retval = krb5_unparse_name(context, kdbe.mod_name, &str_mod_name)))
- com_err(progname, retval, "while unparsing mode name");
- else {
- if (strcmp(str_mod_name, str_master_princ) != 0) {
- fprintf(stderr, "\tmod name isn't the master princ (%s not %s).\n",
- str_mod_name, str_master_princ);
- free(str_mod_name);
- goto errout;
- }
- else free(str_mod_name);
- }
+ if ((retval = krb5_unparse_name(context, kdbe.mod_name, &str_mod_name)))
+ com_err(progname, retval, "while unparsing mode name");
+ else {
+ if (strcmp(str_mod_name, str_master_princ) != 0) {
+ fprintf(stderr, "\tmod name isn't the master princ (%s not %s).\n",
+ str_mod_name, str_master_princ);
+ free(str_mod_name);
+ goto errout;
+ }
+ else free(str_mod_name);
+ }
*/
if (kdbe.attributes != mblock.flags) {
- fprintf(stderr, "\tAttributes did not match stored value for %s.\n",
- princ_name);
- goto errout;
+ fprintf(stderr, "\tAttributes did not match stored value for %s.\n",
+ princ_name);
+ goto errout;
}
- out:
+out:
krb5_db_free_principal(context, &kdbe, nprincs);
return(0);
/* assemble & parse the master key name */
if ((retval = krb5_db_setup_mkey_name(context, mkey_name, cur_realm, 0,
- &master_princ))) {
- com_err(pname, retval, "while setting up master key name");
- return(1);
+ &master_princ))) {
+ com_err(pname, retval, "while setting up master key name");
+ return(1);
}
if (mkey_password) {
- pwd.data = mkey_password;
- pwd.length = strlen(mkey_password);
- retval = krb5_principal2salt(context, master_princ, &scratch);
- if (retval) {
- com_err(pname, retval, "while calculated master key salt");
- return(1);
- }
- if ((retval = krb5_string_to_key(context, &master_encblock,
- &master_keyblock, &pwd, &scratch))) {
- com_err(pname, retval,
- "while transforming master key from password");
- return(1);
- }
- free(scratch.data);
+ pwd.data = mkey_password;
+ pwd.length = strlen(mkey_password);
+ retval = krb5_principal2salt(context, master_princ, &scratch);
+ if (retval) {
+ com_err(pname, retval, "while calculated master key salt");
+ return(1);
+ }
+ if ((retval = krb5_string_to_key(context, &master_encblock,
+ &master_keyblock, &pwd, &scratch))) {
+ com_err(pname, retval,
+ "while transforming master key from password");
+ return(1);
+ }
+ free(scratch.data);
} else {
- if ((retval = krb5_db_fetch_mkey(context, master_princ,
- master_keyblock.enctype,
- manual_mkey, FALSE, (char *) NULL,
+ if ((retval = krb5_db_fetch_mkey(context, master_princ,
+ master_keyblock.enctype,
+ manual_mkey, FALSE, (char *) NULL,
NULL, NULL,
- &master_keyblock))) {
- com_err(pname, retval, "while reading master key");
- return(1);
- }
+ &master_keyblock))) {
+ com_err(pname, retval, "while reading master key");
+ return(1);
+ }
}
/* Ick! Current DAL interface requires that the default_realm
field be set in the krb5_context. */
if ((retval = krb5_set_default_realm(context, cur_realm))) {
- com_err(pname, retval, "setting default realm");
- return 1;
+ com_err(pname, retval, "setting default realm");
+ return 1;
}
/* Pathname is passed to db2 via 'args' parameter. */
args[1] = NULL;
if (asprintf(&args[0], "dbname=%s", dbname) < 0) {
- com_err(pname, errno, "while setting up db parameters");
- return 1;
+ com_err(pname, errno, "while setting up db parameters");
+ return 1;
}
if ((retval = krb5_db_open(context, args, KRB5_KDB_OPEN_RO))) {
- com_err(pname, retval, "while initializing database");
- return(1);
+ com_err(pname, retval, "while initializing database");
+ return(1);
}
if ((retval = krb5_db_verify_master_key(context, master_princ,
- IGNORE_VNO, &master_keyblock))) {
- com_err(pname, retval, "while verifying master key");
- (void) krb5_db_fini(context);
- return(1);
+ IGNORE_VNO, &master_keyblock))) {
+ com_err(pname, retval, "while verifying master key");
+ (void) krb5_db_fini(context);
+ return(1);
}
nentries = 1;
if ((retval = krb5_db_get_principal(context, master_princ, &master_entry,
- &nentries, &more))) {
- com_err(pname, retval, "while retrieving master entry");
- (void) krb5_db_fini(context);
- return(1);
+ &nentries, &more))) {
+ com_err(pname, retval, "while retrieving master entry");
+ (void) krb5_db_fini(context);
+ return(1);
} else if (more) {
- com_err(pname, KRB5KDC_ERR_PRINCIPAL_NOT_UNIQUE,
- "while retrieving master entry");
- (void) krb5_db_fini(context);
- return(1);
+ com_err(pname, KRB5KDC_ERR_PRINCIPAL_NOT_UNIQUE,
+ "while retrieving master entry");
+ (void) krb5_db_fini(context);
+ return(1);
} else if (!nentries) {
- com_err(pname, KRB5_KDB_NOENTRY, "while retrieving master entry");
- (void) krb5_db_fini(context);
- return(1);
+ com_err(pname, KRB5_KDB_NOENTRY, "while retrieving master entry");
+ (void) krb5_db_fini(context);
+ return(1);
}
if ((retval = krb5_unparse_name(context, master_princ,
- &str_master_princ))) {
- com_err(pname, retval, "while unparsing master principal");
- krb5_db_fini(context);
- return(1);
+ &str_master_princ))) {
+ com_err(pname, retval, "while unparsing master principal");
+ krb5_db_fini(context);
+ return(1);
}
if ((retval = krb5_process_key(context,
- &master_encblock, &master_keyblock))) {
- com_err(pname, retval, "while processing master key");
- (void) krb5_db_fini(context);
- return(1);
+ &master_encblock, &master_keyblock))) {
+ com_err(pname, retval, "while processing master key");
+ (void) krb5_db_fini(context);
+ return(1);
}
if ((retval = krb5_init_random_key(context,
- &master_encblock, &master_keyblock,
- &master_random))) {
- com_err(pname, retval, "while initializing random key generator");
- krb5_finish_key(context, &master_encblock);
- (void) krb5_db_fini(context);
- return(1);
+ &master_encblock, &master_keyblock,
+ &master_random))) {
+ com_err(pname, retval, "while initializing random key generator");
+ krb5_finish_key(context, &master_encblock);
+ (void) krb5_db_fini(context);
+ return(1);
}
mblock.max_life = master_entry.max_life;
mblock.max_rlife = master_entry.max_renewable_life;
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* tests/verify/pkey.c
*
#include <stdio.h>
void pkey(k)
- unsigned char *k;
+ unsigned char *k;
{
- int i;
- unsigned int foo;
+ int i;
+ unsigned int foo;
- for (i = 0 ; i < 8 ; i++) {
- foo = *k++;
- fprintf(stderr, "%x ", foo);
- }
+ for (i = 0 ; i < 8 ; i++) {
+ foo = *k++;
+ fprintf(stderr, "%x ", foo);
+ }
}