From 49c3802afe7339871a8387c90de3e5ff798d66b1 Mon Sep 17 00:00:00 2001 From: ian Date: Fri, 30 Aug 2002 20:44:00 +0000 Subject: [PATCH] Perly full service thing, before simple thing. --- base/chiark-tcl.h | 6 ++-- base/tables-examples.tct | 58 +++++++++++++++++++++++++++++++++ base/tcmdifgen | 70 ++++++++++++++++++++++++++++++++++++++++ hbytes/hbytes.h | 6 ++-- 4 files changed, 134 insertions(+), 6 deletions(-) create mode 100644 base/tables-examples.tct create mode 100755 base/tcmdifgen diff --git a/base/chiark-tcl.h b/base/chiark-tcl.h index c6fe050..f136758 100644 --- a/base/chiark-tcl.h +++ b/base/chiark-tcl.h @@ -14,10 +14,10 @@ * * hbytes pkcs5 pa|ua VAR ALG => worked? (always 1 for p) * hbytes pkcs5 pn|un VAR BLOCKSIZE => worked? (always 1 for p) - * hbytes blockcipher e|d VAR ALG MODE [IV] => IV + * hbytes blockcipher d|e VAR ALG MODE [IV] => IV * - * hbytes hash ALG VALUE => hash - * hbytes hmac ALG VALUE KEY [MACLENGTH] => mac + * hbytes hash ALG MESSAGE => hash + * hbytes hmac ALG MESSAGE KEY [MACLENGTH] => mac * * Refs: HMAC: RFC2104 */ diff --git a/base/tables-examples.tct b/base/tables-examples.tct new file mode 100644 index 0000000..1119be8 --- /dev/null +++ b/base/tables-examples.tct @@ -0,0 +1,58 @@ +Type hb Tcl_Obj * +Type hbv Tcl_Obj * + +Table hbytes +Entries + raw2h + binary obj + => hb + h2raw + hex hex + => obj + prefix + v hbv + ... + append + v hbv + ... + concat + v hbv + ... + unprepend + v hbv + length int + => hb + unappend + v hbv + length int + => hb + chopto + v hbv + length int + => hb + pkcs5 + meth enum(PadMethodInfo,padmethodinfos) + ... + blockcipher + encrypt charfrom("de") + v hbv + alg enum(BlockCipherAlgInfo,blockcipheralginfos) + mode enum(BlockCipherModeInfo,blockciphermodeinfos) + ?iv hb + => hb + hash + alg enum(HashAlgInfo,hashalginfos) + message hb + => hb + hmac + alg enum(HashAlgInfo,hashalginfos) + message hb + key hb + maclen int + => hb + +Table padmethodinfos + FuncArgs + Info + int algname; +Entries diff --git a/base/tcmdifgen b/base/tcmdifgen new file mode 100755 index 0000000..498ae50 --- /dev/null +++ b/base/tcmdifgen @@ -0,0 +1,70 @@ +#!/usr/bin/perl + +use IO; +use Data::Dumper; + +parse('builtins','DATA'); + +while (@ARGV) { + $_= shift @ARGV; + die if m/^\-/; + $x= new IO::File $_,'r'; + parse($_,$x); +} + +sub parse ($$) { + my ($wh,$f) = @_; + while (defined($_= $f->getline)) { + chomp; s/^\s+//; s/\s+$//; + next if m/^\#/; + next if !m/\S/; + s/\t/ ' 'x(8-(length $`) % 8) /eg; + + s/^\s+//; + $this_indent= length $&; + while (@i && $this_indent < $i[0]) { shift @i; } + if ($this_indent && (!@i || $this_indent > $i[0])) { + unshift @i, $this_indent; + } + + if (@i==0 && m/^Table\s+(\w+)$/) { + $c_table= $1; + undef $c_entry; + } elsif (@i==1 && m/^([a-z]\w*)$/ && defined $c_table) { + $c_entry= $1; + $tables{$c_table}{$c_entry}{A} = [ ]; + } elsif (@i==2 && m/^(?:\?)?([a-z]\w*)\s.*(\S.*)/ + && defined $c_entry) { + push @{ $tables{$c_table}{$c_entry}{A} }, [ $2, $3, $1 eq '?' ]; + } elsif (@i==2 && m/^\=\>\s.*(\S.*)/ && defined $c_entry) { + $tables{$c_table}{$c_entry}{R}= $1; + } elsif (@i==2 && m/^\.\.\.$/ && defined $c_entry) { + $tables{$c_table}{$c_entry}{V}= 1; + } elsif (@i==0 && s/^Type\s+$//) { + + ($typename,$_)= ($1,$2); + $_ .= '@' unless m/\@/; + $types{$typename}= $_; + } else { + badsyntax($wh,$., sprintf + "bad directive (indent level %d)", scalar @i); + } + } + $f->error and die $!; + $f->close; +} + +print Dumper(\%tables),"\n"; +print Dumper(\%types),"\n"; + +sub badsyntax ($$$) { + die "$_[0]:$_[1]: $_[2]\n"; +} + +__DATA__ +Type int + int +Type obj + Tcl_Obj * +Type charfrom + (const char*) diff --git a/hbytes/hbytes.h b/hbytes/hbytes.h index c6fe050..f136758 100644 --- a/hbytes/hbytes.h +++ b/hbytes/hbytes.h @@ -14,10 +14,10 @@ * * hbytes pkcs5 pa|ua VAR ALG => worked? (always 1 for p) * hbytes pkcs5 pn|un VAR BLOCKSIZE => worked? (always 1 for p) - * hbytes blockcipher e|d VAR ALG MODE [IV] => IV + * hbytes blockcipher d|e VAR ALG MODE [IV] => IV * - * hbytes hash ALG VALUE => hash - * hbytes hmac ALG VALUE KEY [MACLENGTH] => mac + * hbytes hash ALG MESSAGE => hash + * hbytes hmac ALG MESSAGE KEY [MACLENGTH] => mac * * Refs: HMAC: RFC2104 */ -- 2.30.2