def set_verifier(self, new_client_id=None): if new_client_id: client_id = new_client_id key = Conf().backend.get_key_for_client(client_id) if not key: raise AuthenticationError() else: client_id = self.get_client_id() key = self.kpc.get_key() nonce = AESCipher.generate_nonce() response_kpc = AESCipher(key, nonce) self.response_dict.update({"Nonce": nonce, "Verifier": response_kpc.encrypt(nonce)}) self.set_response_kpc = response_kpc
def test_gen_nonce(): nonce = AESCipher.generate_nonce() assert len( nonce ) == 24 # a 16 char number should always result in a 24 char base64 string