diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2000-10-13 13:11:51 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2000-10-13 13:11:51 +0000 |
commit | 55846713e34133e1474a7e4449f59c8fb0890227 (patch) | |
tree | f08e97d4b389f12058e040f833ae1dec959eb42c | |
parent | c1f58a3434456782e25ab7161c0e17c0de3a4f34 (diff) | |
download | gnutls-55846713e34133e1474a7e4449f59c8fb0890227.tar.gz |
added a DER parser from Tarun and updated authors
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | lib/gnutls_cert.lex | 177 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/cli.c | 2 |
5 files changed, 182 insertions, 4 deletions
@@ -1 +1,2 @@ Nikos Mavroyanopoulos <nmav@hellug.gr> +Tarun Upadhyay <tarun@ebprovider.com> diff --git a/configure.in b/configure.in index 67caebf87a..4fa82023c7 100644 --- a/configure.in +++ b/configure.in @@ -11,7 +11,7 @@ AC_DEFINE_UNQUOTED(T_OS, "$target_os") GNUTLS_MAJOR_VERSION=0 GNUTLS_MINOR_VERSION=0 -GNUTLS_MICRO_VERSION=2 +GNUTLS_MICRO_VERSION=3 GNUTLS_VERSION=$GNUTLS_MAJOR_VERSION.$GNUTLS_MINOR_VERSION.$GNUTLS_MICRO_VERSION diff --git a/lib/gnutls_cert.lex b/lib/gnutls_cert.lex new file mode 100644 index 0000000000..66fc1f3aca --- /dev/null +++ b/lib/gnutls_cert.lex @@ -0,0 +1,177 @@ +/* scanner for DER encoded certificates */ + +/* + * Copyright (C) 2000 Tarun Upadhyay <tarun@ebprovider.com> + * + * This file is part of GNUTLS. + * + * GNUTLS is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GNUTLS is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +%{ + /* C declarations block */ +#define CHOP(C) ((c)&'\x7f') + + unsigned long size; + unsigned long levels[64]; + int current = 0; + unsigned long realsize; + + void parselen(void){ + int i; + char c; + printf("\tLEN: "); + c = input(); + realsize = 2; + if (c & '\x80') { + printf("%d/", CHOP(c)); + realsize += CHOP(c); + for (size=0, i = 0; i < CHOP(c); i++){ + size <<= 8; + size += input(); + } + } + else + size = c; + realsize += size; + printf("%d ", size); + } + + void increaselevel(void){ + levels[current++] = realsize; + levels[current] = 0; + } + + void checklevel(void){ + levels[current] += realsize; + if (levels[current] == levels[current-1]) + } +%} + +%% + +\x01 { + printf("\nBOOLEAN"); + input(); + printf("%d ", input()); +} + +\x02 { + int i; + printf("\nINTEGER"); + parselen(); + for (i = 0; i < size; i++) + printf("%x ", input()); + size = 0; +} + +\x03 | +\x04 { + int i; + printf("\nBIT STRING"); + parselen(); + for (i = 0; i < size ; i++) + printf("%x ", input()); + size = 0; +} + +\x05 { + printf("\nNULL"); + input(); +} + +\x06 { + int i; + printf("\nOID"); + parselen(); + for (i = 0; i < size ; i++) + printf("%x.", input()); + size = 0; +} + +\x13 | +\x16 { + int i; + printf("\nSTRING"); + parselen(); + for (i = 0; i < size ; i++) + printf("%c", input()); + size = 0; +} + +\x17 { + char c; + printf("\nUTC TIME"); + parselen(); + c = input(); + + /* year */ + if (c <= '4') + printf("20"); + else + printf("19"); + printf("%c", c); + printf("%c", input()); + + /* month */ + printf("/%c", input()); + printf("%c", input()); + + /* day */ + printf("/%c", input()); + printf("%c", input()); + + /* hours */ + printf(" %c", input()); + printf("%c", input()); + + /* minutes */ + printf(":%c", input()); + printf("%c", input()); + + /* seconds */ + printf(":%c", input()); + printf("%c", input()); + + input(); +} + +[\xa0-\xaf] { + int i; + printf("\nARRAY[%d]", yytext[0] & '\x07'); + parselen(); + increaselevel(); +} + +\x30 { + printf("\nSEQUENCE"); + parselen(); + increaselevel(); +} + +\x31 { + printf("\nSET"); + parselen(); + increaselevel(); +} + +%% + +main (int argc, char ** argv){ + yyin = stdin; + yylex(); + printf("\n"); +} + diff --git a/src/Makefile.am b/src/Makefile.am index 34769a9c75..dc4bd9abf3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,7 @@ EXTRA_DIST = port.h noinst_PROGRAMS = serv cli serv_SOURCES = serv.c -serv_LDADD = ../lib/libgnutls.la -lgcrypt +serv_LDADD = ../lib/libgnutls.la $(GCRYPT_LIBS) cli_SOURCES = cli.c -cli_LDADD = ../lib/libgnutls.la -lgcrypt +cli_LDADD = ../lib/libgnutls.la $(GCRYPT_LIBS) @@ -98,7 +98,7 @@ int main() gnutls_send( sd, state, buffer, strlen(buffer)); } gnutls_close(sd, state); - + shutdown( sd, SHUT_WR); gnutls_deinit(&state); |