Legrandin / pycryptodome

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

How to use ECC from Crypto.PublicKey for encryption? #139

Open koshikraj opened 6 years ago

koshikraj commented 6 years ago

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.

Legrandin commented 6 years ago

Encryption with ECC is not supported right now.

Ahmed-Salama96 commented 6 years ago

Hi, is it supported now or still under maintenance

orangetin commented 1 year ago

Encryption with ECC is not supported right now.

Is it planned?

45gfg9 commented 1 year ago

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?

Legrandin commented 1 year ago

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

ResRipper commented 6 months ago

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.