LogCrypt 0.1 Jason Holt 26 June 2003 Released into the public domain Introduction: ------------- LogCrypt is like Tripwire for logfiles. A secret is established at log creation time and stored somewhere safe, and changes via a one-way cryptographic function every time a line is written to the log. This secret is used to compute a MAC (message authenticaion code) for each line of the log, and optionally to encrypt the log as well. If your system is compromised, the attacker will have no way to recover the secrets used to create MACs for (or decrypt) already-written lines of the log. He can delete the log entirely, but can't modify it without detection. Later, you can use the original secret to see if your logs are still intact. (For best security, you should do this on a separate, secure machine). logcrypt only links against OpenSSL, so I'm not actually sure whether the following are necessary. But thanks to the OpenSSL team and Eric Young for their excellent work on OpenSSL: This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/). This product includes cryptographic software written by Eric Young (eay@cryptsoft.com). Installation: ------------- Type "make". This should produce two programs, "logcrypt" and "logread". You can test them by typing "cd tests ; make ; cd ..". (You may need to set the path to perl in tests/test.pl). Feedback: --------- The amount of work I do on LogCrypt from this point on will probably be proportional to the amount of feedback I get. If I don't hear from anyone, I'll assume noone's using it. So let me know if you do! Using LogCrypt: --------------- To keep MACs for an existing log "messages": $ tail -n 9999999 -f messages | logcrypt >messages.mac 2af5e4e16bd3a26e744e9348432627de6db52640 The line above is the MAC secret, used for verifying log integrity. Keep it in a safe, secret place. In particular, don't leave it anywhere unencrypted on this machine. You could write it on a piece of paper kept somewhere safe, for instance. Be sure to write down the MAC secret for later verification: $ logread -i messages.mac messages $ logread -i messages.mac >>>> MAC error! Line 1 may have been modified! >>>>> MAC error! Line 2 may have been modified! The log appears to have been modified! To encrypt the log as well as keeping MACs, use -e: $ tail -n 9999999 -f messages | logcrypt -e >messages.log 4fbd7e7ea64f2288b251a8e531c1a971fb4d31f4 b0fd3cb7f2205e4baced8d2d4d69b7e5ca70c2bba9620d5a The first line is the MAC secret, used for verifying log integrity. The second line is the encryption secret, which keeps the logs confidential. Keep them in a safe, secret place. In particular, don't leave them anywhere unencrypted on this machine. You could write them on a piece of paper kept somewhere safe, for instance. Later you can decrypt. Because logcrypt has forward secrecy, even if your system has been compromised after you started logcrypt, the intruder can't modify or read messages.log without your detection. With some caveats, of course - if you public-key encrypt the key and keep it in a file, he can replace that file with a different public-key encrypted key. And of course he may also be able to fool you into *thinking* that the log checks out, for instance by modifying your copy of logread. For best results, keep the key off the system, and do your log verification on a separate machine as well. $ ./logread -d messages.mac Later, you can decrypt the MAC secret using your private key and passphrase: $ gpg messageskey.gpg Enter passphrase for LogCrypt: ....... $ ./logread -i messages.mac -r messageskey foo.mac 2>/dev/null tail -n 9999999 -f bar | ./logcrypt -r mackey.tmp >bar.mac 2>/dev/null tail -n 9999999 -f baz | ./logcrypt -r mackey.tmp >baz.mac 2>/dev/null Later, you can run: $ logread -d