# -*-perl-*-
#
-# $Id: algs.PL,v 1.2 2004/04/08 01:36:21 mdw Exp $
+# $Id$
#
# Create tables of algorithms
#
idea safer safersk
rc2 rc5
square rijndael rijndael192 rijndael256
- serpent
+ serpent noekeon
skipjack
mars
tea xtea);
@stream = qw(rc4 seal);
-@hash = qw(md5 md4 md2 tiger
- sha sha256 sha384 sha512
- rmd128 rmd160 rmd256 rmd320);
+@hash = qw(md5 md4 md2 tiger has160
+ sha sha224 sha256 sha384 sha512
+ rmd128 rmd160 rmd256 rmd320
+ whirlpool whirlpool256);
sub enum {
$x = shift;
return @$x;
}
-open OUT, "> $ARGV[0]" or die "couldn't write `$ARGV[0].c': $!";
+open OUT, "> $ARGV[0]" or die "couldn't write `$ARGV[0]': $!";
print OUT <<EOF;
/* -*-c-*-
#include "catacomb-perl.h"
-#include <catacomb/crc32.h>
-
EOF
+print OUT cross("#include <catacomb/", \@cipher, ".h>\n"), "\n";
print OUT cross("#include <catacomb/", \@cipher, "-",
- [qw(ecb cbc cfb counter ofb)], ".h>\n"), "\n";
-print OUT cross("#include <catacomb/", \@stream, ".h>\n"), "\n";
-print OUT cross("#include <catacomb/", \@hash, ".h>\n"), "\n";
-print OUT cross("#include <catacomb/", \@hash, "-",
- [qw(mgf hmac)], ".h>\n"), "\n";
-
-print OUT <<EOF;
+ [qw(counter ofb)], ".h>\n"), "\n";
+print OUT cross("#include <catacomb/", \@hash, "-mgf.h>\n"), "\n";
-const gccipher *ciphertab[] = {
-EOF
-print OUT cross(" &", \@cipher, "_", [qw(ecb cbc cfb counter ofb)], ",\n");
-print OUT cross(" &", \@hash, "_", [qw(mgf)], ",\n");
-print OUT cross(" &", \@stream, ",\n");
print OUT <<EOF;
- 0
-};
-
-const gchash *hashtab[] = {
-EOF
-print OUT cross(" &", \@hash, ",\n");
-print OUT <<EOF;
- &gcrc32,
- 0
-};
-
-const gcmac *mactab[] = {
-EOF
-print OUT cross(" &", \@hash, "_", [qw(hmac nmac sslmac)], ",\n");
-print OUT <<EOF;
- 0
-};
const struct randtab mgftab[] = {
EOF
};
EOF
+foreach my $i (@cipher) {
+ my $I = uc($i);
+ print OUT <<EOF;
+
+static void init_$i(void *ctx, const void *k, size_t ksz) {
+ ${i}_init(ctx, k, ksz);
+}
+static void eblk_$i(const void *ctx, const void *in, void *out) {
+ uint32 w[${I}_BLKSZ / 4];
+ BLKC_LOAD(${I}, w, in);
+ ${i}_eblk(ctx, w, w);
+ BLKC_STORE(${I}, out, w);
+}
+static void dblk_$i(const void *ctx, const void *in, void *out) {
+ uint32 w[${I}_BLKSZ / 4];
+ BLKC_LOAD(${I}, w, in);
+ ${i}_dblk(ctx, w, w);
+ BLKC_STORE(${I}, out, w);
+}
+static PRPClass prp_$i = {
+ "$i",
+ ${i}_keysz, sizeof(${i}_ctx), ${I}_BLKSZ,
+ init_$i, eblk_$i, dblk_$i
+};
+EOF
+}
+
+print OUT <<EOF;
+
+PRPClass *const prptab[] = {
+EOF
+foreach my $i (@cipher) {
+ print OUT " &prp_$i,\n";
+}
+print OUT " 0\n};\n";
+
#----- That's all, folks ----------------------------------------------------