1EVP_PKEY_SET1_RSA(3)                OpenSSL               EVP_PKEY_SET1_RSA(3)
2
3
4

NAME

6       EVP_PKEY_set1_RSA, EVP_PKEY_set1_DSA, EVP_PKEY_set1_DH,
7       EVP_PKEY_set1_EC_KEY, EVP_PKEY_get1_RSA, EVP_PKEY_get1_DSA,
8       EVP_PKEY_get1_DH, EVP_PKEY_get1_EC_KEY, EVP_PKEY_get0_RSA,
9       EVP_PKEY_get0_DSA, EVP_PKEY_get0_DH, EVP_PKEY_get0_EC_KEY,
10       EVP_PKEY_assign_RSA, EVP_PKEY_assign_DSA, EVP_PKEY_assign_DH,
11       EVP_PKEY_assign_EC_KEY, EVP_PKEY_assign_POLY1305,
12       EVP_PKEY_assign_SIPHASH, EVP_PKEY_get0_hmac, EVP_PKEY_get0_poly1305,
13       EVP_PKEY_get0_siphash, EVP_PKEY_type, EVP_PKEY_id, EVP_PKEY_base_id,
14       EVP_PKEY_set_alias_type, EVP_PKEY_set1_engine, EVP_PKEY_get0_engine -
15       EVP_PKEY assignment functions
16

SYNOPSIS

18        #include <openssl/evp.h>
19
20        int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key);
21        int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key);
22        int EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key);
23        int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, EC_KEY *key);
24
25        RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);
26        DSA *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);
27        DH *EVP_PKEY_get1_DH(EVP_PKEY *pkey);
28        EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);
29
30        const unsigned char *EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len);
31        const unsigned char *EVP_PKEY_get0_poly1305(const EVP_PKEY *pkey, size_t *len);
32        const unsigned char *EVP_PKEY_get0_siphash(const EVP_PKEY *pkey, size_t *len);
33        RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey);
34        DSA *EVP_PKEY_get0_DSA(EVP_PKEY *pkey);
35        DH *EVP_PKEY_get0_DH(EVP_PKEY *pkey);
36        EC_KEY *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey);
37
38        int EVP_PKEY_assign_RSA(EVP_PKEY *pkey, RSA *key);
39        int EVP_PKEY_assign_DSA(EVP_PKEY *pkey, DSA *key);
40        int EVP_PKEY_assign_DH(EVP_PKEY *pkey, DH *key);
41        int EVP_PKEY_assign_EC_KEY(EVP_PKEY *pkey, EC_KEY *key);
42        int EVP_PKEY_assign_POLY1305(EVP_PKEY *pkey, ASN1_OCTET_STRING *key);
43        int EVP_PKEY_assign_SIPHASH(EVP_PKEY *pkey, ASN1_OCTET_STRING *key);
44
45        int EVP_PKEY_id(const EVP_PKEY *pkey);
46        int EVP_PKEY_base_id(const EVP_PKEY *pkey);
47        int EVP_PKEY_type(int type);
48        int EVP_PKEY_set_alias_type(EVP_PKEY *pkey, int type);
49
50        ENGINE *EVP_PKEY_get0_engine(const EVP_PKEY *pkey);
51        int EVP_PKEY_set1_engine(EVP_PKEY *pkey, ENGINE *engine);
52

DESCRIPTION

