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_floats():
with pytest.raises(TypeError):
pack_ssh_uint64(4.2)
with pytest.raises(TypeError):
pack_ssh_uint32(4.2)
def test_uint32():
uint32s = {0x00: binascii.unhexlify('00000000'), 0x0a: binascii.unhexlify('0000000a'),
0xab: binascii.unhexlify('000000ab'), 0xabcd: binascii.unhexlify('0000abcd'),
0xabcdef: binascii.unhexlify('00abcdef'), 0xffffffff: binascii.unhexlify('ffffffff'),
0xf0f0f0f0: binascii.unhexlify('f0f0f0f0'), 0x0f0f0f0f: binascii.unhexlify('0f0f0f0f')}
for known_input, known_answer in uint32s.items():
assert known_answer == pack_ssh_uint32(known_input)
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