paramiko / paramiko

The leading native Python SSHv2 protocol library.
http://paramiko.org
GNU Lesser General Public License v2.1
8.95k stars 1.99k forks source link

PKCS8 #2144

Open Jan-Sedlacek opened 1 year ago

Jan-Sedlacek commented 1 year ago

Add a support for modern Key serialization into Transport class. Currently only support of PKCS#1 is present, modern serialization PKCS8 could not be used.

Eg. RSA key generated with:

from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives import serialization

RSAKeyGen = rsa.generate_private_key(public_exponent=65537,key_size=4096)
RSAPem = RSAKeyGen.private_bytes(
    encoding=serialization.Encoding.PEM,
    format=serialization.PrivateFormat.PKCS8,
    encryption_algorithm=serialization.NoEncryption())
with open("./serverKey.pem", "wb") as f:
    f.write(RSAPem)

Should be usable and not raise SSHException("'not a valid RSA private key file'") while loading the RSA key by paramiko RSAKey class

bskinn commented 1 year ago

Flagging this to include/consider in the key/auth rewrite of #387.

Thanks for the suggestion, @Jan-Sedlacek!

abhishekthukaram commented 1 year ago

Hi @Jan-Sedlacek and @bskinn : Any update on the support of PKCS8 in paramiko , I am getting the same issue when using the paramiko library

bskinn commented 1 year ago

Flagging this to include/consider in the key/auth rewrite of #387.

Thanks for the suggestion, @Jan-Sedlacek!

@abhishekthukaram -- bitprophet is now in the beginning stages of the key/auth rewrite -- all things keys should be much better soon.