summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2015-08-19 09:55:02 +0200
committerLinus Nordberg <linus@nordu.net>2015-08-19 16:48:15 +0200
commit0d7c8181f07e1c34ef3a9a8740c8ce2d7b982f74 (patch)
treef66fa48fab1200bde7500c56ac7dc994154f50a3
parentaa703d32d55717b4934c91cf187f0ed165196fd0 (diff)
Script for converting database to new format
-rw-r--r--Makefile57
-rw-r--r--test/oldformat/db/certentries/1e/82/31/1e823118e9abf635d9281c137d689f157754b222dca260260d8aadbaf1ccb5bfbin0 -> 5307 bytes
-rw-r--r--test/oldformat/db/certentries/37/2a/b5/372ab5115a024f8112ae57bf9b67f82a06ff4411bf6a85e7106eaf15b3a0b9d0bin0 -> 4542 bytes
-rw-r--r--test/oldformat/db/certentries/3d/3e/1a/3d3e1ae8cc6f3cf65b243cba3521cc74dbd18e4b7a8494964184c69d84053787bin0 -> 3647 bytes
-rw-r--r--test/oldformat/db/certentries/9f/dc/bf/9fdcbf4205b21a7a08deb49a68b8f5f4a39381c0c55a97334dd403faf2f5ffd1bin0 -> 6181 bytes
-rw-r--r--test/oldformat/db/certentries/a9/be/b5/a9beb566b525c65becdcdf548ce5f90ff0318a4f2b6cb965071505b0b3256e8ebin0 -> 3486 bytes
-rw-r--r--test/oldformat/db/certentries/af/b1/38/afb138f6163475839850257b63829dae8003d9fe97ea36ad4366e032a885358dbin0 -> 5246 bytes
-rw-r--r--test/oldformat/db/certentries/bd/c6/70/bdc6702085624228074a957928299e538c21ddbf5c4ba80e2ced183c7a9fb49fbin0 -> 3971 bytes
-rw-r--r--test/oldformat/db/certindex/1e/82/31/1e823118e9abf635d9281c137d689f157754b222dca260260d8aadbaf1ccb5bf1
-rw-r--r--test/oldformat/db/certindex/37/2a/b5/372ab5115a024f8112ae57bf9b67f82a06ff4411bf6a85e7106eaf15b3a0b9d01
-rw-r--r--test/oldformat/db/certindex/3d/3e/1a/3d3e1ae8cc6f3cf65b243cba3521cc74dbd18e4b7a8494964184c69d840537871
-rw-r--r--test/oldformat/db/certindex/9f/dc/bf/9fdcbf4205b21a7a08deb49a68b8f5f4a39381c0c55a97334dd403faf2f5ffd11
-rw-r--r--test/oldformat/db/certindex/a9/be/b5/a9beb566b525c65becdcdf548ce5f90ff0318a4f2b6cb965071505b0b3256e8e1
-rw-r--r--test/oldformat/db/certindex/af/b1/38/afb138f6163475839850257b63829dae8003d9fe97ea36ad4366e032a885358d1
-rw-r--r--test/oldformat/db/certindex/bd/c6/70/bdc6702085624228074a957928299e538c21ddbf5c4ba80e2ced183c7a9fb49f1
-rw-r--r--test/oldformat/db/entryhash/13/8b/4b/138b4b6fdbf47a6ca2b08050c182b9944405434ef5dbc67170e967d9b5cc70e31
-rw-r--r--test/oldformat/db/entryhash/4b/58/f7/4b58f7ccbd75dd2b9fe902107125f263145a84aded3467653ddddca6faf0bc111
-rw-r--r--test/oldformat/db/entryhash/b3/21/0a/b3210ad4b5267f2d15d8e49039b9e3767eb4b593077260455402a7d57f1a9aa71
-rw-r--r--test/oldformat/db/entryhash/cf/3c/85/cf3c85582a450b98a0b53c612192ce07afabdc525f91413a1af16e71b11f29461
-rw-r--r--test/oldformat/db/entryhash/ed/cc/ad/edccad314e725c036792f61712360ad033a6b6fe1e23fb504a79dec6aa76c4361
-rw-r--r--test/oldformat/db/entryhash/fc/e6/27/fce627418663bd53059e46c8dca181645310df0dcb900e6566031df39ed424151
-rw-r--r--test/oldformat/db/entryhash/fe/1b/ea/fe1bea5d85189106644cda272eccc0d1c49aedb9a932201215794d92ef03f5181
-rw-r--r--test/oldformat/db/index7
-rw-r--r--test/oldformat/db/newentries7
-rw-r--r--test/oldformat/db/sth1
-rw-r--r--test/oldformat/mergedb/chains/1e/82/31/1e823118e9abf635d9281c137d689f157754b222dca260260d8aadbaf1ccb5bfbin0 -> 5307 bytes
-rw-r--r--test/oldformat/mergedb/chains/37/2a/b5/372ab5115a024f8112ae57bf9b67f82a06ff4411bf6a85e7106eaf15b3a0b9d0bin0 -> 4542 bytes
-rw-r--r--test/oldformat/mergedb/chains/3d/3e/1a/3d3e1ae8cc6f3cf65b243cba3521cc74dbd18e4b7a8494964184c69d84053787bin0 -> 3647 bytes
-rw-r--r--test/oldformat/mergedb/chains/9f/dc/bf/9fdcbf4205b21a7a08deb49a68b8f5f4a39381c0c55a97334dd403faf2f5ffd1bin0 -> 6181 bytes
-rw-r--r--test/oldformat/mergedb/chains/a9/be/b5/a9beb566b525c65becdcdf548ce5f90ff0318a4f2b6cb965071505b0b3256e8ebin0 -> 3486 bytes
-rw-r--r--test/oldformat/mergedb/chains/af/b1/38/afb138f6163475839850257b63829dae8003d9fe97ea36ad4366e032a885358dbin0 -> 5246 bytes
-rw-r--r--test/oldformat/mergedb/chains/bd/c6/70/bdc6702085624228074a957928299e538c21ddbf5c4ba80e2ced183c7a9fb49fbin0 -> 3971 bytes
-rw-r--r--test/oldformat/mergedb/logorder7
-rw-r--r--tools/convertdb.py71
-rwxr-xr-xtools/fetchallcerts.py4
-rw-r--r--tools/mergetools.py15
36 files changed, 182 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index a8c81bc..fc922d7 100644
--- a/Makefile
+++ b/Makefile
@@ -117,6 +117,49 @@ tests-wait:
tests-makemk:
tools/compileconfig.py --config=test/catlfish-test.cfg --testmakefile=test/test.mk --machines 1
+tests-formatupgrade-prepare:
+ rm -r $(INSTDIR)/tests/mergedb
+ rm -r $(INSTDIR)/tests/machine/machine-1
+ mkdir $(INSTDIR)/tests/machine/machine-1
+ cp -r test/oldformat/db $(INSTDIR)/tests/machine/machine-1
+ cp -r test/oldformat/mergedb $(INSTDIR)/tests
+ @(cd $(INSTDIR) && python ../tools/convertdb.py tests/machine/machine-1/db/certentries)
+
+tests-formatupgrade-run:
+ @(cd $(INSTDIR) && rm -r fetchcertstore-old || true)
+ @(cd $(INSTDIR) && mkdir fetchcertstore-old)
+ @(cd $(INSTDIR) && python ../tools/fetchallcerts.py $(BASEURL) --no-check-signature --store fetchcertstore-old --publickey=tests/keys/logkey.pem --cafile tests/httpsca/demoCA/cacert.pem) || (echo "Verification failed" ; false)
+ @(cd $(INSTDIR)/fetchcertstore-old && unzip 0000.zip)
+ @(cd $(INSTDIR) && python ../tools/comparecert.py ../tools/testcerts/cert1.txt fetchcertstore-old/00000000) || (echo "Verification failed" ; false)
+ @(cd $(INSTDIR) && python ../tools/comparecert.py ../tools/testcerts/cert2.txt fetchcertstore-old/00000001) || (echo "Verification failed" ; false)
+ @(cd $(INSTDIR) && python ../tools/comparecert.py ../tools/testcerts/cert3.txt fetchcertstore-old/00000002) || (echo "Verification failed" ; false)
+ @(cd $(INSTDIR) && python ../tools/comparecert.py ../tools/testcerts/cert4.txt fetchcertstore-old/00000003) || (echo "Verification failed" ; false)
+ @(cd $(INSTDIR) && python ../tools/comparecert.py ../tools/testcerts/cert5.txt fetchcertstore-old/00000004) || (echo "Verification failed" ; false)
+ @(cd $(INSTDIR) && python ../tools/comparecert.py ../tools/testcerts/pre1.txt:../tools/testcerts/pre2.txt fetchcertstore-old/00000005:fetchcertstore-old/00000006) || (echo "Verification failed" ; false)
+
+tests-formatupgrade-prepare2:
+ -rm $(INSTDIR)/tests/machine/machine-1/db/sth
+ @(cd $(INSTDIR) && python ../tools/convertdb.py tests/mergedb/chains)
+ rm -r $(INSTDIR)/tests/mergedb-secondary
+ mkdir $(INSTDIR)/tests/mergedb-secondary
+ mkdir $(INSTDIR)/tests/mergedb-secondary/chains
+ touch $(INSTDIR)/tests/mergedb-secondary/logorder
+ printf 0 > $(INSTDIR)/tests/mergedb-secondary/verifiedsize
+
+tests-formatupgrade-run2:
+ @(cd $(INSTDIR) && python ../tools/merge.py --config ../test/catlfish-test.cfg --localconfig ../test/catlfish-test-local-merge.cfg) || (echo "Merge failed" ; false)
+ @diff -r -x nursery -x verifiedsize catlfish/tests/mergedb catlfish/tests/mergedb-secondary || (echo "Merge databases not matching" ; false)
+ @(cd $(INSTDIR) && rm -r fetchcertstore-old || true)
+ @(cd $(INSTDIR) && mkdir fetchcertstore-old)
+ @(cd $(INSTDIR) && python ../tools/fetchallcerts.py $(BASEURL) --no-check-signature --store fetchcertstore-old --publickey=tests/keys/logkey.pem --cafile tests/httpsca/demoCA/cacert.pem) || (echo "Verification failed" ; false)
+ @(cd $(INSTDIR)/fetchcertstore-old && unzip 0000.zip)
+ @(cd $(INSTDIR) && python ../tools/comparecert.py ../tools/testcerts/cert1.txt fetchcertstore-old/00000000) || (echo "Verification failed" ; false)
+ @(cd $(INSTDIR) && python ../tools/comparecert.py ../tools/testcerts/cert2.txt fetchcertstore-old/00000001) || (echo "Verification failed" ; false)
+ @(cd $(INSTDIR) && python ../tools/comparecert.py ../tools/testcerts/cert3.txt fetchcertstore-old/00000002) || (echo "Verification failed" ; false)
+ @(cd $(INSTDIR) && python ../tools/comparecert.py ../tools/testcerts/cert4.txt fetchcertstore-old/00000003) || (echo "Verification failed" ; false)
+ @(cd $(INSTDIR) && python ../tools/comparecert.py ../tools/testcerts/cert5.txt fetchcertstore-old/00000004) || (echo "Verification failed" ; false)
+ @(cd $(INSTDIR) && python ../tools/comparecert.py ../tools/testcerts/pre1.txt:../tools/testcerts/pre2.txt fetchcertstore-old/00000005:fetchcertstore-old/00000006) || (echo "Verification failed" ; false)
+
tests:
@make tests-makemk
@make tests-prepare
@@ -130,6 +173,20 @@ tests:
@make tests-wait
@make tests-stop
+tests-formatupgrade:
+ @make tests-makemk
+ @make tests-prepare
+ @make tests-formatupgrade-prepare
+ @make tests-start
+ @make tests-formatupgrade-run || (make tests-stop ; false)
+ @make tests-wait
+ @make tests-stop
+ @make tests-formatupgrade-prepare2
+ @make tests-start
+ @make tests-formatupgrade-run2 || (make tests-stop ; false)
+ @make tests-wait
+ @make tests-stop
+
tests-createca:
mkdir $(INSTDIR)/tests/httpsca
( cd $(INSTDIR)/tests/httpsca ; \
diff --git a/test/oldformat/db/certentries/1e/82/31/1e823118e9abf635d9281c137d689f157754b222dca260260d8aadbaf1ccb5bf b/test/oldformat/db/certentries/1e/82/31/1e823118e9abf635d9281c137d689f157754b222dca260260d8aadbaf1ccb5bf
new file mode 100644
index 0000000..cd6fc29
--- /dev/null
+++ b/test/oldformat/db/certentries/1e/82/31/1e823118e9abf635d9281c137d689f157754b222dca260260d8aadbaf1ccb5bf
Binary files differ
diff --git a/test/oldformat/db/certentries/37/2a/b5/372ab5115a024f8112ae57bf9b67f82a06ff4411bf6a85e7106eaf15b3a0b9d0 b/test/oldformat/db/certentries/37/2a/b5/372ab5115a024f8112ae57bf9b67f82a06ff4411bf6a85e7106eaf15b3a0b9d0
new file mode 100644
index 0000000..2b422ce
--- /dev/null
+++ b/test/oldformat/db/certentries/37/2a/b5/372ab5115a024f8112ae57bf9b67f82a06ff4411bf6a85e7106eaf15b3a0b9d0
Binary files differ
diff --git a/test/oldformat/db/certentries/3d/3e/1a/3d3e1ae8cc6f3cf65b243cba3521cc74dbd18e4b7a8494964184c69d84053787 b/test/oldformat/db/certentries/3d/3e/1a/3d3e1ae8cc6f3cf65b243cba3521cc74dbd18e4b7a8494964184c69d84053787
new file mode 100644
index 0000000..29d1f07
--- /dev/null
+++ b/test/oldformat/db/certentries/3d/3e/1a/3d3e1ae8cc6f3cf65b243cba3521cc74dbd18e4b7a8494964184c69d84053787
Binary files differ
diff --git a/test/oldformat/db/certentries/9f/dc/bf/9fdcbf4205b21a7a08deb49a68b8f5f4a39381c0c55a97334dd403faf2f5ffd1 b/test/oldformat/db/certentries/9f/dc/bf/9fdcbf4205b21a7a08deb49a68b8f5f4a39381c0c55a97334dd403faf2f5ffd1
new file mode 100644
index 0000000..f8781c6
--- /dev/null
+++ b/test/oldformat/db/certentries/9f/dc/bf/9fdcbf4205b21a7a08deb49a68b8f5f4a39381c0c55a97334dd403faf2f5ffd1
Binary files differ
diff --git a/test/oldformat/db/certentries/a9/be/b5/a9beb566b525c65becdcdf548ce5f90ff0318a4f2b6cb965071505b0b3256e8e b/test/oldformat/db/certentries/a9/be/b5/a9beb566b525c65becdcdf548ce5f90ff0318a4f2b6cb965071505b0b3256e8e
new file mode 100644
index 0000000..c008ccc
--- /dev/null
+++ b/test/oldformat/db/certentries/a9/be/b5/a9beb566b525c65becdcdf548ce5f90ff0318a4f2b6cb965071505b0b3256e8e
Binary files differ
diff --git a/test/oldformat/db/certentries/af/b1/38/afb138f6163475839850257b63829dae8003d9fe97ea36ad4366e032a885358d b/test/oldformat/db/certentries/af/b1/38/afb138f6163475839850257b63829dae8003d9fe97ea36ad4366e032a885358d
new file mode 100644
index 0000000..bc8a8b4
--- /dev/null
+++ b/test/oldformat/db/certentries/af/b1/38/afb138f6163475839850257b63829dae8003d9fe97ea36ad4366e032a885358d
Binary files differ
diff --git a/test/oldformat/db/certentries/bd/c6/70/bdc6702085624228074a957928299e538c21ddbf5c4ba80e2ced183c7a9fb49f b/test/oldformat/db/certentries/bd/c6/70/bdc6702085624228074a957928299e538c21ddbf5c4ba80e2ced183c7a9fb49f
new file mode 100644
index 0000000..2100b1e
--- /dev/null
+++ b/test/oldformat/db/certentries/bd/c6/70/bdc6702085624228074a957928299e538c21ddbf5c4ba80e2ced183c7a9fb49f
Binary files differ
diff --git a/test/oldformat/db/certindex/1e/82/31/1e823118e9abf635d9281c137d689f157754b222dca260260d8aadbaf1ccb5bf b/test/oldformat/db/certindex/1e/82/31/1e823118e9abf635d9281c137d689f157754b222dca260260d8aadbaf1ccb5bf
new file mode 100644
index 0000000..7813681
--- /dev/null
+++ b/test/oldformat/db/certindex/1e/82/31/1e823118e9abf635d9281c137d689f157754b222dca260260d8aadbaf1ccb5bf
@@ -0,0 +1 @@
+5 \ No newline at end of file
diff --git a/test/oldformat/db/certindex/37/2a/b5/372ab5115a024f8112ae57bf9b67f82a06ff4411bf6a85e7106eaf15b3a0b9d0 b/test/oldformat/db/certindex/37/2a/b5/372ab5115a024f8112ae57bf9b67f82a06ff4411bf6a85e7106eaf15b3a0b9d0
new file mode 100644
index 0000000..56a6051
--- /dev/null
+++ b/test/oldformat/db/certindex/37/2a/b5/372ab5115a024f8112ae57bf9b67f82a06ff4411bf6a85e7106eaf15b3a0b9d0
@@ -0,0 +1 @@
+1 \ No newline at end of file
diff --git a/test/oldformat/db/certindex/3d/3e/1a/3d3e1ae8cc6f3cf65b243cba3521cc74dbd18e4b7a8494964184c69d84053787 b/test/oldformat/db/certindex/3d/3e/1a/3d3e1ae8cc6f3cf65b243cba3521cc74dbd18e4b7a8494964184c69d84053787
new file mode 100644
index 0000000..c227083
--- /dev/null
+++ b/test/oldformat/db/certindex/3d/3e/1a/3d3e1ae8cc6f3cf65b243cba3521cc74dbd18e4b7a8494964184c69d84053787
@@ -0,0 +1 @@
+0 \ No newline at end of file
diff --git a/test/oldformat/db/certindex/9f/dc/bf/9fdcbf4205b21a7a08deb49a68b8f5f4a39381c0c55a97334dd403faf2f5ffd1 b/test/oldformat/db/certindex/9f/dc/bf/9fdcbf4205b21a7a08deb49a68b8f5f4a39381c0c55a97334dd403faf2f5ffd1
new file mode 100644
index 0000000..62f9457
--- /dev/null
+++ b/test/oldformat/db/certindex/9f/dc/bf/9fdcbf4205b21a7a08deb49a68b8f5f4a39381c0c55a97334dd403faf2f5ffd1
@@ -0,0 +1 @@
+6 \ No newline at end of file
diff --git a/test/oldformat/db/certindex/a9/be/b5/a9beb566b525c65becdcdf548ce5f90ff0318a4f2b6cb965071505b0b3256e8e b/test/oldformat/db/certindex/a9/be/b5/a9beb566b525c65becdcdf548ce5f90ff0318a4f2b6cb965071505b0b3256e8e
new file mode 100644
index 0000000..d8263ee
--- /dev/null
+++ b/test/oldformat/db/certindex/a9/be/b5/a9beb566b525c65becdcdf548ce5f90ff0318a4f2b6cb965071505b0b3256e8e
@@ -0,0 +1 @@
+2 \ No newline at end of file
diff --git a/test/oldformat/db/certindex/af/b1/38/afb138f6163475839850257b63829dae8003d9fe97ea36ad4366e032a885358d b/test/oldformat/db/certindex/af/b1/38/afb138f6163475839850257b63829dae8003d9fe97ea36ad4366e032a885358d
new file mode 100644
index 0000000..bf0d87a
--- /dev/null
+++ b/test/oldformat/db/certindex/af/b1/38/afb138f6163475839850257b63829dae8003d9fe97ea36ad4366e032a885358d
@@ -0,0 +1 @@
+4 \ No newline at end of file
diff --git a/test/oldformat/db/certindex/bd/c6/70/bdc6702085624228074a957928299e538c21ddbf5c4ba80e2ced183c7a9fb49f b/test/oldformat/db/certindex/bd/c6/70/bdc6702085624228074a957928299e538c21ddbf5c4ba80e2ced183c7a9fb49f
new file mode 100644
index 0000000..e440e5c
--- /dev/null
+++ b/test/oldformat/db/certindex/bd/c6/70/bdc6702085624228074a957928299e538c21ddbf5c4ba80e2ced183c7a9fb49f
@@ -0,0 +1 @@
+3 \ No newline at end of file
diff --git a/test/oldformat/db/entryhash/13/8b/4b/138b4b6fdbf47a6ca2b08050c182b9944405434ef5dbc67170e967d9b5cc70e3 b/test/oldformat/db/entryhash/13/8b/4b/138b4b6fdbf47a6ca2b08050c182b9944405434ef5dbc67170e967d9b5cc70e3
new file mode 100644
index 0000000..49844fc
--- /dev/null
+++ b/test/oldformat/db/entryhash/13/8b/4b/138b4b6fdbf47a6ca2b08050c182b9944405434ef5dbc67170e967d9b5cc70e3
@@ -0,0 +1 @@
+7*ZOWg*Djn \ No newline at end of file
diff --git a/test/oldformat/db/entryhash/4b/58/f7/4b58f7ccbd75dd2b9fe902107125f263145a84aded3467653ddddca6faf0bc11 b/test/oldformat/db/entryhash/4b/58/f7/4b58f7ccbd75dd2b9fe902107125f263145a84aded3467653ddddca6faf0bc11
new file mode 100644
index 0000000..2d5a46c
--- /dev/null
+++ b/test/oldformat/db/entryhash/4b/58/f7/4b58f7ccbd75dd2b9fe902107125f263145a84aded3467653ddddca6faf0bc11
@@ -0,0 +1 @@
+84uP%{c6Cf25 \ No newline at end of file
diff --git a/test/oldformat/db/entryhash/b3/21/0a/b3210ad4b5267f2d15d8e49039b9e3767eb4b593077260455402a7d57f1a9aa7 b/test/oldformat/db/entryhash/b3/21/0a/b3210ad4b5267f2d15d8e49039b9e3767eb4b593077260455402a7d57f1a9aa7
new file mode 100644
index 0000000..97f4641
--- /dev/null
+++ b/test/oldformat/db/entryhash/b3/21/0a/b3210ad4b5267f2d15d8e49039b9e3767eb4b593077260455402a7d57f1a9aa7
@@ -0,0 +1 @@
+15(}hwT"ܢ`& ̵ \ No newline at end of file
diff --git a/test/oldformat/db/entryhash/cf/3c/85/cf3c85582a450b98a0b53c612192ce07afabdc525f91413a1af16e71b11f2946 b/test/oldformat/db/entryhash/cf/3c/85/cf3c85582a450b98a0b53c612192ce07afabdc525f91413a1af16e71b11f2946
new file mode 100644
index 0000000..3fa1e9f
--- /dev/null
+++ b/test/oldformat/db/entryhash/cf/3c/85/cf3c85582a450b98a0b53c612192ce07afabdc525f91413a1af16e71b11f2946
@@ -0,0 +1 @@
+=>o<[$<5!tюKzAƝ7 \ No newline at end of file
diff --git a/test/oldformat/db/entryhash/ed/cc/ad/edccad314e725c036792f61712360ad033a6b6fe1e23fb504a79dec6aa76c436 b/test/oldformat/db/entryhash/ed/cc/ad/edccad314e725c036792f61712360ad033a6b6fe1e23fb504a79dec6aa76c436
new file mode 100644
index 0000000..87dac62
--- /dev/null
+++ b/test/oldformat/db/entryhash/ed/cc/ad/edccad314e725c036792f61712360ad033a6b6fe1e23fb504a79dec6aa76c436
@@ -0,0 +1 @@
+ܿBz޴hZ3M \ No newline at end of file
diff --git a/test/oldformat/db/entryhash/fc/e6/27/fce627418663bd53059e46c8dca181645310df0dcb900e6566031df39ed42415 b/test/oldformat/db/entryhash/fc/e6/27/fce627418663bd53059e46c8dca181645310df0dcb900e6566031df39ed42415
new file mode 100644
index 0000000..3186b25
--- /dev/null
+++ b/test/oldformat/db/entryhash/fc/e6/27/fce627418663bd53059e46c8dca181645310df0dcb900e6566031df39ed42415
@@ -0,0 +1 @@
+p bB(Jy()S!ݿ\K,<z \ No newline at end of file
diff --git a/test/oldformat/db/entryhash/fe/1b/ea/fe1bea5d85189106644cda272eccc0d1c49aedb9a932201215794d92ef03f518 b/test/oldformat/db/entryhash/fe/1b/ea/fe1bea5d85189106644cda272eccc0d1c49aedb9a932201215794d92ef03f518
new file mode 100644
index 0000000..00ec68d
--- /dev/null
+++ b/test/oldformat/db/entryhash/fe/1b/ea/fe1bea5d85189106644cda272eccc0d1c49aedb9a932201215794d92ef03f518
@@ -0,0 +1 @@
+f%[T1O+le%n \ No newline at end of file
diff --git a/test/oldformat/db/index b/test/oldformat/db/index
new file mode 100644
index 0000000..80c9aab
--- /dev/null
+++ b/test/oldformat/db/index
@@ -0,0 +1,7 @@
+3d3e1ae8cc6f3cf65b243cba3521cc74dbd18e4b7a8494964184c69d84053787
+372ab5115a024f8112ae57bf9b67f82a06ff4411bf6a85e7106eaf15b3a0b9d0
+a9beb566b525c65becdcdf548ce5f90ff0318a4f2b6cb965071505b0b3256e8e
+bdc6702085624228074a957928299e538c21ddbf5c4ba80e2ced183c7a9fb49f
+afb138f6163475839850257b63829dae8003d9fe97ea36ad4366e032a885358d
+1e823118e9abf635d9281c137d689f157754b222dca260260d8aadbaf1ccb5bf
+9fdcbf4205b21a7a08deb49a68b8f5f4a39381c0c55a97334dd403faf2f5ffd1
diff --git a/test/oldformat/db/newentries b/test/oldformat/db/newentries
new file mode 100644
index 0000000..80c9aab
--- /dev/null
+++ b/test/oldformat/db/newentries
@@ -0,0 +1,7 @@
+3d3e1ae8cc6f3cf65b243cba3521cc74dbd18e4b7a8494964184c69d84053787
+372ab5115a024f8112ae57bf9b67f82a06ff4411bf6a85e7106eaf15b3a0b9d0
+a9beb566b525c65becdcdf548ce5f90ff0318a4f2b6cb965071505b0b3256e8e
+bdc6702085624228074a957928299e538c21ddbf5c4ba80e2ced183c7a9fb49f
+afb138f6163475839850257b63829dae8003d9fe97ea36ad4366e032a885358d
+1e823118e9abf635d9281c137d689f157754b222dca260260d8aadbaf1ccb5bf
+9fdcbf4205b21a7a08deb49a68b8f5f4a39381c0c55a97334dd403faf2f5ffd1
diff --git a/test/oldformat/db/sth b/test/oldformat/db/sth
new file mode 100644
index 0000000..b8042dc
--- /dev/null
+++ b/test/oldformat/db/sth
@@ -0,0 +1 @@
+{"timestamp":1439900447344,"sha256_root_hash":"avqfWqi0ldF4/WxvdxeyqteQWs0YGtrX0dk4NklV0/A=","tree_size":7,"tree_head_signature":"BAMARzBFAiEAwDv52E+VRHd1wbjqOHDjZmHAg9qawZVY70Ur27nVp2wCICj3CjuVBc6Q/k8Rvjcjd+VBOx+bVzZRVjEdeJGjERz4"} \ No newline at end of file
diff --git a/test/oldformat/mergedb/chains/1e/82/31/1e823118e9abf635d9281c137d689f157754b222dca260260d8aadbaf1ccb5bf b/test/oldformat/mergedb/chains/1e/82/31/1e823118e9abf635d9281c137d689f157754b222dca260260d8aadbaf1ccb5bf
new file mode 100644
index 0000000..cd6fc29
--- /dev/null
+++ b/test/oldformat/mergedb/chains/1e/82/31/1e823118e9abf635d9281c137d689f157754b222dca260260d8aadbaf1ccb5bf
Binary files differ
diff --git a/test/oldformat/mergedb/chains/37/2a/b5/372ab5115a024f8112ae57bf9b67f82a06ff4411bf6a85e7106eaf15b3a0b9d0 b/test/oldformat/mergedb/chains/37/2a/b5/372ab5115a024f8112ae57bf9b67f82a06ff4411bf6a85e7106eaf15b3a0b9d0
new file mode 100644
index 0000000..2b422ce
--- /dev/null
+++ b/test/oldformat/mergedb/chains/37/2a/b5/372ab5115a024f8112ae57bf9b67f82a06ff4411bf6a85e7106eaf15b3a0b9d0
Binary files differ
diff --git a/test/oldformat/mergedb/chains/3d/3e/1a/3d3e1ae8cc6f3cf65b243cba3521cc74dbd18e4b7a8494964184c69d84053787 b/test/oldformat/mergedb/chains/3d/3e/1a/3d3e1ae8cc6f3cf65b243cba3521cc74dbd18e4b7a8494964184c69d84053787
new file mode 100644
index 0000000..29d1f07
--- /dev/null
+++ b/test/oldformat/mergedb/chains/3d/3e/1a/3d3e1ae8cc6f3cf65b243cba3521cc74dbd18e4b7a8494964184c69d84053787
Binary files differ
diff --git a/test/oldformat/mergedb/chains/9f/dc/bf/9fdcbf4205b21a7a08deb49a68b8f5f4a39381c0c55a97334dd403faf2f5ffd1 b/test/oldformat/mergedb/chains/9f/dc/bf/9fdcbf4205b21a7a08deb49a68b8f5f4a39381c0c55a97334dd403faf2f5ffd1
new file mode 100644
index 0000000..f8781c6
--- /dev/null
+++ b/test/oldformat/mergedb/chains/9f/dc/bf/9fdcbf4205b21a7a08deb49a68b8f5f4a39381c0c55a97334dd403faf2f5ffd1
Binary files differ
diff --git a/test/oldformat/mergedb/chains/a9/be/b5/a9beb566b525c65becdcdf548ce5f90ff0318a4f2b6cb965071505b0b3256e8e b/test/oldformat/mergedb/chains/a9/be/b5/a9beb566b525c65becdcdf548ce5f90ff0318a4f2b6cb965071505b0b3256e8e
new file mode 100644
index 0000000..c008ccc
--- /dev/null
+++ b/test/oldformat/mergedb/chains/a9/be/b5/a9beb566b525c65becdcdf548ce5f90ff0318a4f2b6cb965071505b0b3256e8e
Binary files differ
diff --git a/test/oldformat/mergedb/chains/af/b1/38/afb138f6163475839850257b63829dae8003d9fe97ea36ad4366e032a885358d b/test/oldformat/mergedb/chains/af/b1/38/afb138f6163475839850257b63829dae8003d9fe97ea36ad4366e032a885358d
new file mode 100644
index 0000000..bc8a8b4
--- /dev/null
+++ b/test/oldformat/mergedb/chains/af/b1/38/afb138f6163475839850257b63829dae8003d9fe97ea36ad4366e032a885358d
Binary files differ
diff --git a/test/oldformat/mergedb/chains/bd/c6/70/bdc6702085624228074a957928299e538c21ddbf5c4ba80e2ced183c7a9fb49f b/test/oldformat/mergedb/chains/bd/c6/70/bdc6702085624228074a957928299e538c21ddbf5c4ba80e2ced183c7a9fb49f
new file mode 100644
index 0000000..2100b1e
--- /dev/null
+++ b/test/oldformat/mergedb/chains/bd/c6/70/bdc6702085624228074a957928299e538c21ddbf5c4ba80e2ced183c7a9fb49f
Binary files differ
diff --git a/test/oldformat/mergedb/logorder b/test/oldformat/mergedb/logorder
new file mode 100644
index 0000000..80c9aab
--- /dev/null
+++ b/test/oldformat/mergedb/logorder
@@ -0,0 +1,7 @@
+3d3e1ae8cc6f3cf65b243cba3521cc74dbd18e4b7a8494964184c69d84053787
+372ab5115a024f8112ae57bf9b67f82a06ff4411bf6a85e7106eaf15b3a0b9d0
+a9beb566b525c65becdcdf548ce5f90ff0318a4f2b6cb965071505b0b3256e8e
+bdc6702085624228074a957928299e538c21ddbf5c4ba80e2ced183c7a9fb49f
+afb138f6163475839850257b63829dae8003d9fe97ea36ad4366e032a885358d
+1e823118e9abf635d9281c137d689f157754b222dca260260d8aadbaf1ccb5bf
+9fdcbf4205b21a7a08deb49a68b8f5f4a39381c0c55a97334dd403faf2f5ffd1
diff --git a/tools/convertdb.py b/tools/convertdb.py
new file mode 100644
index 0000000..c036843
--- /dev/null
+++ b/tools/convertdb.py
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2014, NORDUnet A/S.
+# See LICENSE for licensing information.
+
+import argparse
+import urllib2
+import urllib
+import json
+import base64
+import sys
+import struct
+import hashlib
+import itertools
+from certtools import *
+from mergetools import *
+import zipfile
+import os
+import time
+import shutil
+
+def write_file(fn, contents):
+ tempname = fn + ".new"
+ open(tempname, 'w').write(contents)
+ shutil.move(tempname, fn)
+
+def unpack_entry(entry):
+ pieces = []
+ while len(entry):
+ (length,) = struct.unpack(">I", entry[0:4])
+ data = entry[4:4+length]
+ entry = entry[4+length:]
+ pieces.append(data)
+ return pieces
+
+def read_old_entry(entry, hash):
+ unpacked = unpack_entry(entry)
+ mtl = unpacked[0]
+ assert hash == get_leaf_hash(mtl)
+ (leafcert, timestamp, issuer_key_hash) = unpack_mtl(mtl)
+ certchain = decode_certificate_chain(unpacked[1])
+ if issuer_key_hash:
+ leafcert = certchain[0]
+ certchain = certchain[1:]
+ certtype = "PRC1"
+ else:
+ certtype = "EEC1"
+ return (mtl, leafcert, certtype, certchain)
+
+def convertentry(entry, hash):
+ (mtl, leafcert, certtype, chain) = read_old_entry(entry, hash)
+ entry = tlv_encodelist([("MTL1", mtl),
+ (certtype, leafcert),
+ ("CHN1", tlv_encodelist([("X509", cert) for cert in chain]))])
+ return wrap_entry(entry)
+
+parser = argparse.ArgumentParser(description='')
+parser.add_argument('path', help="Path to database to convert")
+args = parser.parse_args()
+
+for (dirpath, dirnames, filenames) in os.walk(args.path):
+ for filename in filenames:
+ fullpath = dirpath + "/" + filename
+ entry = open(fullpath).read()
+ entry = convertentry(entry, base64.b16decode(filename.upper()))
+ if entry != None:
+ print "writing new entry for", filename
+ write_file(fullpath, entry)
+ else:
+ print "not writing new entry for", filename
diff --git a/tools/fetchallcerts.py b/tools/fetchallcerts.py
index 943759e..66fde74 100755
--- a/tools/fetchallcerts.py
+++ b/tools/fetchallcerts.py
@@ -22,6 +22,7 @@ parser = argparse.ArgumentParser(description='')
parser.add_argument('baseurl', help="Base URL for CT server")
parser.add_argument('--store', default=None, metavar="dir", help='Store certificates in directory dir')
parser.add_argument('--write-sth', action='store_true', help='Write STH')
+parser.add_argument('--no-check-signature', action='store_true', help='Don\'t check signature')
parser.add_argument('--publickey', default=None, metavar="file", help='Public key for the CT log')
parser.add_argument('--cafile', default=None, metavar="file", help='File containing the CA cert')
args = parser.parse_args()
@@ -46,7 +47,8 @@ def print_layer(layer):
logpublickey = get_public_key_from_file(args.publickey) if args.publickey else None
sth = get_sth(args.baseurl)
-check_sth_signature(args.baseurl, sth, publickey=logpublickey)
+if not args.no_check_signature:
+ check_sth_signature(args.baseurl, sth, publickey=logpublickey)
tree_size = sth["tree_size"]
root_hash = base64.decodestring(sth["sha256_root_hash"])
diff --git a/tools/mergetools.py b/tools/mergetools.py
index c3e9688..947d7f4 100644
--- a/tools/mergetools.py
+++ b/tools/mergetools.py
@@ -35,6 +35,11 @@ def tlv_decode(data):
rest = data[length:]
return (type, value, rest)
+def tlv_encode(type, value):
+ assert(len(type) == 4)
+ data = struct.pack(">I", len(value) + 8) + type + value
+ return data
+
def tlv_decodelist(data):
l = []
while len(data):
@@ -43,6 +48,12 @@ def tlv_decodelist(data):
data = rest
return l
+def tlv_encodelist(l):
+ data = ""
+ for (type, value) in l:
+ data += tlv_encode(type, value)
+ return data
+
def unwrap_entry(entry):
ploplevel = tlv_decodelist(entry)
assert(len(ploplevel) == 2)
@@ -54,6 +65,10 @@ def unwrap_entry(entry):
assert(computedchecksum == plopchecksum)
return plopdata
+def wrap_entry(entry):
+ return tlv_encodelist([("PLOP", entry),
+ ("S256", hashlib.sha256(entry).digest())])
+
def verify_entry(verifycert, entry, hash):
packed = unwrap_entry(entry)
unpacked = tlv_decodelist(packed)