def make_symmetric_key(self, nonce1, nonce2): # specs part 6, 6.7.5 key_sizes = (self.signature_key_size, self.symmetric_key_size, 16) (sigkey, key, init_vec) = uacrypto.p_sha256(nonce2, nonce1, key_sizes) self.symmetric_cryptography.Signer = SignerHMac256(sigkey) self.symmetric_cryptography.Encryptor = EncryptorAesCbc(key, init_vec) (sigkey, key, init_vec) = uacrypto.p_sha256(nonce1, nonce2, key_sizes) self.symmetric_cryptography.Verifier = VerifierHMac256(sigkey) self.symmetric_cryptography.Decryptor = DecryptorAesCbc(key, init_vec)
def make_local_symmetric_key(self, secret, seed): # specs part 6, 6.7.5 key_sizes = (self.signature_key_size, self.symmetric_key_size, 16) (sigkey, key, init_vec) = uacrypto.p_sha256(secret, seed, key_sizes) self.symmetric_cryptography.Signer = SignerHMac256(sigkey) self.symmetric_cryptography.Encryptor = EncryptorAesCbc(key, init_vec)
def make_remote_symmetric_key(self, secret, seed): # specs part 6, 6.7.5 key_sizes = (self.signature_key_size, self.symmetric_key_size, 16) (sigkey, key, init_vec) = uacrypto.p_sha256(secret, seed, key_sizes) self.symmetric_cryptography.Verifier = VerifierHMac256(sigkey) self.symmetric_cryptography.Decryptor = DecryptorAesCbc(key, init_vec)
def make_keys(client_nonce, server_nonce): key_sizes = (32, 32, 16) # refer self.security_policy.make_local_symmetric_key(self.remote_nonce, self.local_nonce) from security_policies.py (sigkey, key, init_vec) = uacrypto.p_sha256(server_nonce, client_nonce, key_sizes) server_decrypt_aes = security_policies.DecryptorAesCbc(key, init_vec) client_encrypt_aes = security_policies.EncryptorAesCbc(key, init_vec) client_sign_aes = security_policies.SignerAesCbc(sigkey) # refer self.security_policy.make_remote_symmetric_key(self.local_nonce, self.remote_nonce) from security_policies.py (sigkey, key, init_vec) = uacrypto.p_sha256(client_nonce, server_nonce, key_sizes) client_decrypt_aes = security_policies.DecryptorAesCbc(key, init_vec) server_encrypt_aes = security_policies.EncryptorAesCbc(key, init_vec) server_sign_aes = security_policies.SignerAesCbc(sigkey) return server_decrypt_aes, client_encrypt_aes, client_sign_aes, client_decrypt_aes, server_encrypt_aes, server_sign_aes