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_get0_hmac, EVP_PKEY_type, EVP_PKEY_id,
12       EVP_PKEY_base_id, EVP_PKEY_set_alias_type, EVP_PKEY_set1_engine -
13       EVP_PKEY assignment functions
14

SYNOPSIS

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

DESCRIPTION

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

NOTES

87       In accordance with the OpenSSL naming convention the key obtained from
88       or assigned to the pkey using the 1 functions must be freed as well as
89       pkey.
90
91       EVP_PKEY_assign_RSA(), EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH() and
92       EVP_PKEY_assign_EC_KEY() are implemented as macros.
93
94       Most applications wishing to know a key type will simply call
95       EVP_PKEY_base_id() and will not care about the actual type: which will
96       be identical in almost all cases.
97
98       Previous versions of this document suggested using
99       EVP_PKEY_type(pkey->type) to determine the type of a key. Since
100       EVP_PKEY is now opaque this is no longer possible: the equivalent is
101       EVP_PKEY_base_id(pkey).
102
103       EVP_PKEY_set1_engine() is typically used by an ENGINE returning an HSM
104       key as part of its routine to load a private key.
105

EXAMPLES

107       After loading an ECC key, it is possible to convert it to using SM2
108       algorithms with EVP_PKEY_set_alias_type:
109
110        EVP_PKEY_set_alias_type(pkey, EVP_PKEY_SM2);
111

RETURN VALUES

113       EVP_PKEY_set1_RSA(), EVP_PKEY_set1_DSA(), EVP_PKEY_set1_DH() and
114       EVP_PKEY_set1_EC_KEY() return 1 for success or 0 for failure.
115
116       EVP_PKEY_get1_RSA(), EVP_PKEY_get1_DSA(), EVP_PKEY_get1_DH() and
117       EVP_PKEY_get1_EC_KEY() return the referenced key or NULL if an error
118       occurred.
119
120       EVP_PKEY_assign_RSA(), EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH() and
121       EVP_PKEY_assign_EC_KEY() return 1 for success and 0 for failure.
122
123       EVP_PKEY_base_id(), EVP_PKEY_id() and EVP_PKEY_type() return a key type
124       or NID_undef (equivalently EVP_PKEY_NONE) on error.
125
126       EVP_PKEY_set1_engine() returns 1 for success and 0 for failure.
127
128       EVP_PKEY_set_alias_type() returns 1 for success and 0 for error.
129

SEE ALSO

131       EVP_PKEY_new(3)
132
134       Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved.
135
136       Licensed under the OpenSSL license (the "License").  You may not use
137       this file except in compliance with the License.  You can obtain a copy
138       in the file LICENSE in the source distribution or at
139       <https://www.openssl.org/source/license.html>.
140
141
142
1431.1.1                             2018-09-11              EVP_PKEY_SET1_RSA(3)
Impressum