1=pod 2 3=head1 NAME 4 5EC_GROUP_get_ecparameters, 6EC_GROUP_get_ecpkparameters, 7EC_GROUP_new, 8EC_GROUP_new_from_ecparameters, 9EC_GROUP_new_from_ecpkparameters, 10EC_GROUP_free, 11EC_GROUP_clear_free, 12EC_GROUP_new_curve_GFp, 13EC_GROUP_new_curve_GF2m, 14EC_GROUP_new_by_curve_name, 15EC_GROUP_set_curve, 16EC_GROUP_get_curve, 17EC_GROUP_set_curve_GFp, 18EC_GROUP_get_curve_GFp, 19EC_GROUP_set_curve_GF2m, 20EC_GROUP_get_curve_GF2m, 21EC_get_builtin_curves - Functions for creating and destroying EC_GROUP 22objects 23 24=head1 SYNOPSIS 25 26 #include <openssl/ec.h> 27 28 EC_GROUP *EC_GROUP_new(const EC_METHOD *meth); 29 EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params) 30 EC_GROUP *EC_GROUP_new_from_ecpkparameters(const ECPKPARAMETERS *params) 31 void EC_GROUP_free(EC_GROUP *group); 32 void EC_GROUP_clear_free(EC_GROUP *group); 33 34 EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, 35 const BIGNUM *b, BN_CTX *ctx); 36 EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, 37 const BIGNUM *b, BN_CTX *ctx); 38 EC_GROUP *EC_GROUP_new_by_curve_name(int nid); 39 40 int EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, 41 const BIGNUM *b, BN_CTX *ctx); 42 int EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, 43 BN_CTX *ctx); 44 int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, 45 const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); 46 int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, 47 BIGNUM *a, BIGNUM *b, BN_CTX *ctx); 48 int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, 49 const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); 50 int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, 51 BIGNUM *a, BIGNUM *b, BN_CTX *ctx); 52 53 ECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group, ECPARAMETERS *params) 54 ECPKPARAMETERS *EC_GROUP_get_ecpkparameters(const EC_GROUP *group, ECPKPARAMETERS *params) 55 56 size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); 57 58=head1 DESCRIPTION 59 60Within the library there are two forms of elliptic curve that are of interest. 61The first form is those defined over the prime field Fp. The elements of Fp are 62the integers 0 to p-1, where p is a prime number. This gives us a revised 63elliptic curve equation as follows: 64 65y^2 mod p = x^3 +ax + b mod p 66 67The second form is those defined over a binary field F2^m where the elements of 68the field are integers of length at most m bits. For this form the elliptic 69curve equation is modified to: 70 71y^2 + xy = x^3 + ax^2 + b (where b != 0) 72 73Operations in a binary field are performed relative to an B<irreducible 74polynomial>. All such curves with OpenSSL use a trinomial or a pentanomial for 75this parameter. 76 77A new curve can be constructed by calling EC_GROUP_new(), using the 78implementation provided by B<meth> (see L<EC_GFp_simple_method(3)>). It is then 79necessary to call EC_GROUP_set_curve() to set the curve parameters. 80EC_GROUP_new_from_ecparameters() will create a group from the specified 81B<params> and EC_GROUP_new_from_ecpkparameters() will create a group from the 82specific PK B<params>. 83 84EC_GROUP_set_curve() sets the curve parameters B<p>, B<a> and B<b>. For a curve 85over Fp B<p> is the prime for the field. For a curve over F2^m B<p> represents 86the irreducible polynomial - each bit represents a term in the polynomial. 87Therefore there will either be three or five bits set dependent on whether the 88polynomial is a trinomial or a pentanomial. 89In either case, B<a> and B<b> represents the coefficients a and b from the 90relevant equation introduced above. 91 92EC_group_get_curve() obtains the previously set curve parameters. 93 94EC_GROUP_set_curve_GFp() and EC_GROUP_set_curve_GF2m() are synonyms for 95EC_GROUP_set_curve(). They are defined for backwards compatibility only and 96should not be used. 97 98EC_GROUP_get_curve_GFp() and EC_GROUP_get_curve_GF2m() are synonyms for 99EC_GROUP_get_curve(). They are defined for backwards compatibility only and 100should not be used. 101 102The functions EC_GROUP_new_curve_GFp() and EC_GROUP_new_curve_GF2m() are 103shortcuts for calling EC_GROUP_new() and then the EC_GROUP_set_curve() function. 104An appropriate default implementation method will be used. 105 106Whilst the library can be used to create any curve using the functions described 107above, there are also a number of predefined curves that are available. In order 108to obtain a list of all of the predefined curves, call the function 109EC_get_builtin_curves(). The parameter B<r> should be an array of 110EC_builtin_curve structures of size B<nitems>. The function will populate the 111B<r> array with information about the builtin curves. If B<nitems> is less than 112the total number of curves available, then the first B<nitems> curves will be 113returned. Otherwise the total number of curves will be provided. The return 114value is the total number of curves available (whether that number has been 115populated in B<r> or not). Passing a NULL B<r>, or setting B<nitems> to 0 will 116do nothing other than return the total number of curves available. 117The EC_builtin_curve structure is defined as follows: 118 119 typedef struct { 120 int nid; 121 const char *comment; 122 } EC_builtin_curve; 123 124Each EC_builtin_curve item has a unique integer id (B<nid>), and a human 125readable comment string describing the curve. 126 127In order to construct a builtin curve use the function 128EC_GROUP_new_by_curve_name() and provide the B<nid> of the curve to 129be constructed. 130 131EC_GROUP_free() frees the memory associated with the EC_GROUP. 132If B<group> is NULL nothing is done. 133 134EC_GROUP_clear_free() destroys any sensitive data held within the EC_GROUP and 135then frees its memory. If B<group> is NULL nothing is done. 136 137=head1 RETURN VALUES 138 139All EC_GROUP_new* functions return a pointer to the newly constructed group, or 140NULL on error. 141 142EC_get_builtin_curves() returns the number of builtin curves that are available. 143 144EC_GROUP_set_curve_GFp(), EC_GROUP_get_curve_GFp(), EC_GROUP_set_curve_GF2m(), 145EC_GROUP_get_curve_GF2m() return 1 on success or 0 on error. 146 147=head1 SEE ALSO 148 149L<crypto(7)>, L<EC_GROUP_copy(3)>, 150L<EC_POINT_new(3)>, L<EC_POINT_add(3)>, L<EC_KEY_new(3)>, 151L<EC_GFp_simple_method(3)>, L<d2i_ECPKParameters(3)> 152 153=head1 COPYRIGHT 154 155Copyright 2013-2019 The OpenSSL Project Authors. All Rights Reserved. 156 157Licensed under the OpenSSL license (the "License"). You may not use 158this file except in compliance with the License. You can obtain a copy 159in the file LICENSE in the source distribution or at 160L<https://www.openssl.org/source/license.html>. 161 162=cut 163