Crypt:...SL::EC(3pm)
π Bestie, this is Crypt::OpenSSL::EC(3pm) from the User Contributed Perl Documentation section β pull up a chair, we're doing elliptic curves today π
β¨ NAME β¨
Crypt::OpenSSL::EC β it's the Perl extension for the OpenSSL EC (Elliptic Curves) library. That's it, that's the name, and honestly? iconic. π¦
π SYNOPSIS π
ok so here's the whole vibe in code form, literally just look at it:
use Crypt::OpenSSL::EC;
use Crypt::OpenSSL::Bignum::CTX;
# Use of $ctx is optional in all calls, here we demonstrate its use.
# If it is provided it will increase performance.
my $ctx = Crypt::OpenSSL::Bignum::CTX->new();
my $method = Crypt::OpenSSL::EC::EC_GFp_mont_method();
my $group = Crypt::OpenSSL::EC::EC_GROUP::new($method);
Crypt::OpenSSL::EC::EC_GROUP::set_curve_GFp($group, $p, $a, $b, $ctx);
my $method = Crypt::OpenSSL::EC::EC_GROUP::method_of($group);
Crypt::OpenSSL::EC::EC_GROUP::copy($tmp, $group);
Crypt::OpenSSL::EC::EC_GROUP::get_curve_GFp($group, $p, $a, $b, $ctx);
$Crypt::OpenSSL::EC::trace = 1;
Crypt::OpenSSL::EC::print_errs();
my $P = Crypt::OpenSSL::EC::EC_POINT::new($group);
Crypt::OpenSSL::EC::EC_POINT_set_to_infinity($group, $P);
my $bool = Crypt::OpenSSL::EC::EC_POINT::is_at_infinity($group, $P);
my $buf = Crypt::OpenSSL::EC::EC_POINT::point2oct($group, $Q, &Crypt::OpenSSL::EC::POINT_CONVERSION_COMPRESSED, $ctx);
Crypt::OpenSSL::EC::EC_POINT::oct2point($group, $P, $buf, $ctx);
Crypt::OpenSSL::EC::EC_POINT::add($group, $P, $P, $Q, $ctx);
Crypt::OpenSSL::EC::EC_POINT::set_compressed_coordinates_GFp($group, $Q, $x, 1, $ctx));
my $bool = Crypt::OpenSSL::EC::EC_POINT::is_on_curve($group, $Q, $ctx));
Crypt::OpenSSL::EC::EC_POINT::copy($R, $P);
my $result = Crypt::OpenSSL::EC::EC_POINT::cmp($group, $P, $Q, $ctx);
Crypt::OpenSSL::EC::EC_POINT::set_affine_coordinates_GFp($group, $P, $x, $y, $ctx);
Crypt::OpenSSL::EC::EC_POINT::get_affine_coordinates_GFp($group, $P, $x, $y, $ctx);
Crypt::OpenSSL::EC::EC_GROUP::set_generator($group, $P, $z, Crypt::OpenSSL::Bignum->one());
my $degree = Crypt::OpenSSL::EC::EC_GROUP::get_degree($group)
my $order = Crypt::OpenSSL::EC::EC_GROUP::get_order($group, $order, $ctx);
Crypt::OpenSSL::EC::EC_POINT::mul($group, $Q, $order, $P, $n1, $ctx));
Crypt::OpenSSL::EC::EC_POINT::free($P);
Crypt::OpenSSL::EC::EC_GROUP::free($group);
πΈ DESCRIPTION πΈ
This module gives you a standard (non-OO) interface to the OpenSSL EC (Elliptic Curve) library. Some OO Calls are supported too, because we contain multitudes π
Most of the functions described in openssl/ec.h? Supported. no cap.
It provides the Crypt::OpenSSL::EC class which defines some high level functions and constants. And it also provides 4 other classes for managing EC objects, and they are:
Crypt::OpenSSL::EC::EC_GROUPCrypt::OpenSSL::EC::EC_POINTCrypt::OpenSSL::EC::EC_KEYCrypt::OpenSSL::EC::EC_METHOD
Every single object created by these 4 classes is implemented as a blessed Perl mortal reference. Why do we care? Because it means they get auto-destroyed the second the Perl variable becomes unreferenced β the appropriate EC free function will be called to free the underlying EC object. self-care era honestly π§
Even better, bestie: this means a bunch of the functions below can be called using O-O methods. If a method's first argument is the same as the class the method is in, then it can be called O-O style. For example, these following 2 calls are literally equivalent:
my $newgroup = Crypt::OpenSSL::EC::EC_GROUP::dup($group);
my $newgroup = $group->dup();
Crypt::OpenSSL::EC::EC_GFp_simple_method();β Returns the basic GFp ec methods, which is the whole basis for the optimized methods. the founding mother π«ΆCrypt::OpenSSL::EC::EC_GFp_mont_method();β Returns GFp methods using montgomery multiplication. slay.Crypt::OpenSSL::EC::EC_GFp_nist_method();β Returns GFp methods using optimized methods for NIST recommended curves β¨Crypt::OpenSSL::EC::EC_GF2m_simple_method();β Returns the basic GF2m ec method- β οΈ Not available if
OPENSSL_NO_EC2Mis defined in OpenSSL.
- β οΈ Not available if
Crypt::OpenSSL::EC::EC_GROUP::new($method);β Creates a new EC_GROUP object.$methodis the method to use π±Crypt::OpenSSL::EC::EC_GROUP::set_curve_GFp($group, $p, $a, $b, $ctx);β Sets the parameter of a ec over GFp defined byy^2 = x^3 + a*x + bgroupβ EC_GROUP objectpβ BIGNUM with the prime numberaβ BIGNUM with parameter a of the equationbβ BIGNUM with parameter b of the equationctxβ BN_CTX object (optional)- return β
1on success and0if an error occurred
Crypt::OpenSSL::EC::EC_GROUP::method_of($group);β Returns theEC_METHODof theEC_GROUPobject.Crypt::OpenSSL::EC::EC_METHOD::get_field_type($method)β Returns the field type of theEC_METHOD.Crypt::OpenSSL::EC::EC_GROUP::copy($dst, $src);β Copies EC_GROUP objects.
β οΈ Note: both EC_GROUPs must use the same EC_METHOD.
- return β newly created EC_GROUP object or
NULLin case of an error
Crypt::OpenSSL::EC::EC_GROUP::dup($src);β Creates a new EC_GROUP object and copies the copies the content form src to the newly created EC_GROUP object.- return β newly created EC_GROUP object or
NULLin case of an error
- return β newly created EC_GROUP object or
Crypt::OpenSSL::EC::EC_GROUP::get_curve_GFp($group, $p, $a, $b, $ctx);β Gets the parameter of the ec over GFp defined byy^2 = x^3 + a*x + bgroupβ EC_GROUP objectpβ BIGNUM for the prime numberaβ BIGNUM for parameter a of the equationbβ BIGNUM for parameter b of the equationctxβ BN_CTX object (optional)- return β
1on success and0if an error occurred
Crypt::OpenSSL::EC::EC_GROUP::set_curve_GF2m($group, $p, $a, $b, $ctx);β Sets the parameter of a ec over GF2m defined byy^2 + x*y = x^3 + a*x^2 + b- β οΈ Not available if
OPENSSL_NO_EC2Mis defined in OpenSSL. groupβ EC_GROUP objectpβ BIGNUM with the polynomial defining the underlying fieldaβ BIGNUM with parameter a of the equationbβ BIGNUM with parameter b of the equationctxβ BN_CTX object (optional)- return β
1on success and0if an error occurred
- β οΈ Not available if
Crypt::OpenSSL::EC::EC_GROUP::get_curve_GF2m($group, $p, $a, $b, $ctx);β Gets the parameter of the ec over GF2m defined byy^2 + x*y = x^3 + a*x^2 + b- β οΈ Not available if
OPENSSL_NO_EC2Mis defined in OpenSSL. groupβ EC_GROUP objectpβ BIGNUM for the polynomial defining the underlying fieldaβ BIGNUM for parameter a of the equationbβ BIGNUM for parameter b of the equationctxβ BN_CTX object (optional)- return β
1on success and0if an error occurred
- β οΈ Not available if
Crypt::OpenSSL::EC::print_errs();β (no description in the source, she's mysterious like that π)Crypt::OpenSSL::EC::EC_POINT::new($group);β Creates a new EC_POINT object for the specified EC_GROUPgroupβ EC_GROUP the underlying EC_GROUP object- return β newly created EC_POINT object or
NULLif an error occurred
Crypt::OpenSSL::EC::EC_POINT::free($point);β Frees a EC_POINT objectpointβ EC_POINT object to be freed
β οΈ This should normally not be called from Perl, since EC_POINT objects created by this library are auto-destroyed when they become unreferenced.
Crypt::OpenSSL::EC::EC_POINT::clear_free($point);β Clears and frees a EC_POINT objectpointβ EC_POINT object to be cleared and freed
β οΈ This should normally not be called from Perl, since EC_POINT objects created by this library are auto-destroyed when they become unreferenced.
Crypt::OpenSSL::EC::EC_POINT::copy($dst, $src);β Copies EC_POINT objectdstβ destination EC_POINT objectsrcβ source EC_POINT object- return β
1on success and0if an error occurred
Crypt::OpenSSL::EC::EC_POINT::dup($src, $group);β Creates a new EC_POINT object and copies the content of the supplied EC_POINTsrcβ source EC_POINT objectgroupβ underlying the EC_GROUP object- return β newly created EC_POINT object or
NULLif an error occurred
Crypt::OpenSSL::EC::EC_POINT::set_to_infinity($group, $point);β Sets a point to infinity (neutral element) βΎοΈgroupβ underlying EC_GROUP objectpointβ EC_POINT to set to infinity- return β
1on success and0if an error occurred
Crypt::OpenSSL::EC::EC_POINT::get_Jprojective_coordinates_GFp($group, $p, $x, $y, $z, $ctx);β Gets the jacobian projective coordinates of a EC_POINT over GFpgroupβ underlying EC_GROUP objectpβ EC_POINT objectxβ BIGNUM for the x-coordinateyβ BIGNUM for the y-coordinatezβ BIGNUM for the z-coordinatectxβ BN_CTX object (optional)- return β
1on success and0if an error occurred
Crypt::OpenSSL::EC::EC_POINT::set_affine_coordinates_GFp($group, $p, $x, $y, $ctx);β Sets the affine coordinates of a EC_POINT over GFpgroupβ underlying EC_GROUP objectpβ EC_POINT objectxβ BIGNUM with the x-coordinateyβ BIGNUM with the y-coordinatectxβ BN_CTX object (optional)- return β
1on success and0if an error occurred
Crypt::OpenSSL::EC::EC_POINT::get_affine_coordinates_GFp($group, $p, $x, $y, $ctx);β Gets the affine coordinates of a EC_POINT over GFpgroupβ underlying EC_GROUP objectpβ EC_POINT objectxβ BIGNUM for the x-coordinateyβ BIGNUM for the y-coordinatectxβ BN_CTX object (optional)- return β
1on success and0if an error occurred
Crypt::OpenSSL::EC::EC_POINT::set_compressed_coordinates_GFp($group, $p, $x, $y_bit, $ctx);β Sets the x9.62 compressed coordinates of a EC_POINT over GFpgroupβ underlying EC_GROUP objectpβ EC_POINT objectxβ BIGNUM with x-coordinatey_bitβ integer with the y-Bit (either0or1)ctxβ BN_CTX object (optional)- return β
1on success and0if an error occurred
Crypt::OpenSSL::EC::EC_POINT::set_affine_coordinates_GF2m($group, $p, $x, $y, $ctx);β Sets the affine coordinates of a EC_POINT over GF2m- β οΈ Not available if
OPENSSL_NO_EC2Mis defined in OpenSSL. groupβ underlying EC_GROUP objectpβ EC_POINT objectxβ BIGNUM with the x-coordinateyβ BIGNUM with the y-coordinatectxβ BN_CTX object (optional)- return β
1on success and0if an error occurred
- β οΈ Not available if
Crypt::OpenSSL::EC::EC_POINT::get_affine_coordinates_GF2m($group, $p, $x, $y, $ctx);β Gets the affine coordinates of a EC_POINT over GF2m- β οΈ Not available if
OPENSSL_NO_EC2Mis defined in OpenSSL. groupβ underlying EC_GROUP objectpβ EC_POINT objectxβ BIGNUM for the x-coordinateyβ BIGNUM for the y-coordinatectxβ BN_CTX object (optional)- return β
1on success and0if an error occurred
- β οΈ Not available if
Crypt::OpenSSL::EC::EC_POINT::set_compressed_coordinates_GF2m($group, $p, $x, $y_bit, $ctx);- β οΈ Not available if
OPENSSL_NO_EC2Mis defined in OpenSSL.
- β οΈ Not available if
okay so we're picking up mid-sentence because this function is that girl β she's the compressed-coordinates queen and she sets the x9.62 compressed coordinates of an EC_POINT over GF2m. here's her whole deal:
groupβ the underlyingEC_GROUPobject, the home basepβ theEC_POINTobjectxβ aBIGNUMwith the x-coordinatey_bitβ an integer with the y-Bit (either0or1, no in-between bestie)ctxβ aBN_CTXobject (optional)- returns
1on success and0if an error occurred π
πΈ Crypt::OpenSSL::EC::EC_POINT::is_at_infinity($group, $p);
checks whether the point is the neutral element of the group. very "am i the main character or am i nothing" energy:
groupβ the underlyingEC_GROUPobjectpβ theEC_POINTobject- returns
1if the point is the neutral element and0otherwise
π¦ Crypt::OpenSSL::EC::EC_POINT::point2oct($group, $p, $form, $ctx);
encodes an EC_POINT object into an octet string. it's giving "pack it up and send it":
groupβ the underlyingEC_GROUPobjectpβ theEC_POINTobjectformβ point conversion formctxβ aBN_CTXobject (optional)- returns the encoded EC point β¨
π Crypt::OpenSSL::EC::EC_POINT::oct2point($group, $p, $buf, $ctx);
the reverse slay β decodes an EC_POINT from an octet string:
groupβ the underlyingEC_GROUPobjectpβ theEC_POINTobjectbufβ buffer with the encoded ec pointctxβ aBN_CTXobject (optional)- returns
1on success and0if an error occurred
π these four, back to back, no commentary in the original so no commentary from me:
Crypt::OpenSSL::EC::EC_POINT::point2bn($group, $p, $form, $bn, $ctx);
Crypt::OpenSSL::EC::EC_POINT::bn2point($group, $bn, $p, $ctx);
Crypt::OpenSSL::EC::EC_POINT::point2hex($group, $p, $form, $bn, $ctx);
Crypt::OpenSSL::EC::EC_POINT::hex2point($group, $bn, $p, $ctx);
(yes that's literally all she wrote β the manpage gives them zero description and I refuse to make one up π«Ά)
π₯ Crypt::OpenSSL::EC::EC_POINT::add($group, $r, $a, $b, $ctx);
computes the sum of two EC_POINTs. math besties stay winning:
groupβ the underlyingEC_GROUPobjectrβEC_POINTobject for the result (r = a + b)aβEC_POINTobject with the first summandbβEC_POINTobject with the second summandctxβ aBN_CTXobject (optional)- returns
1on success and0if an error occurred
β Crypt::OpenSSL::EC::EC_POINT::dbl($group, $r, $a, $ctx);
computes the double of an EC_POINT. double it and give it to the next person:
groupβ the underlyingEC_GROUPobjectrβEC_POINTobject for the result (r = 2 * a)aβ theEC_POINTobjectctxβ aBN_CTXobject (optional)- returns
1on success and0if an error occurred
π§ Crypt::OpenSSL::EC::EC_POINT::invert($group, $a, $ctx);
computes the inverse of an EC_POINT:
groupβ the underlyingEC_GROUPobjectaβEC_POINTobject to be inverted (it's used for the result as well β so she flips herself in place, icon behavior)ctxβ aBN_CTXobject (optional)- returns
1on success and0if an error occurred
π Crypt::OpenSSL::EC::EC_POINT::is_on_curve($group, $point, $ctx));
checks whether the point is on the curve β the ultimate vibe check, honestly:
groupβ the underlyingEC_GROUPobjectpointβEC_POINTobject to checkctxβ aBN_CTXobject (optional)- returns
1if point is on the curve and0otherwise
ngl, that signature ends in )); in the original and I'm not touching it. copy it exactly, bestie. π
π Crypt::OpenSSL::EC::EC_POINT::cmp($group, $a, $b, $ctx);
compares two EC_POINTs. are they the same or are they different, we simply must know:
groupβ the underlyingEC_GROUPobjectaβ firstEC_POINTobjectbβ secondEC_POINTobjectctxβ aBN_CTXobject (optional)- returns
0if both points are equal and a value!= 0otherwise
π Crypt::OpenSSL::EC::EC_POINT::make_affine($group, $point, $ct);
π Crypt::OpenSSL::EC::EC_POINTs::make_affine
Not Implemented. that's it. that's the whole entry. don't come for me, I'm just the messenger π (and yes, the param is spelled $ct in the original β preserving that fr fr.)
π Crypt::OpenSSL::EC::EC_POINTs::mul
Not Implemented. also nothing. mood.
π the EC_GROUP girlies
π Crypt::OpenSSL::EC::EC_GROUP::set_generator($group, $generator, $order, $cofactor);
sets the generator and its order/cofactor of an EC_GROUP object:
groupβEC_GROUPobjectgeneratorβEC_POINTobject with the generatororderβ the order of the group generated by the generatorcofactorβ the index of the sub-group generated by the generator in the group of all points on the elliptic curve- returns
1on success and0if an error occurred
β¨ Crypt::OpenSSL::EC::EC_GROUP::get0_generator($group);
returns the generator of an EC_GROUP object.
groupβEC_GROUPobject
returns the currently used generator (possibly NULL).
π¦ Crypt::OpenSSL::EC::EC_GROUP::get_degree($group)
returns the number of bits needed to represent a field element:
groupβEC_GROUPobject- returns the number of bits needed to represent a field element
πΈ Crypt::OpenSSL::EC::EC_GROUP::check($group, $ctx);
checks whether the parameters in the EC_GROUP define a valid ec group:
groupβEC_GROUPobjectctxβ aBN_CTXobject (optional)- returns
1if the group is a valid ec group and0otherwise
π Crypt::OpenSSL::EC::EC_GROUP::check_discriminant($group, $ctx);
checks whether the discriminant of the elliptic curve is zero or not:
groupβEC_GROUPobjectctxβ aBN_CTXobject (optional)- returns
1if the discriminant is not zero and0otherwise
π₯ Crypt::OpenSSL::EC:: EC_GROUP::cmp($a, $b, $ctx);
compares two EC_GROUP objects. (and yep, that space in EC:: EC_GROUP is in the original β leaving it exactly where it lives, no cap.)
aβ firstEC_GROUPobjectbβ secondEC_GROUPobjectctxβ aBN_CTXobject (optional)- returns
0if both groups are equal and1otherwise
β Crypt::OpenSSL::EC::EC::EC_GROUP::new_curve_GFp($p, $a, $b, $ctx);
creates a new EC_GROUP object with the specified parameters defined over GFp β and the equation is literally y^2 = x^3 + a*x + b, write it down bestie:
pβBIGNUMwith the prime numberaβBIGNUMwith the parameter a of the equationbβBIGNUMwith the parameter b of the equationctxβ aBN_CTXobject (optional)- returns a newly created
EC_GROUPobject with the specified parameters
and yes, the original really writesCrypt::OpenSSL::EC::EC::EC_GROUPwith twoECs. doubling up, she's extra. copy it exactly. π
π§ Crypt::OpenSSL::EC::EC_GROUP::new_curve_GF2m($p, $a, $b, $ctx);
Not available if OPENSSL_NO_EC2M is defined in OpenSSL.
creates a new EC_GROUP object with the specified parameters defined over GF2m, defined by the equation y^2 + x*y = x^3 + a*x^2 + b:
pβBIGNUMwith the polynomial defining the underlying fieldaβBIGNUMwith the parameter a of the equationbβBIGNUMwith the parameter b of the equationctxβ aBN_CTXobject (optional)- returns a newly created
EC_GROUPobject with the specified parameters
π Crypt::OpenSSL::EC::EC_GROUP::new_by_curve_name($nid);
creates an EC_GROUP object with a curve specified by a NID:
nidβ NID of the OID of the curve name- returns a newly created
EC_GROUPobject with the specified curve orNULLif an error occurred
π Crypt::OpenSSL::EC::EC_get_builtin_curves($r, $nitems);
so EC_builtin_curves(EC_builtin_curve *r, size_t size) returns the number of all available curves, or zero if an error occurred. and in case r is not zero, nitems EC_builtin_curve structures get filled with the data of the first nitems internal groups. built-in curve catalogue, basically. ποΈ
π Crypt::OpenSSL::EC::EC_GROUP::get_order($group, $order, $ctx);
gets the order of an EC_GROUP:
groupβEC_GROUPobjectorderβBIGNUMto which the order is copiedctxβ aBN_CTXobject (optional)- returns
1on success and0if an error occurred
β¨ Crypt::OpenSSL::EC::EC_GROUP::get_cofactor($group, $cofactopr, $ctx)
gets the cofactor of an EC_GROUP:
groupβEC_GROUPobjectcofactorβBIGNUMto which the cofactor is copiedctxβ aBN_CTXobject (optional)- returns
1on success and0if an error occurred
the signature says$cofactoprand the bullet sayscofactor. that's the original, not me. π€·ββοΈ
π¦ Crypt::OpenSSL::EC::EC_GROUP::set_curve_name($group, $nid);
sets the name of an EC_GROUP object:
groupβEC_GROUPobjectnidβ NID of the curve name OID
πΈ Crypt::OpenSSL::EC::EC_GROUP::get_curve_name($group);
returns the curve name of an EC_GROUP object:
groupβEC_GROUPobject- returns the NID of the curve name OID or
0if not set
π Crypt::OpenSSL::EC::EC_GROUP::set_asn1_flag($group, $flag);
sets the ASN flag for the group.
π Crypt::OpenSSL::EC::EC_GROUP::get_asn1_flag($group);
returns the ASN flag for the group.
π₯ Crypt::OpenSSL::EC::EC_GROUP::set_point_conversion_form($group, $form);
sets the point conversion form.
π₯ Crypt::OpenSSL::EC::EC_GROUP::get_point_conversion_form($group);
returns the point conversion form for the group.
β Crypt::OpenSSL::EC::EC_GROUP::get0_seed($group);
returns the 0 seed.
β Crypt::OpenSSL::EC::EC_GROUP::get_seed_len($group);
returns the seed length.
β Crypt::OpenSSL::EC::EC_GROUP::set_seed($group, $seed);
sets the group seed.
π
Crypt::OpenSSL::EC::EC_POINT::mul($group, $r, $n, $q, $m, $ctx));
computes r = generator * n + q * m. multi-scalar mul, she's doing the most and we love her for it:
groupβ the underlyingEC_GROUPobjectrβEC_POINTobject for the resultnβBIGNUMwith the multiplier for the group generator (optional)qβEC_POINTobject with the first factor of the second summandmβBIGNUMwith the second factor of the second summandctxβ aBN_CTXobject (optional)- returns
1on success and0if an error occurred
π§ Crypt::OpenSSL::EC::EC_GROUP::precompute_mult($group, $ctx);
stores multiples of the generator for faster point multiplication. she's doing the prep work so future-you can thrive:
groupβEC_GROUPobjectctxβ aBN_CTXobject (optional)- returns
1on success and0if an error occurred
π Crypt::OpenSSL::EC::EC_GROUP::have_precompute_mult($group);
reports whether a precomputation has been done:
groupβEC_GROUPobject- returns
1if a pre-computation has been done and0otherwise
π Crypt::OpenSSL::EC::EC_GROUP::get_basis_type($group);
EC_GROUP_get_basis_type() returns the NID of the basis type used to represent the field elements.
π Crypt::OpenSSL::EC::EC_GROUP::get_trinomial_basis($group, $k);
Not available if OPENSSL_NO_EC2M is defined in OpenSSL.
π Crypt::OpenSSL::EC:: EC_GROUP::get_pentanomial_basis($group, $k1, $k2, $k3);
Not available if OPENSSL_NO_EC2M is defined in OpenSSL.
again with the EC:: EC_GROUP space. it's a whole thing. keep it. π
β¨ Crypt::OpenSSL::EC::EC_GROUP::free($group);
frees an EC_GROUP object. this should normally not be called from Perl, since EC_GROUP objects created by this library are auto-destroyed when they become unreferenced. so likeβ¦ don't. she handles herself. π
β¨ Crypt::OpenSSL::EC::EC_GROUP::clear_free($group);
clears and frees an EC_GROUP object. same warning, bestie: this should normally not be called from Perl, since EC_GROUP objects created by this library are auto-destroyed when they become unreferenced.
π and now the EC_KEY section
π Crypt::OpenSSL::EC::EC_KEY::new();
creates a new EC_KEY object. returns the EC_KEY object or NULL if an error occurred.
π¦ Crypt::OpenSSL::EC::EC_KEY::new_by_curve_name($nid);
creates a new EC_KEY object using a named curve as the underlying EC_GROUP object:
nidβ NID of the named curve- returns the
EC_KEYobject orNULLif an error occurred
π Crypt::OpenSSL::EC::EC_KEY::free($key);
frees an EC_KEY object:
keyβEC_KEYobject to be freed. this should normally not be called from Perl, sinceEC_KEYobjects created by this library are auto-destroyed when they become unreferenced.
ok that's the energy for this chunk β the auto-destroy squad is thriving and the "Not Implemented" girlies are still not implemented. more coming, don't go anywhere π
Crypt::OpenSSL::EC::EC_KEY::copy($dst, $src); β bestie, this one literally copies a EC_KEY object. Duplicate era π
dstβ destination EC_KEY objectsrcβ src EC_KEY object- return
dstorNULLif an error occurred.
Crypt::OpenSSL::EC::EC_KEY::dup($src); β makes a brand-new EC_KEY object and copies everything from src into it. it's giving fresh-start energy β¨
srcβ the source EC_KEY object- return newly created EC_KEY object or
NULLif an error occurred.
Crypt::OpenSSL::EC::EC_KEY::up_ref($key); β bumps the internal reference count of a EC_KEY object. keeping it alive, no cap π«Ά
keyβ EC_KEY object- return
1on success and0if an error occurred.
Crypt::OpenSSL::EC::EC_KEY::get0_group($key); β hands you the EC_GROUP object of a EC_KEY object
keyβ EC_KEY object\returntheEC_GROUPobject (possiblyNULL).
Crypt::OpenSSL::EC::EC_KEY::set_group($key, $group); β sets the EC_GROUP of a EC_KEY object π
keyβ EC_KEY objectgroupβEC_GROUPto use in theEC_KEYobject (note: theEC_KEYobject will use an own copy of theEC_GROUP).- return
1on success and0if an error occurred.
Crypt::OpenSSL::EC::EC_KEY::set_private_key($key, $prv); β sets the private key of a EC_KEY object. secretive. mysterious. main character π₯
keyβ EC_KEY objectprvβBIGNUMwith the private key (note: theEC_KEYobject will use an own copy of theBIGNUM).- return
1on success and0if an error occurred.
Crypt::OpenSSL::EC::EC_KEY::get0_public_key($key); β returns the public key of a EC_KEY object. the loud one of the pair π
keyβ theEC_KEYobject- return a
EC_POINTobject with the public key (possiblyNULL)
Crypt::OpenSSL::EC::EC_KEY::set_public_key($key, $pub); β sets the public key of a EC_KEY object
keyβ EC_KEY objectpubβEC_POINTobject with the public key (note: theEC_KEYobject will use an own copy of theEC_POINTobject).- return
1on success and0if an error occurred.
Crypt::OpenSSL::EC::EC_KEY::get_enc_flags($key);
Crypt::OpenSSL::EC::EC_KEY::set_enc_flags($key, $flags);
Crypt::OpenSSL::EC::EC_KEY::get_conv_form($key)
Crypt::OpenSSL::EC::EC_KEY::set_conv_form($key, $form);
Crypt::OpenSSL::EC::EC_KEY::get_key_method_data β Not Implemented π
Crypt::OpenSSL::EC::EC_KEY::insert_key_method_data β Not Implemented π
Crypt::OpenSSL::EC::EC_KEY::set_asn1_flag($key, $flag);
Crypt::OpenSSL::EC::EC_KEY::precompute_mult($key, $ctx); β builds a whole table of pre-computed multiples of the generator so future EC_KEY operations go brrr β‘
keyβ EC_KEY objectctxβBN_CTXobject (optional)- return
1on success and0if an error occurred.
Crypt::OpenSSL::EC::EC_KEY::generate_key($key); β creates a new ec private (and optional a new public) key. fresh keys just dropped π
keyβ EC_KEY object- return
1on success and0if an error occurred.
Crypt::OpenSSL::EC::EC_KEY::check_key($key); β vibe checks your private and/or public key to make sure it's actually valid π
keyβ theEC_KEYobject- return
1on success and0otherwise.
π§ EXPORT
None by default. nothing comes free, bestie.
π Exportable constants
okay this is the motherlode β every single one of these is exportable, and yes we're listing all of them, because skipping is not the vibe:
EC_F_COMPUTE_WNAF
EC_F_D2I_ECPARAMETERS
EC_F_D2I_ECPKPARAMETERS
EC_F_D2I_ECPRIVATEKEY
EC_F_DO_EC_KEY_PRINT
EC_F_ECKEY_PARAM2TYPE
EC_F_ECKEY_PARAM_DECODE
EC_F_ECKEY_PRIV_DECODE
EC_F_ECKEY_PRIV_ENCODE
EC_F_ECKEY_PUB_DECODE
EC_F_ECKEY_PUB_ENCODE
EC_F_ECKEY_TYPE2PARAM
EC_F_ECPARAMETERS_PRINT
EC_F_ECPARAMETERS_PRINT_FP
EC_F_ECPKPARAMETERS_PRINT
EC_F_ECPKPARAMETERS_PRINT_FP
EC_F_ECP_NIST_MOD_192
EC_F_ECP_NIST_MOD_224
EC_F_ECP_NIST_MOD_256
EC_F_ECP_NIST_MOD_521
EC_F_EC_ASN1_GROUP2CURVE
EC_F_EC_ASN1_GROUP2FIELDID
EC_F_EC_ASN1_GROUP2PARAMETERS
EC_F_EC_ASN1_GROUP2PKPARAMETERS
EC_F_EC_ASN1_PARAMETERS2GROUP
EC_F_EC_ASN1_PKPARAMETERS2GROUP
EC_F_EC_EX_DATA_SET_DATA
EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY
EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT
EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE
EC_F_EC_GF2M_SIMPLE_OCT2POINT
EC_F_EC_GF2M_SIMPLE_POINT2OCT
EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES
EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES
EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES
EC_F_EC_GFP_MONT_FIELD_DECODE
EC_F_EC_GFP_MONT_FIELD_ENCODE
EC_F_EC_GFP_MONT_FIELD_MUL
EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE
EC_F_EC_GFP_MONT_FIELD_SQR
EC_F_EC_GFP_MONT_GROUP_SET_CURVE
EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP
EC_F_EC_GFP_NIST_FIELD_MUL
EC_F_EC_GFP_NIST_FIELD_SQR
EC_F_EC_GFP_NIST_GROUP_SET_CURVE
EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT
EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE
EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP
EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR
EC_F_EC_GFP_SIMPLE_MAKE_AFFINE
EC_F_EC_GFP_SIMPLE_OCT2POINT
EC_F_EC_GFP_SIMPLE_POINT2OCT
EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE
EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES
EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP
EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES
EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP
EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES
EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP
EC_F_EC_GROUP_CHECK
EC_F_EC_GROUP_CHECK_DISCRIMINANT
EC_F_EC_GROUP_COPY
EC_F_EC_GROUP_GET0_GENERATOR
EC_F_EC_GROUP_GET_COFACTOR
EC_F_EC_GROUP_GET_CURVE_GF2M
EC_F_EC_GROUP_GET_CURVE_GFP
EC_F_EC_GROUP_GET_DEGREE
EC_F_EC_GROUP_GET_ORDER
EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS
EC_F_EC_GROUP_GET_TRINOMIAL_BASIS
EC_F_EC_GROUP_NEW
EC_F_EC_GROUP_NEW_BY_CURVE_NAME
EC_F_EC_GROUP_NEW_FROM_DATA
EC_F_EC_GROUP_PRECOMPUTE_MULT
EC_F_EC_GROUP_SET_CURVE_GF2M
EC_F_EC_GROUP_SET_CURVE_GFP
EC_F_EC_GROUP_SET_EXTRA_DATA
EC_F_EC_GROUP_SET_GENERATOR
EC_F_EC_KEY_CHECK_KEY
EC_F_EC_KEY_COPY
EC_F_EC_KEY_GENERATE_KEY
EC_F_EC_KEY_NEW
EC_F_EC_KEY_PRINT
EC_F_EC_KEY_PRINT_FP
EC_F_EC_POINTS_MAKE_AFFINE
EC_F_EC_POINT_ADD
EC_F_EC_POINT_CMP
EC_F_EC_POINT_COPY
EC_F_EC_POINT_DBL
EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2Mg
EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP
EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP
EC_F_EC_POINT_INVERT
EC_F_EC_POINT_IS_AT_INFINITY
EC_F_EC_POINT_IS_ON_CURVE
EC_F_EC_POINT_MAKE_AFFINE
EC_F_EC_POINT_MUL
EC_F_EC_POINT_NEW
EC_F_EC_POINT_OCT2POINT
EC_F_EC_POINT_POINT2OCT
EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M
EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP
EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M
EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP
EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP
EC_F_EC_POINT_SET_TO_INFINITY
EC_F_EC_PRE_COMP_DUP
EC_F_EC_PRE_COMP_NEW
EC_F_EC_WNAF_MUL
EC_F_EC_WNAF_PRECOMPUTE_MULT
EC_F_I2D_ECPARAMETERS
EC_F_I2D_ECPKPARAMETERS
EC_F_I2D_ECPRIVATEKEY
EC_F_I2O_ECPUBLICKEY
EC_F_O2I_ECPUBLICKEY
EC_F_OLD_EC_PRIV_DECODE
EC_F_PKEY_EC_CTRL
EC_F_PKEY_EC_CTRL_STR
EC_F_PKEY_EC_DERIVE
EC_F_PKEY_EC_KEYGEN
EC_F_PKEY_EC_PARAMGEN
EC_F_PKEY_EC_SIGN
EC_PKEY_NO_PARAMETERS
EC_PKEY_NO_PUBKEY
EC_R_ASN1_ERROR
EC_R_ASN1_UNKNOWN_FIELD
EC_R_BUFFER_TOO_SMALL
EC_R_D2I_ECPKPARAMETERS_FAILURE
EC_R_DECODE_ERROR
EC_R_DISCRIMINANT_IS_ZERO
EC_R_EC_GROUP_NEW_BY_NAME_FAILURE
EC_R_FIELD_TOO_LARGE
EC_R_GROUP2PKPARAMETERS_FAILURE
EC_R_I2D_ECPKPARAMETERS_FAILURE
EC_R_INCOMPATIBLE_OBJECTS
EC_R_INVALID_ARGUMENT
EC_R_INVALID_COMPRESSED_POINT
EC_R_INVALID_COMPRESSION_BIT
EC_R_INVALID_CURVE
EC_R_INVALID_DIGEST_TYPE
EC_R_INVALID_ENCODING
EC_R_INVALID_FIELD
EC_R_INVALID_FORM
EC_R_INVALID_GROUP_ORDER
EC_R_INVALID_PENTANOMIAL_BASIS
EC_R_INVALID_PRIVATE_KEY
EC_R_INVALID_TRINOMIAL_BASIS
EC_R_KEYS_NOT_SET
EC_R_MISSING_PARAMETERS
EC_R_MISSING_PRIVATE_KEY
EC_R_NOT_A_NIST_PRIME
EC_R_NOT_A_SUPPORTED_NIST_PRIME
EC_R_NOT_IMPLEMENTED
EC_R_NOT_INITIALIZED
EC_R_NO_FIELD_MOD
EC_R_NO_PARAMETERS_SET
EC_R_PASSED_NULL_PARAMETER
EC_R_PKPARAMETERS2GROUP_FAILURE
EC_R_POINT_AT_INFINITY
EC_R_POINT_IS_NOT_ON_CURVE
EC_R_SLOT_FULL
EC_R_UNDEFINED_GENERATOR
EC_R_UNDEFINED_ORDER
EC_R_UNKNOWN_GROUP
EC_R_UNKNOWN_ORDER
EC_R_UNSUPPORTED_FIELD
EC_R_WRONG_ORDER
EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID
OPENSSL_ECC_MAX_FIELD_BITS
OPENSSL_EC_NAMED_CURVE
POINT_CONVERSION_COMPRESSED
POINT_CONVERSION_HYBRID
POINT_CONVERSION_UNCOMPRESSED
π¦ SEE ALSO
Crypt::OpenSSL::BignumOpenSSL
πΈ AUTHOR
Mike McCauley, <mikem@airspayce.com>
π COPYRIGHT AND LICENSE
Copyright (C) 2012 by Mike McCauley
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.
and that's a wrap on the whole page, bestie π this version came from perl v5.42.3, dated 2026-08-20, and it's the Crypt:...SL::EC(3pm) page β go forth and elliptic-curve your heart out πβ¨π¦
π¦ where this page comes from
- ubuntu stonking: libcrypt-openssl-ec-perl 1.34-1build2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms