diff options
author | 2019-10-24 15:47:15 +0000 | |
---|---|---|
committer | 2019-10-24 15:47:15 +0000 | |
commit | dadff3ddff01cfe8d4812beb6ddb70c74aaa04d5 (patch) | |
tree | b9dd5954bb9ae297f50556fa8b39f76dea4293d8 /lib/libcrypto/rsa | |
parent | Add EVP_PKEY_RSA_PSS. (diff) | |
download | wireguard-openbsd-dadff3ddff01cfe8d4812beb6ddb70c74aaa04d5.tar.xz wireguard-openbsd-dadff3ddff01cfe8d4812beb6ddb70c74aaa04d5.zip |
Provide RSA_pkey_ctx_ctrl().
This is a wrapper around EVP_PKEY_CTX_ctrl() which requires the key to be
either RSA or RSA-PSS.
From OpenSSL 1.1.1d.
ok tb@
Diffstat (limited to 'lib/libcrypto/rsa')
-rw-r--r-- | lib/libcrypto/rsa/rsa.h | 4 | ||||
-rw-r--r-- | lib/libcrypto/rsa/rsa_lib.c | 17 |
2 files changed, 19 insertions, 2 deletions
diff --git a/lib/libcrypto/rsa/rsa.h b/lib/libcrypto/rsa/rsa.h index 2aa472f5015..1672297266d 100644 --- a/lib/libcrypto/rsa/rsa.h +++ b/lib/libcrypto/rsa/rsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa.h,v 1.40 2019/06/05 15:41:33 gilles Exp $ */ +/* $OpenBSD: rsa.h,v 1.41 2019/10/24 15:47:15 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -294,6 +294,8 @@ const RSA_METHOD *RSA_PKCS1_SSLeay(void); const RSA_METHOD *RSA_null_method(void); +int RSA_pkey_ctx_ctrl(EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, void *p2); + RSA *d2i_RSAPublicKey(RSA **a, const unsigned char **in, long len); int i2d_RSAPublicKey(const RSA *a, unsigned char **out); extern const ASN1_ITEM RSAPublicKey_it; diff --git a/lib/libcrypto/rsa/rsa_lib.c b/lib/libcrypto/rsa/rsa_lib.c index 84e1dc7eaf7..bf6865d2606 100644 --- a/lib/libcrypto/rsa/rsa_lib.c +++ b/lib/libcrypto/rsa/rsa_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_lib.c,v 1.37 2018/04/14 07:09:21 tb Exp $ */ +/* $OpenBSD: rsa_lib.c,v 1.38 2019/10/24 15:47:15 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -63,9 +63,12 @@ #include <openssl/bn.h> #include <openssl/crypto.h> #include <openssl/err.h> +#include <openssl/evp.h> #include <openssl/lhash.h> #include <openssl/rsa.h> +#include "evp_locl.h" + #ifndef OPENSSL_NO_ENGINE #include <openssl/engine.h> #endif @@ -365,3 +368,15 @@ RSA_set_flags(RSA *r, int flags) { r->flags |= flags; } + +int +RSA_pkey_ctx_ctrl(EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, void *p2) +{ + /* Return an error if the key type is not RSA or RSA-PSS. */ + if (ctx != NULL && ctx->pmeth != NULL && + ctx->pmeth->pkey_id != EVP_PKEY_RSA && + ctx->pmeth->pkey_id != EVP_PKEY_RSA_PSS) + return -1; + + return EVP_PKEY_CTX_ctrl(ctx, -1, optype, cmd, p1, p2); +} |