54       EVP_PKEY_set1_RSA(), EVP_PKEY_set1_DSA(), EVP_PKEY_set1_DH() and
55       EVP_PKEY_set1_EC_KEY() set the key referenced by pkey to key.
56
57       EVP_PKEY_get1_RSA(), EVP_PKEY_get1_DSA(), EVP_PKEY_get1_DH() and
58       EVP_PKEY_get1_EC_KEY() return the referenced key in pkey or NULL if the
59       key is not of the correct type.
60
61       EVP_PKEY_get0_hmac(), EVP_PKEY_get0_poly1305(),
62       EVP_PKEY_get0_siphash(), EVP_PKEY_get0_RSA(), EVP_PKEY_get0_DSA(),
63       EVP_PKEY_get0_DH() and EVP_PKEY_get0_EC_KEY() also return the
64       referenced key in pkey or NULL if the key is not of the correct type
65       but the reference count of the returned key is not incremented and so
66       must not be freed up after use.
67
68       EVP_PKEY_assign_RSA(), EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH(),
69       EVP_PKEY_assign_EC_KEY(), EVP_PKEY_assign_POLY1305() and
70       EVP_PKEY_assign_SIPHASH() also set the referenced key to key however
71       these use the supplied key internally and so key will be freed when the
72       parent pkey is freed.
73
74       EVP_PKEY_base_id() returns the type of pkey. For example an RSA key
75       will return EVP_PKEY_RSA.
76
77       EVP_PKEY_id() returns the actual OID associated with pkey. Historically
78       keys using the same algorithm could use different OIDs. For example an
79       RSA key could use the OIDs corresponding to the NIDs NID_rsaEncryption
80       (equivalent to EVP_PKEY_RSA) or NID_rsa (equivalent to EVP_PKEY_RSA2).
81       The use of alternative non-standard OIDs is now rare so EVP_PKEY_RSA2
82       et al are not often seen in practice.
83
84       EVP_PKEY_type() returns the underlying type of the NID type. For
85       example EVP_PKEY_type(EVP_PKEY_RSA2) will return EVP_PKEY_RSA.
86
87       EVP_PKEY_get0_engine() returns a reference to the ENGINE handling pkey.
88
89       EVP_PKEY_set1_engine() sets the ENGINE handling pkey to engine. It must
90       be called after the key algorithm and components are set up.  If engine
91       does not include an EVP_PKEY_METHOD for pkey an error occurs.
92
93       EVP_PKEY_set_alias_type() allows modifying a EVP_PKEY to use a
94       different set of algorithms than the default. This is currently used to
95       support SM2 keys, which use an identical encoding to ECDSA.
96

NOTES

98       In accordance with the OpenSSL naming convention the key obtained from
99       or assigned to the pkey using the 1 functions must be freed as well as
100       pkey.
101
102       EVP_PKEY_assign_RSA(), EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH(),
103       EVP_PKEY_assign_EC_KEY(), EVP_PKEY_assign_POLY1305() and
104       EVP_PKEY_assign_SIPHASH() are implemented as macros.
105
106       Most applications wishing to know a key type will simply call
107       EVP_PKEY_base_id() and will not care about the actual type: which will
108       be identical in almost all cases.
109
110       Previous versions of this document suggested using
111       EVP_PKEY_type(pkey->type) to determine the type of a key. Since
112       EVP_PKEY is now opaque this is no longer possible: the equivalent is
113       EVP_PKEY_base_id(pkey).
114
115       EVP_PKEY_set1_engine() is typically used by an ENGINE returning an HSM
116       key as part of its routine to load a private key.
117

RETURN VALUES

119       EVP_PKEY_set1_RSA(), EVP_PKEY_set1_DSA(), EVP_PKEY_set1_DH() and
120       EVP_PKEY_set1_EC_KEY() return 1 for success or 0 for failure.
121
122       EVP_PKEY_get1_RSA(), EVP_PKEY_get1_DSA(), EVP_PKEY_get1_DH() and
123       EVP_PKEY_get1_EC_KEY() return the referenced key or NULL if an error
124       occurred.
125
126       EVP_PKEY_assign_RSA(), EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH(),
127       EVP_PKEY_assign_EC_KEY(), EVP_PKEY_assign_POLY1305() and
128       EVP_PKEY_assign_SIPHASH() return 1 for success and 0 for failure.
129
130       EVP_PKEY_base_id(), EVP_PKEY_id() and EVP_PKEY_type() return a key type
131       or NID_undef (equivalently EVP_PKEY_NONE) on error.
132
133       EVP_PKEY_set1_engine() returns 1 for success and 0 for failure.
134
135       EVP_PKEY_set_alias_type() returns 1 for success and 0 for error.
136

EXAMPLES

138       After loading an ECC key, it is possible to convert it to using SM2
139       algorithms with EVP_PKEY_set_alias_type:
140
141        EVP_PKEY_set_alias_type(pkey, EVP_PKEY_SM2);
142

SEE ALSO

144       EVP_PKEY_new(3)
145
147       Copyright 2002-2019 The OpenSSL Project Authors. All Rights Reserved.
148
149       Licensed under the OpenSSL license (the "License").  You may not use
150       this file except in compliance with the License.  You can obtain a copy
151       in the file LICENSE in the source distribution or at
152       <https://www.openssl.org/source/license.html>.
153
154
155
1561.1.1q                            2022-07-21              EVP_PKEY_SET1_RSA(3)
Impressum