Rearrange the file tree.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 2 Jun 2013 11:54:11 +0000 (12:54 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 22 Jun 2013 14:52:06 +0000 (15:52 +0100)
It's actually, like, a tree now.  Testing is a bit wobbly: you really do
have to make the library before the tests will build.  I don't like
this, but the pieces of the library are all rather intertwined.

One small piece of unintertwining: `strongprime.c' no longer includes
`rand.h', which detaches the mathematical code from the symmetric-crypto
build system disaster.

Test files have been moved into `t/' directories as is now established
practice.

Also take the opportunity to eradicate the CVS `$Id...$' droppings.

921 files changed:
.gitignore
.links
Makefile.am
arena.c [deleted file]
arena.h [deleted file]
base/Makefile.am [new file with mode: 0644]
base/arena.c [new file with mode: 0644]
base/arena.h [new file with mode: 0644]
base/ct.c [moved from ct.c with 100% similarity]
base/ct.h [moved from ct.h with 100% similarity]
base/keysz-conv.c [moved from keysz-conv.c with 100% similarity]
base/keysz.c [new file with mode: 0644]
base/keysz.h [moved from keysz.h with 100% similarity]
base/lmem.c [new file with mode: 0644]
base/lmem.h [new file with mode: 0644]
base/paranoia.h [new file with mode: 0644]
bbs-fetch.c [deleted file]
bbs-gen.c [deleted file]
bbs-jump.c [deleted file]
bbs-rand.c [deleted file]
bbs.h [deleted file]
bin-gentab.awk [deleted file]
bintab.h [deleted file]
bintab.in [deleted file]
bitops.h [deleted file]
bittest.c [deleted file]
blkc.h [deleted file]
blowfish-mktab.c [deleted file]
blowfish.c [deleted file]
blowfish.h [deleted file]
buf.c [deleted file]
buf.h [deleted file]
build-setup
calc/ec2.cal
calc/ecp.cal
calc/gfx-test.cal
calc/gfx.cal
cast-base.h [deleted file]
cast-s.c [deleted file]
cast-sk.c [deleted file]
cast-tab.h [deleted file]
cast128.c [deleted file]
cast128.h [deleted file]
cast256.c [deleted file]
cast256.h [deleted file]
catcrypt.c [deleted file]
catsign.c [deleted file]
cbc-def.h [deleted file]
cbc.h [deleted file]
cc-enc.c [deleted file]
cc-kem.c [deleted file]
cc-list.c [deleted file]
cc-sig.c [deleted file]
cc-subcmd.c [deleted file]
cc.h [deleted file]
cfb-def.h [deleted file]
cfb.h [deleted file]
configure.ac
cookie.c [deleted file]
counter-def.h [deleted file]
counter.h [deleted file]
crc32.c [deleted file]
crc32.h [deleted file]
daftstory.h [deleted file]
des-base.c [deleted file]
des-base.h [deleted file]
des-mktab.c [deleted file]
des.c [deleted file]
des.h [deleted file]
des3.c [deleted file]
des3.h [deleted file]
desx-tab.h [deleted file]
desx.c [deleted file]
desx.h [deleted file]
dh-check.c [deleted file]
dh-fetch.c [deleted file]
dh-gen.c [deleted file]
dh-kcdsa.c [deleted file]
dh-limlee.c [deleted file]
dh-param.c [deleted file]
dh.h [deleted file]
dsa-check.c [deleted file]
dsa-gen.c [deleted file]
dsa-sign.c [deleted file]
dsa-verify.c [deleted file]
dsa.h [deleted file]
dsarand.c [deleted file]
dsarand.h [deleted file]
dsig.c [deleted file]
ec-bin.c [deleted file]
ec-exp.c [deleted file]
ec-exp.h [deleted file]
ec-fetch.c [deleted file]
ec-gentab.awk [deleted file]
ec-guts.h [deleted file]
ec-info.c [deleted file]
ec-keys.h [deleted file]
ec-prime.c [deleted file]
ec-raw.c [deleted file]
ec-raw.h [deleted file]
ec-test.c [deleted file]
ec-test.h [deleted file]
ec.c [deleted file]
ec.h [deleted file]
ecb-def.h [deleted file]
ecb.h [deleted file]
ectab.h [deleted file]
ectab.in [deleted file]
exp.c [deleted file]
exp.h [deleted file]
f-binpoly.c [deleted file]
f-niceprime.c [deleted file]
f-prime.c [deleted file]
factorial.c [deleted file]
fibrand.c [deleted file]
fibrand.h [deleted file]
field-exp.c [deleted file]
field-exp.h [deleted file]
field-guts.h [deleted file]
field-parse.c [deleted file]
field.c [deleted file]
field.h [deleted file]
fipstest.c [deleted file]
fipstest.h [deleted file]
g-bin.c [deleted file]
g-ec.c [deleted file]
g-prime.c [deleted file]
gcipher.h [deleted file]
gdsa.c [deleted file]
gdsa.h [deleted file]
genlimits.c [deleted file]
genprimes.c [deleted file]
gf-arith.c [deleted file]
gf-exp.c [deleted file]
gf-exp.h [deleted file]
gf-gcd.c [deleted file]
gf.h [deleted file]
gfn.c [deleted file]
gfn.h [deleted file]
gfreduce-exp.h [deleted file]
gfreduce.c [deleted file]
gfreduce.h [deleted file]
gfshare-mktab.c [deleted file]
gfshare.c [deleted file]
gfshare.h [deleted file]
gfx-kmul.c [deleted file]
gfx-sqr-mktab.c [deleted file]
gfx-sqr.c [deleted file]
gfx.c [deleted file]
gfx.h [deleted file]
ghash-def.h [deleted file]
ghash.h [deleted file]
gkcdsa.c [deleted file]
gkcdsa.h [deleted file]
gmac.h [deleted file]
grand.c [deleted file]
grand.h [deleted file]
group-dstr.c [deleted file]
group-exp.c [deleted file]
group-exp.h [deleted file]
group-file.c [deleted file]
group-guts.h [deleted file]
group-parse.c [deleted file]
group-stdops.c [deleted file]
group-string.c [deleted file]
group-test.c [deleted file]
group.h [deleted file]
has160.c [deleted file]
has160.h [deleted file]
hash.h [deleted file]
hashsum.c [deleted file]
hmac-def.h [deleted file]
hmac.h [deleted file]
idea.c [deleted file]
idea.h [deleted file]
karatsuba.h [deleted file]
key-attr.c [deleted file]
key-binary.c [deleted file]
key-data.c [deleted file]
key-data.h [deleted file]
key-error.c [deleted file]
key-error.h [deleted file]
key-fetch.c [deleted file]
key-file.c [deleted file]
key-flags.c [deleted file]
key-io.c [deleted file]
key-misc.c [deleted file]
key-moan.c [deleted file]
key-pack.c [deleted file]
key-pass.c [deleted file]
key-text.c [deleted file]
key.h [deleted file]
key/Makefile.am [new file with mode: 0644]
key/key-attr.c [new file with mode: 0644]
key/key-binary.c [new file with mode: 0644]
key/key-data.c [new file with mode: 0644]
key/key-data.h [new file with mode: 0644]
key/key-error.c [new file with mode: 0644]
key/key-error.h [new file with mode: 0644]
key/key-fetch.c [new file with mode: 0644]
key/key-file.c [new file with mode: 0644]
key/key-flags.c [new file with mode: 0644]
key/key-io.c [new file with mode: 0644]
key/key-misc.c [new file with mode: 0644]
key/key-moan.c [new file with mode: 0644]
key/key-pack.c [new file with mode: 0644]
key/key-pass.c [new file with mode: 0644]
key/key-text.c [new file with mode: 0644]
key/key.h [new file with mode: 0644]
key/passphrase.c [new file with mode: 0644]
key/passphrase.h [new file with mode: 0644]
key/pixie-common.c [new file with mode: 0644]
key/pixie.h [new file with mode: 0644]
keycheck-mp.c [deleted file]
keycheck-report.c [deleted file]
keycheck.c [deleted file]
keycheck.h [deleted file]
keysz.c [deleted file]
keyutil.c [deleted file]
lcrand.c [deleted file]
lcrand.h [deleted file]
limlee.c [deleted file]
limlee.h [deleted file]
lmem.c [deleted file]
lmem.h [deleted file]
manual/catacomb.tex
mars-mktab.c [deleted file]
mars.c [deleted file]
mars.h [deleted file]
math/Makefile.am [new file with mode: 0644]
math/bin-gentab.awk [new file with mode: 0755]
math/bintab.h [new file with mode: 0644]
math/bintab.in [new file with mode: 0644]
math/bitops.h [new file with mode: 0644]
math/bittest.c [new file with mode: 0644]
math/buf.c [new file with mode: 0644]
math/buf.h [new file with mode: 0644]
math/ec-bin.c [new file with mode: 0644]
math/ec-exp.c [new file with mode: 0644]
math/ec-exp.h [new file with mode: 0644]
math/ec-fetch.c [new file with mode: 0644]
math/ec-gentab.awk [new file with mode: 0755]
math/ec-guts.h [new file with mode: 0644]
math/ec-info.c [new file with mode: 0644]
math/ec-keys.h [new file with mode: 0644]
math/ec-prime.c [new file with mode: 0644]
math/ec-raw.c [new file with mode: 0644]
math/ec-raw.h [new file with mode: 0644]
math/ec-test.c [new file with mode: 0644]
math/ec-test.h [new file with mode: 0644]
math/ec.c [new file with mode: 0644]
math/ec.h [new file with mode: 0644]
math/ectab.h [new file with mode: 0644]
math/ectab.in [new file with mode: 0644]
math/exp.c [new file with mode: 0644]
math/exp.h [new file with mode: 0644]
math/f-binpoly.c [new file with mode: 0644]
math/f-niceprime.c [new file with mode: 0644]
math/f-prime.c [new file with mode: 0644]
math/field-exp.c [new file with mode: 0644]
math/field-exp.h [new file with mode: 0644]
math/field-guts.h [new file with mode: 0644]
math/field-parse.c [new file with mode: 0644]
math/field.c [new file with mode: 0644]
math/field.h [new file with mode: 0644]
math/g-bin.c [new file with mode: 0644]
math/g-ec.c [new file with mode: 0644]
math/g-prime.c [new file with mode: 0644]
math/genlimits.c [new file with mode: 0644]
math/genprimes.c [new file with mode: 0644]
math/genwheel.c [moved from genwheel.c with 100% similarity]
math/gf-arith.c [new file with mode: 0644]
math/gf-exp.c [new file with mode: 0644]
math/gf-exp.h [new file with mode: 0644]
math/gf-gcd.c [new file with mode: 0644]
math/gf.h [new file with mode: 0644]
math/gfn.c [new file with mode: 0644]
math/gfn.h [new file with mode: 0644]
math/gfreduce-exp.h [new file with mode: 0644]
math/gfreduce.c [new file with mode: 0644]
math/gfreduce.h [new file with mode: 0644]
math/gfx-kmul.c [new file with mode: 0644]
math/gfx-sqr-mktab.c [new file with mode: 0644]
math/gfx-sqr.c [new file with mode: 0644]
math/gfx.c [new file with mode: 0644]
math/gfx.h [new file with mode: 0644]
math/group-dstr.c [new file with mode: 0644]
math/group-exp.c [new file with mode: 0644]
math/group-exp.h [new file with mode: 0644]
math/group-file.c [new file with mode: 0644]
math/group-guts.h [new file with mode: 0644]
math/group-parse.c [new file with mode: 0644]
math/group-stdops.c [new file with mode: 0644]
math/group-string.c [new file with mode: 0644]
math/group-test.c [new file with mode: 0644]
math/group.h [new file with mode: 0644]
math/karatsuba.h [new file with mode: 0644]
math/limlee.c [new file with mode: 0644]
math/limlee.h [new file with mode: 0644]
math/mp-arith.c [new file with mode: 0644]
math/mp-const.c [new file with mode: 0644]
math/mp-exp.c [new file with mode: 0644]
math/mp-exp.h [new file with mode: 0644]
math/mp-fibonacci.c [new file with mode: 0644]
math/mp-fibonacci.h [moved from mp-fibonacci.h with 100% similarity]
math/mp-gcd.c [new file with mode: 0644]
math/mp-io.c [new file with mode: 0644]
math/mp-jacobi.c [new file with mode: 0644]
math/mp-mem.c [new file with mode: 0644]
math/mp-misc.c [new file with mode: 0644]
math/mp-modexp.c [new file with mode: 0644]
math/mp-modsqrt.c [new file with mode: 0644]
math/mp-sqrt.c [new file with mode: 0644]
math/mp-test.c [new file with mode: 0644]
math/mp.h [new file with mode: 0644]
math/mparena.c [new file with mode: 0644]
math/mparena.h [new file with mode: 0644]
math/mpbarrett-exp.c [new file with mode: 0644]
math/mpbarrett-exp.h [new file with mode: 0644]
math/mpbarrett-mexp.c [new file with mode: 0644]
math/mpbarrett.c [new file with mode: 0644]
math/mpbarrett.h [new file with mode: 0644]
math/mpcrt.c [new file with mode: 0644]
math/mpcrt.h [new file with mode: 0644]
math/mpdump.c [new file with mode: 0644]
math/mpint.c [new file with mode: 0644]
math/mpint.h [new file with mode: 0644]
math/mpmont-exp.c [new file with mode: 0644]
math/mpmont-exp.h [new file with mode: 0644]
math/mpmont-mexp.c [new file with mode: 0644]
math/mpmont.c [new file with mode: 0644]
math/mpmont.h [new file with mode: 0644]
math/mpmul.c [new file with mode: 0644]
math/mpmul.h [new file with mode: 0644]
math/mprand.c [new file with mode: 0644]
math/mprand.h [new file with mode: 0644]
math/mpreduce-exp.h [new file with mode: 0644]
math/mpreduce.c [new file with mode: 0644]
math/mpreduce.h [new file with mode: 0644]
math/mpscan.c [new file with mode: 0644]
math/mpscan.h [new file with mode: 0644]
math/mptext-dstr.c [new file with mode: 0644]
math/mptext-file.c [new file with mode: 0644]
math/mptext-len.c [new file with mode: 0644]
math/mptext-string.c [new file with mode: 0644]
math/mptext.c [new file with mode: 0644]
math/mptext.h [new file with mode: 0644]
math/mptypes.c [new file with mode: 0644]
math/mpw.h [new file with mode: 0644]
math/mpx-kmul.c [new file with mode: 0644]
math/mpx-ksqr.c [new file with mode: 0644]
math/mpx.c [new file with mode: 0644]
math/mpx.h [new file with mode: 0644]
math/p-gentab.awk [new file with mode: 0755]
math/pfilt.c [new file with mode: 0644]
math/pfilt.h [new file with mode: 0644]
math/pgen-gcd.c [new file with mode: 0644]
math/pgen-simul.c [new file with mode: 0644]
math/pgen-stdev.c [new file with mode: 0644]
math/pgen.c [new file with mode: 0644]
math/pgen.h [new file with mode: 0644]
math/prim.c [new file with mode: 0644]
math/prim.h [new file with mode: 0644]
math/primeiter.c [new file with mode: 0644]
math/primeiter.h [moved from primeiter.h with 100% similarity]
math/ptab.h [new file with mode: 0644]
math/ptab.in [new file with mode: 0644]
math/qdparse.c [new file with mode: 0644]
math/qdparse.h [new file with mode: 0644]
math/rabin.c [new file with mode: 0644]
math/rabin.h [new file with mode: 0644]
math/rho.c [new file with mode: 0644]
math/rho.h [new file with mode: 0644]
math/strongprime.c [new file with mode: 0644]
math/strongprime.h [new file with mode: 0644]
math/t/ec [new file with mode: 0644]
math/t/gf [new file with mode: 0644]
math/t/gfn [new file with mode: 0644]
math/t/gfreduce [new file with mode: 0644]
math/t/gfx [new file with mode: 0644]
math/t/group [new file with mode: 0644]
math/t/mp [new file with mode: 0644]
math/t/mpbarrett [new file with mode: 0644]
math/t/mpcrt [new file with mode: 0644]
math/t/mpint [new file with mode: 0644]
math/t/mpmont [new file with mode: 0644]
math/t/mpreduce [new file with mode: 0644]
math/t/mptext [new file with mode: 0644]
math/t/mpx [new file with mode: 0644]
math/t/mpx-gen [new file with mode: 0755]
math/t/pgen [new file with mode: 0644]
maurer.c [deleted file]
maurer.h [deleted file]
md2-tab.h [deleted file]
md2.c [deleted file]
md2.h [deleted file]
md4.c [deleted file]
md4.h [deleted file]
md5.c [deleted file]
md5.h [deleted file]
mgf-def.h [deleted file]
mgf.h [deleted file]
misc/Makefile.am [new file with mode: 0644]
misc/gfshare-mktab.c [new file with mode: 0644]
misc/gfshare.c [new file with mode: 0644]
misc/gfshare.h [new file with mode: 0644]
misc/share.c [new file with mode: 0644]
misc/share.h [new file with mode: 0644]
mkpgroups [deleted file]
mkphrase.c [deleted file]
modes.am.in [deleted file]
mp-arith.c [deleted file]
mp-const.c [deleted file]
mp-exp.c [deleted file]
mp-exp.h [deleted file]
mp-fibonacci.c [deleted file]
mp-gcd.c [deleted file]
mp-io.c [deleted file]
mp-jacobi.c [deleted file]
mp-mem.c [deleted file]
mp-misc.c [deleted file]
mp-modexp.c [deleted file]
mp-modsqrt.c [deleted file]
mp-sqrt.c [deleted file]
mp-test.c [deleted file]
mp.h [deleted file]
mparena.c [deleted file]
mparena.h [deleted file]
mpbarrett-exp.c [deleted file]
mpbarrett-exp.h [deleted file]
mpbarrett-mexp.c [deleted file]
mpbarrett.c [deleted file]
mpbarrett.h [deleted file]
mpcrt.c [deleted file]
mpcrt.h [deleted file]
mpdump.c [deleted file]
mpint.c [deleted file]
mpint.h [deleted file]
mpmont-exp.c [deleted file]
mpmont-exp.h [deleted file]
mpmont-mexp.c [deleted file]
mpmont.c [deleted file]
mpmont.h [deleted file]
mpmul.c [deleted file]
mpmul.h [deleted file]
mprand.c [deleted file]
mprand.h [deleted file]
mpreduce-exp.h [deleted file]
mpreduce.c [deleted file]
mpreduce.h [deleted file]
mpscan.c [deleted file]
mpscan.h [deleted file]
mptext-dstr.c [deleted file]
mptext-file.c [deleted file]
mptext-len.c [deleted file]
mptext-string.c [deleted file]
mptext.c [deleted file]
mptext.h [deleted file]
mptypes.c [deleted file]
mpw.h [deleted file]
mpx-kmul.c [deleted file]
mpx-ksqr.c [deleted file]
mpx.c [deleted file]
mpx.h [deleted file]
noekeon.c [deleted file]
noekeon.h [deleted file]
noise.c [deleted file]
noise.h [deleted file]
oaep.c [deleted file]
ofb-def.h [deleted file]
ofb.h [deleted file]
p-gentab.awk [deleted file]
papers/rand.tex
paranoia.h [deleted file]
passphrase.c [deleted file]
passphrase.h [deleted file]
pcheck.pl [deleted file]
perftest.c [deleted file]
pfilt.c [deleted file]
pfilt.h [deleted file]
pgen-gcd.c [deleted file]
pgen-simul.c [deleted file]
pgen-stdev.c [deleted file]
pgen.c [deleted file]
pgen.h [deleted file]
pixie-common.c [deleted file]
pixie.c [deleted file]
pixie.h [deleted file]
pkcs1.c [deleted file]
prim.c [deleted file]
prim.h [deleted file]
primeiter.c [deleted file]
progs/Makefile.am [new file with mode: 0644]
progs/catcrypt.1 [moved from catcrypt.1 with 100% similarity]
progs/catcrypt.c [new file with mode: 0644]
progs/catsign.1 [moved from catsign.1 with 100% similarity]
progs/catsign.c [new file with mode: 0644]
progs/cc-enc.c [new file with mode: 0644]
progs/cc-hash.c [moved from cc-hash.c with 100% similarity]
progs/cc-kem.c [new file with mode: 0644]
progs/cc-list.c [new file with mode: 0644]
progs/cc-progress.c [moved from cc-progress.c with 100% similarity]
progs/cc-sig.c [new file with mode: 0644]
progs/cc-subcmd.c [new file with mode: 0644]
progs/cc.h [new file with mode: 0644]
progs/cookie.1 [moved from cookie.1 with 100% similarity]
progs/cookie.c [new file with mode: 0644]
progs/dsig.1 [moved from dsig.1 with 100% similarity]
progs/dsig.c [new file with mode: 0644]
progs/factorial.c [new file with mode: 0644]
progs/fibonacci.c [moved from fibonacci.c with 100% similarity]
progs/hashsum.1 [moved from hashsum.1 with 100% similarity]
progs/hashsum.c [new file with mode: 0644]
progs/key.1 [moved from key.1 with 100% similarity]
progs/key.c [new file with mode: 0644]
progs/keyring.5 [moved from keyring.5 with 100% similarity]
progs/mkphrase.1 [moved from mkphrase.1 with 100% similarity]
progs/mkphrase.c [new file with mode: 0644]
progs/perftest.c [new file with mode: 0644]
progs/pixie.1 [moved from pixie.1 with 100% similarity]
progs/pixie.c [new file with mode: 0644]
progs/rspit.c [new file with mode: 0644]
progs/xpixie [moved from xpixie with 100% similarity]
pss.c [deleted file]
ptab.h [deleted file]
ptab.in [deleted file]
pub/Makefile.am [new file with mode: 0644]
pub/bbs-fetch.c [new file with mode: 0644]
pub/bbs-gen.c [new file with mode: 0644]
pub/bbs-jump.c [new file with mode: 0644]
pub/bbs-rand.c [new file with mode: 0644]
pub/bbs.h [new file with mode: 0644]
pub/dh-check.c [new file with mode: 0644]
pub/dh-fetch.c [new file with mode: 0644]
pub/dh-gen.c [new file with mode: 0644]
pub/dh-kcdsa.c [new file with mode: 0644]
pub/dh-limlee.c [new file with mode: 0644]
pub/dh-param.c [new file with mode: 0644]
pub/dh.h [new file with mode: 0644]
pub/dsa-check.c [new file with mode: 0644]
pub/dsa-gen.c [new file with mode: 0644]
pub/dsa-misc.c [moved from dsa-misc.c with 100% similarity]
pub/dsa-sign.c [new file with mode: 0644]
pub/dsa-verify.c [new file with mode: 0644]
pub/dsa.h [new file with mode: 0644]
pub/gdsa.c [new file with mode: 0644]
pub/gdsa.h [new file with mode: 0644]
pub/gkcdsa.c [new file with mode: 0644]
pub/gkcdsa.h [new file with mode: 0644]
pub/keycheck-mp.c [new file with mode: 0644]
pub/keycheck-report.c [new file with mode: 0644]
pub/keycheck.c [new file with mode: 0644]
pub/keycheck.h [new file with mode: 0644]
pub/oaep.c [new file with mode: 0644]
pub/pkcs1.c [new file with mode: 0644]
pub/pss.c [new file with mode: 0644]
pub/rsa-fetch.c [new file with mode: 0644]
pub/rsa-gen.c [new file with mode: 0644]
pub/rsa-priv.c [new file with mode: 0644]
pub/rsa-pub.c [new file with mode: 0644]
pub/rsa-recover.c [new file with mode: 0644]
pub/rsa-test.c [new file with mode: 0644]
pub/rsa.h [new file with mode: 0644]
pub/t/bbs [new file with mode: 0644]
pub/t/dsa [new file with mode: 0644]
pub/t/gdsa [new file with mode: 0644]
pub/t/gkcdsa [new file with mode: 0644]
pub/t/rsa [new file with mode: 0644]
qdparse.c [deleted file]
qdparse.h [deleted file]
rabin.c [deleted file]
rabin.h [deleted file]
rand.c [deleted file]
rand.h [deleted file]
rand/Makefile.am [new file with mode: 0644]
rand/dsarand.c [new file with mode: 0644]
rand/dsarand.h [new file with mode: 0644]
rand/fibrand.c [new file with mode: 0644]
rand/fibrand.h [new file with mode: 0644]
rand/fipstest.c [new file with mode: 0644]
rand/fipstest.h [new file with mode: 0644]
rand/grand.c [new file with mode: 0644]
rand/grand.h [new file with mode: 0644]
rand/lcrand.c [new file with mode: 0644]
rand/lcrand.h [new file with mode: 0644]
rand/maurer.c [new file with mode: 0644]
rand/maurer.h [new file with mode: 0644]
rand/noise.c [new file with mode: 0644]
rand/noise.h [new file with mode: 0644]
rand/rand.c [new file with mode: 0644]
rand/rand.h [new file with mode: 0644]
rand/sslprf.c [new file with mode: 0644]
rand/sslprf.h [new file with mode: 0644]
rand/t/lcrand [new file with mode: 0644]
rand/t/sslprf [new file with mode: 0644]
rand/t/tlsprf [new file with mode: 0644]
rand/tlsprf.c [new file with mode: 0644]
rand/tlsprf.h [new file with mode: 0644]
rc2-tab.h [deleted file]
rc2.c [deleted file]
rc2.h [deleted file]
rc4.c [deleted file]
rc4.h [deleted file]
rc5.c [deleted file]
rc5.h [deleted file]
rho.c [deleted file]
rho.h [deleted file]
rijndael-base.c [deleted file]
rijndael-base.h [deleted file]
rijndael-mktab.c [deleted file]
rijndael.c [deleted file]
rijndael.h [deleted file]
rijndael192.c [deleted file]
rijndael192.h [deleted file]
rijndael256.c [deleted file]
rijndael256.h [deleted file]
rmd128.c [deleted file]
rmd128.h [deleted file]
rmd160.c [deleted file]
rmd160.h [deleted file]
rmd256.c [deleted file]
rmd256.h [deleted file]
rmd320.c [deleted file]
rmd320.h [deleted file]
rsa-fetch.c [deleted file]
rsa-gen.c [deleted file]
rsa-priv.c [deleted file]
rsa-pub.c [deleted file]
rsa-recover.c [deleted file]
rsa-test.c [deleted file]
rsa.h [deleted file]
rspit.c [deleted file]
safer-mktab.c [deleted file]
safer.c [deleted file]
safer.h [deleted file]
safersk.c [deleted file]
safersk.h [deleted file]
seal.c [deleted file]
seal.h [deleted file]
serpent-check.c [deleted file]
serpent-sbox.h [deleted file]
serpent.c [deleted file]
serpent.h [deleted file]
sha.c [deleted file]
sha.h [deleted file]
sha224.c [deleted file]
sha224.h [deleted file]
sha256.c [deleted file]
sha256.h [deleted file]
sha384.c [deleted file]
sha384.h [deleted file]
sha512.c [deleted file]
sha512.h [deleted file]
share.c [deleted file]
share.h [deleted file]
skipjack-tab.h [deleted file]
skipjack.c [deleted file]
skipjack.h [deleted file]
square-mktab.c [deleted file]
square.c [deleted file]
square.h [deleted file]
sslprf.c [deleted file]
sslprf.h [deleted file]
strongprime.c [deleted file]
strongprime.h [deleted file]
symm/Makefile.am [new file with mode: 0644]
symm/aes-trans [moved from tests/aes-trans with 100% similarity]
symm/blkc.h [new file with mode: 0644]
symm/blowfish-mktab.c [new file with mode: 0644]
symm/blowfish.c [new file with mode: 0644]
symm/blowfish.h [new file with mode: 0644]
symm/cast-base.h [new file with mode: 0644]
symm/cast-s.c [new file with mode: 0644]
symm/cast-sk.c [new file with mode: 0644]
symm/cast-tab.h [new file with mode: 0644]
symm/cast128.c [new file with mode: 0644]
symm/cast128.h [new file with mode: 0644]
symm/cast256.c [new file with mode: 0644]
symm/cast256.h [new file with mode: 0644]
symm/cbc-def.h [new file with mode: 0644]
symm/cbc.h [new file with mode: 0644]
symm/cfb-def.h [new file with mode: 0644]
symm/cfb.h [new file with mode: 0644]
symm/counter-def.h [new file with mode: 0644]
symm/counter.h [new file with mode: 0644]
symm/crc32.c [new file with mode: 0644]
symm/crc32.h [new file with mode: 0644]
symm/daftstory.h [new file with mode: 0644]
symm/des-base.c [new file with mode: 0644]
symm/des-base.h [new file with mode: 0644]
symm/des-mktab.c [new file with mode: 0644]
symm/des.c [new file with mode: 0644]
symm/des.h [new file with mode: 0644]
symm/des3.c [new file with mode: 0644]
symm/des3.h [new file with mode: 0644]
symm/desx-tab.h [new file with mode: 0644]
symm/desx.c [new file with mode: 0644]
symm/desx.h [new file with mode: 0644]
symm/ecb-def.h [new file with mode: 0644]
symm/ecb.h [new file with mode: 0644]
symm/gcipher.h [new file with mode: 0644]
symm/ghash-def.h [new file with mode: 0644]
symm/ghash.h [new file with mode: 0644]
symm/gmac.h [new file with mode: 0644]
symm/gthingtab.c.in [moved from gthingtab.c.in with 100% similarity]
symm/has160.c [new file with mode: 0644]
symm/has160.h [new file with mode: 0644]
symm/hash.h [new file with mode: 0644]
symm/hmac-def.h [new file with mode: 0644]
symm/hmac.h [new file with mode: 0644]
symm/idea.c [new file with mode: 0644]
symm/idea.h [new file with mode: 0644]
symm/mars-mktab.c [new file with mode: 0644]
symm/mars.c [new file with mode: 0644]
symm/mars.h [new file with mode: 0644]
symm/md2-tab.h [new file with mode: 0644]
symm/md2.c [new file with mode: 0644]
symm/md2.h [new file with mode: 0644]
symm/md4.c [new file with mode: 0644]
symm/md4.h [new file with mode: 0644]
symm/md5.c [new file with mode: 0644]
symm/md5.h [new file with mode: 0644]
symm/mgf-def.h [new file with mode: 0644]
symm/mgf.h [new file with mode: 0644]
symm/mode.c.in [moved from mode.c.in with 100% similarity]
symm/mode.h.in [moved from mode.h.in with 100% similarity]
symm/modes.am.in [new file with mode: 0644]
symm/multigen [moved from multigen with 100% similarity]
symm/noekeon.c [new file with mode: 0644]
symm/noekeon.h [new file with mode: 0644]
symm/ofb-def.h [new file with mode: 0644]
symm/ofb.h [new file with mode: 0644]
symm/rc2-tab.h [new file with mode: 0644]
symm/rc2.c [new file with mode: 0644]
symm/rc2.h [new file with mode: 0644]
symm/rc4.c [new file with mode: 0644]
symm/rc4.h [new file with mode: 0644]
symm/rc5.c [new file with mode: 0644]
symm/rc5.h [new file with mode: 0644]
symm/rijndael-base.c [new file with mode: 0644]
symm/rijndael-base.h [new file with mode: 0644]
symm/rijndael-mktab.c [new file with mode: 0644]
symm/rijndael.c [new file with mode: 0644]
symm/rijndael.h [new file with mode: 0644]
symm/rijndael192.c [new file with mode: 0644]
symm/rijndael192.h [new file with mode: 0644]
symm/rijndael256.c [new file with mode: 0644]
symm/rijndael256.h [new file with mode: 0644]
symm/rmd128.c [new file with mode: 0644]
symm/rmd128.h [new file with mode: 0644]
symm/rmd160.c [new file with mode: 0644]
symm/rmd160.h [new file with mode: 0644]
symm/rmd256.c [new file with mode: 0644]
symm/rmd256.h [new file with mode: 0644]
symm/rmd320.c [new file with mode: 0644]
symm/rmd320.h [new file with mode: 0644]
symm/safer-mktab.c [new file with mode: 0644]
symm/safer.c [new file with mode: 0644]
symm/safer.h [new file with mode: 0644]
symm/safersk.c [new file with mode: 0644]
symm/safersk.h [new file with mode: 0644]
symm/seal.c [new file with mode: 0644]
symm/seal.h [new file with mode: 0644]
symm/serpent-check.c [new file with mode: 0644]
symm/serpent-sbox.h [new file with mode: 0644]
symm/serpent.c [new file with mode: 0644]
symm/serpent.h [new file with mode: 0644]
symm/sha.c [new file with mode: 0644]
symm/sha.h [new file with mode: 0644]
symm/sha224.c [new file with mode: 0644]
symm/sha224.h [new file with mode: 0644]
symm/sha256.c [new file with mode: 0644]
symm/sha256.h [new file with mode: 0644]
symm/sha384.c [new file with mode: 0644]
symm/sha384.h [new file with mode: 0644]
symm/sha512.c [new file with mode: 0644]
symm/sha512.h [new file with mode: 0644]
symm/skipjack-tab.h [new file with mode: 0644]
symm/skipjack.c [new file with mode: 0644]
symm/skipjack.h [new file with mode: 0644]
symm/square-mktab.c [new file with mode: 0644]
symm/square.c [new file with mode: 0644]
symm/square.h [new file with mode: 0644]
symm/t/.gitignore [new file with mode: 0644]
symm/t/blowfish [new file with mode: 0644]
symm/t/cast128 [new file with mode: 0644]
symm/t/cast256.aes [moved from tests/cast256.aes with 100% similarity]
symm/t/des [new file with mode: 0644]
symm/t/des3 [new file with mode: 0644]
symm/t/desx [new file with mode: 0644]
symm/t/has160 [new file with mode: 0644]
symm/t/idea [new file with mode: 0644]
symm/t/mars.aes [moved from tests/mars.aes with 100% similarity]
symm/t/md2 [new file with mode: 0644]
symm/t/md4 [new file with mode: 0644]
symm/t/md5 [new file with mode: 0644]
symm/t/noekeon [new file with mode: 0644]
symm/t/rc2 [new file with mode: 0644]
symm/t/rc4 [new file with mode: 0644]
symm/t/rc5 [new file with mode: 0644]
symm/t/rijndael.aes [moved from tests/rijndael.aes with 100% similarity]
symm/t/rijndael192 [new file with mode: 0644]
symm/t/rijndael256 [new file with mode: 0644]
symm/t/rmd128 [new file with mode: 0644]
symm/t/rmd160 [new file with mode: 0644]
symm/t/rmd256 [new file with mode: 0644]
symm/t/rmd320 [new file with mode: 0644]
symm/t/safer [new file with mode: 0644]
symm/t/safersk [new file with mode: 0644]
symm/t/seal [new file with mode: 0644]
symm/t/serpent.aes [moved from tests/serpent.aes with 100% similarity]
symm/t/sha [new file with mode: 0644]
symm/t/sha224 [new file with mode: 0644]
symm/t/sha256 [new file with mode: 0644]
symm/t/sha384 [new file with mode: 0644]
symm/t/sha512 [new file with mode: 0644]
symm/t/skipjack [new file with mode: 0644]
symm/t/square [new file with mode: 0644]
symm/t/tea [new file with mode: 0644]
symm/t/tea-test.c [moved from tests/tea-test.c with 100% similarity]
symm/t/tiger [new file with mode: 0644]
symm/t/twofish.aes [moved from tests/twofish.aes with 100% similarity]
symm/t/whirlpool [new file with mode: 0644]
symm/t/whirlpool256 [new file with mode: 0644]
symm/t/xtea [new file with mode: 0644]
symm/t/xtea-test.c [moved from tests/xtea-test.c with 100% similarity]
symm/tea.c [new file with mode: 0644]
symm/tea.h [new file with mode: 0644]
symm/tiger-base.h [new file with mode: 0644]
symm/tiger-mktab.c [new file with mode: 0644]
symm/tiger.c [new file with mode: 0644]
symm/tiger.h [new file with mode: 0644]
symm/twofish-mktab.c [new file with mode: 0644]
symm/twofish.c [new file with mode: 0644]
symm/twofish.h [new file with mode: 0644]
symm/whirlpool-mktab.c [new file with mode: 0644]
symm/whirlpool.c [new file with mode: 0644]
symm/whirlpool.h [new file with mode: 0644]
symm/whirlpool256.c [new file with mode: 0644]
symm/whirlpool256.h [new file with mode: 0644]
symm/xtea.c [new file with mode: 0644]
symm/xtea.h [new file with mode: 0644]
tea.c [deleted file]
tea.h [deleted file]
tests/.gitignore [deleted file]
tests/bbs [deleted file]
tests/blowfish [deleted file]
tests/cast128 [deleted file]
tests/des [deleted file]
tests/des3 [deleted file]
tests/desx [deleted file]
tests/dsa [deleted file]
tests/ec [deleted file]
tests/gdsa [deleted file]
tests/gf [deleted file]
tests/gfn [deleted file]
tests/gfreduce [deleted file]
tests/gfx [deleted file]
tests/gkcdsa [deleted file]
tests/group [deleted file]
tests/has160 [deleted file]
tests/idea [deleted file]
tests/lcrand [deleted file]
tests/md2 [deleted file]
tests/md4 [deleted file]
tests/md5 [deleted file]
tests/mp [deleted file]
tests/mpbarrett [deleted file]
tests/mpcrt [deleted file]
tests/mpint [deleted file]
tests/mpmont [deleted file]
tests/mpreduce [deleted file]
tests/mptext [deleted file]
tests/mpx [deleted file]
tests/mpx-gen [deleted file]
tests/noekeon [deleted file]
tests/pgen [deleted file]
tests/rc2 [deleted file]
tests/rc4 [deleted file]
tests/rc5 [deleted file]
tests/rijndael192 [deleted file]
tests/rijndael256 [deleted file]
tests/rmd128 [deleted file]
tests/rmd160 [deleted file]
tests/rmd256 [deleted file]
tests/rmd320 [deleted file]
tests/rsa [deleted file]
tests/safer [deleted file]
tests/safersk [deleted file]
tests/seal [deleted file]
tests/sha [deleted file]
tests/sha224 [deleted file]
tests/sha256 [deleted file]
tests/sha384 [deleted file]
tests/sha512 [deleted file]
tests/skipjack [deleted file]
tests/square [deleted file]
tests/sslprf [deleted file]
tests/tea [deleted file]
tests/tiger [deleted file]
tests/tlsprf [deleted file]
tests/whirlpool [deleted file]
tests/whirlpool256 [deleted file]
tests/xtea [deleted file]
tiger-base.h [deleted file]
tiger-mktab.c [deleted file]
tiger.c [deleted file]
tiger.h [deleted file]
tlsprf.c [deleted file]
tlsprf.h [deleted file]
twofish-mktab.c [deleted file]
twofish.c [deleted file]
twofish.h [deleted file]
vars.am [new file with mode: 0644]
whirlpool-mktab.c [deleted file]
whirlpool.c [deleted file]
whirlpool.h [deleted file]
whirlpool256.c [deleted file]
whirlpool256.h [deleted file]
xtea.c [deleted file]
xtea.h [deleted file]

index 41bc25f..e849112 100644 (file)
@@ -1,17 +1,11 @@
-KEYRING
 Makefile.in
 aclocal.m4
 configure
 COPYING.LIB
 autom4te.cache
 config
-getdate.h
-getdate.y
-prof
-tinymp
-*.kr
-*.kr.old
-ylwrap
-modes.am
-auto-version
-confsubst
+progs/getdate.h
+progs/getdate.y
+symm/modes.am
+*.t
+*.to
diff --git a/.links b/.links
index 161dfb0..a6772a4 100644 (file)
--- a/.links
+++ b/.links
@@ -1,5 +1,5 @@
 COPYING.LIB
-getdate.y
-getdate.h
 config/auto-version
 config/confsubst
+progs/getdate.h
+progs/getdate.y
index 11251fa..4cacfbe 100644 (file)
 ### Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 ### MA 02111-1307, USA.
 
-###--------------------------------------------------------------------------
-### Miscellaneous useful definitions.
-
-## Some convenient abbreviations for file suffixes.
-e                       = $(EXEEXT)
-o                       = $(OBJEXT)
-t                       = t$e
-
-## Installation directories.
-archincludedir          = $(pkglibdir)/include
-
-###--------------------------------------------------------------------------
-### Initial values of common variables.
+include $(top_srcdir)/vars.am
 
 SUBDIRS                         =
 
-EXTRA_DIST              =
-CLEANFILES              =
-DISTCLEANFILES          =
-MAINTAINERCLEANFILES    =
-SUFFIXES                =
-TESTS                   =
-BUILT_SOURCES           =
-
-bin_PROGRAMS            =
-noinst_PROGRAMS                 =
-lib_LTLIBRARIES                 =
-noinst_LTLIBRARIES      =
-pkginclude_HEADERS      =
-nodist_pkginclude_HEADERS =
-archinclude_HEADERS     =
-nodist_archinclude_HEADERS =
-dist_man_MANS           =
-
-###--------------------------------------------------------------------------
-### Standard configuration substitutions.
-
-## Substitute tags in files.
-confsubst = $(top_srcdir)/config/confsubst
-EXTRA_DIST             += config/confsubst
-
-SUBSTITUTIONS = \
-               prefix=$(prefix) exec_prefix=$(exec_prefix) \
-               libdir=$(libdir) includedir=$(includedir) \
-               PACKAGE=$(PACKAGE) VERSION=$(VERSION) \
-               CATACOMB_LIBS="$(CATACOMB_LIBS)"
-
-V_SUBST = $(V_SUBST_$(V))
-V_SUBST_ = $(V_SUBST_$(AM_DEFAULT_VERBOSITY))
-V_SUBST_0 = @echo "  SUBST  $@";
-SUBST = $(V_SUBST)$(confsubst)
-
 ###--------------------------------------------------------------------------
 ### The main library.
 
-lib_LTLIBRARIES                += libcatacomb.la
-libcatacomb_la_LIBADD   = $(CATACOMB_LIBS) $(mLib_LIBS)
+lib_LTLIBRARIES                 = libcatacomb.la
 libcatacomb_la_LDFLAGS  = -version-info $(LIBTOOL_VERSION_INFO)
+libcatacomb_la_LIBADD   = $(CATACOMB_LIBS) $(mLib_LIBS)
 libcatacomb_la_SOURCES  =
-nodist_libcatacomb_la_SOURCES =
-
-###--------------------------------------------------------------------------
-### Basic utilities.
-
-## The locked-memory arena.
-pkginclude_HEADERS     += arena.h
-libcatacomb_la_SOURCES += arena.c
-
-## Constant-type operations.
-pkginclude_HEADERS     += ct.h
-libcatacomb_la_SOURCES += ct.c
-
-## Acceptable key-size descriptions.
-pkginclude_HEADERS     += keysz.h
-libcatacomb_la_SOURCES += keysz.c keysz-conv.c
-
-## System-level memory locking.
-pkginclude_HEADERS     += lmem.h
-libcatacomb_la_SOURCES += lmem.c
-
-## Clearing secrets from memory.
-pkginclude_HEADERS     += paranoia.h
-
-###--------------------------------------------------------------------------
-### Main multiprecision integer library.
-
-## This library is unfortunately intertwined with some of the code generation
-## programs, so we must be rather careful.  The important bits of the maths
-## library needed by these programs is separated out into `libmpbase'.  There
-## is work going on to fix this unpleasant situation by generating the
-## relevant files from Python scripts rather than C programs, using
-## information gathered by `configure'.
-noinst_LTLIBRARIES     += libmpbase.la
-libcatacomb_la_LIBADD  += libmpbase.la
-libmpbase_la_LIBADD     = $(mLib_LIBS)
-libmpbase_la_SOURCES    =
-$(libmpbase_la_OBJECTS): mptypes.h
-
-## Additional buffer I/O functions for mathematical objects.
-pkginclude_HEADERS     += buf.h
-libcatacomb_la_SOURCES += buf.c
-
-## Infrastructure for fast exponentiation.
-pkginclude_HEADERS     += exp.h
-libcatacomb_la_SOURCES += exp.c
-
-## Main user-visible multiprecision arithmetic.
-pkginclude_HEADERS     += mp.h
-libmpbase_la_SOURCES   += mp-arith.c
-TESTS                  += mp-arith.$t
-libmpbase_la_SOURCES   += mp-const.c
-libcatacomb_la_SOURCES += mp-exp.c mp-exp.h
-libcatacomb_la_SOURCES += mp-gcd.c
-TESTS                  += mp-gcd.$t
-libmpbase_la_SOURCES   += mp-io.c
-libcatacomb_la_SOURCES += mp-jacobi.c
-TESTS                  += mp-jacobi.$t
-libmpbase_la_SOURCES   += mp-mem.c
-libmpbase_la_SOURCES   += mp-misc.c
-libcatacomb_la_SOURCES += mp-modexp.c
-TESTS                  += mp-modexp.$t
-libcatacomb_la_SOURCES += mp-modsqrt.c
-TESTS                  += mp-modsqrt.$t
-libcatacomb_la_SOURCES += mp-sqrt.c
-TESTS                  += mp-sqrt.$t
-libcatacomb_la_SOURCES += mp-test.c
-EXTRA_DIST             += tests/mp
-
-## Computing Fibonacci numbers.
-pkginclude_HEADERS     += mp-fibonacci.h
-libcatacomb_la_SOURCES += mp-fibonacci.c
-TESTS                  += mp-fibonacci.$t
-
-## Special memory allocation for multiprecision integers.
-pkginclude_HEADERS     += mparena.h
-libmpbase_la_SOURCES   += mparena.c
-
-## Barrett reduction, an efficient method for modular reduction.
-pkginclude_HEADERS     += mpbarrett.h
-libcatacomb_la_SOURCES += mpbarrett.c
-TESTS                  += mpbarrett.$t
-libcatacomb_la_SOURCES += mpbarrett-exp.c mpbarrett-mexp.c mpbarrett-exp.h
-TESTS                  += mpbarrett-exp.$t mpbarrett-mexp.$t
-EXTRA_DIST             += tests/mpbarrett
-
-## Solving congruences using the Chinese Remainder Theorem.
-pkginclude_HEADERS     += mpcrt.h
-libcatacomb_la_SOURCES += mpcrt.c
-TESTS                  += mpcrt.$t
-EXTRA_DIST             += tests/mpcrt
-
-## Conversions between machine-native and multiprecision integers.
-pkginclude_HEADERS     += mpint.h
-libcatacomb_la_SOURCES += mpint.c
-TESTS                  += mpint.$t
-EXTRA_DIST             += tests/mpint
-
-## Table of upper and lower limits of various types of machine integers, as
-## multiprecision integers.
-nodist_archinclude_HEADERS += mplimits.h
-nodist_libcatacomb_la_SOURCES += mplimits.c
-CLEANFILES             += mplimits.h mplimits.c
-noinst_PROGRAMS                += genlimits
-genlimits_LDADD                 = libmpbase.la
-mplimits.c: genlimits$e
-       $(AM_V_GEN)./genlimits c >mplimits.c.new && \
-               mv mplimits.c.new mplimits.c
-mplimits.h: genlimits$e
-       $(AM_V_GEN)./genlimits h >mplimits.h.new && \
-               mv mplimits.h.new mplimits.h
-$(genlimits_OBJECTS): mptypes.h
-mplimits.lo: mplimits.h
-
-## Montgomery reduction, a clever method for modular arithmetic.
-pkginclude_HEADERS     += mpmont.h
-libcatacomb_la_SOURCES += mpmont.c
-TESTS                  += mpmont.$t
-libcatacomb_la_SOURCES += mpmont-exp.c mpmont-mexp.c mpmont-exp.h
-TESTS                  += mpmont-exp.$t mpmont-mexp.$t
-EXTRA_DIST             += tests/mpmont
-
-## Efficient multiplication of many small numbers.
-pkginclude_HEADERS     += mpmul.h
-libcatacomb_la_SOURCES += mpmul.c
-TESTS                  += mpmul.$t
-
-## Generating random numbers.
-pkginclude_HEADERS     += mprand.h
-libcatacomb_la_SOURCES += mprand.c
-
-## Efficient reduction modulo numbers with conveninent binary
-## representations.
-pkginclude_HEADERS     += mpreduce.h
-libcatacomb_la_SOURCES += mpreduce.c mpreduce-exp.h
-TESTS                  += mpreduce.$t
-EXTRA_DIST             += tests/mpreduce
-
-## Iteratiion over the bianry representation of multiprecision integers.
-pkginclude_HEADERS     += mpscan.h
-libmpbase_la_SOURCES   += mpscan.c
-
-## Conversion between multiprecision integers and their textual
-## representations.
-pkginclude_HEADERS     += mptext.h
-libmpbase_la_SOURCES   += mptext.c
-TESTS                  += mptext.$t
-libcatacomb_la_SOURCES += mptext-dstr.c
-libcatacomb_la_SOURCES += mptext-file.c
-libcatacomb_la_SOURCES += mptext-len.c
-libmpbase_la_SOURCES   += mptext-string.c
-EXTRA_DIST             += tests/mptext
-
-## Basic types used in the representation of multiprecision integers.
-nodist_archinclude_HEADERS += mptypes.h
-BUILT_SOURCES          += mptypes.h
-CLEANFILES             += mptypes.h
-noinst_PROGRAMS                += mptypes
-mptypes.h: mptypes$e
-       $(AM_V_GEN)./mptypes >mptypes.h.new && mv mptypes.h.new mptypes.h
-
-## Low-level multiprecision arithmetic.
-pkginclude_HEADERS     += mpx.h bitops.h mpw.h
-libmpbase_la_SOURCES   += mpx.c
-TESTS                  += mpx.$t
-libmpbase_la_SOURCES   += karatsuba.h mpx-kmul.c mpx-ksqr.c
-TESTS                  += mpx-kmul.$t mpx-ksqr.$t
-noinst_PROGRAMS                += bittest
-TESTS                  += bittest
-EXTRA_DIST             += tests/mpx
-
-## A quick-and-dirty parser, used for parsing descriptions of groups, fields,
-## etc.
-pkginclude_HEADERS     += rho.h
-libcatacomb_la_SOURCES += rho.c
-TESTS                  += rho.$t
-
-## Pollard's `rho' algorithm for determining discrete logarithms.
-pkginclude_HEADERS     += qdparse.h
-libcatacomb_la_SOURCES += qdparse.c
-
-###--------------------------------------------------------------------------
-### Prime number checking, searching, and related jobs.
-
-## Generating Lim--Lee groups, i.e., unit groups of finite fields without
-## small subgroups (except for the obvious ones).
-pkginclude_HEADERS     += limlee.h
-libcatacomb_la_SOURCES += limlee.c
-
-## A table of small prime numbers.
-nodist_pkginclude_HEADERS += primetab.h
-nodist_libcatacomb_la_SOURCES += primetab.c
-CLEANFILES             += primetab.h primetab.c
-BUILT_SOURCES          += primetab.h primetab.c
-noinst_PROGRAMS                += genprimes
-genprimes_LDADD                 = $(mLib_LIBS)
-primetab.h: primetab.c
-primetab.c: genprimes$e
-       $(AM_V_GEN)./genprimes -hprimetab.h -cprimetab.c \
-               -sCATACOMB_PRIMETAB_H \
-               -n256 -t"unsigned short" -iprimetab
-
-## Filtering candidate prime numbers by checking for small factors
-## efficiently.
-pkginclude_HEADERS     += pfilt.h
-libcatacomb_la_SOURCES += pfilt.c
-
-## Generating prime numbers (and other kinds of numbers which need searching
-## for).
-pkginclude_HEADERS     += pgen.h
-libcatacomb_la_SOURCES += pgen.c
-libcatacomb_la_SOURCES += pgen-gcd.c
-libcatacomb_la_SOURCES += pgen-simul.c
-libcatacomb_la_SOURCES += pgen-stdev.c
-TESTS                  += pgen.$t
-EXTRA_DIST             += tests/pgen
-
-## Finding primitive elements in finite fields.
-pkginclude_HEADERS     += prim.h
-libcatacomb_la_SOURCES += prim.c
-
-## Iterating over all prime numbers from a given starting point.
-pkginclude_HEADERS     += primeiter.h
-libcatacomb_la_SOURCES += primeiter.c
-TESTS                  += primeiter.$t
-primeiter.lo: wheel.h
-
-## The Miller--Rabin primality test.
-pkginclude_HEADERS     += rabin.h
-libcatacomb_la_SOURCES += rabin.c
-
-## Finding `strong' primes, using Gordon's algorithm.  Once upon a time,
-## products of these kinds of numbers were harder to factor.
-pkginclude_HEADERS     += strongprime.h
-libcatacomb_la_SOURCES += strongprime.c
-
-## A `wheel', used by the prime iteration machinery.
-nodist_pkginclude_HEADERS += wheel.h
-nodist_libcatacomb_la_SOURCES += wheel.c
-CLEANFILES             += wheel.h wheel.c
-noinst_PROGRAMS                += genwheel
-genwheel_LDADD          = $(mLib_LIBS)
-wheel.h: wheel.c
-wheel.c: genwheel$e
-       $(AM_V_GEN)./genwheel -hwheel.h -cwheel.c \
-               -sCATACOMB_WHEEL_H \
-               -n5 -t"unsigned char" -iwheel
-
-###--------------------------------------------------------------------------
-### Binary polynomial arithmetic.
-
-## User-visible binary polynomial arithmetic.
-pkginclude_HEADERS     += gf.h
-libcatacomb_la_SOURCES += gf-arith.c
-TESTS                  += gf-arith.$t
-libcatacomb_la_SOURCES += gf-exp.c gf-exp.h
-libcatacomb_la_SOURCES += gf-gcd.c
-TESTS                  += gf-gcd.$t
-EXTRA_DIST             += tests/gf
-
-## Low-level binary polynomial arithmetic.
-pkginclude_HEADERS     += gfx.h
-libcatacomb_la_SOURCES += gfx.c
-TESTS                  += gfx.$t
-libcatacomb_la_SOURCES += gfx-kmul.c
-TESTS                  += gfx-kmul.$t
-libcatacomb_la_SOURCES += gfx-sqr.c
-gfx-sqr.lo: gfx-sqr-tab.h
-TESTS                  += gfx-sqr.$t
-CLEANFILES             += gfx-sqr-tab.h
-noinst_PROGRAMS                += gfx-sqr-mktab
-gfx-sqr-tab.h: gfx-sqr-mktab$e
-       $(AM_V_GEN)./gfx-sqr-mktab >gfx-sqr-tab.h.in && \
-               mv gfx-sqr-tab.h.in gfx-sqr-tab.h
-EXTRA_DIST             += tests/gfx
-
-## Conversions between normal and polynomial basis representations for binary
-## fields.
-pkginclude_HEADERS     += gfn.h
-libcatacomb_la_SOURCES += gfn.c
-TESTS                  += gfn.$t
-EXTRA_DIST             += tests/gfn
-
-## Efficient reduction modulo sparse polynomials.
-pkginclude_HEADERS     += gfreduce.h
-libcatacomb_la_SOURCES += gfreduce.c gfreduce-exp.h
-TESTS                  += gfreduce.$t
-EXTRA_DIST             += tests/gfreduce
-
-###--------------------------------------------------------------------------
-### Abstractions for various kinds of algebraic objects.
-
-## Abstract cyclic groups.
-pkginclude_HEADERS     += group.h group-guts.h
-libcatacomb_la_SOURCES += group-dstr.c
-libcatacomb_la_SOURCES += group-exp.c group-exp.h
-libcatacomb_la_SOURCES += group-file.c
-libcatacomb_la_SOURCES += group-parse.c
-libcatacomb_la_SOURCES += group-stdops.c
-libcatacomb_la_SOURCES += group-string.c
-libcatacomb_la_SOURCES += g-bin.c
-libcatacomb_la_SOURCES += g-prime.c
-libcatacomb_la_SOURCES += g-ec.c
-EXTRA_DIST             += group-test.c
-TESTS                  += group-test.$t
-EXTRA_DIST             += tests/group
-
-## Abstract finite fields.
-pkginclude_HEADERS     += field.h field-guts.h
-libcatacomb_la_SOURCES += field.c
-libcatacomb_la_SOURCES += field-exp.c field-exp.h
-libcatacomb_la_SOURCES += field-parse.c
-libcatacomb_la_SOURCES += f-binpoly.c
-libcatacomb_la_SOURCES += f-niceprime.c
-libcatacomb_la_SOURCES += f-prime.c
-
-## Table of built-in binary fields.
-pkginclude_HEADERS     += bintab.h
-libcatacomb_la_SOURCES += bintab.c
-CLEANFILES             += bintab.c
-EXTRA_DIST             += bintab.in bin-gentab.awk
-bintab.c: bintab.in bin-gentab.awk mpdump$e
-       $(AM_V_GEN)awk -f $(srcdir)/bin-gentab.awk \
-               <$(srcdir)/bintab.in >bintab.c.new && \
-       mv bintab.c.new bintab.c
-
-## Table of built-in prime fields.
-pkginclude_HEADERS     += ptab.h
-libcatacomb_la_SOURCES += ptab.c
-CLEANFILES             += ptab.c
-EXTRA_DIST             += ptab.in p-gentab.awk
-ptab.c: ptab.in p-gentab.awk mpdump$e
-       $(AM_V_GEN)awk -f $(srcdir)/p-gentab.awk \
-               <$(srcdir)/ptab.in >ptab.c.new && \
-       mv ptab.c.new ptab.c
-
-## A utility for building multiprecision integer constants.
-noinst_PROGRAMS                += mpdump
-mpdump_LDADD            = libmpbase.la
-$(mpdump_OBJECTS): mptypes.h
-
-###--------------------------------------------------------------------------
-### Elliptic curve arithmetic.
-
-## Basic elliptic curve arithmetic.
-pkginclude_HEADERS     += ec.h ec-guts.h
-libcatacomb_la_SOURCES += ec.c
-libcatacomb_la_SOURCES += ec-exp.c ec-exp.h
-libcatacomb_la_SOURCES += ec-info.c
-TESTS                  += ec-info.$t
-libcatacomb_la_SOURCES += ec-bin.c
-TESTS                  += ec-bin.$t
-libcatacomb_la_SOURCES += ec-prime.c
-TESTS                  += ec-prime.$t
-EXTRA_DIST             += tests/ec
-
-## The standard `raw' encoding (`EC2OSP') of elliptic curve points.
-pkginclude_HEADERS     += ec-raw.h
-libcatacomb_la_SOURCES += ec-raw.c
-
-## Test infrastructure for elliptic curves.
-pkginclude_HEADERS     += ec-test.h
-libcatacomb_la_SOURCES += ec-test.c
-TESTS                  += ec-test.$t
-
-## A table of built-in elliptic curves.
-pkginclude_HEADERS     += ectab.h
-libcatacomb_la_SOURCES += ectab.c
-CLEANFILES             += ectab.c
-EXTRA_DIST             += ectab.in ec-gentab.awk
-ectab.c: ectab.in ec-gentab.awk mpdump$e
-       $(AM_V_GEN)awk -f $(srcdir)/ec-gentab.awk \
-               <$(srcdir)/ectab.in >ectab.c.new && \
-       mv ectab.c.new ectab.c
-
-###--------------------------------------------------------------------------
-### Autogenerated lists.
-
-## Fancy template substitutions.
-multigen                = python $(srcdir)/multigen
-EXTRA_DIST             += multigen
-
-## The heart of this is an enormous cross-product of crypto primitives and
-## the corresponding modes of operation.  Rather than write it out longhand,
-## we generate it using `multigen'.  Unfortunately, this needs to be done
-## at the Automake level, which causes some interesting bootstrapping
-## problems.
-include modes.am
-
-EXTRA_DIST             += modes.am.in modes.am
-MAINTAINERCLEANFILES   += $(srcdir)/modes.am
-
-## Generate the lists.
-$(srcdir)/modes.am: modes.am.in
-       $(AM_V_GEN)$(multigen) -g $(srcdir)/modes.am.in $(srcdir)/modes.am \
-               blkc="$(BLKCS)" \
-                       blkcmode="$(BLKCMODES)" \
-                       blkcciphermode="$(BLKCCIPHERMODES)" \
-               hash="$(HASHES)" \
-                       hashmode="$(HASHMODES)" \
-                       hashciphermode="$(HASHCIPHERMODES)" \
-                       hashmacmode="$(HASHMACMODES)"
-
-## Initialize lists of known classes.
-ALL_CIPHERS             = $(CIPHER_MODES)
-ALL_HASHES              = $(HASHES)
-ALL_MACS                = $(MAC_MODES)
-
-###--------------------------------------------------------------------------
-### Block ciphers.
-
-BLKCS                   =
-BLKCMODES               =
-
-BLKCCIPHERMODES                 =
-BLKCMODES              += $(BLKCCIPHERMODES)
-
-## A tool for translating the AES-contest test vectors into a form our test
-## rigs understand.
-EXTRA_DIST             += tests/aes-trans
-
-## Block cipher utility macros, mainly used in mode implementations.
-pkginclude_HEADERS     += blkc.h
-
-## Source code and headers for the block ciphers.
-libcatacomb_la_SOURCES += $(BLKC_C)
-pkginclude_HEADERS     += $(BLKC_H)
-
-## Schneier's `Blowfish' block cipher.
-BLKCS                  += blowfish
-blowfish.lo: blowfish-tab.h
-CLEANFILES             += blowfish-tab.h
-noinst_PROGRAMS                += blowfish-mktab
-blowfish_mktab_CPPFLAGS         = $(AM_CPPFLAGS) -DQUIET
-blowfish-tab.h: blowfish-mktab$e
-       $(AM_V_GEN)./blowfish-mktab >blowfish-tab.h.new && \
-               mv blowfish-tab.h.new blowfish-tab.h
-
-## Adams and Tavares' `CAST' block ciphers.
-BLKCS                  += cast128 cast256
-libcatacomb_la_SOURCES += cast-s.c cast-sk.c cast-base.h cast-tab.h
-cast256.$t: tests/cast256
-EXTRA_DIST             += tests/cast256.aes
-MAINTAINERCLEANFILES   += $(srcdir)/tests/cast256
-tests/cast256: tests/cast256.aes
-       $(AM_V_GEN)$(srcdir)/tests/aes-trans CAST256 \
-               <$(srcdir)/tests/cast256.aes \
-               >$(srcdir)/tests/cast256.new && \
-       mv $(srcdir)/tests/cast256.new $(srcdir)/tests/cast256
-
-## IBM's `DES' block cipher, by Feistel, Coppersmith, and others.
-BLKCS                  += des des3
-libcatacomb_la_SOURCES += des-base.h des-base.c desx-tab.h
-des-base.lo: des-tab.h
-CLEANFILES             += des-tab.h
-noinst_PROGRAMS                += des-mktab
-des-tab.h: des-mktab$e
-       $(AM_V_GEN)./des-mktab >des-tab.h.new && \
-               mv des-tab.h.new des-tab.h
-
-## Rivest's `DESX' variant, with pre- and post-whitening.
-BLKCS                  += desx
-libcatacomb_la_SOURCES += desx-tab.h
-
-## Lai and Massey's IDEA.
-BLKCS                  += idea
-
-## IBM's `MARS' block cipher.
-BLKCS                  += mars
-mars.lo: mars-tab.h
-CLEANFILES             += mars-tab.h
-noinst_PROGRAMS                += mars-mktab
-mars-tab.h: mars-mktab$e
-       $(AM_V_GEN)./mars-mktab >mars-tab.h.new && \
-               mv mars-tab.h.new mars-tab.h
-mars.$t: tests/mars
-EXTRA_DIST             += tests/mars.aes
-MAINTAINERCLEANFILES   += $(srcdir)/tests/mars
-tests/mars: tests/mars.aes
-       $(AM_V_GEN)$(srcdir)/tests/aes-trans Mars \
-               <$(srcdir)/tests/mars.aes \
-               >$(srcdir)/tests/mars.new && \
-       mv $(srcdir)/tests/mars.new $(srcdir)/tests/mars
 
-## Daemen, Peeters, Van Assche and Rijmen's `Noekeon'.
-BLKCS                  += noekeon
+## Basic utilities.
+SUBDIRS                        += base
+libcatacomb_la_LIBADD  += base/libbase.la
 
-## Rivest's `RC2' block cipher.
-BLKCS                  += rc2
-libcatacomb_la_SOURCES += rc2-tab.h
+## Mathematical infrastructure.
+SUBDIRS                        += math
+libcatacomb_la_LIBADD  += math/libmath.la
 
-## Rivest's `RC5'.
-BLKCS                  += rc5
+## Symmetric cryptography.
+SUBDIRS                        += symm
+libcatacomb_la_LIBADD  += symm/libsymm.la
 
-## Daemen and Rijmen's `Rijndael' block cipher, selected as AES.
-BLKCS                  += rijndael rijndael192 rijndael256
-libcatacomb_la_SOURCES += rijndael-base.h rijndael-base.c
-rijndael-base.lo: rijndael-tab.h
-CLEANFILES             += rijndael-tab.h
-noinst_PROGRAMS                += rijndael-mktab
-rijndael-tab.h: rijndael-mktab$e
-       $(AM_V_GEN)./rijndael-mktab >rijndael-tab.h.new && \
-               mv rijndael-tab.h.new rijndael-tab.h
-rijndael.$t: tests/rijndael
-EXTRA_DIST             += tests/rijndael.aes
-MAINTAINERCLEANFILES   += $(srcdir)/tests/rijndael
-tests/rijndael: tests/rijndael.aes
-       $(AM_V_GEN)$(srcdir)/tests/aes-trans Rijndael \
-               <$(srcdir)/tests/rijndael.aes \
-               >$(srcdir)/tests/rijndael.new && \
-       mv $(srcdir)/tests/rijndael.new $(srcdir)/tests/rijndael
+## Key management.
+SUBDIRS                        += key
+libcatacomb_la_LIBADD  += key/libkey.la
 
-## Massey's `SAFER' block ciphers.
-BLKCS                  += safer safersk
-safer.lo: safer-tab.h
-CLEANFILES             += safer-tab.h
-noinst_PROGRAMS                += safer-mktab
-safer-tab.h: safer-mktab$e
-       $(AM_V_GEN)./safer-mktab >safer-tab.h.new && \
-               mv safer-tab.h.new safer-tab.h
+## Miscellaneous cryptography.
+SUBDIRS                        += misc
+libcatacomb_la_LIBADD  += misc/libmisc.la
 
-## Anderson, Biham and Knudsen's `Serpent' block cipher.
-BLKCS                  += serpent
-libcatacomb_la_SOURCES += serpent-sbox.h
-noinst_PROGRAMS                += serpent-check
-TESTS                  += serpent-check
-serpent.$t: tests/serpent
-EXTRA_DIST             += tests/serpent.aes
-MAINTAINERCLEANFILES   += $(srcdir)/tests/serpent
-tests/serpent: tests/serpent.aes
-       $(AM_V_GEN)$(srcdir)/tests/aes-trans Serpent -v rev=1 \
-               <$(srcdir)/tests/serpent.aes \
-               >$(srcdir)/tests/serpent.new && \
-       mv $(srcdir)/tests/serpent.new $(srcdir)/tests/serpent
+## Public-key cryptography.
+SUBDIRS                        += pub
+libcatacomb_la_LIBADD  += pub/libpub.la
 
-## The National Security Agency's `Skipjack' block cipher.  You don't want to
-## use this.
-BLKCS                  += skipjack
-libcatacomb_la_SOURCES += skipjack-tab.h
+## Random number generators and related functionality.
+SUBDIRS                        += rand
+libcatacomb_la_LIBADD  += rand/librand.la
 
-## Daemen and Rijmen's `Square' block cipher.
-BLKCS                  += square
-square.lo: square-tab.h
-CLEANFILES             += square-tab.h
-noinst_PROGRAMS                += square-mktab
-square-tab.h: square-mktab$e
-       $(AM_V_GEN)./square-mktab >square-tab.h.new && \
-               mv square-tab.h.new square-tab.h
-
-## Wheeler and Needham's `TEA' and `XTEA' block ciphers.
-BLKCS                  += tea xtea
-
-## Schneier, Kelsey, Whiting, Wagner, Hall and Ferguson's `Twofish' block
-## cipher.
-BLKCS                  += twofish
-twofish.lo: twofish-tab.h
-CLEANFILES             += twofish-tab.h
-noinst_PROGRAMS                += twofish-mktab
-twofish-tab.h: twofish-mktab$e
-       $(AM_V_GEN)./twofish-mktab >twofish-tab.h.new && \
-               mv twofish-tab.h.new twofish-tab.h
-twofish.$t: tests/twofish
-EXTRA_DIST             += tests/twofish.aes
-MAINTAINERCLEANFILES   += $(srcdir)/tests/twofish
-tests/twofish: tests/twofish.aes
-       $(AM_V_GEN)$(srcdir)/tests/aes-trans Twofish \
-               <$(srcdir)/tests/twofish.aes \
-               >$(srcdir)/tests/twofish.new && \
-       mv $(srcdir)/tests/twofish.new $(srcdir)/tests/twofish
-
-## The old NIST modes for DES.
-BLKCCIPHERMODES                += cbc cfb ecb ofb
-
-## Counter mode.
-BLKCCIPHERMODES                += counter
-
-###--------------------------------------------------------------------------
-### Hash functions.
-
-HASHES                  =
-HASHMODES               =
-
-HASHCIPHERMODES                 =
-HASHMODES              += $(HASHCIPHERMODES)
-
-HASHMACMODES            =
-HASHMODES              += $(HASHMACMODES)
-
-## Common definitions for hash functions.
-pkginclude_HEADERS     += hash.h
-
-## Source code and headers for the hash functions.
-libcatacomb_la_SOURCES += $(HASH_C)
-pkginclude_HEADERS     += $(HASH_H)
-
-## Lim and KISA's `HAS-160', recommended for use with KCDSA.
-HASHES                 += has160
-
-## Rivest's `MD' series of hash functions
-HASHES                 += md2 md4 md5
-libcatacomb_la_SOURCES += md2-tab.h
-
-## Dobbertin, Bosselaers and Preneel's `RIPEMD' suite.
-HASHES                 += rmd128 rmd160 rmd256 rmd320
-
-## The National Security Agency's `SHA-1' hash function.
-HASHES                 += sha
-
-## The National Security Agency's `SHA-2' suite.
-HASHES                 += sha224 sha256
-HASHES                 += sha384 sha512
-
-## Anderson and Biham's `Tiger' hash function.
-HASHES                 += tiger
-libcatacomb_la_SOURCES += tiger-base.h
-tiger.lo: tiger-tab.h
-CLEANFILES             += tiger-tab.h
-noinst_PROGRAMS                += tiger-mktab
-tiger-tab.h: tiger-mktab$e
-       $(AM_V_GEN)./tiger-mktab >tiger-tab.h.new && \
-               mv tiger-tab.h.new tiger-tab.h
-
-## Barreto and Rijmen's `Whirlpool' hash function.
-HASHES                 += whirlpool whirlpool256
-whirlpool.lo: whirlpool-tab.h
-CLEANFILES             += whirlpool-tab.h
-noinst_PROGRAMS                += whirlpool-mktab
-whirlpool-tab.h: whirlpool-mktab$e
-       $(AM_V_GEN)./whirlpool-mktab >whirlpool-tab.h.new && \
-               mv whirlpool-tab.h.new whirlpool-tab.h
-
-## Bellare, Canetti and Krawczyk's `HMAC' mode for message authentication.
-HASHMACMODES           += hmac
-
-## MGF1, used in OAEP and PSS.
-HASHCIPHERMODES                += mgf
-
-###--------------------------------------------------------------------------
-### Other symmetric primitives.
-
-## The CRC32 algorithm, which is useful, but has no worthwhile security.
-pkginclude_HEADERS     += crc32.h
-libcatacomb_la_SOURCES += crc32.c
-ALL_HASHES             += crc32=gcrc32
-
-## Rivest's `RC4' stream cipher.
-pkginclude_HEADERS     += rc4.h
-libcatacomb_la_SOURCES += rc4.c
-TESTS                  += rc4.$t
-EXTRA_DIST             += tests/rc4
-ALL_CIPHERS            += rc4
-
-## Coppersmith and Rogaway's `SEAL' pseudorandom function.
-pkginclude_HEADERS     += seal.h
-libcatacomb_la_SOURCES += seal.c
-TESTS                  += seal.$t
-EXTRA_DIST             += tests/seal
-ALL_CIPHERS            += seal
-###--------------------------------------------------------------------------
-### Autogenerated mode implementations.
-
-## The master stamp file, indicating that we generated all of the sources.
-CLEANFILES             += modes-gen-stamp
-EXTRA_DIST             += mode.h.in mode.c.in
-modes-gen-stamp:
-       $(AM_V_at)touch modes-gen-stamp
-       $(AM_V_GEN)$(multigen) -g $(srcdir)/mode.c.in \
-               @base-@mode.c \
-               base="$(BLKCS)" mode="$(BLKCMODES)"
-       $(AM_V_at)$(multigen) -g $(srcdir)/mode.c.in \
-               @base-@mode.c \
-               base="$(HASHES)" mode="$(HASHMODES)"
-       $(AM_V_at)$(multigen) -g $(srcdir)/mode.h.in \
-               @base-@mode.h \
-               base="$(BLKCS)" mode="$(BLKCMODES)"
-       $(AM_V_at)$(multigen) -g $(srcdir)/mode.h.in \
-               @base-@mode.h \
-               base="$(HASHES)" mode="$(HASHMODES)"
-       $(AM_V_at)touch modes-gen-stamp
-
-## The individual mode interfaces and implementations.
-pkginclude_HEADERS     += $(MODE_H)
-
-## Generated implementations.
-BUILT_SOURCES          += $(GENMODES_C)
-CLEANFILES             += $(GENMODES_C)
-nodist_libcatacomb_la_SOURCES += $(GENMODES_C)
-$(GENMODES_C): modes-gen-stamp
-
-## Generated interfaces.
-BUILT_SOURCES          += $(GENMODES_H)
-CLEANFILES             += $(GENMODES_H)
-nodist_pkginclude_HEADERS += $(GENMODES_H)
-$(GENMODES_H): modes-gen-stamp
-
-###--------------------------------------------------------------------------
-### Tables of classes for encryption, hashing, and message authentication.
-
-## The skeleton for the class tables.
-EXTRA_DIST             += gthingtab.c.in
-
-## Table of cipher classes.
-pkginclude_HEADERS     += gcipher.h
-CLEANFILES             += gciphertab.c
-nodist_libcatacomb_la_SOURCES += gciphertab.c
-gciphertab.c: gthingtab.c.in
-       $(AM_V_GEN)$(multigen) -g $(srcdir)/gthingtab.c.in gciphertab.c \
-               what=gcipher cls=gccipher thing="$(ALL_CIPHERS)"
-
-## Table of hash classes.
-pkginclude_HEADERS     += ghash.h ghash-def.h
-CLEANFILES             += ghashtab.c
-nodist_libcatacomb_la_SOURCES += ghashtab.c
-ghashtab.c: gthingtab.c.in
-       $(AM_V_GEN)$(multigen) -g $(srcdir)/gthingtab.c.in ghashtab.c \
-               what=ghash cls=gchash thing="$(ALL_HASHES)"
-
-## Table of MAC classes.
-pkginclude_HEADERS     += gmac.h
-CLEANFILES             += gmactab.c
-nodist_libcatacomb_la_SOURCES += gmactab.c
-gmactab.c: gthingtab.c.in
-       $(AM_V_GEN)$(multigen) -g $(srcdir)/gthingtab.c.in gmactab.c \
-               what=gmac cls=gcmac thing="$(ALL_MACS)"
-
-###--------------------------------------------------------------------------
-### Testing for symmetric crypto things.
-
-## Run the test programs.
-TESTS                  += $(SYMM_TESTS)
-EXTRA_DIST             += $(SYMM_TEST_FILES)
-
-## A piece of sample text for round-trip testing encryption modes.
-EXTRA_DIST             += daftstory.h
-
-###--------------------------------------------------------------------------
-### Key management.
-
-## Assistance for elliptic-curve keys.
-pkginclude_HEADERS     += ec-keys.h
-libcatacomb_la_SOURCES += ec-fetch.c
-
-## Managing keys and keyring files.
-pkginclude_HEADERS     += key.h
-libcatacomb_la_SOURCES += key-attr.c
-libcatacomb_la_SOURCES += key-fetch.c
-libcatacomb_la_SOURCES += key-file.c
-libcatacomb_la_SOURCES += key-io.c
-libcatacomb_la_SOURCES += key-misc.c
-libcatacomb_la_SOURCES += key-moan.c
-
-## Managing key data.
-pkginclude_HEADERS     += key-data.h
-libcatacomb_la_SOURCES += key-binary.c
-libcatacomb_la_SOURCES += key-data.c
-libcatacomb_la_SOURCES += key-flags.c
-libcatacomb_la_SOURCES += key-pack.c
-libcatacomb_la_SOURCES += key-pass.c
-libcatacomb_la_SOURCES += key-text.c
-
-## Error reporting.
-pkginclude_HEADERS     += key-error.h
-libcatacomb_la_SOURCES += key-error.c
-
-## Reading passphrases.
-pkginclude_HEADERS     += passphrase.h
-libcatacomb_la_SOURCES += passphrase.c
-
-## Interfacing with the passphrase pixie.
-pkginclude_HEADERS     += pixie.h
-libcatacomb_la_SOURCES += pixie-common.c
-
-###--------------------------------------------------------------------------
-### Secret sharing.
-
-## Efficient sharing over GF(2^8).
-pkginclude_HEADERS     += gfshare.h
-libcatacomb_la_SOURCES += gfshare.c
-gfshare.lo: gfshare-tab.h
-CLEANFILES             += gfshare-tab.h
-noinst_PROGRAMS                += gfshare-mktab
-gfshare-tab.h: gfshare-mktab$e
-       $(AM_V_GEN)./gfshare-mktab >gfshare-tab.h.new && \
-               mv gfshare-tab.h.new gfshare-tab.h
-TESTS                  += gfshare.$t
-
-## Number-theoretic sharing over GF(p).
-pkginclude_HEADERS     += share.h
-libcatacomb_la_SOURCES += share.c
-TESTS                  += share.$t
-
-###--------------------------------------------------------------------------
-### Public-key cryptography.
-
-## The Blum--Blum--Shub random-bit generator.
-pkginclude_HEADERS     += bbs.h
-libcatacomb_la_SOURCES += bbs-fetch.c
-libcatacomb_la_SOURCES += bbs-gen.c
-libcatacomb_la_SOURCES += bbs-jump.c
-TESTS                  += bbs-jump.$t
-libcatacomb_la_SOURCES += bbs-rand.c
-TESTS                  += bbs-rand.$t
-EXTRA_DIST             += tests/bbs
-
-## Plain Diffie--Hellman, in Schorr groups.
-pkginclude_HEADERS     += dh.h
-libcatacomb_la_SOURCES += dh-check.c
-libcatacomb_la_SOURCES += dh-fetch.c
-libcatacomb_la_SOURCES += dh-gen.c
-libcatacomb_la_SOURCES += dh-kcdsa.c
-libcatacomb_la_SOURCES += dh-limlee.c
-libcatacomb_la_SOURCES += dh-param.c
-TESTS                  += dh-param.$t
-
-## The National Security Agency's Digital Signature Algorithm.
-pkginclude_HEADERS     += dsa.h
-libcatacomb_la_SOURCES += dsa-gen.c
-TESTS                  += dsa-gen.$t
-libcatacomb_la_SOURCES += dsa-misc.c
-libcatacomb_la_SOURCES += dsa-sign.c
-TESTS                  += dsa-sign.$t
-libcatacomb_la_SOURCES += dsa-verify.c
-TESTS                  += dsa-verify.$t
-libcatacomb_la_SOURCES += dsa-check.c
-EXTRA_DIST             += tests/dsa
-
-## Generalization of DSA to arbitrary cyclic groups.
-pkginclude_HEADERS     += gdsa.h
-libcatacomb_la_SOURCES += gdsa.c
-TESTS                  += gdsa.$t
-EXTRA_DIST             += tests/gdsa
-
-## KISA `KCDSA', generalized to arbitrary cyclic groups.
-pkginclude_HEADERS     += gkcdsa.h
-libcatacomb_la_SOURCES += gkcdsa.c
-TESTS                  += gkcdsa.$t
-EXTRA_DIST             += tests/gkcdsa
-
-## General key validity checking machinery.
-pkginclude_HEADERS     += keycheck.h
-libcatacomb_la_SOURCES += keycheck.c
-libcatacomb_la_SOURCES += keycheck-mp.c
-libcatacomb_la_SOURCES += keycheck-report.c
-
-## The Rivest--Shamir--Adleman trapdoor one-way function.
-pkginclude_HEADERS     += rsa.h
-libcatacomb_la_SOURCES += rsa-fetch.c
-libcatacomb_la_SOURCES += rsa-gen.c
-libcatacomb_la_SOURCES += rsa-priv.c
-libcatacomb_la_SOURCES += rsa-pub.c
-libcatacomb_la_SOURCES += rsa-recover.c
-libcatacomb_la_SOURCES += oaep.c
-libcatacomb_la_SOURCES += pkcs1.c
-libcatacomb_la_SOURCES += pss.c
-EXTRA_DIST             += rsa-test.c
-TESTS                  += rsa-test.$t
-EXTRA_DIST             += tests/rsa
+## At this point, we should construct the library.
+SUBDIRS                        += .
 
 ###--------------------------------------------------------------------------
-### Random number generators.
-
-## The FIPS186 generator used to generate DSA domain parameters.
-pkginclude_HEADERS     += dsarand.h
-libcatacomb_la_SOURCES += dsarand.c
-
-## Knuth's lagged-Fibonacci generator.
-pkginclude_HEADERS     += fibrand.h
-libcatacomb_la_SOURCES += fibrand.c
-
-## The FIPS 140--2 random number generator tests.
-pkginclude_HEADERS     += fipstest.h
-libcatacomb_la_SOURCES += fipstest.c
-
-## Interface for generic random number sources.
-pkginclude_HEADERS     += grand.h
-libcatacomb_la_SOURCES += grand.c
+### Ancillary programs.
 
-## A simple linear-congruential generator.
-pkginclude_HEADERS     += lcrand.h
-libcatacomb_la_SOURCES += lcrand.c
-TESTS                  += lcrand.$t
-EXTRA_DIST             += tests/lcrand
-
-## Maurer's universal statistical test.
-pkginclude_HEADERS     += maurer.h
-libcatacomb_la_SOURCES += maurer.c
-
-## System-specific noise acquisition.
-pkginclude_HEADERS     += noise.h
-libcatacomb_la_SOURCES += noise.c
-
-## Cryptographic laundering for true random data generation.
-pkginclude_HEADERS     += rand.h
-libcatacomb_la_SOURCES += rand.c
-
-## The SSL v3 pseudorandom function.
-pkginclude_HEADERS     += sslprf.h
-libcatacomb_la_SOURCES += sslprf.c
-TESTS                  += sslprf.$t
-EXTRA_DIST             += tests/sslprf
-
-## The TLS v1 pseudorandom function.
-pkginclude_HEADERS     += tlsprf.h
-libcatacomb_la_SOURCES += tlsprf.c
-TESTS                  += tlsprf.$t
-EXTRA_DIST             += tests/tlsprf
-
-###--------------------------------------------------------------------------
-### The `catcrypt' library.
-
-noinst_LTLIBRARIES     += libcatcrypt.la
-libcatcrypt_la_SOURCES  =
-
-## The main library.
-libcatcrypt_la_SOURCES += cc.h
-libcatcrypt_la_SOURCES += cc-enc.c
-libcatcrypt_la_SOURCES += cc-hash.c
-libcatcrypt_la_SOURCES += cc-kem.c
-libcatcrypt_la_SOURCES += cc-list.c
-libcatcrypt_la_SOURCES += cc-progress.c
-libcatcrypt_la_SOURCES += cc-sig.c
-libcatcrypt_la_SOURCES += cc-subcmd.c
-
-## Date parsing.
-libcatcrypt_la_SOURCES += getdate.h
-libcatcrypt_la_SOURCES += getdate.y
-
-###--------------------------------------------------------------------------
-### Utility programs.
-
-UTILS_LIBS              = libcatcrypt.la libcatacomb.la $(mLib_LIBS) $(LIBS)
-
-## Generate and verify datestamped cookies.
-bin_PROGRAMS           += cookie
-cookie_LDADD            = $(UTILS_LIBS)
-dist_man_MANS          += cookie.1
-
-## Asymmetric message encryption and decryption with deniable authentication.
-bin_PROGRAMS           += catcrypt
-catcrypt_LDADD          = $(UTILS_LIBS)
-dist_man_MANS          += catcrypt.1
-
-## Signing and verifying files.
-bin_PROGRAMS           += catsign
-catsign_LDADD           = $(UTILS_LIBS)
-dist_man_MANS          += catsign.1
-
-## Issue and verify signatures on directory trees.
-bin_PROGRAMS           += dsig
-dsig_LDADD              = $(UTILS_LIBS)
-dist_man_MANS          += dsig.1
-
-## Compute factorials to arbitrary precision.
-bin_PROGRAMS           += factorial
-factorial_LDADD                 = $(UTILS_LIBS)
-
-## Compute Fibonacci numbers to arbitrary precision.
-bin_PROGRAMS           += fibonacci
-fibonacci_LDADD                 = $(UTILS_LIBS)
-
-## Compute hashes of files.
-bin_PROGRAMS           += hashsum
-hashsum_LDADD           = $(UTILS_LIBS)
-dist_man_MANS          += hashsum.1
-
-## Key management utility.
-bin_PROGRAMS           += key
-key_SOURCES             = keyutil.c
-key_LDADD               = $(UTILS_LIBS)
-dist_man_MANS          += key.1 keyring.5
-
-## Generate passphrases with given entropy using wordlists and Markov models.
-bin_PROGRAMS           += mkphrase
-mkphrase_LDADD          = $(UTILS_LIBS)
-dist_man_MANS          += mkphrase.1
-
-## Performance testing.
-bin_PROGRAMS           += perftest
-perftest_LDADD          = $(UTILS_LIBS)
-
-## Remember passphrases for limited periods of time.
-bin_PROGRAMS           += pixie
-pixie_SOURCES           = pixie.c
-pixie_LDADD             = libcatacomb.la $(mLib_LIBS) $(PIXIE_LIBS)
-dist_man_MANS          += pixie.1
-EXTRA_DIST             += xpixie
-
-## Generate random data.
-bin_PROGRAMS           += rspit
-rspit_LDADD             = $(UTILS_LIBS)
-
-###--------------------------------------------------------------------------
-### Testing.
-
-SUFFIXES               += .c .$t .to
-.c.to:
-       $(AM_V_CC)$(COMPILE) -c -DTEST_RIG -DSRCDIR=\"$(srcdir)\" $< -o $@
-.to.$t: libcatacomb.la
-       $(AM_V_CCLD)$(LINK) $< libcatacomb.la $(mLib_LIBS) $(LIBS)
-.PRECIOUS: %.to
-CLEANFILES             += *.to *.$t
+SUBDIRS                        += progs
 
 ###--------------------------------------------------------------------------
 ### The pkg-config file.
@@ -1106,6 +93,7 @@ dist-hook::
 
 ## Additional build tools.
 EXTRA_DIST             += config/auto-version
+EXTRA_DIST             += config/confsubst
 
 ###--------------------------------------------------------------------------
 ### Debian.
diff --git a/arena.c b/arena.c
deleted file mode 100644 (file)
index dde8e84..0000000
--- a/arena.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*-c-*-
- *
- * $Id: arena.c,v 1.2 2004/04/08 01:36:15 mdw Exp $
- *
- * Abstraction for memory allocation arenas
- *
- * (c) 2000 Straylight/Edgeware
- */
-
-/*----- Licensing notice --------------------------------------------------*
- *
- * This file is part of Catacomb.
- *
- * Catacomb is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * Catacomb is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with Catacomb; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- */
-
-/*----- Header files ------------------------------------------------------*/
-
-#include <mLib/arena.h>
-#include <mLib/sub.h>
-
-#include "arena.h"
-
-/*----- Global variables --------------------------------------------------*/
-
-arena *arena_secure = &arena_stdlib;
-subarena *arena_subsecure = &sub_global;
-
-/*----- Static variables --------------------------------------------------*/
-
-static subarena sub;
-
-/*----- Main code ---------------------------------------------------------*/
-
-/* --- @arena_setsecure@ --- *
- *
- * Arguments:  @arena *a@ = arena to use for secure allocation
- *
- * Returns:    ---
- *
- * Use:                Call at the beginning of the program to set the arena for
- *             secure allocations.
- */
-
-void arena_setsecure(arena *a)
-{
-  arena_secure = a;
-  subarena_create(&sub, a);
-  arena_subsecure = &sub;
-}
-
-/*----- That's all, folks -------------------------------------------------*/
diff --git a/arena.h b/arena.h
deleted file mode 100644 (file)
index acae679..0000000
--- a/arena.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*-c-*-
- *
- * $Id: arena.h,v 1.2 2004/04/08 01:36:15 mdw Exp $
- *
- * Abstraction for memory allocation arenas
- *
- * (c) 2000 Straylight/Edgeware
- */
-
-/*----- Licensing notice --------------------------------------------------*
- *
- * This file is part of Catacomb.
- *
- * Catacomb is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * Catacomb is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with Catacomb; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- */
-
-#ifndef CATACOMB_ARENA_H
-#define CATACOMB_ARENA_H
-
-#ifdef __cplusplus
-  extern "C" {
-#endif
-
-/*----- Header files ------------------------------------------------------*/
-
-#include <mLib/arena.h>
-#include <mLib/sub.h>
-
-/*----- Global variables --------------------------------------------------*/
-
-extern arena *arena_secure;
-extern subarena *arena_subsecure;
-
-/*----- Handy macros ------------------------------------------------------*/
-
-#define S_ALLOC(sz) A_ALLOC(arena_secure, sz)
-#define S_FREE(sz) A_FREE(arena_secure, sz)
-
-#define XS_ALLOC(sz) x_alloc(arena_secure, sz)
-#define XS_REALLOC(p, sz) x_realloc(arena_secure, p, sz)
-#define XS_FREE(p) x_free(arena_secure, p)
-
-#define S_CREATE(type) A_CREATE(arena_subsecure, type)
-#define S_DESTROY(p) A_DESTROY(arena_subsecure, p)
-
-/*----- Functions provided ------------------------------------------------*/
-
-/* --- @arena_setsecure@ --- *
- *
- * Arguments:  @arena *a@ = arena to use for secure allocation
- *
- * Returns:    ---
- *
- * Use:                Call at the beginning of the program to set the arena for
- *             secure allocations.
- */
-
-extern void arena_setsecure(arena */*a*/);
-
-/*----- That's all, folks -------------------------------------------------*/
-
-#ifdef __cplusplus
-  }
-#endif
-
-#endif
diff --git a/base/Makefile.am b/base/Makefile.am
new file mode 100644 (file)
index 0000000..35c86ff
--- /dev/null
@@ -0,0 +1,54 @@
+### -*-makefile-*-
+###
+### Build script for basic utilities
+###
+### (c) 2013 Straylight/Edgeware
+###
+
+###----- Licensing notice ---------------------------------------------------
+###
+### This file is part of Catacomb.
+###
+### Catacomb is free software; you can redistribute it and/or modify
+### it under the terms of the GNU Library General Public License as
+### published by the Free Software Foundation; either version 2 of the
+### License, or (at your option) any later version.
+###
+### Catacomb is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+### GNU Library General Public License for more details.
+###
+### You should have received a copy of the GNU Library General Public
+### License along with Catacomb; if not, write to the Free
+### Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+### MA 02111-1307, USA.
+
+include $(top_srcdir)/vars.am
+
+noinst_LTLIBRARIES      = libbase.la
+libbase_la_SOURCES      =
+
+###--------------------------------------------------------------------------
+### Component files.
+
+## The locked-memory arena.
+pkginclude_HEADERS     += arena.h
+libbase_la_SOURCES     += arena.c
+
+## Constant-type operations.
+pkginclude_HEADERS     += ct.h
+libbase_la_SOURCES     += ct.c
+
+## Acceptable key-size descriptions.
+pkginclude_HEADERS     += keysz.h
+libbase_la_SOURCES     += keysz.c keysz-conv.c
+
+## System-level memory locking.
+pkginclude_HEADERS     += lmem.h
+libbase_la_SOURCES     += lmem.c
+
+## Clearing secrets from memory.
+pkginclude_HEADERS     += paranoia.h
+
+###----- That's all, folks --------------------------------------------------
diff --git a/base/arena.c b/base/arena.c
new file mode 100644 (file)
index 0000000..93cbfa5
--- /dev/null
@@ -0,0 +1,63 @@
+/* -*-c-*-
+ *
+ * Abstraction for memory allocation arenas
+ *
+ * (c) 2000 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * Catacomb is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with Catacomb; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <mLib/arena.h>
+#include <mLib/sub.h>
+
+#include "arena.h"
+
+/*----- Global variables --------------------------------------------------*/
+
+arena *arena_secure = &arena_stdlib;
+subarena *arena_subsecure = &sub_global;
+
+/*----- Static variables --------------------------------------------------*/
+
+static subarena sub;
+
+/*----- Main code ---------------------------------------------------------*/
+
+/* --- @arena_setsecure@ --- *
+ *
+ * Arguments:  @arena *a@ = arena to use for secure allocation
+ *
+ * Returns:    ---
+ *
+ * Use:                Call at the beginning of the program to set the arena for
+ *             secure allocations.
+ */
+
+void arena_setsecure(arena *a)
+{
+  arena_secure = a;
+  subarena_create(&sub, a);
+  arena_subsecure = &sub;
+}
+
+/*----- That's all, folks -------------------------------------------------*/
diff --git a/base/arena.h b/base/arena.h
new file mode 100644 (file)
index 0000000..70952da
--- /dev/null
@@ -0,0 +1,77 @@
+/* -*-c-*-
+ *
+ * Abstraction for memory allocation arenas
+ *
+ * (c) 2000 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * Catacomb is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with Catacomb; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+#ifndef CATACOMB_ARENA_H
+#define CATACOMB_ARENA_H
+
+#ifdef __cplusplus
+  extern "C" {
+#endif
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <mLib/arena.h>
+#include <mLib/sub.h>
+
+/*----- Global variables --------------------------------------------------*/
+
+extern arena *arena_secure;
+extern subarena *arena_subsecure;
+
+/*----- Handy macros ------------------------------------------------------*/
+
+#define S_ALLOC(sz) A_ALLOC(arena_secure, sz)
+#define S_FREE(sz) A_FREE(arena_secure, sz)
+
+#define XS_ALLOC(sz) x_alloc(arena_secure, sz)
+#define XS_REALLOC(p, sz) x_realloc(arena_secure, p, sz)
+#define XS_FREE(p) x_free(arena_secure, p)
+
+#define S_CREATE(type) A_CREATE(arena_subsecure, type)
+#define S_DESTROY(p) A_DESTROY(arena_subsecure, p)
+
+/*----- Functions provided ------------------------------------------------*/
+
+/* --- @arena_setsecure@ --- *
+ *
+ * Arguments:  @arena *a@ = arena to use for secure allocation
+ *
+ * Returns:    ---
+ *
+ * Use:                Call at the beginning of the program to set the arena for
+ *             secure allocations.
+ */
+
+extern void arena_setsecure(arena */*a*/);
+
+/*----- That's all, folks -------------------------------------------------*/
+
+#ifdef __cplusplus
+  }
+#endif
+
+#endif
diff --git a/ct.c b/base/ct.c
similarity index 100%
rename from ct.c
rename to base/ct.c
diff --git a/ct.h b/base/ct.h
similarity index 100%
rename from ct.h
rename to base/ct.h
similarity index 100%
rename from keysz-conv.c
rename to base/keysz-conv.c
diff --git a/base/keysz.c b/base/keysz.c
new file mode 100644 (file)
index 0000000..8291928
--- /dev/null
@@ -0,0 +1,81 @@
+/* -*-c-*-
+ *
+ * General block cipher utilities
+ *
+ * (c) 2000 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * Catacomb is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with Catacomb; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <assert.h>
+
+#include "gcipher.h"
+
+/*----- Main code ---------------------------------------------------------*/
+
+/* --- @keysz@ --- *
+ *
+ * Arguments:  @size_t sz@ = a proposed key size, or zero
+ *             @const octet *ksz@ = pointer to key size table
+ *
+ * Returns:    See below.
+ *
+ * Use:                Returns a sensible key size.  If @sz@ is nonzero, it is
+ *             interpreted as an amount (in bytes) of key material which the
+ *             caller has available, and the return value is either the
+ *             largest allowable key size less than or equal to the caller's
+ *             size, or zero if there is no valid key length small enough.
+ *             If @sz@ is zero, the function returns a `recommended' key
+ *             size.
+ */
+
+size_t keysz(size_t sz, const octet *ksz)
+{
+  if (sz == 0)
+    return (ksz[1]);
+  else switch (ksz[0]) {
+    case KSZ_ANY:
+      return (sz);
+    case KSZ_RANGE:
+      if (ksz[4])
+       sz -= sz % ksz[4];
+      if (sz < ksz[2])
+       return (0);
+      if (ksz[3] && sz > ksz[3])
+       return (ksz[3]);
+      return (sz);
+    case KSZ_SET: {
+      unsigned q = 0;
+      for (ksz++; *ksz; ksz++) {
+       if (sz >= *ksz && q < *ksz)
+         q = *ksz;
+      }
+      return (q);
+    }
+  }
+
+  assert(((void)"bad key size table", 0));
+  return (0);
+}
+
+/*----- That's all, folks -------------------------------------------------*/
similarity index 100%
rename from keysz.h
rename to base/keysz.h
diff --git a/base/lmem.c b/base/lmem.c
new file mode 100644 (file)
index 0000000..a613a54
--- /dev/null
@@ -0,0 +1,344 @@
+/* -*-c-*-
+ *
+ * Locked memory allocation (Unix-specific)
+ *
+ * (c) 1999 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * Catacomb is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with Catacomb; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+/*----- Header files ------------------------------------------------------*/
+
+#include "config.h"
+
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <unistd.h>
+
+#ifdef HAVE_MLOCK
+#  include <sys/mman.h>
+#endif
+
+#include <mLib/arena.h>
+#include <mLib/dstr.h>
+#include <mLib/sub.h>
+
+#include "lmem.h"
+
+/*----- Arena operations --------------------------------------------------*/
+
+static void *aalloc(arena *a, size_t sz) { return l_alloc((lmem *)a, sz); }
+static void afree(arena *a, void *p) { l_free((lmem *)a, p); }
+static void apurge(arena *a) { l_purge((lmem *)a); }
+
+static const arena_ops l_ops = { aalloc, arena_fakerealloc, afree, apurge };
+
+/*----- Main code ---------------------------------------------------------*/
+
+/* --- @l_init@ --- *
+ *
+ * Arguments:  @lmem *lm@ = pointer to locked memory descriptor
+ *             @size_t sz@ = size of locked memory area requested
+ *
+ * Returns:    Zero if everything is fine, @+1@ if some insecure memory was
+ *             allocated, and @-1@ if everything went horribly wrong.
+ *
+ * Use:                Initializes the locked memory manager.  This function is safe
+ *             to call in a privileged program; privileges should usually be
+ *             dropped after allocating the locked memory block.
+ *
+ *             You must call @sub_init@ before allocating locked memory
+ *             buffers.
+ */
+
+int l_init(lmem *lm, size_t sz)
+{
+  char *p;
+  int rc = 0;
+  l_node *l;
+
+  /* --- Preliminaries --- */
+
+  lm->a.ops = &l_ops;
+  lm->err = 0;
+  lm->f = 0;
+
+  /* --- Try making a secure locked passphrase buffer --- *
+   *
+   * Drop privileges before emitting diagnostic messages.
+   */
+
+#ifdef HAVE_MLOCK
+
+  /* --- Memory-map a page from somewhere --- */
+
+#  ifdef MAP_ANON
+  p = mmap(0, sz, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+#  else
+  {
+    int fd;
+    if ((fd = open("/dev/zero", O_RDWR)) >= 0) {
+      p = mmap(0, sz, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
+      close(fd);
+    }
+  }
+#  endif
+
+  /* --- Lock the page in memory --- *
+   *
+   * Why does @mmap@ return such a stupid result if it fails?
+   */
+
+  if (p == 0 || p == MAP_FAILED) {
+    lm->emsg = "couldn't map locked memory area: %s";
+    lm->err = errno;
+    p = 0;
+  } else if (mlock(p, sz)) {
+    lm->emsg = "error locking memory area: %s";
+    lm->err = errno;
+    munmap(p, sz);
+    p = 0;
+  } else
+    lm->f |= LF_LOCKED;
+
+#endif
+
+  /* --- Make a standard passphrase buffer --- */
+
+#ifdef HAVE_MLOCK
+  if (!p)
+#else
+  lm->err = 0;
+  lm->emsg = "locked memory not available on this system";
+#endif
+  {
+    if ((p = malloc(sz)) == 0) {
+      lm->emsg = "not enough standard memory!";
+      lm->err = ENOMEM;
+      return (-1);
+    }
+    rc = +1;
+  }
+
+  /* --- Initialize the buffer --- */
+
+  lm->sz = lm->free = sz;
+  lm->p = p;
+
+  /* --- Initialize the free list --- */
+
+  l = CREATE(l_node);
+  l->next = 0;
+  l->p = p;
+  l->sz = sz;
+  l->f = 0;
+  lm->l = l;
+
+  /* --- Done --- */
+
+  return (rc);
+}
+
+/* --- @l_alloc@ --- *
+ *
+ * Arguments:  @lmem *lm@ = pointer to locked memory descriptor
+ *             @size_t sz@ = size requested
+ *
+ * Returns:    Pointer to allocated memory.
+ *
+ * Use:                Allocates @sz@ bytes of locked memory.
+ */
+
+void *l_alloc(lmem *lm, size_t sz)
+{
+  l_node *l;
+
+  sz = (sz + 3u) & ~3u;
+  for (l = lm->l; l; l = l->next) {
+    if (l->f & LF_ALLOC)
+      continue;
+    if (l->sz < sz)
+      continue;
+    l->f |= LF_ALLOC;
+    if (l->sz > sz) {
+      l_node *n = CREATE(l_node);
+      n->next = l->next;
+      n->p = l->p + sz;
+      n->sz = l->sz - sz;
+      l->sz = sz;
+      n->f = 0;
+      l->next = n;
+    }
+    assert(((void)"Locked buffer space has vanished", lm->free >= sz));
+    lm->free -= sz;
+    return (l->p);
+  }
+  return (0);
+}
+
+/* --- @l_free@ --- *
+ *
+ * Arguments:  @lmem *lm@ = pointer to locked memory descriptor
+ *             @void *p@ = pointer to block
+ *
+ * Returns:    ---
+ *
+ * Use:                Releases a block of locked memory.
+ */
+
+void l_free(lmem *lm, void *p)
+{
+  l_node *l;
+  l_node *ll = 0;
+
+  for (l = lm->l; l; l = l->next) {
+    size_t sz;
+
+    /* --- If this isn't the block, skip it --- */
+
+    if (l->p != p) {
+      ll = l;
+      continue;
+    }
+    assert(((void)"Block is already free", l->f & LF_ALLOC));
+
+    /* --- Coalesce with adjacent free blocks --- */
+
+    l->f &= ~LF_ALLOC;
+    sz = l->sz;
+    memset(p, 0, sz);
+
+    if (ll && !(ll->f & LF_ALLOC)) {
+      assert(((void)"Previous block doesn't fit", ll->p + ll->sz == p));
+      ll->sz += sz;
+      ll->next = l->next;
+      DESTROY(l);
+      l = ll;
+    }
+
+    ll = l->next;
+    if (ll && !(ll->f & LF_ALLOC)) {
+      assert(((void)"Next block doesn't fit", ll->p == l->p + l->sz));
+      l->sz += ll->sz;
+      l->next = ll->next;
+      DESTROY(ll);
+    }
+
+    lm->free += sz;
+    assert(((void)"Free lunch", lm->free <= lm->sz));
+    return;
+  }
+  assert(((void)"Not a locked block", 0));
+}
+
+/* --- @l_purge@ --- *
+ *
+ * Arguments:  @lmem *lm@ = pointer to locked memory descriptor
+ *
+ * Returns:    ---
+ *
+ * Use:                Purges all the free blocks in the buffer, and clears all of
+ *             the locked memory.  Memory is not freed back to the system.
+ */
+
+void l_purge(lmem *lm)
+{
+  l_node *l;
+
+  l = lm->l;
+  while (l) {
+    l_node *ll = l->next;
+    DESTROY(l);
+    l = ll;
+  }
+  memset(lm->p, 0, lm->sz);
+  l = CREATE(l_node);
+  l->next = 0;
+  l->p = lm->p;
+  l->sz = lm->sz;
+  l->f = 0;
+  lm->l = l;
+  lm->free = l->sz;
+}
+
+/* --- @l_destroy@ --- *
+ *
+ * Arguments:  @lmem *lm@ = pointer to locked memory descriptor
+ *
+ * Returns:    ---
+ *
+ * Use:                Disposes of a locked memory arena permanently.
+ */
+
+void l_destroy(lmem *lm)
+{
+  l_node *l;
+
+  l = lm->l;
+  while (l) {
+    l_node *ll = l->next;
+    DESTROY(l);
+    l = ll;
+  }
+  memset(lm->p, 0, lm->sz);
+
+#ifdef HAVE_MLOCK
+  if (lm->f & LF_LOCKED)
+    munmap(lm->p, lm->sz);
+  else
+#endif
+    free(lm->p); /*sic*/
+}
+
+/* --- @l_report@ --- *
+ *
+ * Arguments:  @lmem *lm@ = pointer to locked memory descriptor
+ *             @dstr *d@ = string to write the error message on
+ *
+ * Returns:    Zero if the buffer is fine, @+1@ if there was a problem
+ *             getting locked memory but insecure stuff could be allocated,
+ *             and @-1@ if not even insecure memory could be found.
+ *
+ * Use:                Returns a user-digestable explanation for the state of a
+ *             locked memory buffer.  If the return code is zero, no message
+ *             is emitted to the string @d@.
+ */
+
+int l_report(lmem *lm, dstr *d)
+{
+  int rc;
+  if (lm->err)
+    dstr_putf(d, lm->emsg, strerror(lm->err));
+  if (!lm->p)
+    rc = -1;
+  else if (lm->err)
+    rc = +1;
+  else
+    rc = 0;
+  return (rc);
+}
+
+/*----- That's all, folks -------------------------------------------------*/
diff --git a/base/lmem.h b/base/lmem.h
new file mode 100644 (file)
index 0000000..88b0062
--- /dev/null
@@ -0,0 +1,164 @@
+/* -*-c-*-
+ *
+ * Locked memory allocation
+ *
+ * (c) 1999 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * Catacomb is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with Catacomb; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+#ifndef CATACOMB_LMEM_H
+#define CATACOMB_LMEM_H
+
+#ifdef __cplusplus
+  extern "C" {
+#endif
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <stddef.h>
+
+#include <mLib/arena.h>
+#include <mLib/dstr.h>
+
+/*----- Data structures ---------------------------------------------------*/
+
+/* --- Block list --- *
+ *
+ * The block list is kept in normal memory, to avoid wasting precious locked
+ * memory.  Entries are sorted into ascending address order to make
+ * coalescing free blocks easier.  All blocks, free or not, are included in
+ * the list.
+ */
+
+typedef struct l_node {
+  struct l_node *next;                 /* Next free block in chain */
+  char *p;                             /* Pointer to the block */
+  size_t sz;                           /* Size of the block */
+  unsigned f;                          /* Various flags */
+} l_node;
+
+#define LF_ALLOC 1u
+
+/* --- Locked memory buffer state --- */
+
+typedef struct lmem {
+  arena a;                             /* Arena header block */
+  unsigned f;                          /* Various flags */
+  char *p;                             /* Pointer to locked buffer */
+  l_node *l;                           /* Pointer to block list */
+  size_t sz;                           /* Size of locked buffer */
+  size_t free;                         /* Size of free area */
+  int err; char *emsg;                 /* Error indicators */
+} lmem;
+
+#define LF_LOCKED 1u
+
+/*----- Functions provided ------------------------------------------------*/
+
+/* --- @l_init@ --- *
+ *
+ * Arguments:  @lmem *lm@ = pointer to locked memory descriptor
+ *             @size_t sz@ = size of locked memory area requested
+ *
+ * Returns:    Zero if everything is fine, @+1@ if some insecure memory was
+ *             allocated, and @-1@ if everything went horribly wrong.
+ *
+ * Use:                Initializes the locked memory manager.  This function is safe
+ *             to call in a privileged program; privileges should usually be
+ *             dropped after allocating the locked memory block.
+ *
+ *             You must call @sub_init@ before allocating locked memory
+ *             buffers.
+ */
+
+extern int l_init(lmem */*lm*/, size_t /*sz*/);
+
+/* --- @l_alloc@ --- *
+ *
+ * Arguments:  @lmem *lm@ = pointer to locked memory descriptor
+ *             @size_t sz@ = size requested
+ *
+ * Returns:    Pointer to allocated memory.
+ *
+ * Use:                Allocates @sz@ bytes of locked memory.
+ */
+
+extern void *l_alloc(lmem */*lm*/, size_t /*sz*/);
+
+/* --- @l_free@ --- *
+ *
+ * Arguments:  @lmem *lm@ = pointer to locked memory descriptor
+ *             @void *p@ = pointer to block
+ *
+ * Returns:    ---
+ *
+ * Use:                Releases a block of locked memory.
+ */
+
+extern void l_free(lmem */*lm*/, void */*p*/);
+
+/* --- @l_purge@ --- *
+ *
+ * Arguments:  @lmem *lm@ = pointer to locked memory descriptor
+ *
+ * Returns:    ---
+ *
+ * Use:                Purges all the free blocks in the buffer, and clears all of
+ *             the locked memory.  Memory is not freed back to the system.
+ */
+
+extern void l_purge(lmem */*lm*/);
+
+/* --- @l_destroy@ --- *
+ *
+ * Arguments:  @lmem *lm@ = pointer to locked memory descriptor
+ *
+ * Returns:    ---
+ *
+ * Use:                Disposes of a locked memory arena permanently.
+ */
+
+extern void l_destroy(lmem */*lm*/);
+
+/* --- @l_report@ --- *
+ *
+ * Arguments:  @lmem *lm@ = pointer to locked memory descriptor
+ *             @dstr *d@ = string to write the error message on
+ *
+ * Returns:    Zero if the buffer is fine, @+1@ if there was a problem
+ *             getting locked memory but insecure stuff could be allocated,
+ *             and @-1@ if not even insecure memory could be found.
+ *
+ * Use:                Returns a user-digestable explanation for the state of a
+ *             locked memory buffer.  If the return code is zero, no message
+ *             is emitted to the string @d@.
+ */
+
+extern int l_report(lmem */*lm*/, dstr */*d*/);
+
+/*----- That's all, folks -------------------------------------------------*/
+
+#ifdef __cplusplus
+  }
+#endif
+
+#endif
diff --git a/base/paranoia.h b/base/paranoia.h
new file mode 100644 (file)
index 0000000..368667c
--- /dev/null
@@ -0,0 +1,49 @@
+/* -*-c-*-
+ *
+ * Macros and functions for cryptographic paranoia
+ *
+ * (c) 1998 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * Catacomb is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with Catacomb; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+#ifndef CATACOMB_PARANOIA_H
+#define CATACOMB_PARANOIA_H
+
+#ifdef __cplusplus
+  extern "C" {
+#endif
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <string.h>
+
+/*----- Macros ------------------------------------------------------------*/
+
+#define BURN(x) (memset(&(x), 0, sizeof(x)))
+
+/*----- That's all, folks -------------------------------------------------*/
+
+#ifdef __cplusplus
+  }
+#endif
+
+#endif
diff --git a/bbs-fetch.c b/bbs-fetch.c
deleted file mode 100644 (file)
index 96c21d0..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/* -*-c-*-
- *
- * $Id: bbs-fetch.c,v 1.3 2004/04/08 01:36:15 mdw Exp $
- *
- * Key fetching for BBS public and private keys
- *
- * (c) 2000 Straylight/Edgeware
- */
-
-/*----- Licensing notice --------------------------------------------------*
- *
- * This file is part of Catacomb.
- *
- * Catacomb is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * Catacomb is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with Catacomb; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- */
-
-/*----- Header files ------------------------------------------------------*/
-
-#include "bbs.h"
-#include "key.h"
-
-/*----- Key fetching ------------------------------------------------------*/
-
-const key_fetchdef bbs_pubfetch[] = {
-  { "n",       offsetof(bbs_pub, n),           KENC_MP,        0 },
-  { 0,         0,                              0,              0 }
-};
-
-static const key_fetchdef priv[] = {
-  { "p",       offsetof(bbs_priv, p),          KENC_MP,        0 },
-  { "q",       offsetof(bbs_priv, q),          KENC_MP,        0 },
-  { 0,         0,                              0,              0 }
-};
-
-const key_fetchdef bbs_privfetch[] = {
-  { "n",       offsetof(bbs_priv, n),          KENC_MP,        0 },
-  { "private", 0,                              KENC_STRUCT,    priv },
-  { 0,         0,                              0,              0 }
-};
-
-/* --- @bbs_pubfree@, @bbs_privfree@ --- *
- *
- * Arguments:  @bbs_pub *bp@, @bbs_priv *bp@ = pointer to key block
- *
- * Returns:    ---
- *
- * Use:                Frees an RSA key block.
- */
-
-void bbs_pubfree(bbs_pub *bp)
-{
-  mp_drop(bp->n);
-}
-
-void bbs_privfree(bbs_priv *bp)
-{
-  mp_drop(bp->n);
-  mp_drop(bp->p);
-  mp_drop(bp->q);
-}
-
-/*----- That's all, folks -------------------------------------------------*/
diff --git a/bbs-gen.c b/bbs-gen.c
deleted file mode 100644 (file)
index c668b21..0000000
--- a/bbs-gen.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* -*-c-*-
- *
- * $Id: bbs-gen.c,v 1.6 2004/04/08 01:36:15 mdw Exp $
- *
- * Generate Blum integers
- *
- * (c) 1999 Straylight/Edgeware
- */
-
-/*----- Licensing notice --------------------------------------------------*
- *
- * This file is part of Catacomb.
- *
- * Catacomb is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * Catacomb is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with Catacomb; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- */
-
-/*----- Header files ------------------------------------------------------*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "bbs.h"
-#include "mp.h"
-#include "mprand.h"
-#include "pgen.h"
-#include "strongprime.h"
-
-/*----- Main code ---------------------------------------------------------*/
-
-/* --- @bbs_gen@ --- *
- *
- * Arguments:  @bbs_priv *bp@ = pointer to parameter block
- *             @unsigned nbits@ = number of bits in the modulus
- *             @grand *r@ = pointer to random number source
- *             @unsigned n@ = number of attempts to make
- *             @pgen_proc *event@ = event handler function
- *             @void *ectx@ = argument for event handler
- *
- * Returns:    If it worked OK, @PGEN_DONE@, otherwise @PGEN_ABORT@.
- *
- * Use:                Finds two prime numbers %$p'$% and %$q'$% such that both are
- *             congruent to %$3 \bmod 4$%, and  $(p - 1)/2$% and
- *             %$(q - 1)/2$% have no common factors.  The product %$n = pq$%
- *             is eminently suitable for use as a modulus in a Blum-Blum-
- *             Shub pseudorandom bit generator.
- */
-
-int bbs_gen(bbs_priv *bp, unsigned nbits, grand *r, unsigned n,
-           pgen_proc *event, void *ectx)
-{
-  rabin rb;
-  pfilt jp;
-  pgen_jumpctx j;
-  pgen_gcdstepctx g;
-  unsigned nb = nbits/2;
-  mp *x = MP_NEW;
-
-  /* --- Generate @p@ --- */
-
-again:
-  if ((x = strongprime_setup("p", x, &jp, nb, r, n, event, ectx)) == 0)
-    goto fail_x;
-  j.j = &jp;
-  bp->p = pgen("p", MP_NEW, x, event, ectx, n, pgen_jump, &j,
-              rabin_iters(nb), pgen_test, &rb);
-  pfilt_destroy(&jp);
-  if (!bp->p) {
-    if (n)
-      goto fail_p;
-    goto again;
-  }
-
-  /* --- Generate @q@ --- */
-
-  nb = nbits - nb;
-  if ((x = strongprime_setup("q", x, &g.jp, nb, r, n, event, ectx)) == 0)
-    goto fail_q;
-  if ((x->v[0] & 3) != 3)
-    x = mp_add(x, x, g.jp.m);
-  pfilt_muladd(&g.jp, &g.jp, 2, 0);
-  g.r = mp_lsr(MP_NEW, bp->p, 1);
-  g.g = MP_NEW;
-  g.max = MP_ONE;
-  bp->q = pgen("q", MP_NEW, x, event, ectx, n, pgen_gcdstep, &g,
-              rabin_iters(nb), pgen_test, &rb);
-  pfilt_destroy(&g.jp);
-  mp_drop(g.r);
-  mp_drop(g.g);
-  if (!bp->q) {
-    if (n)
-      goto fail_q;
-    mp_drop(bp->p);
-    goto again;
-  }
-
-  /* --- Compute @n@ --- */
-
-  bp->n = mp_mul(MP_NEW, bp->p, bp->q);
-  mp_drop(x);
-  return (PGEN_DONE);
-
-  /* --- Tidy up if things went wrong --- */
-
-fail_q:
-  mp_drop(bp->p);
-fail_p:
-  mp_drop(x);
-fail_x:
-  return (PGEN_ABORT);
-}
-
-/*----- That's all, folks -------------------------------------------------*/
diff --git a/bbs-jump.c b/bbs-jump.c
deleted file mode 100644 (file)
index 7275bd9..0000000
+++ /dev/null
@@ -1,296 +0,0 @@
-/* -*-c-*-
- *
- * $Id$
- *
- * Jumping around a BBS sequence
- *
- * (c) 1999 Straylight/Edgeware
- */
-
-/*----- Licensing notice --------------------------------------------------*
- *
- * This file is part of Catacomb.
- *
- * Catacomb is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * Catacomb is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with Catacomb; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- */
-
-/*----- Header files ------------------------------------------------------*/
-
-#include "bbs.h"
-#include "mp.h"
-#include "mpbarrett.h"
-#include "mpcrt.h"
-#include "mpint.h"
-
-/*----- Main code ---------------------------------------------------------*/
-
-/* --- @jump@ --- *
- *
- * Arguments:  @bbs *b@ = pointer to BBS generator context
- *             @const bbs_priv *bp@ = pointer to BBS modulus factors
- *             @mp *n@ = number of steps to move
- *             @mp *px@ = exponent mod @p@ for a one-step jump
- *             @mp *qx@ = exponent mod @q@ for a one-step jump
- *
- * Returns:    ---
- *
- * Use:                Jumps a BBS context a certain number of places (assuming the
- *             arguments are right).
- *
- *             Let the BBS modulus be %$n = pq$% and the current residue be
- *             %$x$%.  Then the computations performed are:
- *
- *               * Calculate %$x_p = x \bmod p$% and %$x_q = x \bmod q$%.
- *
- *               * Determine %$e_p = px^n \bmod (p - 1)$% and similarly
- *                 %$e_q = qx^n \bmod (p - 1)$%.
- *
- *               * Calculate %$x_p' = x_p^{e_p} \bmod p$% and
- *                 %$x_q' = x_q^{e_q} \bmod q$%.
- *
- *               * Combine %$x_p'$% and %$x_q'$% using the Chinese Remainder
- *                 Theorem.
- *
- *             If you want to step the generator forwards, simply set
- *             %$px = qx = 2$%.  If you want to step backwards, make
- *             %$px = (p + 1)/4$% and %$qx = (q + 1)/4$%.  Note that, if
- *             %$x$% is a quadratic residue mod $%p$%, then
- *
- *             %$(x^2) ^ {(p + 1)/4}$%
- *               %${} = x^{(p + 1)/2}$%
- *               %${} = x \cdot x^{(p - 1)/2}$%
- *               %${} = x$%
- *
- *             Simple, no?  (Note that the division works because
- *             %$p \equiv 3 \pmod 4$%.)
- */
-
-static void jump(bbs *b, const bbs_priv *bp, mp *n,
-                mp *px, mp *qx)
-{
-  mp *ep, *eq;
-  mp *v[2] = { MP_NEW, MP_NEW };
-
-  /* --- First work out the exponents --- */
-
-  {
-    mpbarrett mb;
-    mp *m;
-
-    m = mp_sub(MP_NEW, bp->p, MP_ONE);
-    mpbarrett_create(&mb, m);
-    ep = mpbarrett_exp(&mb, MP_NEW, px, n);
-    mpbarrett_destroy(&mb);
-    if (qx == px)
-      eq = MP_COPY(ep);
-    else {
-      m = mp_sub(m, bp->q, MP_ONE);
-      mpbarrett_create(&mb, m);
-      eq = mpbarrett_exp(&mb, MP_NEW, qx, n);
-      mpbarrett_destroy(&mb);
-    }
-
-    mp_drop(m);
-  }
-
-  /* --- Now calculate the residues of @x@ --- */
-
-  mp_div(0, &v[0], b->x, bp->p);
-  mp_div(0, &v[1], b->x, bp->q);
-
-  /* --- Exponentiate --- */
-
-  {
-    mpbarrett mb;
-
-    mpbarrett_create(&mb, bp->p);
-    v[0] = mpbarrett_exp(&mb, v[0], v[0], ep);
-    mpbarrett_destroy(&mb);
-
-    mpbarrett_create(&mb, bp->q);
-    v[1] = mpbarrett_exp(&mb, v[1], v[1], eq);
-    mpbarrett_destroy(&mb);
-
-    mp_drop(ep);
-    mp_drop(eq);
-  }
-
-  /* --- Sort out the result using the Chinese Remainder Theorem --- */
-
-  {
-    mpcrt_mod mv[2];
-    mpcrt c;
-    int i;
-
-    mv[0].m = MP_COPY(bp->p);
-    mv[1].m = MP_COPY(bp->q);
-    for (i = 0; i < 2; i++)
-      mv[i].n = mv[i].ni = mv[i].nni = MP_NEW;
-    mpcrt_create(&c, mv, 2, b->mb.m);
-    b->x = mpcrt_solve(&c, b->x, v);
-    mpcrt_destroy(&c);
-  }
-
-  /* --- Tidy away --- */
-
-  mp_drop(v[0]);
-  mp_drop(v[1]);
-  b->r = b->x->v[0];
-  b->b = b->k;
-}
-
-/* --- @bbs_{ff,rew}{,n}@ --- *
- *
- * Arguments:  @bbs *b@ = pointer to a BBS generator state
- *             @const bbs_priv *bp@ = pointer to BBS modulus factors
- *             @mp *n@, @unsigned long n@ = number of steps to make
- *
- * Returns:    ---
- *
- * Use:                `Fast-forwards' or rewinds a Blum-Blum-Shub generator by @n@
- *             steps.  The @...n@ versions take an @unsigned long@ argument;
- *             the non-@...n@ versions a multiprecision integer.  If @n@ is
- *             negative then the generator is stepped in the reverse
- *             direction.
- */
-
-static void ff(bbs *b, const bbs_priv *bp, mp *n)
-  { jump(b, bp, n, MP_TWO, MP_TWO); }
-
-static void rew(bbs *b, const bbs_priv *bp, mp *n)
-{
-  mp *px = mp_lsr(MP_NEW, bp->p, 2);
-  mp *qx = mp_lsr(MP_NEW, bp->q, 2);
-  px = mp_add(px, px, MP_ONE);
-  qx = mp_add(qx, qx, MP_ONE);
-  jump(b, bp, n, px, qx);
-  mp_drop(px);
-  mp_drop(qx);
-}
-
-void bbs_ff(bbs *b, const bbs_priv *bp, mp *n)
-{
-  if (!MP_NEGP(n))
-    ff(b, bp, n);
-  else {
-    n = mp_neg(MP_NEW, n);
-    rew(b, bp, n);
-    mp_drop(n);
-  }
-}
-
-void bbs_ffn(bbs *b, const bbs_priv *bp, unsigned long n)
-  { mp *nn = mp_fromulong(MP_NEW, n); ff(b, bp, nn); mp_drop(nn); }
-
-void bbs_rew(bbs *b, const bbs_priv *bp, mp *n)
-{
-  if (!MP_NEGP(n))
-    rew(b, bp, n);
-  else {
-    n = mp_neg(MP_NEW, n);
-    ff(b, bp, n);
-    mp_drop(n);
-  }
-}
-
-void bbs_rewn(bbs *b, const bbs_priv *bp, unsigned long n)
-  { mp *nn = mp_fromulong(MP_NEW, n); bbs_rew(b, bp, nn); mp_drop(nn); }
-
-/*----- Test rig ----------------------------------------------------------*/
-
-#ifdef TEST_RIG
-
-static int verify(dstr *v)
-{
-  bbs_priv bp;
-  bbs b;
-  mp *x;
-  unsigned long n;
-  int ok = 1;
-  uint32 p, q, r;
-  int i;
-
-  bp.p = *(mp **)v[0].buf;
-  bp.q = *(mp **)v[1].buf;
-  bp.n = mp_mul(MP_NEW, bp.p, bp.q);
-  x = *(mp **)v[2].buf;
-  n = *(unsigned long *)v[3].buf;
-
-  bbs_create(&b, bp.n, x);
-  p = bbs_bits(&b, 32);
-
-  bbs_seed(&b, x);
-  for (i = 0; i < n; i++)
-    bbs_step(&b);
-  q = bbs_bits(&b, 32);
-  bbs_wrap(&b);
-
-  bbs_rewn(&b, &bp, n + (32 + b.k - 1) / b.k);
-  r = bbs_bits(&b, 32);
-
-  if (r != p) {
-    fputs("\n*** bbs rewind failure\n", stderr);
-    fputs("p = ", stderr); mp_writefile(bp.p, stderr, 10); fputc('\n', stderr);
-    fputs("q = ", stderr); mp_writefile(bp.q, stderr, 10); fputc('\n', stderr);
-    fputs("n = ", stderr); mp_writefile(bp.n, stderr, 10); fputc('\n', stderr);
-    fputs("x = ", stderr); mp_writefile(x, stderr, 10); fputc('\n', stderr);
-    fprintf(stderr, "stepped %lu back\n", n + (32 + b.k - 1) / b.k);
-    fprintf(stderr, "expected output = %08lx, found %08lx\n",
-           (unsigned long)p, (unsigned long)r);
-    ok = 0;
-  }
-
-  bbs_seed(&b, x);
-  bbs_ffn(&b, &bp, n);
-  r = bbs_bits(&b, 32);
-
-  if (q != r) {
-    fputs("\n*** bbs fastforward failure\n", stderr);
-    fputs("p = ", stderr); mp_writefile(bp.p, stderr, 10); fputc('\n', stderr);
-    fputs("q = ", stderr); mp_writefile(bp.q, stderr, 10); fputc('\n', stderr);
-    fputs("n = ", stderr); mp_writefile(bp.n, stderr, 10); fputc('\n', stderr);
-    fputs("x = ", stderr); mp_writefile(x, stderr, 10); fputc('\n', stderr);
-    fprintf(stderr, "stepped %lu back\n", n + (32 + b.k - 1) / b.k);
-    fprintf(stderr, "expected output = %08lx, found %08lx\n",
-           (unsigned long)q, (unsigned long)r);
-    ok = 0;
-  }
-
-  bbs_destroy(&b);
-  mp_drop(bp.p);
-  mp_drop(bp.q);
-  mp_drop(bp.n);
-  mp_drop(x);
-
-  assert(mparena_count(MPARENA_GLOBAL) == 0);
-  return (ok);
-}
-
-static test_chunk tests[] = {
-  { "bbs-jump", verify, { &type_mp, &type_mp, &type_mp, &type_ulong, 0 } },
-  { 0, 0, { 0 } }
-};
-
-int main(int argc, char *argv[])
-{
-  sub_init();
-  test_run(argc, argv, tests, SRCDIR "/tests/bbs");
-  return (0);
-}
-
-#endif
-
-/*----- That's all, folks -------------------------------------------------*/
diff --git a/bbs-rand.c b/bbs-rand.c
deleted file mode 100644 (file)
index 20d9c7a..0000000
+++ /dev/null
@@ -1,423 +0,0 @@
-/* -*-c-*-
- *
- * $Id$
- *
- * Blum-Blum-Shub secure random number generator
- *
- * (c) 1999 Straylight/Edgeware
- */
-
-/*----- Licensing notice --------------------------------------------------*
- *
- * This file is part of Catacomb.
- *
- * Catacomb is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * Catacomb is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with Catacomb; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- */
-
-/*----- Header files ------------------------------------------------------*/
-
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <mLib/bits.h>
-#include <mLib/sub.h>
-
-#include "arena.h"
-#include "bbs.h"
-#include "grand.h"
-#include "mp.h"
-#include "mpbarrett.h"
-#include "mpint.h"
-#include "mprand.h"
-#include "paranoia.h"
-
-/*----- Main code ---------------------------------------------------------*/
-
-/* --- @bbs_create@ --- *
- *
- * Arguments:  @bbs *b@ = pointer to BBS generator state to initialize
- *             @mp *m@ = modulus (must be a Blum integer)
- *             @mp *x@ = initial seed for generator
- *
- * Returns:    ---
- *
- * Use:                Initializes a BBS generator.  The generator is stepped once
- *             after initialization, as for @bbs_seed@.
- */
-
-void bbs_create(bbs *b, mp *m, mp *x)
-{
-  mpw kw;
-  mp k;
-
-  mpbarrett_create(&b->mb, m);
-  kw = mp_bits(m) - 1;
-  mp_build(&k, &kw, &kw + 1);
-  b->k = mp_bits(&k) - 1;
-  b->x = 0;
-  bbs_seed(b, x);
-}
-
-/* --- @bbs_destroy@ --- *
- *
- * Arguments:  @bbs *b@ = pointer to BBS generator state
- *
- * Returns:    ---
- *
- * Use:                Destroys a generator state when it's no longer wanted.
- */
-
-void bbs_destroy(bbs *b)
-{
-  mp_drop(b->x);
-  mpbarrett_destroy(&b->mb);
-}
-
-/* --- @bbs_step@ --- *
- *
- * Arguments:  @bbs *b@ = pointer to BBS generator state
- *
- * Returns:    ---
- *
- * Use:                Steps the generator once.  This isn't too useful in client
- *             code.
- */
-
-void bbs_step(bbs *b)
-{
-  mp *x = b->x;
-  x = mp_sqr(x, x);
-  x = mpbarrett_reduce(&b->mb, x, x);
-  b->x = x;
-  b->b = b->k;
-  b->r = b->x->v[0];
-}
-
-/* --- @bbs_set@ --- *
- *
- * Arguments:  @bbs *b@ = pointer to BBS generator state
- *             @mp *x@ = new residue to set
- *
- * Returns:    ---
- *
- * Use:                Sets a new quadratic residue.  The generator is stepped once.
- */
-
-void bbs_set(bbs *b, mp *x)
-{
-  mp_drop(b->x);
-  b->x = MP_COPY(x);
-  bbs_step(b);
-}
-
-/* --- @bbs_seed@ --- *
- *
- * Arguments:  @bbs *b@ = pointer to BBS generator state
- *             @mp *x@ = new seed to set
- *
- * Returns     ---
- *
- * Use:                Sets a new seed.  The generator is stepped until the residue
- *             has clearly wrapped around.
- */
-
-void bbs_seed(bbs *b, mp *x)
-{
-  mp *y;
-  x = MP_COPY(x);
-  for (;;) {
-    y = mp_sqr(MP_NEW, x);
-    y = mpbarrett_reduce(&b->mb, y, y);
-    if (MP_CMP(y, <, x))
-      break;
-    mp_drop(x);
-    x = y;
-  }
-  mp_drop(x);
-  bbs_set(b, y);
-  mp_drop(y);
-}
-
-/* --- @bbs_bits@ --- *
- *
- * Arguments:  @bbs *b@ = pointer to BBS generator state
- *             @unsigned bits@ = number of bits wanted
- *
- * Returns:    Bits extracted from the BBS generator.
- *
- * Use:                Extracts a requested number of bits from the BBS generator.
- */
-
-uint32 bbs_bits(bbs *b, unsigned bits)
-{
-  uint32 x = 0;
-  mpw m;
-
-  /* --- Keep turning the handle until there's enough in the reservoir --- */
-
-  while (bits >= b->b) {
-    bits -= b->b;
-    m = (1 << b->b) - 1;
-    x |= (b->r & m) << bits;
-    bbs_step(b);
-  }
-
-  /* --- Extract the last few bits needed --- */
-
-  if (bits) {
-    m = (1 << bits) - 1;
-    b->b -= bits;
-    x |= (b->r >> b->b) & m;
-  }
-
-  /* --- Done --- */
-
-  return (x);
-}
-
-/* --- @bbs_wrap@ --- *
- *
- * Arguments:  @bbs *b@ = pointer to BBS generator state
- *
- * Returns:    ---
- *
- * Use:                Steps the generator if any of the reservoir bits are used.
- *             This can be used to `wrap up' after a Blum-Goldwasser
- *             encryption, for example, producing the final value to be sent
- *             along with the ciphertext.
- *
- *             If a generator is seeded, %$b$% bits are extracted, and then
- *             @bbs_wrap@ is called, the generator will have been stepped
- *             %$\lceil b/k \rceil$% times.
- */
-
-void bbs_wrap(bbs *b)
-{
-  if (b->b < b->k)
-    bbs_step(b);
-}
-
-/*----- Generic random number generator interface -------------------------*/
-
-typedef struct gctx {
-  grand r;
-  bbs b;
-} gctx;
-
-static void gdestroy(grand *r)
-{
-  gctx *g = (gctx *)r;
-  bbs_destroy(&g->b);
-  BURN(*g);
-  S_DESTROY(g);
-}
-
-static int gmisc(grand *r, unsigned op, ...)
-{
-  gctx *g = (gctx *)r;
-  va_list ap;
-  int rc = 0;
-  va_start(ap, op);
-
-  switch (op) {
-    case GRAND_CHECK:
-      switch (va_arg(ap, unsigned)) {
-       case GRAND_CHECK:
-       case GRAND_SEEDINT:
-       case GRAND_SEEDUINT32:
-       case GRAND_SEEDMP:
-       case GRAND_SEEDRAND:
-       case BBS_SET:
-       case BBS_STEP:
-       case BBS_STEPSZ:
-       case BBS_BITS:
-       case BBS_WRAP:
-       case BBS_FF:
-       case BBS_FFN:
-       case BBS_REW:
-       case BBS_REWN:
-       case BBS_MOD:
-       case BBS_STATE:
-         rc = 1;
-         break;
-       default:
-         rc = 0;
-         break;
-      }
-      break;
-    case GRAND_SEEDINT: {
-      mp *x = mp_fromuint(MP_NEW, va_arg(ap, unsigned));
-      bbs_seed(&g->b, x);
-      mp_drop(x);
-    } break;
-    case GRAND_SEEDUINT32: {
-      mp *x = mp_fromuint32(MP_NEW, va_arg(ap, uint32));
-      bbs_seed(&g->b, x);
-      mp_drop(x);
-    } break;
-    case GRAND_SEEDMP:
-      bbs_seed(&g->b, va_arg(ap, mp *));
-      break;
-    case GRAND_SEEDRAND: {
-      grand *rr = va_arg(ap, grand *);
-      mp *m = mprand(MP_NEW, mp_bits(g->b.mb.m) - 1, rr, 0);
-      bbs_seed(&g->b, m);
-      mp_drop(m);
-    } break;
-    case BBS_SET:
-      bbs_set(&g->b, va_arg(ap, mp *));
-      break;
-    case BBS_STEP:
-      bbs_step(&g->b);
-      break;
-    case BBS_STEPSZ:
-      rc = g->b.k;
-      break;
-    case BBS_BITS: {
-      unsigned nb = va_arg(ap, unsigned);
-      uint32 *w = va_arg(ap, uint32 *);
-      *w = bbs_bits(&g->b, nb);
-    } break;
-    case BBS_WRAP:
-      bbs_wrap(&g->b);
-      break;
-    case BBS_FF: {
-      const bbs_priv *bp = va_arg(ap, const bbs_priv *);
-      mp *n = va_arg(ap, mp *);
-      bbs_ff(&g->b, bp, n);
-    } break;
-    case BBS_FFN: {
-      const bbs_priv *bp = va_arg(ap, const bbs_priv *);
-      unsigned long n = va_arg(ap, unsigned long);
-      bbs_ffn(&g->b, bp, n);
-    } break;
-    case BBS_REW: {
-      const bbs_priv *bp = va_arg(ap, const bbs_priv *);
-      mp *n = va_arg(ap, mp *);
-      bbs_rew(&g->b, bp, n);
-    } break;
-    case BBS_REWN: {
-      const bbs_priv *bp = va_arg(ap, const bbs_priv *);
-      unsigned long n = va_arg(ap, unsigned long);
-      bbs_rewn(&g->b, bp, n);
-    } break;
-    case BBS_MOD: {
-      mp **n = va_arg(ap, mp **);
-      if (*n) MP_DROP(*n);
-      *n = MP_COPY(g->b.mb.m);
-    } break;
-    case BBS_STATE: {
-      mp **n = va_arg(ap, mp **);
-      if (*n) MP_DROP(*n);
-      *n = MP_COPY(g->b.x);
-    } break;
-    default:
-      GRAND_BADOP;
-      break;
-  }
-
-  va_end(ap);
-  return (rc);
-}
-
-static octet gbyte(grand *r)
-{
-  gctx *g = (gctx *)r;
-  return (bbs_bits(&g->b, 8));
-}
-
-static uint32 gword(grand *r)
-{
-  gctx *g = (gctx *)r;
-  return (bbs_bits(&g->b, 32));
-}
-
-static const grand_ops gops = {
-  "bbs",
-  GRAND_CRYPTO, 0,
-  gmisc, gdestroy,
-  gword, gbyte, gword, grand_range, grand_fill
-};
-
-/* --- @bbs_rand@ --- *
- *
- * Arguments:  @mp *m@ = modulus
- *             @mp *x@ = initial seed
- *
- * Returns:    Pointer to a generic generator.
- *
- * Use:                Constructs a generic generator interface over a
- *             Blum-Blum-Shub generator.
- */
-
-grand *bbs_rand(mp *m, mp *x)
-{
-  gctx *g = S_CREATE(gctx);
-  g->r.ops = &gops;
-  bbs_create(&g->b, m, x);
-  return (&g->r);
-}
-
-/*----- Test rig ----------------------------------------------------------*/
-
-#ifdef TEST_RIG
-
-static int verify(dstr *v)
-{
-  mp *n = *(mp **)v[0].buf;
-  mp *x = *(mp **)v[1].buf;
-  grand *b = bbs_rand(n, x);
-  dstr d = DSTR_INIT;
-  int ok = 1;
-
-  dstr_ensure(&d, v[2].len);
-  b->ops->fill(b, d.buf, v[2].len);
-  d.len = v[2].len;
-  if (memcmp(d.buf, v[2].buf, v[2].len) != 0) {
-    fputs("\n*** bbs failure\n", stderr);
-    fputs("n = ", stderr); mp_writefile(n, stderr, 10); fputc('\n', stderr);
-    fputs("x = ", stderr); mp_writefile(x, stderr, 10); fputc('\n', stderr);
-    fputs("expected = ", stderr); type_hex.dump(&v[2], stderr);
-    fputc('\n', stderr);
-    fputs("   found = ", stderr); type_hex.dump(&d, stderr);
-    fputc('\n', stderr);
-    fprintf(stderr, "k = %u\n", ((gctx *)b)->b.k);
-    ok = 0;
-  }
-  b->ops->destroy(b);
-  mp_drop(x);
-  mp_drop(n);
-  dstr_destroy(&d);
-  assert(mparena_count(MPARENA_GLOBAL) == 0);
-  return (ok);
-}
-
-static test_chunk tests[] = {
-  { "bbs", verify, { &type_mp, &type_mp, &type_hex, 0 } },
-  { 0, 0, { 0 } }
-};
-
-int main(int argc, char *argv[])
-{
-  sub_init();
-  test_run(argc, argv, tests, SRCDIR "/tests/bbs");
-  return (0);
-}
-
-#endif
-
-/*----- That's all, folks -------------------------------------------------*/
diff --git a/bbs.h b/bbs.h
deleted file mode 100644 (file)
index 30fb474..0000000
--- a/bbs.h
+++ /dev/null
@@ -1,296 +0,0 @@
-/* -*-c-*-
- *
- * $Id$
- *
- * The Blum-Blum-Shub random bit generator
- *
- * (c) 1999 Straylight/Edgeware
- */
-
-/*----- Licensing notice --------------------------------------------------*
- *
- * This file is part of Catacomb.
- *
- * Catacomb is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * Catacomb is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with Catacomb; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- */
-
-/*----- Notes on the BBS generator ----------------------------------------*
- *
- * The Blum-Blum-Shub generator takes the least significant bits from the
- * sequence %$x_i = x_{i - 1}^2 \bmod n$%, where %$n = pq$% is the product of
- * two primes %$p$% and %$q$%, each of which are congruent to %$3 \bmod 4$%.
- * For maximum period of the generator, %$(p - 1)/2$% and %$(q - 1)/1$%
- * should be coprime.  It is safe to use the least significant
- * %$\log \log n$% bits of each step in the sequence -- an adversary must
- * factor the modulus before being able to work forwards or backwards.  The
- * output of the generator cannot be distinguished from a (uniform,
- * independent) random sequence of bits using any polynomial-time test.  This
- * is by far the strongest pseudorandom number generator provided in
- * Catacomb, and by far the slowest too.  For normal use, the standard
- * Catacomb @rand@ generator should be more than adequate.
- */
-
-#ifndef CATACOMB_BBS_H
-#define CATACOMB_BBS_H
-
-#ifdef __cplusplus
-  extern "C" {
-#endif
-
-/*----- Header files ------------------------------------------------------*/
-
-#include <mLib/bits.h>
-
-#ifndef CATACOMB_GRAND_H
-#  include "grand.h"
-#endif
-
-#ifndef CATACOMB_KEY_H
-#  include "key.h"
-#endif
-
-#ifndef CATACOMB_MP_H
-#  include "mp.h"
-#endif
-
-#ifndef CATACOMB_MPBARRETT_H
-#  include "mpbarrett.h"
-#endif
-
-#ifndef CATACOMB_PGEN_H
-#  include "pgen.h"
-#endif
-
-/*----- Data structures ---------------------------------------------------*/
-
-/* --- Basic generator state --- */
-
-typedef struct bbs {
-  mpbarrett mb;                                /* Barrett reduction context */
-  mp *x;                               /* Current quadratic residue */
-  unsigned k;                          /* Number of bits from each step */
-  unsigned b;                          /* Number of bits in reservoir */
-  mpw r;                               /* Reservoir of output bits */
-} bbs;
-
-/* --- Parameters --- */
-
-typedef struct bbs_pub {
-  mp *n;
-} bbs_pub;
-
-typedef struct bbs_priv {
-  mp *p, *q;                           /* Prime factors (3 mod 4) */
-  mp *n;                               /* Product @pq@ -- a Blum integer */
-} bbs_priv;
-
-/*----- Key fetching ------------------------------------------------------*/
-
-extern const key_fetchdef bbs_pubfetch[];
-#define BBS_PUBFETCHSZ 3
-
-extern const key_fetchdef bbs_privfetch[];
-#define BBS_PRIVFETCHSZ 7
-
-/* --- @bbs_pubfree@, @bbs_privfree@ --- *
- *
- * Arguments:  @bbs_pub *bp@, @bbs_priv *bp@ = pointer to key block
- *
- * Returns:    ---
- *
- * Use:                Frees a BBS key block.
- */
-
-extern void bbs_pubfree(bbs_pub */*bp*/);
-extern void bbs_privfree(bbs_priv */*bp*/);
-
-/*----- The basic generator -----------------------------------------------*/
-
-/* --- @bbs_create@ --- *
- *
- * Arguments:  @bbs *b@ = pointer to BBS generator state to initialize
- *             @mp *m@ = modulus (must be a Blum integer)
- *             @mp *x@ = initial seed for generator
- *
- * Returns:    ---
- *
- * Use:                Initializes a BBS generator.  The generator is stepped once
- *             after initialization, as for @bbs_seed@.
- */
-
-extern void bbs_create(bbs */*b*/, mp */*m*/, mp */*x*/);
-
-/* --- @bbs_destroy@ --- *
- *
- * Arguments:  @bbs *b@ = pointer to BBS generator state
- *
- * Returns:    ---
- *
- * Use:                Destroys a generator state when it's no longer wanted.
- */
-
-extern void bbs_destroy(bbs */*b*/);
-
-/* --- @bbs_step@ --- *
- *
- * Arguments:  @bbs *b@ = pointer to BBS generator state
- *
- * Returns:    ---
- *
- * Use:                Steps the generator once.  This isn't too useful in client
- *             code.
- */
-
-extern void bbs_step(bbs */*b*/);
-
-/* --- @bbs_set@ --- *
- *
- * Arguments:  @bbs *b@ = pointer to BBS generator state
- *             @mp *x@ = new residue to set
- *
- * Returns:    ---
- *
- * Use:                Sets a new quadratic residue.  The generator is stepped once.
- */
-
-extern void bbs_set(bbs */*b*/, mp */*x*/);
-
-/* --- @bbs_seed@ --- *
- *
- * Arguments:  @bbs *b@ = pointer to BBS generator state
- *             @mp *x@ = new seed to set
- *
- * Returns     ---
- *
- * Use:                Sets a new seed.  The generator is stepped until the residue
- *             has clearly wrapped around.
- */
-
-extern void bbs_seed(bbs */*b*/, mp */*x*/);
-
-/* --- @bbs_bits@ --- *
- *
- * Arguments:  @bbs *b@ = pointer to BBS generator state
- *             @unsigned bits@ = number of bits wanted
- *
- * Returns:    Bits extracted from the BBS generator.
- *
- * Use:                Extracts a requested number of bits from the BBS generator.
- */
-
-extern uint32 bbs_bits(bbs */*b*/, unsigned /*bits*/);
-
-/* --- @bbs_wrap@ --- *
- *
- * Arguments:  @bbs *b@ = pointer to BBS generator state
- *
- * Returns:    ---
- *
- * Use:                Steps the generator if any of the reservoir bits are used.
- *             This can be used to `wrap up' after a Blum-Goldwasser
- *             encryption, for example, producing the final value to be sent
- *             along with the ciphertext.
- *
- *             If a generator is seeded, %$b$% bits are extracted, and then
- *             @bbs_wrap@ is called, the generator will have been stepped
- *             %$\lceil b/k \rceil$% times.
- */
-
-extern void bbs_wrap(bbs */*b*/);
-
-/*----- Large forwards and backwards jumps --------------------------------*/
-
-/* --- @bbs_{ff,rew}{,n}@ --- *
- *
- * Arguments:  @bbs *b@ = pointer to a BBS generator state
- *             @const bbs_priv *bp@ = pointer to BBS modulus factors
- *             @mp *n@, @unsigned long n@ = number of steps to make
- *
- * Returns:    ---
- *
- * Use:                `Fast-forwards' or rewinds a Blum-Blum-Shub generator by @n@
- *             steps.  The @...n@ versions take an @unsigned long@ argument;
- *             the non-@...n@ versions a multiprecision integer.  If @n@ is
- *             negative then the generator is stepped in the reverse
- *             direction.
- */
-
-extern void bbs_ff(bbs */*b*/, const bbs_priv */*bp*/, mp */*n*/);
-extern void bbs_ffn(bbs */*b*/, const bbs_priv */*bp*/, unsigned long /*n*/);
-extern void bbs_rew(bbs */*b*/, const bbs_priv */*bp*/, mp */*n*/);
-extern void bbs_rewn(bbs */*b*/, const bbs_priv */*bp*/, unsigned long /*n*/);
-
-/*----- Parameter generation ----------------------------------------------*/
-
-/* --- @bbs_gen@ --- *
- *
- * Arguments:  @bbs_priv *bp@ = pointer to parameter block
- *             @unsigned nbits@ = number of bits in the modulus
- *             @grand *r@ = pointer to random number source
- *             @unsigned n@ = number of attempts to make
- *             @pgen_proc *event@ = event handler function
- *             @void *ectx@ = argument for event handler
- *
- * Returns:    If it worked OK, @PGEN_DONE@, otherwise @PGEN_ABORT@.
- *
- * Use:                Finds two prime numbers %$p'$% and %$q'$% such that both are
- *             congruent to %$3 \bmod 4$%, and  $(p - 1)/2$% and
- *             %$(q - 1)/2$% have no common factors.  The product %$n = pq$%
- *             is eminently suitable for use as a modulus in a Blum-Blum-
- *             Shub pseudorandom bit generator.
- */
-
-extern int bbs_gen(bbs_priv */*bp*/, unsigned /*nbits*/, grand */*r*/,
-                  unsigned /*n*/, pgen_proc */*event*/, void */*ectx*/);
-
-/*----- Generic random number generator interface -------------------------*/
-
-/* --- @bbs_rand@ --- *
- *
- * Arguments:  @mp *m@ = modulus
- *             @mp *x@ = initial seed
- *
- * Returns:    Pointer to a generic generator.
- *
- * Use:                Constructs a generic generator interface over a
- *             Blum-Blum-Shub generator.
- */
-
-extern grand *bbs_rand(mp */*m*/, mp */*x*/);
-
-/* --- Blum-Blum-Shub-specific misc op codes --- */
-
-enum {
-  BBS_SET = GRAND_SPECIFIC('B'),       /* @mp *x@ */
-  BBS_STEP,                            /* @void@ */
-  BBS_STEPSZ,                          /* @void@ */
-  BBS_BITS,                            /* @unsigned bits, uint32 *w@ */
-  BBS_WRAP,                            /* @void@ */
-  BBS_FF,                              /* @bbs_priv *p, mp *n@ */
-  BBS_FFN,                             /* @bbs_priv *p, unsigned long n@ */
-  BBS_REW,                             /* @bbs_priv *p, mp *n@ */
-  BBS_REWN,                            /* @bbs_priv *p, unsigned long n@ */
-  BBS_MOD,                             /* @mp **n@ */
-  BBS_STATE                            /* @mp **x@ */
-};
-
-/*----- That's all, folks -------------------------------------------------*/
-
-#ifdef __cplusplus
-  }
-#endif
-
-#endif
diff --git a/bin-gentab.awk b/bin-gentab.awk
deleted file mode 100755 (executable)
index fb8630e..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-#! /usr/bin/awk -f
-#
-# $Id: p-gentab.awk 2187 2004-09-04 07:50:08Z mdw $
-
-function banner(name,  s, i)
-{
-  s = "/*----- " name " ";
-  while (length(s) < 75) s = s "-";
-  return (s "*/");
-}
-
-function fix(name)
-{
-  gsub(/[^0-9A-Za-z_]+/, "_", name);
-  return (name);
-}
-
-BEGIN {
-  print "/* -*-c-*-";
-  print " *";
-  print " * Table of binary groups [generated]";
-  print " */";
-  print "";
-  print "#include \"bintab.h\"";
-  print "";
-  print "#define N(x) (sizeof(x)/sizeof(*x))";
-  print "#define MP(x) { x, x + N(x), N(x), 0, MP_CONST, 0 }";
-  print "#define NOMP { 0, 0, 0, 0, 0 }";
-  print "";
-  print banner("Binary group data");
-  print "";
-
-  d_i = 0;
-  name = "";
-}
-
-function putmp(x,  d)
-{
-  if (!(x in data)) {
-    print "group " name ": missing " x >"/dev/stderr";
-    exit 1;
-  }
-  d = data[x];
-  if (!(d in cache)) {
-    n = "p_" fix(name) "_" x;
-    print "static mpw " n "[] = {";
-    system("./mpdump " d);
-    print "};";
-    print "";
-    cache[d] = n;
-  }
-  mp[x] = cache[d];
-}
-
-function flush()
-{
-  if (name == "") return;
-  print "/* --- Group " name " --- */";
-  delete mp;
-  print "";
-  putmp("p");
-  putmp("q");
-  putmp("g");
-  print "static bindata bin_" fix(name) " = {";
-  print "  MP(" mp["p"] "),"
-  print "  MP(" mp["q"] "),"
-  print "  MP(" mp["g"] ")"
-  print "};";
-  print "";
-  dname[d_i++] = name;
-  d[name] = name;
-  r[name] = "bin_" fix(name);
-  name = "";
-}
-
-/^[ \t]*(#|$)/ { next; }
-
-$1 == "alias" { flush(); dname[d_i++] = $2; d[$2] = $3; next; }
-
-$1 == "group" { flush(); delete data; name = $2; next; }
-
-{ data[$1] = $2; next; }
-
-END {
-  flush();
-  print banner("Main table");
-  print "";
-  print "const binentry bintab[] = {";
-  for (i = 0; i < d_i; i++) {
-    name = dname[i];
-    rname = d[name];
-    if (!rname in r) {
-      print "group " rname " not found (alias from " name ")" >"/dev/stderr";
-      exit 1;
-    }
-    print "  { \"" name "\", &" r[rname] " },";
-  }
-  print "  { 0, 0 }";
-  print "};"
-  print "";
-  print banner("That's all, folks");
-}
diff --git a/bintab.h b/bintab.h
deleted file mode 100644 (file)
index 221d749..0000000
--- a/bintab.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*-c-*-
- *
- * $Id$
- *
- * Table of standard (ish) binary groups
- *
- * (c) 2004 Straylight/Edgeware
- */
-
-/*----- Licensing notice --------------------------------------------------*
- *
- * This file is part of Catacomb.
- *
- * Catacomb is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * Catacomb is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with Catacomb; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- */
-
-#ifndef CATACOMB_BINTAB_H
-#define CATACOMB_BINTAB_H
-
-#ifdef __cplusplus
-  extern "C" {
-#endif
-
-/*----- Header files ------------------------------------------------------*/
-
-#include "mp.h"
-#include "ptab.h"
-
-/*----- Data structures ---------------------------------------------------*/
-
-typedef pdata bindata;
-typedef pentry binentry;
-
-/*----- Global variables --------------------------------------------------*/
-
-extern const binentry bintab[];
-
-/*----- That's all, folks -------------------------------------------------*/
-
-#ifdef __cplusplus
-  }
-#endif
-
-#endif
diff --git a/bintab.in b/bintab.in
deleted file mode 100644 (file)
index debe112..0000000
--- a/bintab.in
+++ /dev/null
@@ -1,37 +0,0 @@
-# $Id$
-#
-# Standard binary groups
-
-#----- From P1363 annex A ---------------------------------------------------
-
-group p1363-40
-  p 0x200000000000000000000000000000000000000000000065
-  q 0xabbcb671934086d21ff5f7
-  g 0x66704fca38d7962439e5f9bdab4d9ac6f0dd745c72f822e
-
-group p1363-56
-  p 0x100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100d
-  q 0x5538ed0653399777d80d50e508fd01
-  g 0x44e2fd3317b4a1968ce65b7e72f8d64262987d0a818a5a5189a6d588b67317c9ee05a38e3e5691e34933e3e050543d8b
-
-group p1363-64
-  p 0x4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800001
-  q 0x84b73a6a902299c1aeeb8b537f1ea87c1
-  g 0xce10e3ae38cacb7c1076723b80be855c629c03abef26d2a5ca898f75d2bd794daa9e21781f063ab2785a8c402f976d73e5c8d66072cd950dee1ea722bb8f3d
-
-group p1363-80
-  p 0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080043
-  q 0x519f0cb14cf36cfcda7d08fab2b578314c9542801
-  g 0xd0f0d0046d995f82b1599c7bceb20010b2ec0d27748d113c532657584c9ea11ab6be6b7236cfafc2a087503e1ad108e559206d559e7c30f4a516da71fa3e08fc50e03084f18af4a59e9c6835beb67dfd2b47ef8d0ea30d8f65e378e9ba82819ffc0ade685fa6cb346dcecca7134893db0a6950c2beab89ee38508f03f2f1f186
-
-group p1363-112
-  p 0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040481
-  q 0x399ac734bd00a6f622bdd00c5f930dcf2ae5d7c521755f7b664f104e423bddd
-  g 0x40154611e5cd5d4826382b23d4ba28fa9d050bb4db5e81b90816fa2823b62328798b70c061734b327e7e3221002a08554e4902f26c476a152380f49e7e2624066de81ef26ddabf4b2c4cc9374f60189e4e5446e04c39d1de05947c54eb6d8c63e498a83d5025ea9fcf2ff3195fb76d76cc2df73918268b72f693a28a01c14622351cc53546bdaacfc95ad19aee16d3d88fbb5fe8143a8a3dcf3d48525be95bef28921edcee081b5269d0b5307ed97f55e5d0218dd17a39f393e017fcfe999626f1fc6ae9a485395a62a3e969d2e0cce55755cc0e22c4356741313d762505c9a2594af3e94d8f913798d92ccf6a73d2447c474ed2924a29856c5c2feeb178a35b15545
-
-group p1363-128
-  p 0x1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002441
-  q 0xa5c52c0d53fc1f43b2cbfd7447d53d55c37004338502dfda0f31b7df76bde74081
-  g 0x9447bb7ca087a37a5268c9e4cd3b9c3eb752272af39657d616181d28f18634368ba972a26b93b2980b391e23d7a9313785a5a17adfd9f810a3677cc20342965e09afc81b8413c5b3054c3adffec6411f088942d5877eef220b2a01cd7c48e8bae8f394b2a0893eb293f6355fc3ea962e503ae1d6fd0c3d718de374100cf89cb9c72e125fac9f930abb9959d03ef18354dd16f3a51e42e2c43ef100a8c3ca9523e6decbdf1f67db454df5781d16d55e94663f9633985d2f76b71a9bb10a985a8c6e8cb4190bef038798e9f402ea8027698e9d28a4ee14f0a6724f38dab82578a0e9600fa5717f40d8f107cb148c896c3061945318b25436c04f84a1b0fa043417bf7904915fa6afaed5fd24c73a5a1328973f39e8bc930ccc3099d7f715f8738b13d0b113899200b2293cdba34a46d22c0fab4d8ed33a71c691ba90687000030ad2fe05b5668520e24edb37edcf43827d9cf0b96ff776f88a2041eadd6902e12428716b46533d765d
-
-#----- That's all, folks ----------------------------------------------------
diff --git a/bitops.h b/bitops.h
deleted file mode 100644 (file)
index 02f9a34..0000000
--- a/bitops.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*-c-*-
- *
- * $Id: bitops.h,v 1.2 2004/04/08 01:36:15 mdw Exp $
- *
- * Bit operations by truth table
- *
- * (c) 2002 Straylight/Edgeware
- */
-
-/*----- Licensing notice --------------------------------------------------*
- *
- * This file is part of Catacomb.
- *
- * Catacomb is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * Catacomb is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with Catacomb; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- */
-
-#ifndef CATACOMB_BITOPS_H
-#define CATACOMB_BITOPS_H
-
-#ifdef __cplusplus
-  extern "C" {
-#endif
-
-/*----- Macros ------------------------------------------------------------*/
-
-#define B0000(x, y) (0u)
-#define B0001(x, y) ((x) & (y))
-#define B0010(x, y) ((x) & ~(y))
-#define B0011(x, y) (x)
-#define B0100(x, y) (~(x) & (y))
-#define B0101(x, y) (y)
-#define B0110(x, y) ((x) ^ (y))
-#define B0111(x, y) ((x) | (y))
-#define B1000(x, y) (~((x) | (y)))
-#define B1001(x, y) (~((x) ^ (y)))
-#define B1010(x, y) (~(y))
-#define B1011(x, y) ((x) | ~(y))
-#define B1100(x, y) (~(x))
-#define B1101(x, y) (~(x) | (y))
-#define B1110(x, y) (~((x) & (y)))
-#define B1111(x, y) (~0u)
-
-/*----- That's all, folks -------------------------------------------------*/
-
-#ifdef __cplusplus
-  }
-#endif
-
-#endif
diff --git a/bittest.c b/bittest.c
deleted file mode 100644 (file)
index f13d358..0000000
--- a/bittest.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*-c-*-
- *
- * $Id: bittest.c,v 1.2 2004/04/08 01:36:15 mdw Exp $
- *
- * Check the bit operations work
- *
- * (c) 2002 Straylight/Edgeware
- */
-
-/*----- Licensing notice --------------------------------------------------*
- *
- * This file is part of Catacomb.
- *
- * Catacomb is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * Catacomb is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with Catacomb; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- */
-
-/*----- Header files ------------------------------------------------------*/
-
-#include <stdio.h>
-#include <string.h>
-#include "bitops.h"
-#include "mpx.h"
-
-/*----- Main code ---------------------------------------------------------*/
-
-int main(void)
-{
-  int rc = 0;
-#define CHECK(string) do {                                             \
-  const char *ref = #string;                                           \
-  char buf[5];                                                         \
-  buf[0] = B##string(0u, 0u) & 1u? '1' : '0';                          \
-  buf[1] = B##string(0u, 1u) & 1u? '1' : '0';                          \
-  buf[2] = B##string(1u, 0u) & 1u? '1' : '0';                          \
-  buf[3] = B##string(1u, 1u) & 1u? '1' : '0';                          \
-  buf[4] = 0;                                                          \
-  if (strcmp(buf, ref) != 0) {                                         \
-    fprintf(stderr, "mismatch ref `%s' != buf `%s'\n", ref, buf);      \
-    rc = 1;                                                            \
-  }                                                                    \
-} while (0);
-  MPX_DOBIN(CHECK)
-  return (rc);
-}
-/*----- That's all, folks -------------------------------------------------*/
diff --git a/blkc.h b/blkc.h
deleted file mode 100644 (file)
index d95c4f9..0000000
--- a/blkc.h
+++ /dev/null
@@ -1,347 +0,0 @@
-/* -*-c-*-
- *
- * $Id$
- *
- * Common definitions for block ciphers
- *
- * (c) 1999 Straylight/Edgeware
- */
-
-/*----- Licensing notice --------------------------------------------------*
- *
- * This file is part of Catacomb.
- *
- * Catacomb is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * Catacomb is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with Catacomb; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- */
-
-#ifndef CATACOMB_BLKC_H
-#define CATACOMB_BLKC_H
-
-#ifdef __cplusplus
-  extern "C" {
-#endif
-
-/*----- Header files ------------------------------------------------------*/
-
-#include <assert.h>
-
-#include <mLib/bits.h>
-
-/*----- Theory of operation -----------------------------------------------*
- *
- * A block cipher has associated with it a triple, called PRE_CLASS, of the
- * form `(TYPE, ENDIAN, BITS)', where TYPE is either `N' (representing an
- * implemented bit size) or `X' (representing an unimplemented bit size,
- * causing loops to be compiled rather than unrolled code), ENDIAN is `B'
- * (big) or `L' (little), and BITS is the block size of the cipher in bits.
- */
-
-/*----- Data movement macros ----------------------------------------------*/
-
-/*
- * `The C preprocessor.  You will never find a more wretched hive of bogus
- * hackery.  We must be cautious.'
- */
-
-/* --- General dispatch macros --- */
-
-#define BLKC_DOGLUE(x, y) x ## y
-#define BLKC_GLUE(x, y) BLKC_DOGLUE(x, y)
-#define BLKC_APPLY(f, x) f x
-#define BLKC_FIRST(x, y, z) x
-#define BLKC_SECOND(x, y, z) y
-#define BLKC_THIRD(x, y, z) z
-#define BLKC_TYPE(PRE) BLKC_APPLY(BLKC_FIRST, PRE##_CLASS)
-#define BLKC_ENDIAN(PRE) BLKC_APPLY(BLKC_SECOND, PRE##_CLASS)
-#define BLKC_BITS(PRE) BLKC_APPLY(BLKC_THIRD, PRE##_CLASS)
-
-#define BLKC_STORE_E(PRE) BLKC_GLUE(STORE32_, BLKC_ENDIAN(PRE))
-#define BLKC_LOAD_E(PRE) BLKC_GLUE(LOAD32_, BLKC_ENDIAN(PRE))
-
-/* --- Interface macros --- */
-
-#define BLKC_STORE(PRE, b, w)                                          \
-  BLKC_GLUE(BLKC_STORE_, BLKC_TYPE(PRE))                               \
-    (PRE, b, w, BLKC_STORE_E(PRE), BLKC_BITS(PRE))
-
-#define BLKC_XSTORE(PRE, b, w, wx)                                     \
-  BLKC_GLUE(BLKC_XSTORE_, BLKC_TYPE(PRE))                              \
-    (PRE, b, w, wx, BLKC_STORE_E(PRE), BLKC_BITS(PRE))
-
-#define BLKC_LOAD(PRE, w, b)                                           \
-  BLKC_GLUE(BLKC_LOAD_, BLKC_TYPE(PRE))                                        \
-    (PRE, w, b, BLKC_LOAD_E(PRE), BLKC_BITS(PRE))
-
-#define BLKC_XLOAD(PRE, w, b)                                          \
-  BLKC_GLUE(BLKC_XLOAD_, BLKC_TYPE(PRE))                               \
-    (PRE, w, b, BLKC_LOAD_E(PRE), BLKC_BITS(PRE))
-
-#define BLKC_MOVE(PRE, w, wx)                                          \
-  BLKC_GLUE(BLKC_MOVE_, BLKC_TYPE(PRE))                                        \
-    (PRE, w, wx, BLKC_BITS(PRE))
-
-#define BLKC_XMOVE(PRE, w, wx)                                         \
-  BLKC_GLUE(BLKC_XMOVE_, BLKC_TYPE(PRE))                               \
-    (PRE, w, wx, BLKC_BITS(PRE))
-
-#define BLKC_STEP(PRE, w)                                              \
-  BLKC_GLUE(BLKC_STEP_X_, BLKC_ENDIAN(PRE))                            \
-    (PRE, w)
-
-#define BLKC_ZERO(PRE, w)                                              \
-  BLKC_GLUE(BLKC_ZERO_, BLKC_TYPE(PRE))                                        \
-    (PRE, w, BLKC_BITS(PRE))
-
-#define BLKC_SET(PRE, w, x)                                            \
-  BLKC_GLUE(BLKC_SET_X_, BLKC_ENDIAN(PRE))                             \
-    (PRE, w, x)
-
-#define BLKC_SHOW(PRE, tag, w) do {                                    \
-  fputs(tag ": ", stdout);                                             \
-  BLKC_SKEL_X(PRE, BLKC_W(w);, printf("%08x ", *_w++););               \
-  fputc('\n', stdout);                                                 \
-} while (0)
-
-/* --- General implementation skeleton --- */
-
-#define BLKC_SKEL(PRE, decl, guts) do {                                        \
-  decl                                                                 \
-  guts                                                                 \
-} while (0)
-
-#define BLKC_P(p) register octet *_p = (octet *)(p)
-#define BLKC_W(w) register uint32 *_w = (w)
-#define BLKC_WX(wx) register uint32 *_wx = (wx)
-
-/* --- Implementation for unusual block sizes --- */
-
-#define BLKC_SKEL_X(PRE, decl, guts)                                   \
-  BLKC_SKEL(PRE, unsigned _i; decl,                                    \
-           for (_i = 0; _i < PRE##_BLKSZ / 4; _i++) {                  \
-             guts                                                      \
-           })
-
-#define BLKC_STORE_X(PRE, b, w, op, n)                                 \
-  BLKC_SKEL_X(PRE, BLKC_P(b); const BLKC_W(w);,                                \
-             op(_p, *_w); _p += 4; _w++; )
-
-#define BLKC_XSTORE_X(PRE, b, w, wx, op, n)                            \
-  BLKC_SKEL_X(PRE, BLKC_P(b); const BLKC_W(w); const BLKC_WX(wx);,     \
-             op(_p, *_w ^ *_wx); _p += 4; _w++; _wx++; )
-
-#define BLKC_LOAD_X(PRE, w, b, op, n)                                  \
-  BLKC_SKEL_X(PRE, const BLKC_P(b); BLKC_W(w);,                                \
-             *_w = op(_p); _p += 4; _w++; )
-
-#define BLKC_XLOAD_X(PRE, w, b, op, n)                                 \
-  BLKC_SKEL_X(PRE, const BLKC_P(b); BLKC_W(w);,                                \
-             *_w ^= op(_p); _p += 4; _w++; )
-
-#define BLKC_MOVE_X(PRE, w, wx, n)                                     \
-  BLKC_SKEL_X(PRE, BLKC_W(w); const BLKC_WX(wx);,                      \
-             *_w = *_wx; _w++; _wx++; )                                \
-
-#define BLKC_XMOVE_X(PRE, w, wx, n)                                    \
-  BLKC_SKEL_X(PRE, BLKC_W(w); const BLKC_WX(wx);,                      \
-             *_w ^= *_wx; _w++; _wx++; )                               \
-
-#define BLKC_ZERO_X(PRE, w, n)                                         \
-  BLKC_SKEL_X(PRE, BLKC_W(w);, *_w++ = 0;)
-
-#define BLKC_STEP_X_B(PRE, w) do {                                     \
-  unsigned _i = PRE##_BLKSZ / 4; BLKC_W(w); uint32 _x = 0;             \
-  while (_i && !_x) { _i--; _w[_i] = _x = U32(_w[_i] + 1); }           \
-} while (0)
-
-#define BLKC_STEP_X_L(PRE, w) do {                                     \
-  unsigned _i = 0; BLKC_W(w); uint32 _x = 0;                           \
-  while (_i < PRE##_BLKSZ / 4 && !_x)                                  \
-    { _w[_i] = _x = U32(_w[_i] + 1); _i++; }                           \
-} while (0)
-
-#define BLKC_SET_X_B(PRE, w, x) do {                                   \
-  unsigned _i; BLKC_W(w); unsigned long _x = x;                                \
-  for (_i = 0; _i < PRE##_BLKSZ / 4; _i++) {                           \
-    *_w++ = U32(_x);                                                   \
-    _x = ((_x & ~MASK32) >> 16) >> 16;                                 \
-  }                                                                    \
-} while (0)
-
-#define BLKC_SET_X_L(PRE, w, x) do {                                   \
-  unsigned _i; BLKC_W(w); unsigned long _x = x;        _w += PRE##_BLKSZ / 4;  \
-  for (_i = 0; _i < PRE##_BLKSZ / 4; _i++) {                           \
-    *--_w = U32(_x);                                                   \
-    _x = ((_x & ~MASK32) >> 16) >> 16;                                 \
-  }                                                                    \
-} while (0)
-
-/* --- Implementation for known block sizes --- */
-
-#define BLKC_SKEL_64(PRE, decl, op, guts)                              \
-  BLKC_SKEL(PRE, decl, guts(op, 0); guts(op, 1);)
-
-#define BLKC_SKEL_96(PRE, decl, op, guts)                              \
-  BLKC_SKEL(PRE, decl, guts(op, 0); guts(op, 1); guts(op, 2);)
-
-#define BLKC_SKEL_128(PRE, decl, op, guts)                             \
-  BLKC_SKEL(PRE, decl, guts(op, 0); guts(op, 1); guts(op, 2); guts(op, 3);)
-
-#define BLKC_SKEL_192(PRE, decl, op, guts)                             \
-  BLKC_SKEL(PRE, decl,                                                 \
-           guts(op, 0); guts(op, 1); guts(op, 2); guts(op, 3);         \
-           guts(op, 4); guts(op, 5);)
-
-#define BLKC_SKEL_256(PRE, decl, op, guts)                             \
-  BLKC_SKEL(PRE, decl,                                                 \
-           guts(op, 0); guts(op, 1); guts(op, 2); guts(op, 3);         \
-           guts(op, 4); guts(op, 5); guts(op, 6); guts(op, 7);)
-
-#define BLKC_STORE_GUTS(op, i) op(_p + 4 * i, _w[i])
-#define BLKC_XSTORE_GUTS(op, i) op(_p + 4 * i, _w[i] ^ _wx[i])
-#define BLKC_LOAD_GUTS(op, i) _w[i] = op(_p + 4 * i)
-#define BLKC_XLOAD_GUTS(op, i) _w[i] ^= op(_p + 4 * i)
-#define BLKC_MOVE_GUTS(op, i) _w[i] = _wx[i]
-#define BLKC_XMOVE_GUTS(op, i) _w[i] ^= _wx[i]
-#define BLKC_ZERO_GUTS(op, i) _w[i] = 0
-
-#define BLKC_STORE_N(PRE, b, w, op, n)                                 \
-  BLKC_GLUE(BLKC_SKEL_, n)                                             \
-    (PRE, BLKC_P(b); const BLKC_W(w);, op, BLKC_STORE_GUTS)
-
-#define BLKC_XSTORE_N(PRE, b, w, wx, op, n)                            \
-  BLKC_GLUE(BLKC_SKEL_, n)                                             \
-    (PRE, BLKC_P(b); const BLKC_W(w); const BLKC_WX(wx);,              \
-     op, BLKC_XSTORE_GUTS)
-
-#define BLKC_LOAD_N(PRE, w, b, op, n)                                  \
-  BLKC_GLUE(BLKC_SKEL_, n)                                             \
-    (PRE, const BLKC_P(b); BLKC_W(w);, op, BLKC_LOAD_GUTS)
-
-#define BLKC_XLOAD_N(PRE, w, b, op, n)                                 \
-  BLKC_GLUE(BLKC_SKEL_, n)                                             \
-    (PRE, const BLKC_P(b); BLKC_W(w);, op, BLKC_XLOAD_GUTS)
-
-#define BLKC_MOVE_N(PRE, w, wx, n)                                     \
-  BLKC_GLUE(BLKC_SKEL_, n)                                             \
-    (PRE, BLKC_W(w); const BLKC_WX(wx);, op, BLKC_MOVE_GUTS)
-
-#define BLKC_ZERO_N(PRE, w, n)                                         \
-  BLKC_GLUE(BLKC_SKEL_, n)                                             \
-    (PRE, BLKC_W(w); , op, BLKC_ZERO_GUTS)
-
-#define BLKC_XMOVE_N(PRE, w, wx, n)                                    \
-  BLKC_GLUE(BLKC_SKEL_, n)                                             \
-    (PRE, BLKC_W(w); const BLKC_WX(wx);, op, BLKC_XMOVE_GUTS)
-
-/*----- Test rig for block ciphers ----------------------------------------*/
-
-/* --- @BLKC_TEST@ --- *
- *
- * Arguments:  @PRE@, @pre@ = prefixes for cipher-specific definitions
- *
- * Use:                Standard test rig for block ciphers.
- */
-
-#ifdef TEST_RIG
-
-#include <string.h>
-
-#include <mLib/quis.h>
-#include <mLib/testrig.h>
-
-#define BLKC_VERIFY(PRE, pre)                                          \
-                                                                       \
-static int pre##_verify(dstr *v)                                       \
-{                                                                      \
-  pre##_ctx k;                                                         \
-  uint32 p[PRE##_BLKSZ / 4];                                           \
-  uint32 c[PRE##_BLKSZ / 4];                                           \
-  uint32 d[PRE##_BLKSZ / 4];                                           \
-  dstr b = DSTR_INIT;                                                  \
-  int ok = 1;                                                          \
-                                                                       \
-  /* --- Initialize the key buffer --- */                              \
-                                                                       \
-  dstr_ensure(&b, PRE##_BLKSZ);                                                \
-  b.len = PRE##_BLKSZ;                                                 \
-  pre##_init(&k, v[0].buf, v[0].len);                                  \
-  BLKC_LOAD(PRE, p, v[1].buf);                                         \
-  BLKC_LOAD(PRE, c, v[2].buf);                                         \
-                                                                       \
-  /* --- Test encryption --- */                                                \
-                                                                       \
-  BLKC_MOVE(PRE, d, p);                                                        \
-  pre##_eblk(&k, d, d);                                                        \
-  BLKC_STORE(PRE, b.buf, d);                                           \
-  if (memcmp(b.buf, v[2].buf, PRE##_BLKSZ)) {                          \
-    ok = 0;                                                            \
-    printf("\nfail encryption:"                                                \
-          "\n\tkey        = ");                                        \
-    type_hex.dump(&v[0], stdout);                                      \
-    printf("\n\tplaintext  = "); type_hex.dump(&v[1], stdout);         \
-    printf("\n\texpected   = "); type_hex.dump(&v[2], stdout);         \
-    printf("\n\tcalculated = "); type_hex.dump(&b, stdout);            \
-    putchar('\n');                                                     \
-  }                                                                    \
-                                                                       \
-  /* --- Test decryption --- */                                                \
-                                                                       \
-  BLKC_MOVE(PRE, d, c);                                                        \
-  pre##_dblk(&k, d, d);                                                        \
-  BLKC_STORE(PRE, b.buf, d);                                           \
-  if (memcmp(b.buf, v[1].buf, PRE##_BLKSZ)) {                          \
-    ok = 0;                                                            \
-    printf("\nfail decryption:"                                                \
-          "\n\tkey        = ");                                        \
-    type_hex.dump(&v[0], stdout);                                      \
-    printf("\n\tciphertext = "); type_hex.dump(&v[2], stdout);         \
-    printf("\n\texpected   = "); type_hex.dump(&v[1], stdout);         \
-    printf("\n\tcalculated = "); type_hex.dump(&b, stdout);            \
-    putchar('\n');                                                     \
-  }                                                                    \
-                                                                       \
-  /* --- Return --- */                                                 \
-                                                                       \
-  return (ok);                                                         \
-}
-
-#define BLKC_TEST(PRE, pre)                                            \
-                                                                       \
-BLKC_VERIFY(PRE, pre)                                                  \
-                                                                       \
-static const test_chunk defs[] = {                                     \
-  { #pre, pre##_verify, { &type_hex, &type_hex, &type_hex, 0 } },      \
-  { 0, 0, { 0 } }                                                      \
-};                                                                     \
-                                                                       \
-int main(int argc, char *argv[])                                       \
-{                                                                      \
-  test_run(argc, argv, defs, SRCDIR"/tests/" #pre);                    \
-  return (0);                                                          \
-}
-
-#else
-#  define BLKC_VERIFY(PRE, pre)
-#  define BLKC_TEST(PRE, pre)
-#endif
-
-/*----- That's all, folks -------------------------------------------------*/
-
-#ifdef __cplusplus
-  }
-#endif
-
-#endif
diff --git a/blowfish-mktab.c b/blowfish-mktab.c
deleted file mode 100644 (file)
index 9d6fcb2..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-/* -*-c-*-
- *
- * $Id: blowfish-mktab.c,v 1.3 2004/04/08 01:36:15 mdw Exp $
- *
- * Build Blowfish key table
- *
- * (c) 2000 Straylight/Edgeware
- */
-
-/*----- Licensing notice --------------------------------------------------*
- *
- * This file is part of Catacomb.
- *
- * Catacomb is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * Catacomb is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with Catacomb; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- */
-
-/*----- Header files ------------------------------------------------------*/
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <mLib/bits.h>
-
-/*----- Main code ---------------------------------------------------------*/
-
-/* --- @spigot@ --- *
- *
- * Arguments:  @uint32 *buf@ = pointer to the output buffer
- *             @size_t n@ = number of output digits wanted
- *
- * Returns:    ---
- *
- * Use:                Writes digits of %$\pi$% to the given array.  The algorithm
- *             is based on the Spigot algorithm by Stanley Rabinowitz and
- *             Stan Wagon, published in Amer.Math.Monthly, March 1995, with
- *             bug fixes by C. Haenel.  I then bodged it to output hex
- *             digits rather than decimal ones, and to leave off the initial
- *             `3'.
- *
- *             I've not analysed the algorithm very much.
- */
-
-#define SPIGOT_WORDS (18 + 4 * 256ul)
-#define SPIGOT_BITS 8
-#define SPIGOT_RADIX (1ul << SPIGOT_BITS)
-#define SPIGOT_BUFLEN (SPIGOT_WORDS * 32)
-
-#ifdef QUIET
-#  define Q(x)
-#else
-#  define Q(x) x
-#endif
-
-static void spigot(uint32 *buf, size_t n)
-{
-  uint32 acc = 0;
-  int b = -1;
-  unsigned a[SPIGOT_BUFLEN] = { 0 };
-  uint32 p = 0;
-  unsigned f = 0;
-  unsigned max = 32 * n;
-  Q( size_t step = n / 60; )
-
-  Q( fputs("[                                                         ]\r[",
-          stderr); )
-
-#define EMIT(z) do {                                                   \
-  if (b == -1)                                                         \
-    b = 0;                                                             \
-  else {                                                               \
-    acc = (acc << SPIGOT_BITS) | (z);                                  \
-    b += SPIGOT_BITS;                                                  \
-    if (b == 32) {                                                     \
-      *buf++ = acc;                                                    \
-      acc = 0;                                                         \
-      b = 0;                                                           \
-      n--;                                                             \
-      if (!n)                                                          \
-       goto done;                                                      \
-      Q( if (n % step == 0)                                            \
-          fputc('.', stderr); )                                        \
-    }                                                                  \
-  }                                                                    \
-} while (0)
-
-  while (n) {
-    uint32 q = 0;
-    uint32 i;
-    uint32 x = 0;
-    uint32 k = max * 2 - 1;
-
-    for (i = max; i; i--)