summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp
diff options
context:
space:
mode:
authortb <>2018-02-17 13:47:36 +0000
committertb <>2018-02-17 13:47:36 +0000
commite1b05f77869d986a0aee6aa4076f008274e98d27 (patch)
treef0cc2d3dd2a3842c40f792227fe86c133a668af2 /src/lib/libcrypto/evp
parent0c7165079d7f7c944f8c516a5bb23a71b674c170 (diff)
downloadopenbsd-e1b05f77869d986a0aee6aa4076f008274e98d27.tar.gz
openbsd-e1b05f77869d986a0aee6aa4076f008274e98d27.tar.bz2
openbsd-e1b05f77869d986a0aee6aa4076f008274e98d27.zip
Provide further parts of the OpenSSL 1.1 API: {DH,DSA}_get0_{key,pqg}(),
EVP_PKEY_get0_{DH,DSA,RSA}(), RSA_{g,s}et0_key(). ok jsing
Diffstat (limited to 'src/lib/libcrypto/evp')
-rw-r--r--src/lib/libcrypto/evp/evp.h11
-rw-r--r--src/lib/libcrypto/evp/p_lib.c67
2 files changed, 55 insertions, 23 deletions
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h
index 09df7db64b..c8da89844d 100644
--- a/src/lib/libcrypto/evp/evp.h
+++ b/src/lib/libcrypto/evp/evp.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp.h,v 1.54 2018/02/14 16:40:42 jsing Exp $ */ 1/* $OpenBSD: evp.h,v 1.55 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 *
@@ -870,18 +870,21 @@ void *EVP_PKEY_get0(EVP_PKEY *pkey);
870 870
871#ifndef OPENSSL_NO_RSA 871#ifndef OPENSSL_NO_RSA
872struct rsa_st; 872struct rsa_st;
873int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, struct rsa_st *key); 873struct rsa_st *EVP_PKEY_get0_RSA(EVP_PKEY *pkey);
874struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey); 874struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);
875int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, struct rsa_st *key);
875#endif 876#endif
876#ifndef OPENSSL_NO_DSA 877#ifndef OPENSSL_NO_DSA
877struct dsa_st; 878struct dsa_st;
878int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, struct dsa_st *key); 879struct dsa_st *EVP_PKEY_get0_DSA(EVP_PKEY *pkey);
879struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey); 880struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);
881int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, struct dsa_st *key);
880#endif 882#endif
881#ifndef OPENSSL_NO_DH 883#ifndef OPENSSL_NO_DH
882struct dh_st; 884struct dh_st;
883int EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key); 885struct dh_st *EVP_PKEY_get0_DH(EVP_PKEY *pkey);
884struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey); 886struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey);
887int EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key);
885#endif 888#endif
886#ifndef OPENSSL_NO_EC 889#ifndef OPENSSL_NO_EC
887struct ec_key_st; 890struct ec_key_st;
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