AES Hash fix for keys > 128 and Collision safety refactoring

This has been cherry picked and rebased from java/all