示例#1
0
    def encode(dsa_key: object, **kwargs):
        public_key = DSAPublicKey('public_key', dsa_key.p, dsa_key.q,
                                  dsa_key.g, dsa_key.y)
        encoded = generate_openssh_public_key_params(PKIEncoding.SSH2,
                                                     SSH_PUBLIC_HEADER,
                                                     public_key)

        return SSH2DSAPublicKey.transport_encode(encoded, **kwargs)
示例#2
0
    def encode(eddsa_key: object, **kwargs):
        public_key = EdDSAPublicKey('public_key', eddsa_key.a)
        encoded = generate_openssh_public_key_params(PKIEncoding.OpenSSH,
                                                     SSH_PUBLIC_HEADER,
                                                     public_key,
                                                     user=kwargs.get('user'))

        return OpenSSHEdDSAPublicKey.transport_encode(encoded, **kwargs)
示例#3
0
    def encode(ecdsa_key: object, **kwargs):
        curve, x_y_bytes = serialize_public_point(ecdsa_key)
        public_key = ECDSAPublicKey('public_key', curve, x_y_bytes)
        encoded = generate_openssh_public_key_params(PKIEncoding.SSH2,
                                                     b'ecdsa-sha2-' + curve,
                                                     public_key)

        return SSH2ECDSAPublicKey.transport_encode(encoded, **kwargs)
示例#4
0
    def encode(rsa_key: object, **kwargs):
        public_key = RSAPublicKey('public_key', rsa_key.n, rsa_key.e)
        encoded = generate_openssh_public_key_params(PKIEncoding.SSH2, SSH_PUBLIC_HEADER, public_key)

        return SSH2RSAPublicKey.transport_encode(encoded, **kwargs)