def public_key_fingerprint(self): if self.pk is None: return b'' writer = _OpensshWriter() writer.string(_SSH_TYPE_STRINGS['ed25519']) writer.string(self.pk) return fingerprint(writer.bytes())
def public_key_fingerprint(self): if any([self.e is None, self.n is None]): return b'' writer = _OpensshWriter() writer.string(_SSH_TYPE_STRINGS['rsa']) writer.mpint(self.e) writer.mpint(self.n) return fingerprint(writer.bytes())
def public_key_fingerprint(self): if any([self.curve is None, self.public_key is None]): return b'' writer = _OpensshWriter() writer.string(_SSH_TYPE_STRINGS[_ECDSA_CURVE_IDENTIFIERS_LOOKUP[self.curve]]) writer.string(self.curve) writer.string(self.public_key) return fingerprint(writer.bytes())
def public_key_fingerprint(self): if any([self.p is None, self.q is None, self.g is None, self.y is None]): return b'' writer = _OpensshWriter() writer.string(_SSH_TYPE_STRINGS['dsa']) writer.mpint(self.p) writer.mpint(self.q) writer.mpint(self.g) writer.mpint(self.y) return fingerprint(writer.bytes())
def test_invalid_uint64(uint64): with pytest.raises(ValueError): _OpensshWriter().uint64(uint64)
def test_valid_uint32(uint32): assert OpensshParser( _OpensshWriter().uint32(uint32).bytes()).uint32() == uint32
def test_valid_uint64(uint64): assert OpensshParser( _OpensshWriter().uint64(uint64).bytes()).uint64() == uint64
def test_valid_boolean(boolean): assert OpensshParser( _OpensshWriter().boolean(boolean).bytes()).boolean() == boolean
def test_invalid_boolean(boolean): with pytest.raises(TypeError): _OpensshWriter().boolean(boolean)
def test_writer_bytes(): buffer = bytearray(b'buffer') assert _OpensshWriter(buffer).bytes() == buffer
def test_invalid_mpint(mpint): with pytest.raises(TypeError): _OpensshWriter().mpint(mpint)
def test_valid_mpint(mpint): assert OpensshParser( _OpensshWriter().mpint(mpint).bytes()).mpint() == mpint
def test_invalid_string(ssh_string): with pytest.raises(TypeError): _OpensshWriter().string(ssh_string)
def test_valid_string(ssh_string): assert OpensshParser( _OpensshWriter().string(ssh_string).bytes()).string() == ssh_string