diff options
author | lloyd <[email protected]> | 2008-09-29 20:17:08 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-09-29 20:17:08 +0000 |
commit | 7c0319368d1948d54db514e5f72c589a397e2909 (patch) | |
tree | 2d52b6dd8715a6ea0fc21b3a66673fb38a8d4ebb /doc | |
parent | 0f2dfff90fe3882a85308d66a05803178a452023 (diff) |
Remove the misc dir:
Moved XS, Boost Python, and SWIG wrappers to new toplevel directory 'wrappers'
Moved NIST X.509 test suite into checks directory
Move the build information used by configure.pl to src/build-data
Move scripts directory to doc (for lack of a better spot)
Diffstat (limited to 'doc')
-rwxr-xr-x | doc/scripts/comba.py | 65 | ||||
-rwxr-xr-x | doc/scripts/combine_bmarks.pl | 120 | ||||
-rwxr-xr-x | doc/scripts/dist.sh | 63 | ||||
-rwxr-xr-x | doc/scripts/primes.py | 63 |
4 files changed, 311 insertions, 0 deletions
diff --git a/doc/scripts/comba.py b/doc/scripts/comba.py new file mode 100755 index 000000000..ce3cfed77 --- /dev/null +++ b/doc/scripts/comba.py @@ -0,0 +1,65 @@ +#!/usr/bin/python + +import sys + +def comba_indexes(N): + + indexes = [] + + for i in xrange(0, 2*N): + x = [] + + for j in xrange(max(0, i-N+1), min(N, i+1)): + x += [(j,i-j)] + indexes += [sorted(x)] + + return indexes + +def comba_sqr_indexes(N): + + indexes = [] + + for i in xrange(0, 2*N): + x = [] + + for j in xrange(max(0, i-N+1), min(N, i+1)): + if j < i-j: + x += [(j,i-j)] + else: + x += [(i-j,j)] + indexes += [sorted(x)] + + return indexes + +def comba_multiply_code(N): + indexes = comba_indexes(N) + + for (i,idx) in zip(range(0, len(indexes)), indexes): + for pair in idx: + print "word3_muladd(&w2, &w1, &w0, x[%2d], y[%2d]);" % (pair) + print "z[%2d] = w0; w0 = w1; w1 = w2; w2 = 0;" % (i) + +def comba_square_code(N): + indexes = comba_sqr_indexes(N) + + for (rnd,idx) in zip(range(0, len(indexes)), indexes): + for (i,pair) in zip(range(0, len(idx)), idx): + if pair[0] == pair[1]: + print " word3_muladd(&w2, &w1, &w0, x[%2d], x[%2d]);" % (pair) + elif i % 2 == 0: + print " word3_muladd_2(&w2, &w1, &w0, x[%2d], x[%2d]);" % (pair[0], pair[1]) + if rnd < len(idx)-2: + print " z[%2d] = w0; w0 = w1; w1 = w2; w2 = 0;\n" % (rnd) + elif rnd == len(idx)-1: + print " z[%2d] = w0;\n" % (rnd) + else: + print " z[%2d] = w1;\n" % (rnd) + +def main(args = None): + if args is None: + args = sys.argv + #comba_square_code(int(args[1])) + comba_multiply_code(int(args[1])) + +if __name__ == '__main__': + sys.exit(main()) diff --git a/doc/scripts/combine_bmarks.pl b/doc/scripts/combine_bmarks.pl new file mode 100755 index 000000000..b6436496e --- /dev/null +++ b/doc/scripts/combine_bmarks.pl @@ -0,0 +1,120 @@ +#!/usr/bin/perl -w + +use strict; + +my %results; +my %pk; + +my %pk_algos; +my %algos; + +my %filename_to_desc; + +for my $filename (@ARGV) { + + open IN, "<$filename" or die "Couldn't read $filename ($!)\n"; + + my $desc = <IN>; + chomp $desc; + + $results{$desc} = {}; + + while(<IN>) { + if(/(.*): +(.*) Mbytes\/sec/) { + $results{$desc}{$1} = $2; + $algos{$1} = undef; + } + if(/(.*): (.*) ops \/ second \((.*)\)/) { + my $alg = "$1"; + $alg = "$alg $3" if defined($3); + $pk{$desc}{$alg} = $2; + $pk_algos{$alg} = undef; + } + } +} + + +sub print_table { + my @columns = sort keys %results; + + print "\n<P>All results are in MiB / second:\n"; + print "<TABLE BORDER CELLSPACING=1>\n<THEAD>\n"; + + my %col_index = (); + + my $line = "<TR><TH>Algorithm "; + + foreach my $col (@columns) { + $col_index{$col} = length($line); + $line .= "<TH>" . $col . " "; + } + + $line .= "\n<TBODY>\n"; + + print $line; + + $line = ''; + + foreach my $algo (sort keys %algos) { + $line = " <TR><TH>$algo "; + + for my $col (@columns) { + my $result = $results{$col}{$algo}; + $result = "-" if not defined($result); + + $result = "<TH>$result"; + + $line .= ' ' while(length($line) < ($col_index{$col})); + $line .= $result; + + } + + print $line, "\n"; + $line = ''; + } + + print "</TABLE>\n"; +} + + +sub print_pk_table { + my @columns = sort keys %pk; + + print "\n<P>All results are in operations per second:\n"; + print "<TABLE BORDER CELLSPACING=1>\n<THEAD>\n"; + + my %col_index = (); + + my $line = "<TR><TH>Algorithm "; + + foreach my $col (@columns) { + $col_index{$col} = length($line); + $line .= "<TH>" . $col . " "; + } + + $line .= "\n<TBODY>\n"; + + print $line; + + foreach my $algo (sort keys %pk_algos) { + my $line = " <TR><TH>$algo "; + + for my $col (@columns) { + my $result = $pk{$col}{$algo}; + $result = '-' if not defined($result); + + $result = "<TH>$result"; + + $line .= ' ' while(length($line) < ($col_index{$col})); + $line .= $result; + + } + + print $line, "\n"; + } + + print "</TABLE>\n"; +} + +print_table(); +print_pk_table(); diff --git a/doc/scripts/dist.sh b/doc/scripts/dist.sh new file mode 100755 index 000000000..88edc71be --- /dev/null +++ b/doc/scripts/dist.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +SELECTOR=h:net.randombit.botan +KEY_ID=EFBADFBC +MTN_DB=${HOME}/var/mtn/botan.mtn +WEB_DIR=${HOME}/projects/www + +DIST_DIR=~/Botan-dist + +# You shouldn't have to change anything after this +mkdir -p $DIST_DIR +cd $DIST_DIR + +mtn -d $MTN_DB checkout -r $SELECTOR Botan + +VERSION=$(Botan/configure.pl --version | sed 's/Botan //') + +mv Botan Botan-$VERSION + +cd Botan-$VERSION +rm -rf _MTN +rm -f .mtn-ignore + +# Build docs +cd doc + +for doc in api tutorial building +do + latex $doc.tex + latex $doc.tex + dvips $doc.dvi -o + pdflatex $doc.tex + pdflatex $doc.tex + cp $doc.pdf $DIST_DIR + mv $doc.ps $DIST_DIR + # Clean up after TeX + rm -f $doc.aux $doc.log $doc.dvi $doc.toc +done + +cp log.txt ../.. + +cd .. # topdir +cd .. # now in DIST_DIR + +tar -cf Botan-$VERSION.tar Botan-$VERSION + +bzip2 -9 -k Botan-$VERSION.tar +gzip -9 Botan-$VERSION.tar + +rm -rf Botan-$VERSION + +mv Botan-$VERSION.tar.gz Botan-$VERSION.tgz +mv Botan-$VERSION.tar.bz2 Botan-$VERSION.tbz + +echo "*****************************************************" +read -a PASSWORD -p "Enter PGP password (or ^C to skip signatures): " + +echo $PASSWORD | gpg --batch --armor -b --passphrase-fd 0 -u $KEY_ID Botan-$VERSION.tgz +echo $PASSWORD | gpg --batch --armor -b --passphrase-fd 0 -u $KEY_ID Botan-$VERSION.tbz + +mv Botan-$VERSION.tgz* $WEB_DIR/files/botan/archive/v1.7 +mv Botan-$VERSION.tbz* $WEB_DIR/files/botan/ +mv -f log.txt $WEB_DIR/botan/log.txt diff --git a/doc/scripts/primes.py b/doc/scripts/primes.py new file mode 100755 index 000000000..cf4d139e3 --- /dev/null +++ b/doc/scripts/primes.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python + +import sys + +def gcd(x,y): + if x <= 0 or y <= 0: + raise ValueError, "Arguments must be positive integers" + g = y + while x > 0: + g = x + x = y % x + y = g + return g + + +def gen_primes(): + primes = [2,3,5,7,11] + + # Primes < 11351 fit into less than 256x64 bits + for i in xrange(1+primes[-1], 11351+1): + for prime in primes: + if gcd(i, prime) != 1: + break + else: + primes.append(i) + + return primes + +def extract_product(primes): + product = 1 + + used = set() + + for prime in sorted(primes, reverse=True): + if product * prime < 2**64: + product *= prime + used.add(prime) + + primes -= used + + return product + +def main(): + primes = gen_primes() + + primes.sort() + primes.reverse() + + primes = set(primes) + + while len(primes): + print "0x%016X, " % extract_product(primes) + + #product = 1 + #for prime in primes: + # product *= prime + + # if product >= 2**64: + # print "%016X" % (product/prime) + # product = prime + +if __name__ == '__main__': + sys.exit(main()) |