def test_xor_bad_length(self): # test xor function when given mismatching lengths key = Fernet.generate_key() fernet = Fernet(key) # check xor functionality x = bytes(bytearray(16)) for i in xrange(1, 20): if i == 16: continue y = os.urandom(i) with pytest.raises(AssertionError) as e: fernet._xor(x, y)
def test_xor(self): # check xor for normal functionality key = Fernet.generate_key() fernet = Fernet(key) x = bytes(bytearray(16)) for i in xrange(20): y = os.urandom(16) assert(fernet._xor(x, y) == y) # xor of 0 and y == y