Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_uint64():
uint64s = {0x00: binascii.unhexlify('0000000000000000'), 0x0a: binascii.unhexlify('000000000000000a'),
0xab: binascii.unhexlify('00000000000000ab'), 0xabcd: binascii.unhexlify('000000000000abcd'),
0xabcdef: binascii.unhexlify('0000000000abcdef'),
0xffffffff: binascii.unhexlify('00000000ffffffff'),
0xf0f0f0f0: binascii.unhexlify('00000000f0f0f0f0'),
0x0f0f0f0f: binascii.unhexlify('000000000f0f0f0f'),
0xf0f0f0f000000000: binascii.unhexlify('f0f0f0f000000000'),
0x0f0f0f0f00000000: binascii.unhexlify('0f0f0f0f00000000'),
0xffffffffffffffff: binascii.unhexlify('ffffffffffffffff')}
for known_input, known_answer in uint64s.items():
assert known_answer == pack_ssh_uint64(known_input)
def test_floats():
with pytest.raises(TypeError):
pack_ssh_uint64(4.2)
with pytest.raises(TypeError):
pack_ssh_uint32(4.2)
def test_uint_too_long():
with pytest.raises(ValueError):
pack_ssh_uint64(0x1FFFFFFFFFFFFFFFF)
with pytest.raises(ValueError):
pack_ssh_uint32(int(0x1FFFFFFFF))
with pytest.raises(ValueError):
pack_ssh_uint32(int(0x1FFFFFFFF))
def _serialize_certificate_body(self):
body = pack_ssh_string(self.cert_key_type)
body += pack_ssh_string(self.nonce)
body += self._serialize_ssh_public_key()
body += pack_ssh_uint64(self.serial)
body += pack_ssh_uint32(self.cert_type)
body += pack_ssh_string(self.key_id)
body += pack_ssh_string(self._serialize_valid_principals())
body += pack_ssh_uint64(self.valid_after)
body += pack_ssh_uint64(self.valid_before)
body += pack_ssh_string(self._serialize_critical_options())
body += pack_ssh_string(self._serialize_extensions())
body += pack_ssh_string('')
body += pack_ssh_string(self.ca.get_signature_key())
return body
def _serialize_certificate_body(self):
body = pack_ssh_string(self.cert_key_type)
body += pack_ssh_string(self.nonce)
body += self._serialize_ssh_public_key()
body += pack_ssh_uint64(self.serial)
body += pack_ssh_uint32(self.cert_type)
body += pack_ssh_string(self.key_id)
body += pack_ssh_string(self._serialize_valid_principals())
body += pack_ssh_uint64(self.valid_after)
body += pack_ssh_uint64(self.valid_before)
body += pack_ssh_string(self._serialize_critical_options())
body += pack_ssh_string(self._serialize_extensions())
body += pack_ssh_string('')
body += pack_ssh_string(self.ca.get_signature_key())
return body
def _serialize_certificate_body(self):
body = pack_ssh_string(self.cert_key_type)
body += pack_ssh_string(self.nonce)
body += self._serialize_ssh_public_key()
body += pack_ssh_uint64(self.serial)
body += pack_ssh_uint32(self.cert_type)
body += pack_ssh_string(self.key_id)
body += pack_ssh_string(self._serialize_valid_principals())
body += pack_ssh_uint64(self.valid_after)
body += pack_ssh_uint64(self.valid_before)
body += pack_ssh_string(self._serialize_critical_options())
body += pack_ssh_string(self._serialize_extensions())
body += pack_ssh_string('')
body += pack_ssh_string(self.ca.get_signature_key())
return body