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.