Legrandin / pycryptodome

A self-contained cryptographic library for Python
https://www.pycryptodome.org
Other
2.81k stars 502 forks source link

Clarifying behavior for Crypto.PublicKey.RSA.export_key in docs #798

Open Prateek2000 opened 7 months ago

Prateek2000 commented 7 months ago

The format='OpenSSH' parameter in Crypto.PublicKey.RSA.export_key when used with a private key exports the public key instead. The code extracts only the public key parameters and writes them to bytes from what I understand.

The current doc says "Only suitable for public keys", which I think does not convey what could happen if someone were to use a private key anyhow. It does not throw an error either. So I believe it would make sense to document this behavior.