| 1 | #! /usr/bin/perl |
| 2 | |
| 3 | @cipher = qw(blowfish cast128 cast256 des des3 idea rc2 rc5 rijndael serpent |
| 4 | skipjack square tea twofish xtea); |
| 5 | @streams = qw(rc4 seal); |
| 6 | @hash = qw(md5 md4 md2 tiger |
| 7 | sha sha256 sha384 sha512 |
| 8 | rmd128 rmd160 rmd256 rmd320); |
| 9 | |
| 10 | sub enum { |
| 11 | $x = shift; |
| 12 | if (!ref($x)) { return $x; } |
| 13 | elsif (ref($x) eq ARRAY) { return @$x } |
| 14 | else { die "bad ref"; } |
| 15 | } |
| 16 | |
| 17 | sub cross { |
| 18 | my $x = []; |
| 19 | foreach my $i (@_) { |
| 20 | my @y = enum($i); |
| 21 | if (@$x) { |
| 22 | my @x = (); |
| 23 | foreach my $j (@$x) { foreach my $k (@y) { push(@x, $j.$k); } } |
| 24 | $x = \@x; |
| 25 | } else { |
| 26 | $x = \@y; |
| 27 | } |
| 28 | } |
| 29 | return @$x; |
| 30 | } |
| 31 | |
| 32 | print <<EOF; |
| 33 | /* -*-c-*- |
| 34 | * |
| 35 | * Cipher.xs [generated] |
| 36 | */ |
| 37 | |
| 38 | #include <assert.h> |
| 39 | |
| 40 | #include <EXTERN.h> |
| 41 | #include <perl.h> |
| 42 | #include <XSUB.h> |
| 43 | |
| 44 | #include <catacomb/gcipher.h> |
| 45 | |
| 46 | EOF |
| 47 | print cross("#include <catacomb/", \@cipher, "-", |
| 48 | [qw(ecb cbc cfb counter ofb)], ".h>\n"), "\n"; |
| 49 | print cross("#include <catacomb/", \@hash, ".h>\n"), "\n"; |
| 50 | print cross("#include <catacomb/", \@hash, "-", |
| 51 | [qw(mgf hmac)], ".h>\n"), "\n"; |