Refactored existing code and added support for symmetric encryption.

@russjones it's zeroed by spec, so there should not be any variations