6
$\begingroup$

This is probably a simple question, but I haven't been able to see it stated anywhere. Is it possible to directly encrypt a file (of any length) with some form of EC using the 25519 curve.

I know it's common to exchange a key with EC and then use symmetric encryption (AES) to encrypt a file, however I was curious if it was possible directly ?

I've seen the salsa20 and chacha stream ciphers but I am unsure if they are suitable. If so is there a pre-existing tool that can be used or is something like libsodium the way to go.

As you probably have guessed, I'm still in research mode and I'm fairly keen to use as many pre-existing tools as possible.

$\endgroup$
7
$\begingroup$

No, you cannot "directly" encrypt a file using ECC without generating your own algorithm. Encrypting a file would be extremely inefficient; this is because the block size of ECC is very small, leading to a very high overhead both with regards to data usage (the ciphertext would be strictly larger than the plaintext) as well as CPU-usage.

Yes, any curve can be used to encrypt something if it is suitable to perform ECDH. If ECDH is used then the curve can be used to implement EC-IES.

I've seen the salsa20 and chacha stream ciphers but I am unsure if they are suitable. If so is there a pre-existing tool that can be used or is something like libsodium the way to go.

Any secure cipher is suitable. It may be smart to go for some existing protocol/library if you haven't implemented a secure protocol or library yet.


Using authenticated encryption should be preferred.

$\endgroup$
  • 3
    $\begingroup$ Actually, if one were sufficiently insane, they could encrypt a file using, say, EC-El Gamal; they'd need to way to translate bit patterns into EC points (e.g. by taking sections of n-64 bits, and searching for the remaining 64 bits that form a legal x coordinate). As you said, it would be extremely inefficient, but it could be done... $\endgroup$ – poncho Jan 1 '16 at 17:01
  • $\begingroup$ @poncho Changed second sentence to match your comment. It was to be expected that it is possible, in hindsight. It's just that nobody wants to be heading in that direction in the first place. $\endgroup$ – Maarten Bodewes Jan 1 '16 at 17:09
0
$\begingroup$

You can indeed use curve 255-19 with ECIES to encrypt whatever needs to be encrypted. You may want to assess the performance of the scheme for your purpose before you make a final decision.

$\endgroup$
0
$\begingroup$

In general, asymmetric encryption is slow, and generating a lot of ciphertext opens you to attack. Thus asymmetric encryption either provides signatures (small bits of encryption) or encryption of a symmetric algorithm, as you observe.

It's technically-feasible to encrypt large amounts of data with RSA or Curve 25519; it's just not particularly useful.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.