aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmisc/scripts/comba.py65
-rwxr-xr-xmisc/scripts/dist.sh63
-rwxr-xr-xmisc/scripts/primes.py63
3 files changed, 191 insertions, 0 deletions
diff --git a/misc/scripts/comba.py b/misc/scripts/comba.py
new file mode 100755
index 000000000..ce3cfed77
--- /dev/null
+++ b/misc/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/misc/scripts/dist.sh b/misc/scripts/dist.sh
new file mode 100755
index 000000000..88edc71be
--- /dev/null
+++ b/misc/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/misc/scripts/primes.py b/misc/scripts/primes.py
new file mode 100755
index 000000000..cf4d139e3
--- /dev/null
+++ b/misc/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())