CollectDCrypto: Skeleton class

CollectDCrypto will handle all signed/encrypted communication
for collectd. Packets are sent to CollectDCrypto where they are
parsed, decrypted or verified and dropped or have their payload
forwarded to CollectDParser according to the security policy.

Two new configuration options are added:
 - collectd_security_level: 0 (default), 1 or 'Sign', 2 or 'Encrypt'
 - collectd_auth_file: The location of the file used to verify
   decrypt the packets.
similar to the 'SecurityLevel' and 'AuthFile' options of collectd's
network plugin.

CollectDCrypto requires PyCrypto.

Possible interactions of client and server security settings
are as described in:
https://collectd.org/wiki/index.php/Networking_introduction#Possible_interactions
CollectDCrypto: Signed pkt parsing (HMAC-SHA256)

- First 2 bytes is the part type. Signed parts have a type of 0x0200.
- Next 2 bytes specify the part's length.
- Next 32 bytes are an HMAC-SHA256 tag on all the bytes following
  the tag.
- Next (part_len - 36) bytes are the username.
- Payload to forward is all bytes after username.

(The hmac is on the username + payload)
CollectDCrypto: Encrypted pkt parsing (AES256)

- First 2 bytes is the part type. For encrypted parts it's 0x0210.
- Next 2 bytes specify the part length.
- Next 2 bytes specify the username length.
- Next uname_len bytes are the username.
- Next 16 bytes are the initialization vector (iv).
- Remaining bytes are the ciphertext. It needs to be padded to a
  multiple of 16 before decryption and unpadded afterwards
  (OFB mode turns AES into a stream cipher).
- The user's password is hashed with SHA256 to produce the
  encryption key.
- Ciphertext is decrypted with AES using the key and iv from above.
- First 20 bytes in the plaintext (padding removed) is a SHA1 hash
  of the remaining bytes of the plaintext.
- Remaining bytes (without the SHA1 tag) are the payload to forward.
CollectDCrypto: Basic test for signing
CollectDCrypto: Basic test for encryption
CollectDCrypto: hashlib & hmac replace Crypto.Hash

Quick tests showed that the functions from hashlib and hmac
were faster than the ones provided by Crypto.Hash

This way, CollectDCrypto's parsing of signed packets doesn't
require PyCrypto.

For encryption, PyCrypto is still required to use AES.
CollectDCrypto: make python3 compatible
Add sleep statements in tests

Without them, tests with python3 fail for me
CollectDCrypto: Clean up code and minor bug fixes

Fix security policy
Raise exceptions in case of error
Simplify code
Check all hashes in constant time
CollectDCrypto: Test security policy works

Add tests for all 3 available security levels
(None=0, Sign=1, Encrypt=2)
with valid and invalid passwords to make sure the signed
or encrypted packets are parsed appropriately.

Minor change to t.set_cfg decorator to return wrapped function's
result, so that it can be used in a more flexible manner.
CollectDCrypto: Reload authfile when modified

This requires the 'watchdog' module. A general purpose single
file monitor has been put in a new file 'helpers.py' since it
didn't really fit anywhere else.
Move temp_file() to tests/t.py
Add test for bucky.helpers.FileMonitor
CollectDCrypto: Add tests for authfile load/reload
Small change in FileMonitor and test for py3
CollectdCrypto: Minor changes for better parsing
Require PyCrypto, remove optional import

PyCrypto is required for its AES implementation that is used
in CollectDCrypto for decrypting encrypted packets.
Add watchdog module to requirements.txt

It is used by bucky.helpers.FileMonitor to monitor a file for
modifications. FileMonitor is used by collectd.CollectDCrypto
to reload the authfile when it changes without restarting
bucky.
CollectDCrypto: Update README.rst
Small changes so that flake8 doesn't complain

These two lines aren't recent but caused my build to fail.