xref: /minix3/usr.sbin/syslogd/sign.html (revision 3e07920fe2355e64a2f9017c962f62d77d988a44)
1*3e07920fSDavid van Moolenbroek<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
2*3e07920fSDavid van Moolenbroek<html>
3*3e07920fSDavid van Moolenbroek<head>
4*3e07920fSDavid van Moolenbroek<title>NetBSD &amp; Google's Summer of Code: Martin Schuette - Improve syslogd (syslogd)</title>
5*3e07920fSDavid van Moolenbroek</head>
6*3e07920fSDavid van Moolenbroek<body>
7*3e07920fSDavid van Moolenbroek
8*3e07920fSDavid van Moolenbroek<h1>syslog-sign</h1>
9*3e07920fSDavid van Moolenbroek<p><a href="http://tools.ietf.org/html/draft-ietf-syslog-sign">syslog-sign</a> defines digital signatures for logfiles. This provides end-to-end authentication for network transports, enables the detection of lost UDP messages, and also makes it possible to check a log archive for later modifications (assuming the private key was kept safe).</p>
10*3e07920fSDavid van Moolenbroek
11*3e07920fSDavid van Moolenbroek<h2>Signature Groups</h2>
12*3e07920fSDavid van Moolenbroek<p>A basic concept of syslog-sign is the signature group which describes a set of messages that are grouped and signed together. Their purpose becomes clear with an example: assume you split your messages to two logservers <em>serverA</em> and <em>serverB</em>. Now if all messages were singed as one stream, then a) where do the signatures go to? and b) how could <em>serverA</em>, having only hashes and signatures, decide which message are missing and which are on <em>serverB</em>?<br>
13*3e07920fSDavid van MoolenbroekThus the messages are selected into two signature groups containing all signatures for messages to <em>serverA</em> and <em>serverB</em> respectively. Then every server has its own messages and its own signatures to verify them.</p>
14*3e07920fSDavid van Moolenbroek<p>There are three predefined and one custom signature groups:</p>
15*3e07920fSDavid van Moolenbroek<ol start="0">
16*3e07920fSDavid van Moolenbroek  <li>one global signature group, useful if all messages go to one central logserver anyway</li>
17*3e07920fSDavid van Moolenbroek  <li>every syslog priority (=combination of facility and severity) gets its own group, i.e. 192 of them, useful if there are lots of different destinations which all receive messages with different priorities</li>
18*3e07920fSDavid van Moolenbroek  <li>take the priorities and split them into intervals, useful to define bigger subsets, e.g. one signature group for the mail facility and two for everything else</li>
19*3e07920fSDavid van Moolenbroek  <li>not defined and reserved for custom strategy. I use this to have one signature group for every configured destination. In this case the selector in syslog.conf will determine which messages go into one group; it is also the only strategy that allows a message to be in multiple groups.</li>
20*3e07920fSDavid van Moolenbroek</ol>
21*3e07920fSDavid van Moolenbroek<p>Every signature group has several attributes and only the combination of several values determines one signature group unambiguously. Currently the key to identify a signature group is the tuple (hostname, reboot session ID, SG value, SPRI value). <!-- In a later draft the program name or process ID might be added to allow multiple syslog-sign senders per host.--></p>
22*3e07920fSDavid van Moolenbroek
23*3e07920fSDavid van Moolenbroek<h2>Configuration/Activation</h2>
24*3e07920fSDavid van Moolenbroek<p>syslog-sign is enabled with the option "sign_sg" in syslog.conf. The value selects the signature group strategy, so for example the line "sign_sg=0" enables syslog-sign with one signature group.</p>
25*3e07920fSDavid van Moolenbroek<p>The SG="2" strategy is the only one that might require additional configuration. When selected (with "sign_sg=2") the default is to use one signature group per facility (kernel, user, mail, ...). To allow custom configuration there is an additional option "sign_sg2_delim" to specify the numerical SPRI values, i.e. the boundaries betwen the signature groups.<br>
26*3e07920fSDavid van MoolenbroekExample: With "sign_sg2_delim = 15 31" syslogd will set up three signature groups: one for all priorities x &le; 15 (kernel.*,user.*), one for priorities 15 &lt; x &le; 31 (mail.*), and one for all priorities x &gt; 31.</p>
27*3e07920fSDavid van Moolenbroek
28*3e07920fSDavid van Moolenbroek<h2>Key, Signature, and Hash Types</h2>
29*3e07920fSDavid van Moolenbroek<p>The current internet draft defines two values for the VERsion field for using either SHA-1 or SHA-256 hashes. Both versions mandate DSA keys and signatures.<br>
30*3e07920fSDavid van MoolenbroekThere are several alternatives for sending the public key in the initial Certificate Block. If a X.509 certificate is available (for TLS connections) then syslogd will use key type 'C' (PKIX) and send the certificate in DER encoding. Otherwise it generates a new DSA key and uses key type 'K' (public key) to send the public key in DER encoding.</p>
31*3e07920fSDavid van Moolenbroek
32*3e07920fSDavid van Moolenbroek<h2>Redundancy</h2>
33*3e07920fSDavid van Moolenbroek<p>As mentioned above one design target of syslog-sign is the detection of lost messages, e.g. due to UDP datagram loss. So one has to take extra precaution to prevent lost signature messages and send them multiple times.<br>
34*3e07920fSDavid van MoolenbroekThis implementation sends the first Certificate block only on demand, just before the first Signature Block. After that it is resent <em>n</em> times with several seconds delay. The Signature Blocks are not repeated but use a sliding window so that every message hash is included in <em>m</em> sequential Signature Blocks.</p>
35*3e07920fSDavid van Moolenbroek
36*3e07920fSDavid van Moolenbroek<h2>Verification</h2>
37*3e07920fSDavid van Moolenbroek<p>Sending signatures is only half of the job, -- they have to be verified as well. I used Perl to write an <a href="verify-sign/verify.pl">offline verification</a> tool that reads a complete logfile and prints all messages in their correct order. See the example below for a sample usage and output.</p>
38*3e07920fSDavid van Moolenbroek
39*3e07920fSDavid van Moolenbroek<h2>Example</h2>
40*3e07920fSDavid van Moolenbroek<p>Here is an example of a signed message sequence. I let syslogd generate me a DSA key for a self-signed X.509 certificate and use that for signing. I also changed one message so you can see the resulting verification output below.</p>
41*3e07920fSDavid van Moolenbroek
42*3e07920fSDavid van Moolenbroek<pre>
43*3e07920fSDavid van Moolenbroek$ cat test.log
44*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg0
45*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg1
46*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg2
47*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg3
48*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg4
49*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg5
50*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg6
51*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg7
52*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg8
53*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg9
54*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg10
55*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg11
56*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - modified msg12
57*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg13
58*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg14
59*3e07920fSDavid van Moolenbroek<110>1 2008-08-02T01:09:27.773505+02:00 host.example.org syslogd - - [ssign-cert VER="0111" RSID="1217632162" SG="3" SPRI="0" TBPL="1059" INDEX="1" FLEN="1059" FRAG="2008-08-02T01:09:27.773464+02:00 C MIIC+jCCArmgAwIBAwIBATAJBgcqhkjOOAQDMCIxIDAeBgNVBAMTF2NvcmRlbGlhLm1zY2h1ZXR0ZS5uYW1lMB4XDTA4MDczMDIyMDYyMloXDTA5MDczMDIyMDYyMlowIjEgMB4GA1UEAxMXY29yZGVsaWEubXNjaHVldHRlLm5hbWUwggG3MIIBKwYHKoZIzjgEATCCAR4CgYEA92S335Kxy2TTMfdg9Vi/CJvyDCHMHpPYxWwEkEI26xEdKybzLghTfbG/RZw/nnFuhRTH4Xe6GVvlFi2zIzySSClXr+zyXg/D9uHyiVL5TEsu8uQT2IREmGOB8pu70FukL9nQGOr82YxuRFQzZ1p6KltIggivi5ffR4B33+1xoSkCFQDYe5GJKM9Cw6nkLngHkzFGRmcXIQKBgDbHeOLBKYLkRZyRpXd0aTNU2igcKTWyWlUTySJuv/iTAeB09p9WyTIPyAhtqN77CIwX8Ui2jGu6NYT6TWEYJVvL+C/TvddAvAMyefv+w+HPNF2L77IVrjNVRCneERoNKlWc6IzjKH3otl/Lh2D7NAWRid55vxF6Z0oO459+4vpRA4GFAAKBgQCzcJVR343IRntcQs8aENs/QMxoxHN6JVdpSLB9moY5/RC9ooxz32fkakSL0s8zLITLt/y+yzf0F/9JhmTC1XeD8gvPBesE6dc0ZzPCos0hg8WpKUWR0YqXFDOC//uBwIa94DncC8xZ0mCwavno6gtkz57S7ywSwnmrdjhmpdAZuqOBgDB+MBEGCWCGSAGG+EIBAQQEAwIGQDAzBglghkgBhvhCAQ0EJhYkYXV0by1nZW5lcmF0ZWQgYnkgdGhlIE5ldEJTRCBzeXNsb2dkMCYGCWCGSAGG+EIBDAQZFhdjb3JkZWxpYS5tc2NodWV0dGUubmFtZTAMBgNVHRMBAf8EAjAAMAkGByqGSM44BAMDMAAwLQIUZcsHdrbuyx9lR3tyyeiJvClj0B8CFQC+5+NlulgCd/yoSlLPZgsTHYmCYA==" SIGN="MC0CFFEHx8UX391lbmhbisJNS0zLGD/WAhUAuMfCO0BWtARt2vEWHbM2mAe2k+o="]
60*3e07920fSDavid van Moolenbroek<110>1 2008-08-02T01:09:27.778347+02:00 host.example.org syslogd - - [ssign VER="0111" RSID="1217632162" SG="3" SPRI="0" GBC="1" FMN="1" CNT="15" HB="siUJM358eYFHOS2K0MTlveWeH/U= zTxfthW8WqmtFhOG4k/+ZxkirTA= j9dubU1GNVp7qWShwph/w32nD08= XQDLZ/NuwirmLdMORtm84r9kIW4= RNDFNCo7hiCsK/EKumsPBbFHNZA= ANiE3KbY948J6cEB640fAtWXuO4= e2M/OqjHDfxLVUSPt1CsNJHm9wU= Y+racQst7F1gR8eEUh8O7o+M53s= JAMULRxjMPbOO5EhhKbsUkAwbl0= pd+N5kmlnyQ0BoItELd/KWQrcMg= dsMQSzPHIS6S3Vaa23/t7U8JAJ4= i4rE3x7N4qyQGTkmaWHsWDFP9SY= qgTqV4EgfUFd3uZXNPvJ25erzBI= XW0YrME5kQEh+fxhg1fetnWxfIc= 7YPcRHsDwXWnQuGRWaJtFWw9hus=" SIGN="MCwCFF5hS5GTLxLDwsDCUmOnHhzkmWzbAhRJ0io+LBKM6Ux/cM7eqZ6eRAI11Q=="]
61*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg15
62*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg16
63*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg17
64*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg18
65*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg19
66*3e07920fSDavid van Moolenbroek<110>1 2008-08-02T01:09:32.399406+02:00 host.example.org syslogd - - [ssign VER="0111" RSID="1217632162" SG="3" SPRI="0" GBC="4" FMN="1" CNT="20" HB="siUJM358eYFHOS2K0MTlveWeH/U= zTxfthW8WqmtFhOG4k/+ZxkirTA= j9dubU1GNVp7qWShwph/w32nD08= XQDLZ/NuwirmLdMORtm84r9kIW4= RNDFNCo7hiCsK/EKumsPBbFHNZA= ANiE3KbY948J6cEB640fAtWXuO4= e2M/OqjHDfxLVUSPt1CsNJHm9wU= Y+racQst7F1gR8eEUh8O7o+M53s= JAMULRxjMPbOO5EhhKbsUkAwbl0= pd+N5kmlnyQ0BoItELd/KWQrcMg= dsMQSzPHIS6S3Vaa23/t7U8JAJ4= i4rE3x7N4qyQGTkmaWHsWDFP9SY= qgTqV4EgfUFd3uZXNPvJ25erzBI= XW0YrME5kQEh+fxhg1fetnWxfIc= 7YPcRHsDwXWnQuGRWaJtFWw9hus= PIvLm0mh+he5+PDihG1p7sQlx8k= lPzUvx0I1VwSGWV7yKF9W//Yb2U= X+PWYcx5AXnsDVSNAHLZUGk5ioY= okXY88MGG4QybrYMf8HJN23WO1Y= HcaPyHfQ2s1SuSciTKw4woYWuMg=" SIGN="MCwCFFr0i6taT1vWowR7yc5bEQxFfY7/AhQBCK+rBNPgzR0vUgxPeARvD24kIQ=="]
67*3e07920fSDavid van Moolenbroek</pre>
68*3e07920fSDavid van Moolenbroek<p>Just in case you wonder about the different timestamps: The messages were send with a normal syslog(3), so the syslogd received them in BSD Syslog format without subsecond resolution.</p>
69*3e07920fSDavid van Moolenbroek<hr>
70*3e07920fSDavid van Moolenbroek<pre>
71*3e07920fSDavid van Moolenbroek$ perl verify.pl --help
72*3e07920fSDavid van Moolenbroek
73*3e07920fSDavid van Moolenbroeksyslog-sign verifier
74*3e07920fSDavid van Moolenbroekreads logfile and verifies message signatures
75*3e07920fSDavid van Moolenbroek
76*3e07920fSDavid van MoolenbroekNotes:
77*3e07920fSDavid van Moolenbroek- By default uses only SHA-1 hashes. Use option "--sha256" to use only
78*3e07920fSDavid van Moolenbroek  SHA-256 and "--sha1 --sha256"to use both types.
79*3e07920fSDavid van Moolenbroek- Some status messages are printed to stderr.
80*3e07920fSDavid van Moolenbroek  Use option "--quiet" to disable them.
81*3e07920fSDavid van Moolenbroek- All verified messages are printed with their identifying signature group.
82*3e07920fSDavid van Moolenbroek  Every line starts with a comma-separated tuple: hostname, reboot session ID,
83*3e07920fSDavid van Moolenbroek  SG value, SPRI value, and message number.
84*3e07920fSDavid van Moolenbroek- If only one hash is used then all messages not signed are printed as well.
85*3e07920fSDavid van Moolenbroek
86*3e07920fSDavid van MoolenbroekLimitations: handles only key types 'C' (PKIX) and 'K' (public key)
87*3e07920fSDavid van Moolenbroek  with DSA keys and signatures
88*3e07920fSDavid van Moolenbroek
89*3e07920fSDavid van MoolenbroekCommand Line Options:
90*3e07920fSDavid van Moolenbroek  -i  --in         input file (default: stdin)
91*3e07920fSDavid van Moolenbroek  -o  --out        output file for verified messages (default: stdout)
92*3e07920fSDavid van Moolenbroek  -u  --unsigned   output file for unsigned messages (default: stdout)
93*3e07920fSDavid van Moolenbroek      --sha1       use SHA-1 hashes (default)
94*3e07920fSDavid van Moolenbroek      --sha256     use SHA-256 hashes
95*3e07920fSDavid van Moolenbroek  -v  --verbose    shows some internals (every CB,SB,hash,...)
96*3e07920fSDavid van Moolenbroek  -q  --quiet      no status messages to stderr
97*3e07920fSDavid van Moolenbroek  -h  --help       this help
98*3e07920fSDavid van Moolenbroek
99*3e07920fSDavid van Moolenbroek$ perl verify.pl -i test.log
100*3e07920fSDavid van Moolenbroekreading input...
101*3e07920fSDavid van Moolenbroekprocessing CBs...
102*3e07920fSDavid van Moolenbroekdecoding SGs...
103*3e07920fSDavid van Moolenbroekgot PKIX DSA key
104*3e07920fSDavid van Moolenbroekverifying CBs...
105*3e07920fSDavid van Moolenbroekverified CB and got key for SG: (host.example.org,1217632162,0111,3,0), start: 2008-08-02T01:09:27.773464+02:00
106*3e07920fSDavid van Moolenbroeknow process SBs
107*3e07920fSDavid van Moolenbroeksigned messages:
108*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,1  <15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg0
109*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,2  <15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg1
110*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,3  <15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg2
111*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,4  <15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg3
112*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,5  <15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg4
113*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,6  <15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg5
114*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,7  <15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg6
115*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,8  <15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg7
116*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,9  <15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg8
117*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,10 <15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg9
118*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,11 <15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg10
119*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,12 <15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg11
120*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,13 **** msg lost
121*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,14 <15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg13
122*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,15 <15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg14
123*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,16 <15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg15
124*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,17 <15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg16
125*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,18 <15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg17
126*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,19 <15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg18
127*3e07920fSDavid van Moolenbroekhost.example.org,1217632162,0111,3,0,20 <15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - msg19
128*3e07920fSDavid van Moolenbroekmessages without signature:
129*3e07920fSDavid van Moolenbroek<15>1 2008-08-02T02:09:27+02:00 host.example.org test 6255 - - modified msg12
130*3e07920fSDavid van Moolenbroek</pre>
131*3e07920fSDavid van Moolenbroek
132*3e07920fSDavid van Moolenbroek<hr>
133*3e07920fSDavid van Moolenbroek<table border=0>
134*3e07920fSDavid van Moolenbroek<tr>
135*3e07920fSDavid van Moolenbroek<td>
136*3e07920fSDavid van Moolenbroek<a href="http://sourceforge.net"><img align="top" src="http://sourceforge.net/sflogo.php?group_id=141771&amp;type=2" width="125" height="37" border="0" alt="SourceForge.net Logo"></a>
137*3e07920fSDavid van Moolenbroek<td>
138*3e07920fSDavid van Moolenbroek  <table>
139*3e07920fSDavid van Moolenbroek  <tr> <td> Martin Sch&uuml;tte &lt;<tt>info@mschuette.name</tt>&gt; </td> </tr>
140*3e07920fSDavid van Moolenbroek  <tr> <td> $Id: sign.html,v 1.1 2008/10/31 16:12:19 christos Exp $ </td> </tr>
141*3e07920fSDavid van Moolenbroek  </table>
142*3e07920fSDavid van Moolenbroek</tr>
143*3e07920fSDavid van Moolenbroek</table>
144*3e07920fSDavid van Moolenbroek
145*3e07920fSDavid van Moolenbroek</body>
146*3e07920fSDavid van Moolenbroek</html>
147