Crypt-OpenSSL-EC

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

	hints directory. The hints are now incorporated directly in Makefile.PL.
	
1.3	 2017-06-01
	 Fixed test failures in t/prime-field.t if EC2M is not available in OpenSSL
	 
1.2	 2017-06-01
	 Fixed leak in EC_POINT::point2hex, reported by OLEG
	 
1.01  2015-01-29
      Added some more tests.
      Fixed crashes associated with get0_private_key and get0_group.

0.9   2015-01-29
      Fixed a problem where EC_KEY_get0_public_key did not duplicate the
      returned EC_POINT, potentially causing a double free of the point and
      subsequent crash. Reported by Dick Franks.

0.8   2015-01-28
      Omitted Changes for 0.7

0.7   2015-01-28

EC.xs  view on Meta::CPAN

int 
EC_KEY_up_ref(EC_KEY *key)

const EC_GROUP *
EC_KEY_get0_group(const EC_KEY *key)

int 
EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group)

const BIGNUM *
EC_KEY_get0_private_key(const EC_KEY *key)
    CODE:
        RETVAL = BN_dup(EC_KEY_get0_private_key(key));
    OUTPUT:
        RETVAL

int 
EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv)

const EC_POINT *
EC_KEY_get0_public_key(const EC_KEY *key)
    CODE:
        RETVAL = EC_POINT_dup(EC_KEY_get0_public_key(key), EC_KEY_get0_group(key));
    OUTPUT:
        RETVAL

int 
EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub)

lib/Crypt/OpenSSL/EC.pm  view on Meta::CPAN

  \return the EC_GROUP object (possibly NULL).

=item Crypt::OpenSSL::EC::EC_KEY::set_group($key, $group);

Sets the EC_GROUP of a EC_KEY object.
  key    EC_KEY object
  group  EC_GROUP to use in the EC_KEY object (note: the EC_KEY
         object will use an own copy of the EC_GROUP).
  return 1 on success and 0 if an error occurred.

=item Crypt::OpenSSL::EC::EC_KEY::set_private_key($key, $prv);

Sets the private key of a EC_KEY object.
  key  EC_KEY object
  prv  BIGNUM with the private key (note: the EC_KEY object
       will use an own copy of the BIGNUM).
  return 1 on success and 0 if an error occurred.

=item Crypt::OpenSSL::EC::EC_KEY::get0_public_key($key);

Returns the public key of a EC_KEY object.

t/Crypt-OpenSSL-EC.t  view on Meta::CPAN

my $point = Crypt::OpenSSL::EC::EC_POINT::new($group);
ok($point);
$point = Crypt::OpenSSL::EC::EC_POINT::new($group);
ok($point);

my $key = Crypt::OpenSSL::EC::EC_KEY::new();
ok($key);
$key = Crypt::OpenSSL::EC::EC_KEY::new();
ok($key);

my $bignum = $key->get0_private_key();
ok($bignum);

$group = $key->get0_group();
ok($group);

$point = $key->get0_public_key();
ok($point);

my $nid   = 415;        # NID_X9_62_prime256v1
$group = Crypt::OpenSSL::EC::EC_GROUP::new_by_curve_name($nid);
my $ctx   = Crypt::OpenSSL::Bignum::CTX->new();
my $order = Crypt::OpenSSL::Bignum->zero;
$group->get_order( $order, $ctx );
my $eckey = Crypt::OpenSSL::EC::EC_KEY::new();
ok($eckey);
ok($eckey->set_group($group));
ok($eckey->generate_key());
$bignum = $eckey->get0_private_key();
ok($bignum);
#print '$bignum ', $bignum, "\n";
my $binary = $bignum->to_bin;
ok($binary);
my $K = $eckey->get0_public_key();
ok($K);
#print '$K: ', $K, "\n";



( run in 0.273 second using v1.01-cache-2.11-cpan-a5abf4f5562 )