]> pere.pagekite.me Git - homepage.git/blob - blog/data/2014-03-25-trusted-timestamping.txt
01b68597975a75b7a4db16e8e0ac17dad9ab04e9
[homepage.git] / blog / data / 2014-03-25-trusted-timestamping.txt
1 Title: Public Trusted Timestamping services for everyone
2 Tags: english, sikkerhet
3 Date: 2014-03-25 12:50
4
5 <p>Did you ever need to store logs or other files in a way that would
6 allow it to be used as evidence in court, and needed a way to
7 demonstrate without reasonable doubt that the file had not been
8 changed since it was created? Or, did you ever need to document that
9 a given document was received at some point in time, like some
10 archived document or the answer to an exam, and not changed after it
11 was received? The problem in these settings is to remove the need to
12 trust yourself and your computers, while still being able to prove
13 that a file is the same as it was at some given time in the past.</p>
14
15 <p>A solution to these problems is to have a trusted third party
16 "stamp" the document and verify that at some given time the document
17 looked a given way. Such
18 <a href="https://en.wikipedia.org/wiki/Notarius">notarius</a> service
19 have been around for thousands of years, and its digital equivalent is
20 called a
21 <a href="http://en.wikipedia.org/wiki/Trusted_timestamping">trusted
22 timestamping service</a>. <a href="http://www.ietf.org/">The Internet
23 Engineering Task Force</a> standardised how such service could work a
24 few years ago as <a href="http://tools.ietf.org/html/rfc3161">RFC
25 3161</a>. The mechanism is simple. Create a hash of the file in
26 question, send it to a trusted third party which add a time stamp to
27 the hash and sign the result with its private key, and send back the
28 signed hash + timestamp. Anyone with the document and the signature
29 can then verify that the document matches the signature by creating
30 their own hash and checking the signature using the trusted third
31 party public key. There are several commercial services around
32 providing such timestamping. A quick search for
33 "<a href="https://duckduckgo.com/?q=rfc+3161+service">rfc 3161
34 service</a>" pointed me to at least
35 <a href="https://www.digistamp.com/technical/how-a-digital-time-stamp-works/">DigiStamp</a>,
36 <a href="http://www.quovadisglobal.co.uk/CertificateServices/SigningServices/TimeStamp.aspx">Quo
37 Vadis</a>,
38 <a href="https://www.globalsign.com/timestamp-service/">Global Sign</a>
39 and <a href="http://www.globaltrustfinder.com/TSADefault.aspx">Global
40 Trust Finder</a>. The system work as long as the private key of the
41 trusted third party is not compromised.</p>
42
43 <p>But as far as I can tell, there are very few public trusted
44 timestamp services available for everyone. I've been looking for one
45 for a while now. But yesterday I found one over at
46 <a href="https://www.pki.dfn.de/zeitstempeldienst/">Deutches
47 Forschungsnetz</a> mentioned in
48 <a href="http://www.d-mueller.de/blog/dealing-with-trusted-timestamps-in-php-rfc-3161/">a
49 blog by David Müller</a>. I then found a good recipe on how to use
50 over at the
51 <a href="http://www.rz.uni-greifswald.de/support/dfn-pki-zertifikate/zeitstempeldienst.html">University
52 of Greifswald</a>.</p>
53
54 <p><a href="http://www.openssl.org/">The OpenSSL library</a> contain
55 both server and tools to use and set up your own signing service. See
56 the ts(1SSL), tsget(1SSL) manual pages for more details. The
57 following shell script demonstrate how to extract a signed timestamp
58 for any file on the disk in a Debian environment:</p>
59
60 <p><blockquote><pre>
61 #!/bin/sh
62 set -e
63 url="http://zeitstempel.dfn.de"
64 caurl="https://pki.pca.dfn.de/global-services-ca/pub/cacert/chain.txt"
65 reqfile=$(mktemp -t tmp.XXXXXXXXXX.tsq)
66 resfile=$(mktemp -t tmp.XXXXXXXXXX.tsr)
67 cafile=chain.txt
68 if [ ! -f $cafile ] ; then
69 wget -O $cafile "$caurl"
70 fi
71 openssl ts -query -data "$1" -cert | tee "$reqfile" \
72 | /usr/lib/ssl/misc/tsget -h "$url" -o "$resfile"
73 openssl ts -reply -in "$resfile" -text 1>&2
74 openssl ts -verify -data "$1" -in "$resfile" -CAfile "$cafile" 1>&2
75 base64 < "$resfile"
76 rm "$reqfile" "$resfile"
77 </pre></blockquote></p>
78
79 <p>The argument to the script is the file to timestamp, and the output
80 is a base64 encoded version of the signature to STDOUT and details
81 about the signature to STDERR. Note that due to
82 <a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=742553">a bug
83 in the tsget script</a>, you might need to modify the included script
84 and remove the last line. Or just write your own HTTP uploader using
85 curl. :) Now you too can prove and verify that files have not been
86 changed.</p>
87
88 <p>But the Internet need more public trusted timestamp services.
89 Perhaps something for <a href="http://www.uninett.no/">Uninett</a> or
90 my work place the <a href="http://www.uio.no/">University of Oslo</a>
91 to set up?</p>