Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 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_ssh_public_key(self):
     """
     Serialize the Public Key into the RSA exponent and public modulus stored as SSH mpints.
     http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.certkeys
     :return: The bytes that belong in the SSH Certificate between the nonce and the
     certificate serial number.
     """
     public_key = pack_ssh_mpint(self.e)
     public_key += pack_ssh_mpint(self.n)
     return public_key
Exemplo n.º 4
0
def test_mpints():
    mpints = {long(-1): '00000001ff'.decode('hex'), long(1): '0000000101'.decode('hex'),
              long(127): '000000017f'.decode('hex'), long(128): '000000020080'.decode('hex'),
              long(-128): '0000000180'.decode('hex'), long(-129): '00000002ff7f'.decode('hex'),
              long(255): '0000000200ff'.decode('hex'), long(256): '000000020100'.decode('hex'),
              long(-256): '00000002ff00'.decode('hex'), long(-257): '00000002feff'.decode('hex')}
    for known_input, known_answer in mpints.iteritems():
        assert known_answer == pack_ssh_mpint(known_input)
Exemplo n.º 5
0
def test_mpint_known_answers():
    # mipint values are from https://www.ietf.org/rfc/rfc4251.txt
    mpints = {long(0): '00000000'.decode('hex'),
              long(0x9a378f9b2e332a7): '0000000809a378f9b2e332a7'.decode('hex'),
              long(0x80): '000000020080'.decode('hex'), long(-0x1234): '00000002edcc'.decode('hex'),
              long(-0xdeadbeef): '00000005ff21524111'.decode('hex')}
    for known_input, known_answer in mpints.iteritems():
        assert known_answer == pack_ssh_mpint(known_input)
Exemplo n.º 6
0
def test_mpints():
    mpints = {int(-1): binascii.unhexlify('00000001ff'), int(1): binascii.unhexlify('0000000101'),
              int(127): binascii.unhexlify('000000017f'), int(128): binascii.unhexlify('000000020080'),
              int(-128): binascii.unhexlify('0000000180'), int(-129): binascii.unhexlify('00000002ff7f'),
              int(255): binascii.unhexlify('0000000200ff'), int(256): binascii.unhexlify('000000020100'),
              int(-256): binascii.unhexlify('00000002ff00'), int(-257): binascii.unhexlify('00000002feff')}
    for known_input, known_answer in mpints.items():
        assert known_answer == pack_ssh_mpint(known_input)
Exemplo n.º 7
0
def test_mpint_known_answers():
    # mipint values are from https://www.ietf.org/rfc/rfc4251.txt
    mpints = {int(0): binascii.unhexlify('00000000'),
              int(0x9a378f9b2e332a7): binascii.unhexlify('0000000809a378f9b2e332a7'),
              int(0x80): binascii.unhexlify('000000020080'), int(-0x1234): binascii.unhexlify('00000002edcc'),
              int(-0xdeadbeef): binascii.unhexlify('00000005ff21524111')}
    for known_input, known_answer in mpints.items():
        assert known_answer == pack_ssh_mpint(known_input)
def test_mpint_known_answers():
    # mipint values are from https://www.ietf.org/rfc/rfc4251.txt
    mpints = {
        long(0): '00000000'.decode('hex'),
        long(0x9a378f9b2e332a7): '0000000809a378f9b2e332a7'.decode('hex'),
        long(0x80): '000000020080'.decode('hex'),
        long(-0x1234): '00000002edcc'.decode('hex'),
        long(-0xdeadbeef): '00000005ff21524111'.decode('hex')
    }
    for known_input, known_answer in mpints.iteritems():
        assert known_answer == pack_ssh_mpint(known_input)
def test_mpints():
    mpints = {
        long(-1): '00000001ff'.decode('hex'),
        long(1): '0000000101'.decode('hex'),
        long(127): '000000017f'.decode('hex'),
        long(128): '000000020080'.decode('hex'),
        long(-128): '0000000180'.decode('hex'),
        long(-129): '00000002ff7f'.decode('hex'),
        long(255): '0000000200ff'.decode('hex'),
        long(256): '000000020100'.decode('hex'),
        long(-256): '00000002ff00'.decode('hex'),
        long(-257): '00000002feff'.decode('hex')
    }
    for known_input, known_answer in mpints.iteritems():
        assert known_answer == pack_ssh_mpint(known_input)