]> pere.pagekite.me Git - homepage.git/blob - blog/data/2014-03-25-trusted-timestamping.txt
Generated.
[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. Both email, FTP and HTTP can be used to
29 request such signature, depending on what is provided by the service
30 used. Anyone with the document and the signature can then verify that
31 the document matches the signature by creating their own hash and
32 checking the signature using the trusted third party public key.
33 There are several commercial services around providing such
34 timestamping. A quick search for
35 "<a href="https://duckduckgo.com/?q=rfc+3161+service">rfc 3161
36 service</a>" pointed me to at least
37 <a href="https://www.digistamp.com/technical/how-a-digital-time-stamp-works/">DigiStamp</a>,
38 <a href="http://www.quovadisglobal.co.uk/CertificateServices/SigningServices/TimeStamp.aspx">Quo
39 Vadis</a>,
40 <a href="https://www.globalsign.com/timestamp-service/">Global Sign</a>
41 and <a href="http://www.globaltrustfinder.com/TSADefault.aspx">Global
42 Trust Finder</a>. The system work as long as the private key of the
43 trusted third party is not compromised.</p>
44
45 <p>But as far as I can tell, there are very few public trusted
46 timestamp services available for everyone. I've been looking for one
47 for a while now. But yesterday I found one over at
48 <a href="https://www.pki.dfn.de/zeitstempeldienst/">Deutches
49 Forschungsnetz</a> mentioned in
50 <a href="http://www.d-mueller.de/blog/dealing-with-trusted-timestamps-in-php-rfc-3161/">a
51 blog by David Müller</a>. I then found
52 <a href="http://www.rz.uni-greifswald.de/support/dfn-pki-zertifikate/zeitstempeldienst.html">a
53 good recipe on how to use the service</a> over at the University of
54 Greifswald.</p>
55
56 <p><a href="http://www.openssl.org/">The OpenSSL library</a> contain
57 both server and tools to use and set up your own signing service. See
58 the ts(1SSL), tsget(1SSL) manual pages for more details. The
59 following shell script demonstrate how to extract a signed timestamp
60 for any file on the disk in a Debian environment:</p>
61
62 <p><blockquote><pre>
63 #!/bin/sh
64 set -e
65 url="http://zeitstempel.dfn.de"
66 caurl="https://pki.pca.dfn.de/global-services-ca/pub/cacert/chain.txt"
67 reqfile=$(mktemp -t tmp.XXXXXXXXXX.tsq)
68 resfile=$(mktemp -t tmp.XXXXXXXXXX.tsr)
69 cafile=chain.txt
70 if [ ! -f $cafile ] ; then
71 wget -O $cafile "$caurl"
72 fi
73 openssl ts -query -data "$1" -cert | tee "$reqfile" \
74 | /usr/lib/ssl/misc/tsget -h "$url" -o "$resfile"
75 openssl ts -reply -in "$resfile" -text 1>&2
76 openssl ts -verify -data "$1" -in "$resfile" -CAfile "$cafile" 1>&2
77 base64 < "$resfile"
78 rm "$reqfile" "$resfile"
79 </pre></blockquote></p>
80
81 <p>The argument to the script is the file to timestamp, and the output
82 is a base64 encoded version of the signature to STDOUT and details
83 about the signature to STDERR. Note that due to
84 <a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=742553">a bug
85 in the tsget script</a>, you might need to modify the included script
86 and remove the last line. Or just write your own HTTP uploader using
87 curl. :) Now you too can prove and verify that files have not been
88 changed.</p>
89
90 <p>But the Internet need more public trusted timestamp services.
91 Perhaps something for <a href="http://www.uninett.no/">Uninett</a> or
92 my work place the <a href="http://www.uio.no/">University of Oslo</a>
93 to set up?</p>