diff options
author | nectar <nectar@FreeBSD.org> | 2003-10-09 19:36:20 +0000 |
---|---|---|
committer | nectar <nectar@FreeBSD.org> | 2003-10-09 19:36:20 +0000 |
commit | 5c90662d441c12cd30c694eb1172d6fea2f8f282 (patch) | |
tree | cb08d962a1d1ff9fd191e67849a7057861f42a50 /crypto/heimdal/lib/asn1 | |
parent | 12eb3dee85137da9effa7d2df35e855dd0a3814a (diff) | |
download | FreeBSD-src-5c90662d441c12cd30c694eb1172d6fea2f8f282.zip FreeBSD-src-5c90662d441c12cd30c694eb1172d6fea2f8f282.tar.gz |
Vendor import of Heimdal 0.6.
Diffstat (limited to 'crypto/heimdal/lib/asn1')
-rw-r--r-- | crypto/heimdal/lib/asn1/Makefile.am | 13 | ||||
-rw-r--r-- | crypto/heimdal/lib/asn1/Makefile.in | 50 | ||||
-rw-r--r-- | crypto/heimdal/lib/asn1/check-common.c | 125 | ||||
-rw-r--r-- | crypto/heimdal/lib/asn1/check-common.h | 53 | ||||
-rw-r--r-- | crypto/heimdal/lib/asn1/check-der.c | 124 | ||||
-rw-r--r-- | crypto/heimdal/lib/asn1/check-gen.c | 193 | ||||
-rw-r--r-- | crypto/heimdal/lib/asn1/der_copy.c | 5 | ||||
-rw-r--r-- | crypto/heimdal/lib/asn1/der_put.c | 15 | ||||
-rw-r--r-- | crypto/heimdal/lib/asn1/gen.c | 10 | ||||
-rw-r--r-- | crypto/heimdal/lib/asn1/k5.asn1 | 7 |
10 files changed, 448 insertions, 147 deletions
diff --git a/crypto/heimdal/lib/asn1/Makefile.am b/crypto/heimdal/lib/asn1/Makefile.am index e202697..36cd9f0 100644 --- a/crypto/heimdal/lib/asn1/Makefile.am +++ b/crypto/heimdal/lib/asn1/Makefile.am @@ -1,11 +1,11 @@ -# $Id: Makefile.am,v 1.68 2002/03/10 23:41:33 assar Exp $ +# $Id: Makefile.am,v 1.69.2.1 2003/05/12 15:20:44 joda Exp $ include $(top_srcdir)/Makefile.am.common YFLAGS = -d lib_LTLIBRARIES = libasn1.la -libasn1_la_LDFLAGS = -version-info 6:0:0 +libasn1_la_LDFLAGS = -version-info 6:1:0 libasn1_la_LIBADD = @LIB_com_err@ @@ -69,8 +69,12 @@ gen_files = \ noinst_PROGRAMS = asn1_compile asn1_print -check_PROGRAMS = check-der -TESTS = check-der +check_PROGRAMS = check-der check-gen +TESTS = check-der check-gen + +check_der_SOURCES = check-der.c check-common.c +check_gen_SOURCES = check-gen.c check-common.c + asn1_compile_SOURCES = \ gen.c \ @@ -102,6 +106,7 @@ check_der_LDADD = \ libasn1.la \ $(LIB_roken) +check_gen_LDADD = $(check_der_LDADD) asn1_print_LDADD = $(check_der_LDADD) CLEANFILES = lex.c parse.c parse.h krb5_asn1.h $(BUILT_SOURCES) \ diff --git a/crypto/heimdal/lib/asn1/Makefile.in b/crypto/heimdal/lib/asn1/Makefile.in index 8871e79..e97ee04 100644 --- a/crypto/heimdal/lib/asn1/Makefile.in +++ b/crypto/heimdal/lib/asn1/Makefile.in @@ -14,11 +14,11 @@ @SET_MAKE@ -# $Id: Makefile.am,v 1.68 2002/03/10 23:41:33 assar Exp $ +# $Id: Makefile.am,v 1.69.2.1 2003/05/12 15:20:44 joda Exp $ # $Id: Makefile.am.common,v 1.5 2002/05/19 18:35:37 joda Exp $ -# $Id: Makefile.am.common,v 1.36 2002/08/19 16:10:25 joda Exp $ +# $Id: Makefile.am.common,v 1.37.2.1 2003/05/08 17:08:09 joda Exp $ SHELL = @SHELL@ srcdir = @srcdir@ @@ -114,6 +114,7 @@ LIB_roken = @LIB_roken@ LIB_security = @LIB_security@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ NEED_WRITEAUTH_FALSE = @NEED_WRITEAUTH_FALSE@ NEED_WRITEAUTH_TRUE = @NEED_WRITEAUTH_TRUE@ NROFF = @NROFF@ @@ -192,7 +193,7 @@ LIB_readline = @LIB_readline@ NROFF_MAN = groff -mandoc -Tascii -@KRB4_TRUE@LIB_kafs = $(top_builddir)/lib/kafs/libkafs.la $(AIX_EXTRA_KAFS) +LIB_kafs = $(top_builddir)/lib/kafs/libkafs.la $(AIX_EXTRA_KAFS) @KRB5_TRUE@LIB_krb5 = $(top_builddir)/lib/krb5/libkrb5.la \ @KRB5_TRUE@ $(top_builddir)/lib/asn1/libasn1.la @@ -204,7 +205,7 @@ NROFF_MAN = groff -mandoc -Tascii YFLAGS = -d lib_LTLIBRARIES = libasn1.la -libasn1_la_LDFLAGS = -version-info 6:0:0 +libasn1_la_LDFLAGS = -version-info 6:1:0 libasn1_la_LIBADD = @LIB_com_err@ @@ -269,8 +270,11 @@ gen_files = \ noinst_PROGRAMS = asn1_compile asn1_print -check_PROGRAMS = check-der -TESTS = check-der +check_PROGRAMS = check-der check-gen +TESTS = check-der check-gen + +check_der_SOURCES = check-der.c check-common.c +check_gen_SOURCES = check-gen.c check-common.c asn1_compile_SOURCES = \ gen.c \ @@ -306,6 +310,7 @@ check_der_LDADD = \ $(LIB_roken) +check_gen_LDADD = $(check_der_LDADD) asn1_print_LDADD = $(check_der_LDADD) CLEANFILES = lex.c parse.c parse.h krb5_asn1.h $(BUILT_SOURCES) \ @@ -344,7 +349,7 @@ am__objects_5 = $(am__objects_6) asn1_err.lo am_libasn1_la_OBJECTS = der_get.lo der_put.lo der_free.lo der_length.lo \ der_copy.lo timegm.lo $(am__objects_5) libasn1_la_OBJECTS = $(am_libasn1_la_OBJECTS) -check_PROGRAMS = check-der$(EXEEXT) +check_PROGRAMS = check-der$(EXEEXT) check-gen$(EXEEXT) noinst_PROGRAMS = asn1_compile$(EXEEXT) asn1_print$(EXEEXT) PROGRAMS = $(noinst_PROGRAMS) @@ -359,10 +364,14 @@ asn1_print_SOURCES = asn1_print.c asn1_print_OBJECTS = asn1_print.$(OBJEXT) asn1_print_DEPENDENCIES = libasn1.la asn1_print_LDFLAGS = -check_der_SOURCES = check-der.c -check_der_OBJECTS = check-der.$(OBJEXT) +am_check_der_OBJECTS = check-der.$(OBJEXT) check-common.$(OBJEXT) +check_der_OBJECTS = $(am_check_der_OBJECTS) check_der_DEPENDENCIES = libasn1.la check_der_LDFLAGS = +am_check_gen_OBJECTS = check-gen.$(OBJEXT) check-common.$(OBJEXT) +check_gen_OBJECTS = $(am_check_gen_OBJECTS) +check_gen_DEPENDENCIES = libasn1.la +check_gen_LDFLAGS = DEFS = @DEFS@ DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include @@ -384,22 +393,22 @@ LTLEXCOMPILE = $(LIBTOOL) --mode=compile $(LEX) $(LFLAGS) $(AM_LFLAGS) YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS) LTYACCCOMPILE = $(LIBTOOL) --mode=compile $(YACC) $(YFLAGS) $(AM_YFLAGS) DIST_SOURCES = $(libasn1_la_SOURCES) $(asn1_compile_SOURCES) \ - asn1_print.c check-der.c + asn1_print.c $(check_der_SOURCES) $(check_gen_SOURCES) HEADERS = $(include_HEADERS) DIST_COMMON = $(include_HEADERS) Makefile.am Makefile.in lex.c parse.c \ parse.h -SOURCES = $(libasn1_la_SOURCES) $(asn1_compile_SOURCES) asn1_print.c check-der.c +SOURCES = $(libasn1_la_SOURCES) $(asn1_compile_SOURCES) asn1_print.c $(check_der_SOURCES) $(check_gen_SOURCES) all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .et .h .x .1 .3 .5 .8 .cat1 .cat3 .cat5 .cat8 .c .l .lo .o .obj .y -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/Makefile.am.common $(top_srcdir)/cf/Makefile.am.common $(top_srcdir)/configure.in $(ACLOCAL_M4) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/Makefile.am.common $(top_srcdir)/cf/Makefile.am.common $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --foreign lib/asn1/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) libLTLIBRARIES_INSTALL = $(INSTALL) install-libLTLIBRARIES: $(lib_LTLIBRARIES) @@ -441,6 +450,9 @@ asn1_print$(EXEEXT): $(asn1_print_OBJECTS) $(asn1_print_DEPENDENCIES) check-der$(EXEEXT): $(check_der_OBJECTS) $(check_der_DEPENDENCIES) @rm -f check-der$(EXEEXT) $(LINK) $(check_der_LDFLAGS) $(check_der_OBJECTS) $(check_der_LDADD) $(LIBS) +check-gen$(EXEEXT): $(check_gen_OBJECTS) $(check_gen_DEPENDENCIES) + @rm -f check-gen$(EXEEXT) + $(LINK) $(check_gen_LDFLAGS) $(check_gen_OBJECTS) $(check_gen_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) core *.core @@ -682,7 +694,9 @@ info: info-am info-am: -install-data-am: install-data-local install-includeHEADERS +install-data-am: install-includeHEADERS + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-data-hook install-exec-am: install-libLTLIBRARIES @$(NORMAL_INSTALL) @@ -711,9 +725,9 @@ uninstall-am: uninstall-includeHEADERS uninstall-info-am \ clean-libLTLIBRARIES clean-libtool clean-noinstPROGRAMS \ distclean distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am info info-am install \ - install-am install-data install-data-am install-data-local \ - install-exec install-exec-am install-includeHEADERS \ - install-info install-info-am install-libLTLIBRARIES install-man \ + install-am install-data install-data-am install-exec \ + install-exec-am install-includeHEADERS install-info \ + install-info-am install-libLTLIBRARIES install-man \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ @@ -844,7 +858,7 @@ dist-hook: dist-cat1-mans dist-cat3-mans dist-cat5-mans dist-cat8-mans install-cat-mans: $(SHELL) $(top_srcdir)/cf/install-catman.sh "$(INSTALL_DATA)" "$(mkinstalldirs)" "$(srcdir)" "$(DESTDIR)$(mandir)" '$(CATMANEXT)' $(man_MANS) $(man1_MANS) $(man3_MANS) $(man5_MANS) $(man8_MANS) -install-data-local: install-cat-mans +install-data-hook: install-cat-mans .et.h: $(COMPILE_ET) $< diff --git a/crypto/heimdal/lib/asn1/check-common.c b/crypto/heimdal/lib/asn1/check-common.c new file mode 100644 index 0000000..20a41ad --- /dev/null +++ b/crypto/heimdal/lib/asn1/check-common.c @@ -0,0 +1,125 @@ +/* + * Copyright (c) 1999 - 2003 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include <stdio.h> +#include <string.h> +#include <err.h> +#include <roken.h> + +#include "check-common.h" + +RCSID("$Id: check-common.c,v 1.1 2003/01/23 10:21:36 lha Exp $"); + +static void +print_bytes (unsigned const char *buf, size_t len) +{ + int i; + + for (i = 0; i < len; ++i) + printf ("%02x ", buf[i]); +} + +int +generic_test (const struct test_case *tests, + unsigned ntests, + size_t data_size, + int (*encode)(unsigned char *, size_t, void *, size_t *), + int (*length)(void *), + int (*decode)(unsigned char *, size_t, void *, size_t *), + int (*cmp)(void *a, void *b)) +{ + unsigned char buf[4711]; + int i; + int failures = 0; + void *val = malloc (data_size); + + if (data_size != 0 && val == NULL) + err (1, "malloc"); + + for (i = 0; i < ntests; ++i) { + int ret; + size_t sz, consumed_sz, length_sz; + unsigned char *beg; + + ret = (*encode) (buf + sizeof(buf) - 1, sizeof(buf), + tests[i].val, &sz); + beg = buf + sizeof(buf) - sz; + if (ret != 0) { + printf ("encoding of %s failed\n", tests[i].name); + ++failures; + } + if (sz != tests[i].byte_len) { + printf ("encoding of %s has wrong len (%lu != %lu)\n", + tests[i].name, + (unsigned long)sz, (unsigned long)tests[i].byte_len); + ++failures; + } + + length_sz = (*length) (tests[i].val); + if (sz != length_sz) { + printf ("length for %s is bad (%lu != %lu)\n", + tests[i].name, (unsigned long)length_sz, (unsigned long)sz); + ++failures; + } + + if (memcmp (beg, tests[i].bytes, tests[i].byte_len) != 0) { + printf ("encoding of %s has bad bytes:\n" + "correct: ", tests[i].name); + print_bytes (tests[i].bytes, tests[i].byte_len); + printf ("\nactual: "); + print_bytes (beg, sz); + printf ("\n"); + ++failures; + } + ret = (*decode) (beg, sz, val, &consumed_sz); + if (ret != 0) { + printf ("decoding of %s failed\n", tests[i].name); + ++failures; + } + if (sz != consumed_sz) { + printf ("different length decoding %s (%ld != %ld)\n", + tests[i].name, + (unsigned long)sz, (unsigned long)consumed_sz); + ++failures; + } + if ((*cmp)(val, tests[i].val) != 0) { + printf ("%s: comparison failed\n", tests[i].name); + ++failures; + } + } + free (val); + return failures; +} diff --git a/crypto/heimdal/lib/asn1/check-common.h b/crypto/heimdal/lib/asn1/check-common.h new file mode 100644 index 0000000..52d59cb --- /dev/null +++ b/crypto/heimdal/lib/asn1/check-common.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 1999 - 2003 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +struct test_case { + void *val; + int byte_len; + const unsigned char *bytes; + char *name; +}; + +typedef int (*generic_encode)(unsigned char *, size_t, void *, size_t *); +typedef int (*generic_length)(void *); +typedef int (*generic_decode)(unsigned char *, size_t, void *, size_t *); + +int +generic_test (const struct test_case *tests, + unsigned ntests, + size_t data_size, + int (*encode)(unsigned char *, size_t, void *, size_t *), + int (*length)(void *), + int (*decode)(unsigned char *, size_t, void *, size_t *), + int (*cmp)(void *a, void *b)); + diff --git a/crypto/heimdal/lib/asn1/check-der.c b/crypto/heimdal/lib/asn1/check-der.c index 32e474e..7cb0577 100644 --- a/crypto/heimdal/lib/asn1/check-der.c +++ b/crypto/heimdal/lib/asn1/check-der.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 - 2002 Kungliga Tekniska Högskolan + * Copyright (c) 1999 - 2003 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -43,95 +43,9 @@ #include <asn1_err.h> #include <der.h> -RCSID("$Id: check-der.c,v 1.8 2002/08/23 03:17:34 assar Exp $"); +#include "check-common.h" -static void -print_bytes (unsigned const char *buf, size_t len) -{ - int i; - - for (i = 0; i < len; ++i) - printf ("%02x ", buf[i]); -} - -struct test_case { - void *val; - int byte_len; - const unsigned char *bytes; - char *name; -}; - -static int -generic_test (const struct test_case *tests, - unsigned ntests, - size_t data_size, - int (*encode)(unsigned char *, size_t, void *, size_t *), - int (*length)(void *), - int (*decode)(unsigned char *, size_t, void *, size_t *), - int (*cmp)(void *a, void *b)) -{ - unsigned char buf[4711]; - int i; - int failures = 0; - void *val = malloc (data_size); - - if (data_size != 0 && val == NULL) - err (1, "malloc"); - - for (i = 0; i < ntests; ++i) { - int ret; - size_t sz, consumed_sz, length_sz; - unsigned char *beg; - - ret = (*encode) (buf + sizeof(buf) - 1, sizeof(buf), - tests[i].val, &sz); - beg = buf + sizeof(buf) - sz; - if (ret != 0) { - printf ("encoding of %s failed\n", tests[i].name); - ++failures; - } - if (sz != tests[i].byte_len) { - printf ("encoding of %s has wrong len (%lu != %lu)\n", - tests[i].name, - (unsigned long)sz, (unsigned long)tests[i].byte_len); - ++failures; - } - - length_sz = (*length) (tests[i].val); - if (sz != length_sz) { - printf ("length for %s is bad (%lu != %lu)\n", - tests[i].name, (unsigned long)length_sz, (unsigned long)sz); - ++failures; - } - - if (memcmp (beg, tests[i].bytes, tests[i].byte_len) != 0) { - printf ("encoding of %s has bad bytes:\n" - "correct: ", tests[i].name); - print_bytes (tests[i].bytes, tests[i].byte_len); - printf ("\nactual: "); - print_bytes (beg, sz); - printf ("\n"); - ++failures; - } - ret = (*decode) (beg, sz, val, &consumed_sz); - if (ret != 0) { - printf ("decoding of %s failed\n", tests[i].name); - ++failures; - } - if (sz != consumed_sz) { - printf ("different length decoding %s (%ld != %ld)\n", - tests[i].name, - (unsigned long)sz, (unsigned long)consumed_sz); - ++failures; - } - if ((*cmp)(val, tests[i].val) != 0) { - printf ("%s: comparison failed\n", tests[i].name); - ++failures; - } - } - free (val); - return failures; -} +RCSID("$Id: check-der.c,v 1.9 2003/01/23 10:19:49 lha Exp $"); static int cmp_integer (void *a, void *b) @@ -170,11 +84,9 @@ test_integer (void) } return generic_test (tests, ntests, sizeof(int), - (int (*)(unsigned char *, size_t, - void *, size_t *))encode_integer, - (int (*)(void *))length_integer, - (int (*)(unsigned char *, size_t, - void *, size_t *))decode_integer, + (generic_encode)encode_integer, + (generic_length) length_integer, + (generic_decode)decode_integer, cmp_integer); } @@ -204,11 +116,9 @@ test_octet_string (void) asprintf (&tests[0].name, "a octet string"); return generic_test (tests, ntests, sizeof(octet_string), - (int (*)(unsigned char *, size_t, - void *, size_t *))encode_octet_string, - (int (*)(void *))length_octet_string, - (int (*)(unsigned char *, size_t, - void *, size_t *))decode_octet_string, + (generic_encode)encode_octet_string, + (generic_length)length_octet_string, + (generic_decode)decode_octet_string, cmp_octet_string); } @@ -235,11 +145,9 @@ test_general_string (void) asprintf (&tests[0].name, "the string \"%s\"", s1); return generic_test (tests, ntests, sizeof(unsigned char *), - (int (*)(unsigned char *, size_t, - void *, size_t *))encode_general_string, - (int (*)(void *))length_general_string, - (int (*)(unsigned char *, size_t, - void *, size_t *))decode_general_string, + (generic_encode)encode_general_string, + (generic_length)length_general_string, + (generic_decode)decode_general_string, cmp_general_string); } @@ -269,11 +177,9 @@ test_generalized_time (void) } return generic_test (tests, ntests, sizeof(time_t), - (int (*)(unsigned char *, size_t, - void *, size_t *))encode_generalized_time, - (int (*)(void *))length_generalized_time, - (int (*)(unsigned char *, size_t, - void *, size_t *))decode_generalized_time, + (generic_encode)encode_generalized_time, + (generic_length)length_generalized_time, + (generic_decode)decode_generalized_time, cmp_generalized_time); } diff --git a/crypto/heimdal/lib/asn1/check-gen.c b/crypto/heimdal/lib/asn1/check-gen.c new file mode 100644 index 0000000..0b0bec9 --- /dev/null +++ b/crypto/heimdal/lib/asn1/check-gen.c @@ -0,0 +1,193 @@ +/* + * Copyright (c) 1999 - 2003 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include <stdio.h> +#include <string.h> +#include <err.h> +#include <roken.h> + +#include <asn1-common.h> +#include <asn1_err.h> +#include <der.h> +#include <krb5_asn1.h> + +#include "check-common.h" + +RCSID("$Id: check-gen.c,v 1.2.2.1 2003/05/06 16:49:57 joda Exp $"); + +static char *lha_princ[] = { "lha" }; +static char *lharoot_princ[] = { "lha", "root" }; +static char *datan_princ[] = { "host", "nutcracker.e.kth.se" }; + + +#define COMPARE_STRING(ac,bc,e) \ + do { if (strcmp((ac)->e, (bc)->e) != 0) return 1; } while(0) +#define COMPARE_INTEGER(ac,bc,e) \ + do { if ((ac)->e != (bc)->e) return 1; } while(0) +#define COMPARE_MEM(ac,bc,e,len) \ + do { if (memcmp((ac)->e, (bc)->e,len) != 0) return 1; } while(0) + +static int +cmp_principal (void *a, void *b) +{ + Principal *pa = a; + Principal *pb = b; + int i; + + COMPARE_STRING(pa,pb,realm); + COMPARE_INTEGER(pa,pb,name.name_type); + COMPARE_INTEGER(pa,pb,name.name_string.len); + + for (i = 0; i < pa->name.name_string.len; i++) + COMPARE_STRING(pa,pb,name.name_string.val[i]); + + return 0; +} + +static int +test_principal (void) +{ + + struct test_case tests[] = { + { NULL, 29, + (unsigned char*)"\x30\x1b\xa0\x10\x30\x0e\xa0\x03\x02\x01\x01\xa1\x07\x30\x05\x1b" + "\x03\x6c\x68\x61\xa1\x07\x1b\x05\x53\x55\x2e\x53\x45" + }, + { NULL, 35, + (unsigned char*)"\x30\x21\xa0\x16\x30\x14\xa0\x03\x02\x01\x01\xa1\x0d\x30\x0b\x1b" + "\x03\x6c\x68\x61\x1b\x04\x72\x6f\x6f\x74\xa1\x07\x1b\x05\x53\x55" + "\x2e\x53\x45" + }, + { NULL, 54, + (unsigned char*)"\x30\x34\xa0\x26\x30\x24\xa0\x03\x02\x01\x03\xa1\x1d\x30\x1b\x1b" + "\x04\x68\x6f\x73\x74\x1b\x13\x6e\x75\x74\x63\x72\x61\x63\x6b\x65" + "\x72\x2e\x65\x2e\x6b\x74\x68\x2e\x73\x65\xa1\x0a\x1b\x08\x45\x2e" + "\x4b\x54\x48\x2e\x53\x45" + } + }; + + + Principal values[] = { + { { KRB5_NT_PRINCIPAL, { 1, lha_princ } }, "SU.SE" }, + { { KRB5_NT_PRINCIPAL, { 2, lharoot_princ } }, "SU.SE" }, + { { KRB5_NT_SRV_HST, { 2, datan_princ } }, "E.KTH.SE" } + }; + int i; + int ntests = sizeof(tests) / sizeof(*tests); + + for (i = 0; i < ntests; ++i) { + tests[i].val = &values[i]; + asprintf (&tests[i].name, "Principal %d", i); + } + + return generic_test (tests, ntests, sizeof(Principal), + (generic_encode)encode_Principal, + (generic_length)length_Principal, + (generic_decode)decode_Principal, + cmp_principal); +} + +static int +cmp_authenticator (void *a, void *b) +{ + Authenticator *aa = a; + Authenticator *ab = b; + int i; + + COMPARE_INTEGER(aa,ab,authenticator_vno); + COMPARE_STRING(aa,ab,crealm); + + COMPARE_INTEGER(aa,ab,cname.name_type); + COMPARE_INTEGER(aa,ab,cname.name_string.len); + + for (i = 0; i < aa->cname.name_string.len; i++) + COMPARE_STRING(aa,ab,cname.name_string.val[i]); + + return 0; +} + +static int +test_authenticator (void) +{ + struct test_case tests[] = { + { NULL, 63, + (unsigned char*)"\x62\x3d\x30\x3b\xa0\x03\x02\x01\x05\xa1\x0a\x1b\x08" + "\x45\x2e\x4b\x54\x48\x2e\x53\x45\xa2\x10\x30\x0e\xa0" + "\x03\x02\x01\x01\xa1\x07\x30\x05\x1b\x03\x6c\x68\x61" + "\xa4\x03\x02\x01\x0a\xa5\x11\x18\x0f\x31\x39\x37\x30" + "\x30\x31\x30\x31\x30\x30\x30\x31\x33\x39\x5a" + }, + { NULL, 67, + (unsigned char*)"\x62\x41\x30\x3f\xa0\x03\x02\x01\x05\xa1\x07\x1b\x05" + "\x53\x55\x2e\x53\x45\xa2\x16\x30\x14\xa0\x03\x02\x01" + "\x01\xa1\x0d\x30\x0b\x1b\x03\x6c\x68\x61\x1b\x04\x72" + "\x6f\x6f\x74\xa4\x04\x02\x02\x01\x24\xa5\x11\x18\x0f" + "\x31\x39\x37\x30\x30\x31\x30\x31\x30\x30\x31\x36\x33" + "\x39\x5a" + } + }; + + Authenticator values[] = { + { 5, "E.KTH.SE", { KRB5_NT_PRINCIPAL, { 1, lha_princ } }, + NULL, 10, 99, NULL, NULL, NULL }, + { 5, "SU.SE", { KRB5_NT_PRINCIPAL, { 2, lharoot_princ } }, + NULL, 292, 999, NULL, NULL, NULL } + }; + int i; + int ntests = sizeof(tests) / sizeof(*tests); + + for (i = 0; i < ntests; ++i) { + tests[i].val = &values[i]; + asprintf (&tests[i].name, "Authenticator %d", i); + } + + return generic_test (tests, ntests, sizeof(Authenticator), + (generic_encode)encode_Authenticator, + (generic_length)length_Authenticator, + (generic_decode)decode_Authenticator, + cmp_authenticator); +} + +int +main(int argc, char **argv) +{ + int ret = 0; + + ret += test_principal (); + ret += test_authenticator(); + + return ret; +} diff --git a/crypto/heimdal/lib/asn1/der_copy.c b/crypto/heimdal/lib/asn1/der_copy.c index 30027e1..eefc914 100644 --- a/crypto/heimdal/lib/asn1/der_copy.c +++ b/crypto/heimdal/lib/asn1/der_copy.c @@ -33,15 +33,14 @@ #include "der_locl.h" -RCSID("$Id: der_copy.c,v 1.9 2001/09/25 13:39:25 assar Exp $"); +RCSID("$Id: der_copy.c,v 1.10 2003/04/17 07:13:08 lha Exp $"); int copy_general_string (const general_string *from, general_string *to) { - *to = malloc(strlen(*from) + 1); + *to = strdup(*from); if(*to == NULL) return ENOMEM; - strcpy(*to, *from); return 0; } diff --git a/crypto/heimdal/lib/asn1/der_put.c b/crypto/heimdal/lib/asn1/der_put.c index 1dfafdc..41733c5 100644 --- a/crypto/heimdal/lib/asn1/der_put.c +++ b/crypto/heimdal/lib/asn1/der_put.c @@ -33,7 +33,7 @@ #include "der_locl.h" -RCSID("$Id: der_put.c,v 1.27 2001/09/25 23:37:25 assar Exp $"); +RCSID("$Id: der_put.c,v 1.28 2003/04/17 07:12:24 lha Exp $"); /* * All encoding functions take a pointer `p' to first position in @@ -375,15 +375,18 @@ int time2generalizedtime (time_t t, octet_string *s) { struct tm *tm; + size_t len; - s->data = malloc(16); + len = 15; + + s->data = malloc(len + 1); if (s->data == NULL) return ENOMEM; - s->length = 15; + s->length = len; tm = gmtime (&t); - sprintf (s->data, "%04d%02d%02d%02d%02d%02dZ", tm->tm_year + 1900, - tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, - tm->tm_sec); + snprintf (s->data, len + 1, "%04d%02d%02d%02d%02d%02dZ", + tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec); return 0; } diff --git a/crypto/heimdal/lib/asn1/gen.c b/crypto/heimdal/lib/asn1/gen.c index 5b85a48..8580360 100644 --- a/crypto/heimdal/lib/asn1/gen.c +++ b/crypto/heimdal/lib/asn1/gen.c @@ -33,15 +33,15 @@ #include "gen_locl.h" -RCSID("$Id: gen.c,v 1.49 2002/09/04 15:06:18 joda Exp $"); +RCSID("$Id: gen.c,v 1.50 2003/04/17 07:09:18 lha Exp $"); FILE *headerfile, *codefile, *logfile; #define STEM "asn1" static const char *orig_filename; -static char header[1024]; -static char headerbase[1024] = STEM; +static char *header; +static char *headerbase = STEM; /* * list of all IMPORTs @@ -75,8 +75,8 @@ init_generate (const char *filename, const char *base) { orig_filename = filename; if(base) - strcpy(headerbase, base); - sprintf(header, "%s.h", headerbase); + asprintf(&headerbase, "%s", base); + asprintf(&header, "%s.h", headerbase); headerfile = fopen (header, "w"); if (headerfile == NULL) err (1, "open %s", header); diff --git a/crypto/heimdal/lib/asn1/k5.asn1 b/crypto/heimdal/lib/asn1/k5.asn1 index 53436c8..37c60a8 100644 --- a/crypto/heimdal/lib/asn1/k5.asn1 +++ b/crypto/heimdal/lib/asn1/k5.asn1 @@ -1,4 +1,4 @@ --- $Id: k5.asn1,v 1.27 2002/09/03 17:32:09 joda Exp $ +-- $Id: k5.asn1,v 1.28 2003/01/15 03:13:47 lha Exp $ KERBEROS5 DEFINITIONS ::= BEGIN @@ -70,7 +70,8 @@ CKSUMTYPE ::= INTEGER { CKSUMTYPE_RSA_MD5(7), CKSUMTYPE_RSA_MD5_DES(8), CKSUMTYPE_RSA_MD5_DES3(9), - -- CKSUMTYPE_SHA1(10), + CKSUMTYPE_HMAC_SHA1_96_AES_128(10), + CKSUMTYPE_HMAC_SHA1_96_AES_256(11), CKSUMTYPE_HMAC_SHA1_DES3(12), CKSUMTYPE_SHA1(1000), -- correct value? 10 (9 also) CKSUMTYPE_GSSAPI(0x8003), @@ -90,6 +91,8 @@ ENCTYPE ::= INTEGER { ETYPE_ENCRYPT_RSA_PRIV(9), ETYPE_ENCRYPT_RSA_PUB(10), ETYPE_DES3_CBC_SHA1(16), -- with key derivation + ETYPE_AES128_CTS_HMAC_SHA1_96(17), + ETYPE_AES256_CTS_HMAC_SHA1_96(18), ETYPE_ARCFOUR_HMAC_MD5(23), ETYPE_ARCFOUR_HMAC_MD5_56(24), ETYPE_ENCTYPE_PK_CROSS(48), |