Initial working implementation of encryption/authentication