Fixed issues with selecting context for encryption/decryption and reading/writing MACs.