5 # Create tables of algorithms
7 # (c) 2001 Straylight/Edgeware
10 #----- Licensing notice -----------------------------------------------------
12 # This file is part of the Perl interface to Catacomb.
14 # Catacomb/Perl is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
19 # Catacomb/Perl is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with Catacomb/Perl; if not, write to the Free Software Foundation,
26 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 @cipher = qw(des desx des3
33 square rijndael rijndael192 rijndael256
38 @stream = qw(rc4 seal);
39 @hash = qw(md5 md4 md2 tiger has160
40 sha sha224 sha256 sha384 sha512
41 rmd128 rmd160 rmd256 rmd320
42 whirlpool whirlpool256);
46 if (!ref($x)) { return $x; }
47 elsif (ref($x) eq ARRAY) { return @$x }
48 else { die "bad ref"; }
57 foreach my $j (@$x) { foreach my $k (@y) { push(@x, $j.$k); } }
66 open OUT, "> $ARGV[0]" or die "couldn't write `$ARGV[0]': $!";
74 #include "catacomb-perl.h"
77 print OUT cross("#include <catacomb/", \@cipher, ".h>\n"), "\n";
78 print OUT cross("#include <catacomb/", \@cipher, "-",
79 [qw(counter ofb)], ".h>\n"), "\n";
80 print OUT cross("#include <catacomb/", \@hash, "-mgf.h>\n"), "\n";
84 const struct randtab mgftab[] = {
86 foreach my $i (@hash) { print OUT " { \"$i\", ${i}_mgfrand },\n"; }
91 const struct randtab ctrtab[] = {
93 foreach my $i (@cipher) { print OUT " { \"$i\", ${i}_counterrand },\n"; }
98 const struct randtab ofbtab[] = {
100 foreach my $i (@cipher) { print OUT " { \"$i\", ${i}_ofbrand },\n"; }
106 foreach my $i (@cipher) {
110 static void init_$i(void *ctx, const void *k, size_t ksz) {
111 ${i}_init(ctx, k, ksz);
113 static void eblk_$i(const void *ctx, const void *in, void *out) {
114 uint32 w[${I}_BLKSZ / 4];
115 BLKC_LOAD(${I}, w, in);
116 ${i}_eblk(ctx, w, w);
117 BLKC_STORE(${I}, out, w);
119 static void dblk_$i(const void *ctx, const void *in, void *out) {
120 uint32 w[${I}_BLKSZ / 4];
121 BLKC_LOAD(${I}, w, in);
122 ${i}_dblk(ctx, w, w);
123 BLKC_STORE(${I}, out, w);
125 static PRPClass prp_$i = {
127 ${i}_keysz, sizeof(${i}_ctx), ${I}_BLKSZ,
128 init_$i, eblk_$i, dblk_$i
135 PRPClass *const prptab[] = {
137 foreach my $i (@cipher) {
138 print OUT " &prp_$i,\n";
140 print OUT " 0\n};\n";
142 #----- That's all, folks ----------------------------------------------------