summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/p_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/evp/p_lib.c')
-rw-r--r--src/lib/libcrypto/evp/p_lib.c67
1 files changed, 48 insertions, 19 deletions
diff --git a/src/lib/libcrypto/evp/p_lib.c b/src/lib/libcrypto/evp/p_lib.c
index e001755ef1..3cd1bf3b34 100644
--- a/src/lib/libcrypto/evp/p_lib.c
+++ b/src/lib/libcrypto/evp/p_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p_lib.c,v 1.18 2018/02/14 16:40:42 jsing Exp $ */ 1/* $OpenBSD: p_lib.c,v 1.19 2018/02/17 13:47:36 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -286,13 +286,14 @@ EVP_PKEY_get0(EVP_PKEY *pkey)
286} 286}
287 287
288#ifndef OPENSSL_NO_RSA 288#ifndef OPENSSL_NO_RSA
289int 289RSA *
290EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key) 290EVP_PKEY_get0_RSA(EVP_PKEY *pkey)
291{ 291{
292 int ret = EVP_PKEY_assign_RSA(pkey, key); 292 if (pkey->type != EVP_PKEY_RSA) {
293 if (ret) 293 EVPerror(EVP_R_EXPECTING_AN_RSA_KEY);
294 RSA_up_ref(key); 294 return NULL;
295 return ret; 295 }
296 return pkey->pkey.rsa;
296} 297}
297 298
298RSA * 299RSA *
@@ -305,17 +306,27 @@ EVP_PKEY_get1_RSA(EVP_PKEY *pkey)
305 RSA_up_ref(pkey->pkey.rsa); 306 RSA_up_ref(pkey->pkey.rsa);
306 return pkey->pkey.rsa; 307 return pkey->pkey.rsa;
307} 308}
308#endif
309 309
310#ifndef OPENSSL_NO_DSA
311int 310int
312EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key) 311EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key)
313{ 312{
314 int ret = EVP_PKEY_assign_DSA(pkey, key); 313 int ret = EVP_PKEY_assign_RSA(pkey, key);
315 if (ret) 314 if (ret)
316 DSA_up_ref(key); 315 RSA_up_ref(key);
317 return ret; 316 return ret;
318} 317}
318#endif
319
320#ifndef OPENSSL_NO_DSA
321DSA *
322EVP_PKEY_get0_DSA(EVP_PKEY *pkey)
323{
324 if (pkey->type != EVP_PKEY_DSA) {
325 EVPerror(EVP_R_EXPECTING_A_DSA_KEY);
326 return NULL;
327 }
328 return pkey->pkey.dsa;
329}
319 330
320DSA * 331DSA *
321EVP_PKEY_get1_DSA(EVP_PKEY *pkey) 332EVP_PKEY_get1_DSA(EVP_PKEY *pkey)
@@ -327,6 +338,15 @@ EVP_PKEY_get1_DSA(EVP_PKEY *pkey)
327 DSA_up_ref(pkey->pkey.dsa); 338 DSA_up_ref(pkey->pkey.dsa);
328 return pkey->pkey.dsa; 339 return pkey->pkey.dsa;
329} 340}
341
342int
343EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key)
344{
345 int ret = EVP_PKEY_assign_DSA(pkey, key);
346 if (ret)
347 DSA_up_ref(key);
348 return ret;
349}
330#endif 350#endif
331 351
332#ifndef OPENSSL_NO_EC 352#ifndef OPENSSL_NO_EC
@@ -354,14 +374,14 @@ EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)
354 374
355 375
356#ifndef OPENSSL_NO_DH 376#ifndef OPENSSL_NO_DH
357 377DH *
358int 378EVP_PKEY_get0_DH(EVP_PKEY *pkey)
359EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key)
360{ 379{
361 int ret = EVP_PKEY_assign_DH(pkey, key); 380 if (pkey->type != EVP_PKEY_DH) {
362 if (ret) 381 EVPerror(EVP_R_EXPECTING_A_DH_KEY);
363 DH_up_ref(key); 382 return NULL;
364 return ret; 383 }
384 return pkey->pkey.dh;
365} 385}
366 386
367DH * 387DH *
@@ -374,6 +394,15 @@ EVP_PKEY_get1_DH(EVP_PKEY *pkey)
374 DH_up_ref(pkey->pkey.dh); 394 DH_up_ref(pkey->pkey.dh);
375 return pkey->pkey.dh; 395 return pkey->pkey.dh;
376} 396}
397
398int
399EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key)
400{
401 int ret = EVP_PKEY_assign_DH(pkey, key);
402 if (ret)
403 DH_up_ref(key);
404 return ret;
405}
377#endif 406#endif
378 407
379int 408int