Refactoring and changes to support AES-GCM.