1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
from noiseprotocol.backends.default import noise_backend
from noiseprotocol.noise_protocol import NoiseProtocol
from noiseprotocol.state import CipherState, SymmetricState
class TestRevision33Compatibility(object):
def test_noise_protocol_accepts_slash(self):
class FakeSHA3_256():
fn = None
noise_name = b"Noise_NN_25519_AESGCM_SHA3/256"
modified_backend = noise_backend
modified_backend.hashes['SHA3/256'] = FakeSHA3_256 # Add callable to hash functions mapping
modified_class = NoiseProtocol
modified_class(noise_name, modified_backend)
def test_cipher_state_set_nonce(self):
noise_protocol = NoiseProtocol(b"Noise_NN_25519_AESGCM_SHA256", backend=noise_backend)
cipher_state = CipherState(noise_protocol)
cipher_state.initialize_key(b'\x00'*32)
assert cipher_state.n == 0
cipher_state.set_nonce(42)
assert cipher_state.n == 42
def test_symmetric_state_get_handshake_hash(self):
symmetric_state = SymmetricState()
symmetric_state.h = 42
assert symmetric_state.get_handshake_hash() == 42
|