From 50e5605acbcc6e6bf44f795b6e2747dbecef349d Mon Sep 17 00:00:00 2001 From: jsing <> Date: Thu, 24 Oct 2019 15:47:15 +0000 Subject: 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@ --- src/lib/libcrypto/Symbols.list | 1 + src/lib/libcrypto/rsa/rsa.h | 4 +++- src/lib/libcrypto/rsa/rsa_lib.c | 17 ++++++++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list index e56bb9ca5c..4ec01fe9c8 100644 --- a/src/lib/libcrypto/Symbols.list +++ b/src/lib/libcrypto/Symbols.list @@ -2356,6 +2356,7 @@ RSA_padding_check_PKCS1_type_1 RSA_padding_check_PKCS1_type_2 RSA_padding_check_X931 RSA_padding_check_none +RSA_pkey_ctx_ctrl RSA_print RSA_print_fp RSA_private_decrypt diff --git a/src/lib/libcrypto/rsa/rsa.h b/src/lib/libcrypto/rsa/rsa.h index 2aa472f501..1672297266 100644 --- a/src/lib/libcrypto/rsa/rsa.h +++ b/src/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/src/lib/libcrypto/rsa/rsa_lib.c b/src/lib/libcrypto/rsa/rsa_lib.c index 84e1dc7eaf..bf6865d260 100644 --- a/src/lib/libcrypto/rsa/rsa_lib.c +++ b/src/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 #include #include +#include #include #include +#include "evp_locl.h" + #ifndef OPENSSL_NO_ENGINE #include #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); +} -- cgit v1.2.3-55-g6feb