コード例 #1
0
    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())
コード例 #2
0
    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())
コード例 #3
0
    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())
コード例 #4
0
    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())
コード例 #5
0
def test_invalid_uint64(uint64):
    with pytest.raises(ValueError):
        _OpensshWriter().uint64(uint64)
コード例 #6
0
def test_valid_uint32(uint32):
    assert OpensshParser(
        _OpensshWriter().uint32(uint32).bytes()).uint32() == uint32
コード例 #7
0
def test_valid_uint64(uint64):
    assert OpensshParser(
        _OpensshWriter().uint64(uint64).bytes()).uint64() == uint64
コード例 #8
0
def test_valid_boolean(boolean):
    assert OpensshParser(
        _OpensshWriter().boolean(boolean).bytes()).boolean() == boolean
コード例 #9
0
def test_invalid_boolean(boolean):
    with pytest.raises(TypeError):
        _OpensshWriter().boolean(boolean)
コード例 #10
0
def test_writer_bytes():
    buffer = bytearray(b'buffer')
    assert _OpensshWriter(buffer).bytes() == buffer
コード例 #11
0
def test_invalid_mpint(mpint):
    with pytest.raises(TypeError):
        _OpensshWriter().mpint(mpint)
コード例 #12
0
def test_valid_mpint(mpint):
    assert OpensshParser(
        _OpensshWriter().mpint(mpint).bytes()).mpint() == mpint
コード例 #13
0
def test_invalid_string(ssh_string):
    with pytest.raises(TypeError):
        _OpensshWriter().string(ssh_string)
コード例 #14
0
def test_valid_string(ssh_string):
    assert OpensshParser(
        _OpensshWriter().string(ssh_string).bytes()).string() == ssh_string