Refactor the decrypting of the db to build a Safe object

Start fleshing out a Safe object that is constructed when decrypting
the file. This allows the HMAC to be verified before dumping the
database.

The code is still an unruly mess of c and c++ styles.