Hello. Exploring ECC.pm. I must be missing something really simple. Happen to be on Windows 10. Interested in ECDH in Perl5. Use case is to leverage an elliptical public private key method to sign then encrypt a string of text. At the moment, focusing on encrypting the string. The string of text to encrypt may be up to 5000 characters but could be much longer. Question: When using ecc_encrypt the clear text appears to be limited to 20 bytes (20 characters) (SHA1) or 32 characters (SHA256) for $message. Now, there is no surprise on known hash length output. BTW I will not be using SHA1… just trying to figure this problem out. But, the surprise is that a hash function is used at (i.e. SHA1 or SHA256) all in the implementation of ECC based encryption.

Note: You'll notice that I have not included the signing part… just the encryption part. How I am generating keys

use Crypt::PK::ECC; open (OUT_priv,">.\\keys\\priv_pem.txt"); open (OUT_pub,">.\\keys\\pub_pem.txt"); #Key generation my $pk = Crypt::PK::ECC->new(); $pk->generate_key('secp256k1'); my $private_pem = $pk->export_key_pem('private'); my $public_pem = $pk->export_key_pem('public'); print OUT_priv "priv_pem $private_pem\n"; print OUT_pub "pub_pem $public_pem\n";

How I am attempting to encrypt and then decrypt a string.

use Crypt::PK::ECC; use strict; my $pub_key_filename = ".\\keys\\pub_pem.txt"; my $priv_key_filename = ".\\keys\\priv_pem.txt"; my $message = "123456789 123456789 123456789 12"; print "Encrypting now...\n"; my $pk = Crypt::PK::ECC->new($pub_key_filename); my $ct = $pk->ecc_encrypt($message,'SHA256'); #Why do I have to specif +ify a hash function? print "ct... \n $ct\n"; ### In session decrypt my $ciphertext = $ct; my $pk = Crypt::PK::ECC->new($priv_key_filename); my $pt = $pk->ecc_decrypt($ciphertext); print "decrypted...\n $pt\n";

So, if I add one more character to $message then I get an error
FATAL: ecc_encrypt_key failed: Invalid hash specified. at C:/Perl64/site/lib/Crypt/PK/ECC.pm line 574.

Within ecc.pm line 574 specifies (by default) SHA1. And, this is where I am confused because I am hoping to not use a hash function but elliptic curve cryptography.

Now if I keep the message size to say 32 characters then no problem at all. So, any ideas?


In reply to ECC.pm ecc_encrypt $message clear text is limited in length by JalapenoBob

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.