Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _serialize_critical_options(self):
# Options must be lexically ordered by "name" if they appear in the
# sequence. Each named option may only appear once in a certificate.
serialized = b''
if self.critical_option_force_command is not None:
serialized += pack_ssh_string('force-command')
serialized += pack_ssh_string(
pack_ssh_string(self.critical_option_force_command))
if self.critical_option_source_address is not None:
serialized += pack_ssh_string('source-address')
serialized += pack_ssh_string(
pack_ssh_string(self.critical_option_source_address))
return serialized
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
def _serialize_critical_options(self):
# Options must be lexically ordered by "name" if they appear in the
# sequence. Each named option may only appear once in a certificate.
serialized = b''
if self.critical_option_force_command is not None:
serialized += pack_ssh_string('force-command')
serialized += pack_ssh_string(
pack_ssh_string(self.critical_option_force_command))
if self.critical_option_source_address is not None:
serialized += pack_ssh_string('source-address')
serialized += pack_ssh_string(
pack_ssh_string(self.critical_option_source_address))
return serialized
def _serialize_critical_options(self):
# Options must be lexically ordered by "name" if they appear in the
# sequence. Each named option may only appear once in a certificate.
serialized = b''
if self.critical_option_force_command is not None:
serialized += pack_ssh_string('force-command')
serialized += pack_ssh_string(
pack_ssh_string(self.critical_option_force_command))
if self.critical_option_source_address is not None:
serialized += pack_ssh_string('source-address')
serialized += pack_ssh_string(
pack_ssh_string(self.critical_option_source_address))
return serialized
def get_signature_key(self):
"""
Get the SSH Public Key associated with this CA.
Packed per RFC4253 section 6.6.
:return: SSH Public Key.
"""
key = pack_ssh_string(self.public_key_type)
key += pack_ssh_mpint(self.e)
key += pack_ssh_mpint(self.n)
return key
def _serialize_extensions(self):
# Options must be lexically ordered by "name" if they appear in the
# sequence. Each named option may only appear once in a certificate.
extensions_list = sorted(self.extensions)
serialized = b''
# Format is a series of {extension name}{empty string}
for extension in extensions_list:
serialized += pack_ssh_string(extension)
serialized += pack_ssh_string('')
return serialized
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_critical_options(self):
# Options must be lexically ordered by "name" if they appear in the
# sequence. Each named option may only appear once in a certificate.
serialized = b''
if self.critical_option_force_command is not None:
serialized += pack_ssh_string('force-command')
serialized += pack_ssh_string(
pack_ssh_string(self.critical_option_force_command))
if self.critical_option_source_address is not None:
serialized += pack_ssh_string('source-address')
serialized += pack_ssh_string(
pack_ssh_string(self.critical_option_source_address))
return serialized