diff options
author | Manuel Mausz <manuel@mausz.at> | 2016-06-02 18:48:46 +0200 |
---|---|---|
committer | karel-m <karel.miko@gmail.com> | 2016-06-02 18:48:46 +0200 |
commit | db018d4f770f26627216e5d75c826398897d8a56 (patch) | |
tree | fbae63cba91a8a092690f7e5bdf11c0379c9ba66 /t/pk_ecc.t | |
parent | 783873ccb9dcccb8084caccb7c1a66c21037d026 (diff) |
Ensure Crypt::PK::ECC->key2hash()->{curve_name} is lowercase (#14)
Depending on how the ec key gets created or imported key2hash() either
returns the curve_name property either in lower- or uppercase.
The value is lowercase if the curve parameters are imported or set by
the user and uppercase if the name is directly returned from
libtomcrypt.
Since generate_key() expects the name in lowercase, we convert the value
to lowercase as well.
As a sideeffect this also avoids unneccessary curve parameter lookups in
Crypt::PK::ECC::_curve_name_lookup().
Diffstat (limited to 't/pk_ecc.t')
-rw-r--r-- | t/pk_ecc.t | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -1,6 +1,6 @@ use strict; use warnings; -use Test::More tests => 91; +use Test::More tests => 95; use Crypt::PK::ECC qw(ecc_encrypt ecc_decrypt ecc_sign_message ecc_verify_message ecc_sign_hash ecc_verify_hash ecc_shared_secret); @@ -128,6 +128,7 @@ for my $priv (qw/openssl_ec-short.pem openssl_ec-short.der/) { is($k->size, 32, "size $priv"); is(uc($k->key2hash->{pub_x}), 'A01532A3C0900053DE60FBEFEFCCA58793301598D308B41E6F4E364E388C2711', "key2hash $priv"); is(uc($k->curve2hash->{prime}), 'FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF', "curve2hash $priv"); + is($k->key2hash->{curve_name}, "secp256r1", "EC curve_name is lowercase"); } for my $pub (qw/openssl_ec-short.pub.pem openssl_ec-short.pub.der/) { @@ -136,4 +137,5 @@ for my $pub (qw/openssl_ec-short.pub.pem openssl_ec-short.pub.der/) { ok(!$k->is_private, "is_private $pub"); is($k->size, 32, "$pub size"); is(uc($k->key2hash->{pub_x}), 'A01532A3C0900053DE60FBEFEFCCA58793301598D308B41E6F4E364E388C2711', "key2hash $pub"); + is($k->key2hash->{curve_name}, "secp256r1", "EC curve_name is lowercase"); } |