Python 3 openssl decrypt rsa

broken image
broken image

If you do have to re-use that key pair for anything else, and don't want to use a deprecated function or pre-3.x version, then you'll have to fake to OpenSSL which key is the public vs. Presumably you already have code to do this, so it shouldn't be that much of a change. The verification side needs to decrypt the hash and then verify it directly, rather than using any built-in verify function. If you're using a unique keypair here, then the minimal-extra-work version is to simply treat the private key as the public key and vice versa, and using the public key, encrypt the hash in PKCS#1 format. Deprecated functionality or legacy versions are probably the only viable route for you if you need to use the same keypair for anything else, and want to avoid doing some extra work.

broken image