def test_random_of_length(self): """ Verify that the Python implementation guarantees byte length by setting most significant bit to 1 """ for x in range(10): val = _pysrp.get_random_of_length(32) self.assertTrue(val >> 255 == 1)
def test_ephemeral_length(self): """ Verify that all implementations require 32 bytes for ephemeral values """ random31 = _pysrp.long_to_bytes(_pysrp.get_random_of_length(31)) random33 = _pysrp.long_to_bytes(_pysrp.get_random_of_length(33)) def verf_len(mod, val): with self.assertRaises(ValueError) as ctx: mod.User('uname', 'pwd', bytes_a=val) self.assertIn('bytes_a', str(ctx.exception) ) with self.assertRaises(ValueError) as ctx: mod.Verifier('uname', random31, random31, random31, bytes_b=val) self.assertIn('bytes_b', str(ctx.exception) ) for mod in [_ctsrp, _pysrp]: for val in [random31, random33]: verf_len(mod, val)
def test_ephemeral_length(self): """ Verify that all implementations require 32 bytes for ephemeral values """ random31 = _pysrp.long_to_bytes(_pysrp.get_random_of_length(31)) random33 = _pysrp.long_to_bytes(_pysrp.get_random_of_length(33)) def verf_len(mod, val): with self.assertRaises(ValueError) as ctx: mod.User('uname', 'pwd', bytes_a=val) self.assertIn('bytes_a', str(ctx.exception)) with self.assertRaises(ValueError) as ctx: mod.Verifier('uname', random31, random31, random31, bytes_b=val) self.assertIn('bytes_b', str(ctx.exception)) for mod in [_ctsrp, _pysrp]: for val in [random31, random33]: verf_len(mod, val)