Optimize msg_key
Add size checking
aes_key_iv