chiark / gitweb /
Perly full service thing, before simple thing.
authorian <ian>
Fri, 30 Aug 2002 20:44:00 +0000 (20:44 +0000)
committerian <ian>
Fri, 30 Aug 2002 20:44:00 +0000 (20:44 +0000)
base/chiark-tcl.h
base/tables-examples.tct [new file with mode: 0644]
base/tcmdifgen [new file with mode: 0755]
hbytes/hbytes.h

index c6fe050..f136758 100644 (file)
  *
  *  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 (file)
index 0000000..1119be8
--- /dev/null
@@ -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 (executable)
index 0000000..498ae50
--- /dev/null
@@ -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*)
index c6fe050..f136758 100644 (file)
  *
  *  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
  */