1EC_KEY_new(3) OpenSSL EC_KEY_new(3)
2
3
4
6 EC_KEY_new, EC_KEY_get_flags, EC_KEY_set_flags, EC_KEY_clear_flags,
7 EC_KEY_new_by_curve_name, EC_KEY_free, EC_KEY_copy, EC_KEY_dup,
8 EC_KEY_up_ref, EC_KEY_get0_group, EC_KEY_set_group,
9 EC_KEY_get0_private_key, EC_KEY_set_private_key,
10 EC_KEY_get0_public_key, EC_KEY_set_public_key, EC_KEY_get_enc_flags,
11 EC_KEY_set_enc_flags, EC_KEY_get_conv_form, EC_KEY_set_conv_form,
12 EC_KEY_get_key_method_data, EC_KEY_insert_key_method_data,
13 EC_KEY_set_asn1_flag, EC_KEY_precompute_mult, EC_KEY_generate_key,
14 EC_KEY_check_key, EC_KEY_set_public_key_affine_coordinates - Functions
15 for creating, destroying and manipulating EC_KEY objects.
16
18 #include <openssl/ec.h>
19 #include <openssl/bn.h>
20
21 EC_KEY *EC_KEY_new(void);
22 int EC_KEY_get_flags(const EC_KEY *key);
23 void EC_KEY_set_flags(EC_KEY *key, int flags);
24 void EC_KEY_clear_flags(EC_KEY *key, int flags);
25 EC_KEY *EC_KEY_new_by_curve_name(int nid);
26 void EC_KEY_free(EC_KEY *key);
27 EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src);
28 EC_KEY *EC_KEY_dup(const EC_KEY *src);
29 int EC_KEY_up_ref(EC_KEY *key);
30 const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);
31 int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);
32 const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);
33 int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);
34 const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);
35 int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);
36 point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key);
37 void EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform);
38 void *EC_KEY_get_key_method_data(EC_KEY *key,
39 void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
40 void EC_KEY_insert_key_method_data(EC_KEY *key, void *data,
41 void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
42 void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag);
43 int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);
44 int EC_KEY_generate_key(EC_KEY *key);
45 int EC_KEY_check_key(const EC_KEY *key);
46 int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *y);
47
49 An EC_KEY represents a public key and (optionaly) an associated private
50 key. A new EC_KEY (with no associated curve) can be constructed by
51 calling EC_KEY_new. The reference count for the newly created EC_KEY
52 is initially set to 1. A curve can be associated with the EC_KEY by
53 calling EC_KEY_set_group.
54
55 Alternatively a new EC_KEY can be constructed by calling
56 EC_KEY_new_by_curve_name and supplying the nid of the associated curve.
57 Refer to EC_GROUP_new(3) for a description of curve names. This
58 function simply wraps calls to EC_KEY_new and
59 EC_GROUP_new_by_curve_name.
60
61 Calling EC_KEY_free decrements the reference count for the EC_KEY
62 object, and if it has dropped to zero then frees the memory associated
63 with it.
64
65 EC_KEY_copy copies the contents of the EC_KEY in src into dest.
66
67 EC_KEY_dup creates a new EC_KEY object and copies ec_key into it.
68
69 EC_KEY_up_ref increments the reference count associated with the EC_KEY
70 object.
71
72 EC_KEY_generate_key generates a new public and private key for the
73 supplied eckey object. eckey must have an EC_GROUP object associated
74 with it before calling this function. The private key is a random
75 integer (0 < priv_key < order, where order is the order of the EC_GROUP
76 object). The public key is an EC_POINT on the curve calculated by
77 multiplying the generator for the curve by the private key.
78
79 EC_KEY_check_key performs various sanity checks on the EC_KEY object to
80 confirm that it is valid.
81
82 EC_KEY_set_public_key_affine_coordinates sets the public key for key
83 based on its affine co-ordinates, i.e. it constructs an EC_POINT object
84 based on the supplied x and y values and sets the public key to be this
85 EC_POINT. It will also performs certain sanity checks on the key to
86 confirm that it is valid.
87
88 The functions EC_KEY_get0_group, EC_KEY_set_group,
89 EC_KEY_get0_private_key, EC_KEY_set_private_key,
90 EC_KEY_get0_public_key, and EC_KEY_set_public_key get and set the
91 EC_GROUP object, the private key and the EC_POINT public key for the
92 key respectively.
93
94 The functions EC_KEY_get_conv_form and EC_KEY_set_conv_form get and set
95 the point_conversion_form for the key. For a description of
96 point_conversion_forms please refer to EC_POINT_new(3).
97
98 EC_KEY_insert_key_method_data and EC_KEY_get_key_method_data enable the
99 caller to associate arbitrary additional data specific to the elliptic
100 curve scheme being used with the EC_KEY object. This data is treated as
101 a "black box" by the ec library. The data to be stored by
102 EC_KEY_insert_key_method_data is provided in the data parameter, which
103 must have associated functions for duplicating, freeing and
104 "clear_freeing" the data item. If a subsequent
105 EC_KEY_get_key_method_data call is issued, the functions for
106 duplicating, freeing and "clear_freeing" the data item must be provided
107 again, and they must be the same as they were when the data item was
108 inserted.
109
110 EC_KEY_set_flags sets the flags in the flags parameter on the EC_KEY
111 object. Any flags that are already set are left set. The currently
112 defined standard flags are EC_FLAG_NON_FIPS_ALLOW and
113 EC_FLAG_FIPS_CHECKED. In addition there is the flag
114 EC_FLAG_COFACTOR_ECDH which is specific to ECDH and is defined in
115 ecdh.h. EC_KEY_get_flags returns the current flags that are set for
116 this EC_KEY. EC_KEY_clear_flags clears the flags indicated by the flags
117 parameter. All other flags are left in their existing state.
118
119 EC_KEY_set_asn1_flag sets the asn1_flag on the underlying EC_GROUP
120 object (if set). Refer to EC_GROUP_copy(3) for further information on
121 the asn1_flag.
122
123 EC_KEY_precompute_mult stores multiples of the underlying EC_GROUP
124 generator for faster point multiplication. See also EC_POINT_add(3).
125
127 EC_KEY_new, EC_KEY_new_by_curve_name and EC_KEY_dup return a pointer to
128 the newly created EC_KEY object, or NULL on error.
129
130 EC_KEY_get_flags returns the flags associated with the EC_KEY object as
131 an integer.
132
133 EC_KEY_copy returns a pointer to the destination key, or NULL on error.
134
135 EC_KEY_up_ref, EC_KEY_set_group, EC_KEY_set_private_key,
136 EC_KEY_set_public_key, EC_KEY_precompute_mult, EC_KEY_generate_key,
137 EC_KEY_check_key and EC_KEY_set_public_key_affine_coordinates return 1
138 on success or 0 on error.
139
140 EC_KEY_get0_group returns the EC_GROUP associated with the EC_KEY.
141
142 EC_KEY_get0_private_key returns the private key associated with the
143 EC_KEY.
144
145 EC_KEY_get_conv_form return the point_conversion_form for the EC_KEY.
146
148 crypto(3), ec(3), EC_GROUP_new(3), EC_GROUP_copy(3), EC_POINT_new(3),
149 EC_POINT_add(3), EC_GFp_simple_method(3), d2i_ECPKParameters(3)
150
151
152
1531.0.2o 2019-09-10 EC_KEY_new(3)