import libcrypto (LibreSSL 2.5.2)
[unleashed.git] / lib / libcrypto / man / EVP_PKEY_set1_RSA.3
blob851184ae3c0e41f8456e1ba69a484494f36d4e44
1 .\"     $OpenBSD: EVP_PKEY_set1_RSA.3,v 1.5 2016/12/11 12:21:48 schwarze Exp $
2 .\"     OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400
3 .\"
4 .\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5 .\" Copyright (c) 2002, 2014, 2016 The OpenSSL Project.  All rights reserved.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\"
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\"
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\"    notice, this list of conditions and the following disclaimer in
16 .\"    the documentation and/or other materials provided with the
17 .\"    distribution.
18 .\"
19 .\" 3. All advertising materials mentioning features or use of this
20 .\"    software must display the following acknowledgment:
21 .\"    "This product includes software developed by the OpenSSL Project
22 .\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23 .\"
24 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25 .\"    endorse or promote products derived from this software without
26 .\"    prior written permission. For written permission, please contact
27 .\"    openssl-core@openssl.org.
28 .\"
29 .\" 5. Products derived from this software may not be called "OpenSSL"
30 .\"    nor may "OpenSSL" appear in their names without prior written
31 .\"    permission of the OpenSSL Project.
32 .\"
33 .\" 6. Redistributions of any form whatsoever must retain the following
34 .\"    acknowledgment:
35 .\"    "This product includes software developed by the OpenSSL Project
36 .\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37 .\"
38 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
42 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
50 .\"
51 .Dd $Mdocdate: December 11 2016 $
52 .Dt EVP_PKEY_SET1_RSA 3
53 .Os
54 .Sh NAME
55 .Nm EVP_PKEY_set1_RSA ,
56 .Nm EVP_PKEY_set1_DSA ,
57 .Nm EVP_PKEY_set1_DH ,
58 .Nm EVP_PKEY_set1_EC_KEY ,
59 .Nm EVP_PKEY_get1_RSA ,
60 .Nm EVP_PKEY_get1_DSA ,
61 .Nm EVP_PKEY_get1_DH ,
62 .Nm EVP_PKEY_get1_EC_KEY ,
63 .Nm EVP_PKEY_assign_RSA ,
64 .Nm EVP_PKEY_assign_DSA ,
65 .Nm EVP_PKEY_assign_DH ,
66 .Nm EVP_PKEY_assign_EC_KEY ,
67 .Nm EVP_PKEY_id ,
68 .Nm EVP_PKEY_base_id ,
69 .Nm EVP_PKEY_type
70 .Nd EVP_PKEY assignment functions
71 .Sh SYNOPSIS
72 .In openssl/evp.h
73 .Ft int
74 .Fo EVP_PKEY_set1_RSA
75 .Fa "EVP_PKEY *pkey"
76 .Fa "RSA *key"
77 .Fc
78 .Ft int
79 .Fo EVP_PKEY_set1_DSA
80 .Fa "EVP_PKEY *pkey"
81 .Fa "DSA *key"
82 .Fc
83 .Ft int
84 .Fo EVP_PKEY_set1_DH
85 .Fa "EVP_PKEY *pkey"
86 .Fa "DH *key"
87 .Fc
88 .Ft int
89 .Fo EVP_PKEY_set1_EC_KEY
90 .Fa "EVP_PKEY *pkey"
91 .Fa "EC_KEY *key"
92 .Fc
93 .Ft RSA *
94 .Fo EVP_PKEY_get1_RSA
95 .Fa "EVP_PKEY *pkey"
96 .Fc
97 .Ft DSA *
98 .Fo EVP_PKEY_get1_DSA
99 .Fa "EVP_PKEY *pkey"
101 .Ft DH *
102 .Fo EVP_PKEY_get1_DH
103 .Fa "EVP_PKEY *pkey"
105 .Ft EC_KEY *
106 .Fo EVP_PKEY_get1_EC_KEY
107 .Fa "EVP_PKEY *pkey"
109 .Ft int
110 .Fo EVP_PKEY_assign_RSA
111 .Fa "EVP_PKEY *pkey"
112 .Fa "RSA *key"
114 .Ft int
115 .Fo EVP_PKEY_assign_DSA
116 .Fa "EVP_PKEY *pkey"
117 .Fa "DSA *key"
119 .Ft int
120 .Fo EVP_PKEY_assign_DH
121 .Fa "EVP_PKEY *pkey"
122 .Fa "DH *key"
124 .Ft int
125 .Fo EVP_PKEY_assign_EC_KEY
126 .Fa "EVP_PKEY *pkey"
127 .Fa "EC_KEY *key"
129 .Ft int
130 .Fo EVP_PKEY_id
131 .Fa "EVP_PKEY *pkey"
133 .Ft int
134 .Fo EVP_PKEY_base_id
135 .Fa "EVP_PKEY *pkey"
137 .Ft int
138 .Fo EVP_PKEY_type
139 .Fa "int type"
141 .Sh DESCRIPTION
142 .Fn EVP_PKEY_set1_RSA ,
143 .Fn EVP_PKEY_set1_DSA ,
144 .Fn EVP_PKEY_set1_DH ,
146 .Fn EVP_PKEY_set1_EC_KEY
147 set the key referenced by
148 .Fa pkey
150 .Fa key .
152 .Fn EVP_PKEY_get1_RSA ,
153 .Fn EVP_PKEY_get1_DSA ,
154 .Fn EVP_PKEY_get1_DH ,
156 .Fn EVP_PKEY_get1_EC_KEY
157 return the key referenced in
158 .Fa pkey
160 .Dv NULL
161 if the key is not of the correct type.
163 .Fn EVP_PKEY_assign_RSA ,
164 .Fn EVP_PKEY_assign_DSA ,
165 .Fn EVP_PKEY_assign_DH ,
167 .Fn EVP_PKEY_assign_EC_KEY
168 also set the referenced key to
169 .Fa key ;
170 however these use the supplied
171 .Fa key
172 internally and so
173 .Fa key
174 will be freed when the parent
175 .Fa pkey
176 is freed.
178 .Fn EVP_PKEY_base_id
179 returns the type of
180 .Fa pkey .
181 For example, an RSA key will return
182 .Dv EVP_PKEY_RSA .
184 .Fn EVP_PKEY_id
185 returns the actual OID associated with
186 .Fa pkey .
187 Historically keys using the same algorithm could use different OIDs.
188 For example, an RSA key could use the OIDs corresponding to the NIDs
189 .Dv NID_rsaEncryption
190 (equivalent to
191 .Dv EVP_PKEY_RSA )
193 .Dv NID_rsa
194 (equivalent to
195 .Dv EVP_PKEY_RSA2 ) .
196 The use of alternative non-standard OIDs is now rare, so
197 .Dv EVP_PKEY_RSA2
198 et al. are not often seen in practice.
200 .Fn EVP_PKEY_type
201 returns the underlying type of the NID
202 .Fa type .
203 For example,
204 .Fn EVP_PKEY_type EVP_PKEY_RSA2
205 will return
206 .Dv EVP_PKEY_RSA .
208 Most applications wishing to know a key type will simply call
209 .Fn EVP_PKEY_base_id
210 and will not care about the actual type,
211 which will be identical in almost all cases.
213 In accordance with the OpenSSL naming convention, the key obtained from
214 or assigned to
215 .Fa pkey
216 using the
217 .Sy 1
218 functions must be freed as well as
219 .Fa pkey .
221 .Fn EVP_PKEY_assign_RSA ,
222 .Fn EVP_PKEY_assign_DSA ,
223 .Fn EVP_PKEY_assign_DH ,
225 .Fn EVP_PKEY_assign_EC_KEY
226 are implemented as macros.
227 .Sh RETURN VALUES
228 .Fn EVP_PKEY_set1_RSA ,
229 .Fn EVP_PKEY_set1_DSA ,
230 .Fn EVP_PKEY_set1_DH ,
232 .Fn EVP_PKEY_set1_EC_KEY
233 return 1 for success or 0 for failure.
235 .Fn EVP_PKEY_get1_RSA ,
236 .Fn EVP_PKEY_get1_DSA ,
237 .Fn EVP_PKEY_get1_DH ,
239 .Fn EVP_PKEY_get1_EC_KEY
240 return the referenced key or
241 .Dv NULL
242 if an error occurred.
244 .Fn EVP_PKEY_assign_RSA ,
245 .Fn EVP_PKEY_assign_DSA ,
246 .Fn EVP_PKEY_assign_DH ,
248 .Fn EVP_PKEY_assign_EC_KEY
249 return 1 for success and 0 for failure.
251 .Fn EVP_PKEY_base_id ,
252 .Fn EVP_PKEY_id ,
254 .Fn EVP_PKEY_type
255 return a key type or
256 .Dv NID_undef
257 (equivalently
258 .Dv EVP_PKEY_NONE )
259 on error.
260 .Sh SEE ALSO
261 .Xr EVP_PKEY_new 3 ,
262 .Xr RSA_new 3