summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/evp.h
diff options
context:
space:
mode:
authortb <>2025-07-02 06:36:52 +0000
committertb <>2025-07-02 06:36:52 +0000
commitee8028bd119b3e4cd917dc91bde28658b6256b9f (patch)
tree9209c373920f0b7491e3c9c0a2dd3aaa7a762f23 /src/lib/libcrypto/evp/evp.h
parent352bfb516a8a7791f3f4d8ce80d477d61afeb90f (diff)
downloadopenbsd-ee8028bd119b3e4cd917dc91bde28658b6256b9f.tar.gz
openbsd-ee8028bd119b3e4cd917dc91bde28658b6256b9f.tar.bz2
openbsd-ee8028bd119b3e4cd917dc91bde28658b6256b9f.zip
Const correct EVP_PKEY_get{0,1}_{DH,DSA,EC_KEY,RSA}()
These are safe to call concurrently and they don't modify the memory region pointed to by the pkey - they only bump the refcount of the key hanging off of it. The returned "legacy" key has to be handled with care in threaded constexts, so it is handed back as non-const. This also matches what EVP_PKEY_get0() always had. This way our signature is identical to BoringSSL's and doesn't cause compiler warnings in code that overuses const because one of the many API incoherencies added by OpenSSL 3 was to turn get0 into a function that takes and returns const while leaving get1 as it was. dlg agrees ok kenjiro
Diffstat (limited to 'src/lib/libcrypto/evp/evp.h')
-rw-r--r--src/lib/libcrypto/evp/evp.h30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h
index c2b81d0576..94295e1262 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.137 2024/08/31 10:38:49 tb Exp $ */ 1/* $OpenBSD: evp.h,v 1.138 2025/07/02 06:36:52 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 *
@@ -778,28 +778,24 @@ void *EVP_PKEY_get0(const EVP_PKEY *pkey);
778const unsigned char *EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len); 778const unsigned char *EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len);
779 779
780#ifndef OPENSSL_NO_RSA 780#ifndef OPENSSL_NO_RSA
781struct rsa_st; 781RSA *EVP_PKEY_get0_RSA(const EVP_PKEY *pkey);
782struct rsa_st *EVP_PKEY_get0_RSA(EVP_PKEY *pkey); 782RSA *EVP_PKEY_get1_RSA(const EVP_PKEY *pkey);
783struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey); 783int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key);
784int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, struct rsa_st *key);
785#endif 784#endif
786#ifndef OPENSSL_NO_DSA 785#ifndef OPENSSL_NO_DSA
787struct dsa_st; 786DSA *EVP_PKEY_get0_DSA(const EVP_PKEY *pkey);
788struct dsa_st *EVP_PKEY_get0_DSA(EVP_PKEY *pkey); 787DSA *EVP_PKEY_get1_DSA(const EVP_PKEY *pkey);
789struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey); 788int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key);
790int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, struct dsa_st *key);
791#endif 789#endif
792#ifndef OPENSSL_NO_DH 790#ifndef OPENSSL_NO_DH
793struct dh_st; 791DH *EVP_PKEY_get0_DH(const EVP_PKEY *pkey);
794struct dh_st *EVP_PKEY_get0_DH(EVP_PKEY *pkey); 792DH *EVP_PKEY_get1_DH(const EVP_PKEY *pkey);
795struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey); 793int EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key);
796int EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key);
797#endif 794#endif
798#ifndef OPENSSL_NO_EC 795#ifndef OPENSSL_NO_EC
799struct ec_key_st; 796EC_KEY *EVP_PKEY_get0_EC_KEY(const EVP_PKEY *pkey);
800struct ec_key_st *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey); 797EC_KEY *EVP_PKEY_get1_EC_KEY(const EVP_PKEY *pkey);
801struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey); 798int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, EC_KEY *key);
802int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key);
803#endif 799#endif
804 800
805EVP_PKEY *EVP_PKEY_new(void); 801EVP_PKEY *EVP_PKEY_new(void);