summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2018-02-20 18:05:28 +0000
committertb <>2018-02-20 18:05:28 +0000
commit9d17df01c5dd3ba327b7cd95fb5de819941ff77a (patch)
treed0e432a5dae1c3d68b3f72c5b22ce5f8a3d9964d /src/lib
parentaccf1b94b3627d2ed5d78c6638d3d618404a8a2d (diff)
downloadopenbsd-9d17df01c5dd3ba327b7cd95fb5de819941ff77a.tar.gz
openbsd-9d17df01c5dd3ba327b7cd95fb5de819941ff77a.tar.bz2
openbsd-9d17df01c5dd3ba327b7cd95fb5de819941ff77a.zip
Provide EVP_PKEY_get0_EC_KEY() and 'if (ret)' vs 'if (ret != 0)' cosmetics.
ok jsing
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/Symbols.list1
-rw-r--r--src/lib/libcrypto/evp/evp.h5
-rw-r--r--src/lib/libcrypto/evp/p_lib.c31
3 files changed, 24 insertions, 13 deletions
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list
index 885d5fb111..39ef6bf430 100644
--- a/src/lib/libcrypto/Symbols.list
+++ b/src/lib/libcrypto/Symbols.list
@@ -1388,6 +1388,7 @@ EVP_PKEY_free
1388EVP_PKEY_get0 1388EVP_PKEY_get0
1389EVP_PKEY_get0_DH 1389EVP_PKEY_get0_DH
1390EVP_PKEY_get0_DSA 1390EVP_PKEY_get0_DSA
1391EVP_PKEY_get0_EC_KEY
1391EVP_PKEY_get0_RSA 1392EVP_PKEY_get0_RSA
1392EVP_PKEY_get0_asn1 1393EVP_PKEY_get0_asn1
1393EVP_PKEY_get1_DH 1394EVP_PKEY_get1_DH
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h
index aec6fa4249..e12e771cc5 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.57 2018/02/17 16:54:08 jsing Exp $ */ 1/* $OpenBSD: evp.h,v 1.58 2018/02/20 18:05:28 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 *
@@ -893,8 +893,9 @@ int EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key);
893#endif 893#endif
894#ifndef OPENSSL_NO_EC 894#ifndef OPENSSL_NO_EC
895struct ec_key_st; 895struct ec_key_st;
896int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key); 896struct ec_key_st *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey);
897struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey); 897struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);
898int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key);
898#endif 899#endif
899#ifndef OPENSSL_NO_GOST 900#ifndef OPENSSL_NO_GOST
900struct gost_key_st; 901struct gost_key_st;
diff --git a/src/lib/libcrypto/evp/p_lib.c b/src/lib/libcrypto/evp/p_lib.c
index 3cd1bf3b34..811fe0c86d 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.19 2018/02/17 13:47:36 tb Exp $ */ 1/* $OpenBSD: p_lib.c,v 1.20 2018/02/20 18:05:28 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 *
@@ -311,7 +311,7 @@ int
311EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key) 311EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key)
312{ 312{
313 int ret = EVP_PKEY_assign_RSA(pkey, key); 313 int ret = EVP_PKEY_assign_RSA(pkey, key);
314 if (ret) 314 if (ret != 0)
315 RSA_up_ref(key); 315 RSA_up_ref(key);
316 return ret; 316 return ret;
317} 317}
@@ -343,21 +343,21 @@ int
343EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key) 343EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key)
344{ 344{
345 int ret = EVP_PKEY_assign_DSA(pkey, key); 345 int ret = EVP_PKEY_assign_DSA(pkey, key);
346 if (ret) 346 if (ret != 0)
347 DSA_up_ref(key); 347 DSA_up_ref(key);
348 return ret; 348 return ret;
349} 349}
350#endif 350#endif
351 351
352#ifndef OPENSSL_NO_EC 352#ifndef OPENSSL_NO_EC
353 353EC_KEY *
354int 354EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)
355EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, EC_KEY *key)
356{ 355{
357 int ret = EVP_PKEY_assign_EC_KEY(pkey, key); 356 if (pkey->type != EVP_PKEY_EC) {
358 if (ret) 357 EVPerror(EVP_R_EXPECTING_A_EC_KEY);
359 EC_KEY_up_ref(key); 358 return NULL;
360 return ret; 359 }
360 return pkey->pkey.ec;
361} 361}
362 362
363EC_KEY * 363EC_KEY *
@@ -370,6 +370,15 @@ EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)
370 EC_KEY_up_ref(pkey->pkey.ec); 370 EC_KEY_up_ref(pkey->pkey.ec);
371 return pkey->pkey.ec; 371 return pkey->pkey.ec;
372} 372}
373
374int
375EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, EC_KEY *key)
376{
377 int ret = EVP_PKEY_assign_EC_KEY(pkey, key);
378 if (ret != 0)
379 EC_KEY_up_ref(key);
380 return ret;
381}
373#endif 382#endif
374 383
375 384
@@ -399,7 +408,7 @@ int
399EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key) 408EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key)
400{ 409{
401 int ret = EVP_PKEY_assign_DH(pkey, key); 410 int ret = EVP_PKEY_assign_DH(pkey, key);
402 if (ret) 411 if (ret != 0)
403 DH_up_ref(key); 412 DH_up_ref(key);
404 return ret; 413 return ret;
405} 414}