Sortix cross-volatile manual
This manual documents Sortix cross-volatile. You can instead view this document in the latest official manual.
NAME
EC_GROUP_new_by_curve_name, EC_GROUP_free, EC_GROUP_dup, EC_GROUP_cmp, EC_get_builtin_curves, EC_curve_nid2nist, EC_curve_nist2nid — instantiate named curves built into libcryptoSYNOPSIS
library “libcrypto”#include <openssl/bn.h>
#include <openssl/ec.h>
#include <openssl/objects.h>
EC_GROUP_new_by_curve_name(int nid);
EC_GROUP_free(EC_GROUP *group);
EC_GROUP_dup(const EC_GROUP *group);
EC_GROUP_cmp(const EC_GROUP *group1, const EC_GROUP *group2, BN_CTX *ctx);
typedef struct {
int nid;
const char *comment;
} EC_builtin_curve;
size_t
EC_get_builtin_curves(EC_builtin_curve *curves, size_t ncurves);
EC_curve_nist2nid(const char *name);
EC_curve_nid2nist(int nid);
DESCRIPTION
Most elliptic curves used in cryptographic protocols have a standardized representation as a named curve, where an ASN.1 Object Identifier (OID) is used instead of detailed domain parameters. This OID is represented internally by a Numerical Identifier (NID), and the parameters themselves must be built into the library. In the EC library the curve name refers to this NID.
NIST name |
ASN.1 NID | notes |
| “P-224” | NID_secp224r1 | |
| “P-256” | NID_X9_62_prime256v1 | also known as secp256r1 |
| “P-384” | NID_secp384r1 | |
| “P-521” | NID_secp521r1 |
RETURN VALUES
EC_GROUP_new_by_curve_name() returns a newly allocated group or NULL if there is no built-in group with NID nid, or if memory allocation fails.EXAMPLES
Print the list of builtin curves, their NIDs, their NIST name and a comment describing each curve:
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <openssl/ec.h>
int
main(void)
{
EC_builtin_curve *curves;
size_t ncurves, i;
if (pledge("stdio", NULL) == -1)
err(1, "pledge");
ncurves = EC_get_builtin_curves(NULL, 0);
if ((curves = calloc(ncurves, sizeof(*curves))) == NULL)
err(1, NULL);
(void)EC_get_builtin_curves(curves, ncurves);
printf("curve\tnid\tNIST\tcomment\n");
for (i = 0; i < ncurves; i++) {
const char *nist_name = EC_curve_nid2nist(curves[i].nid);
printf("%2zu\t%d\t%s\t%s\n", i, curves[i].nid,
nist_name != NULL ? nist_name : "", curves[i].comment);
}
free(curves);
return 0;
}