pycryptodome icon indicating copy to clipboard operation
pycryptodome copied to clipboard

How to use ECC from Crypto.PublicKey for encryption?

Open koshikraj opened this issue 7 years ago • 6 comments

I need to perform encryption-decryption of a message using ECC from Crypto.PublicKey package. Is there any package I can use to encrypt using ECC like once exists for RSA (PKCS1_OAEP).

This is how I perform encryption using RSA, I need the ECC equivalent method.

from Crypto.PublicKey import RSA
from Crypto.Cipher import PKCS1_OAEP


# Encryption part
message = "plaintext for RSA"

key = RSA.generate(2048)
public = key.publickey()

cipher = PKCS1_OAEP.new(public)
cipher_text = cipher.encrypt(message.encode())
print("Data is encrypted")

# Decryption part
cipher = PKCS1_OAEP.new(key)
message = cipher.decrypt(cipher_text)
print("Decrypted data is : \"{}\"".format(message.decode()))

Thank you.

koshikraj avatar Feb 27 '18 05:02 koshikraj

Encryption with ECC is not supported right now.

Legrandin avatar Mar 09 '18 08:03 Legrandin

Hi, is it supported now or still under maintenance

Ahmed-Salama96 avatar May 26 '18 00:05 Ahmed-Salama96

Encryption with ECC is not supported right now.

Is it planned?

orangetin avatar Apr 05 '23 23:04 orangetin

It's been five years. Any update? Why is this not implemented after so long? Is it because there's not a standard on how to encrypt data with ECC keys?

Edit: It seems that GnuPG has adopted Curve25519 encryption for, also around five years? Do we have any plan for this?

45gfg9 avatar Jul 17 '23 08:07 45gfg9

Now that a decent standard is available (HPKE, RFC 9180), I plan to add it in the coming weeks.

Legrandin avatar Jul 30 '23 13:07 Legrandin

I plan to add it in the coming weeks.

Any update on this? Just want to know if I should use RSA for encryption instead.

ResRipper avatar May 04 '24 05:05 ResRipper