JalapenoBob has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: ECC.pm ecc_encrypt $message clear text is limited in length
by roboticus (Chancellor) on Feb 08, 2018 at 03:07 UTC | |
by JalapenoBob (Initiate) on Feb 08, 2018 at 04:05 UTC | |
|
Re: ECC.pm ecc_encrypt $message clear text is limited in length
by hippo (Archbishop) on Feb 09, 2018 at 09:36 UTC | |
by JalapenoBob (Initiate) on Feb 09, 2018 at 22:17 UTC | |
|
Re: ECC.pm ecc_encrypt $message clear text is limited in length
by JalapenoBob (Initiate) on Feb 09, 2018 at 00:48 UTC | |
|
Re: ECC.pm ecc_encrypt $message clear text is limited in length
by JalapenoBob (Initiate) on Feb 08, 2018 at 20:35 UTC |