summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2019-10-24 15:47:15 +0000
committerjsing <>2019-10-24 15:47:15 +0000
commit50e5605acbcc6e6bf44f795b6e2747dbecef349d (patch)
treee97555b995bdb0199ee9fe306f2b474d1305fa88
parentef4abacfcb7c75a1b082fb154737c8d3af8f14ab (diff)
downloadopenbsd-50e5605acbcc6e6bf44f795b6e2747dbecef349d.tar.gz
openbsd-50e5605acbcc6e6bf44f795b6e2747dbecef349d.tar.bz2
openbsd-50e5605acbcc6e6bf44f795b6e2747dbecef349d.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@
-rw-r--r--src/lib/libcrypto/Symbols.list1
-rw-r--r--src/lib/libcrypto/rsa/rsa.h4
-rw-r--r--src/lib/libcrypto/rsa/rsa_lib.c17
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
2356RSA_padding_check_PKCS1_type_2 2356RSA_padding_check_PKCS1_type_2
2357RSA_padding_check_X931 2357RSA_padding_check_X931
2358RSA_padding_check_none 2358RSA_padding_check_none
2359RSA_pkey_ctx_ctrl
2359RSA_print 2360RSA_print
2360RSA_print_fp 2361RSA_print_fp
2361RSA_private_decrypt 2362RSA_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 @@
1/* $OpenBSD: rsa.h,v 1.40 2019/06/05 15:41:33 gilles Exp $ */ 1/* $OpenBSD: rsa.h,v 1.41 2019/10/24 15:47:15 jsing 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 *
@@ -294,6 +294,8 @@ const RSA_METHOD *RSA_PKCS1_SSLeay(void);
294 294
295const RSA_METHOD *RSA_null_method(void); 295const RSA_METHOD *RSA_null_method(void);
296 296
297int RSA_pkey_ctx_ctrl(EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, void *p2);
298
297RSA *d2i_RSAPublicKey(RSA **a, const unsigned char **in, long len); 299RSA *d2i_RSAPublicKey(RSA **a, const unsigned char **in, long len);
298int i2d_RSAPublicKey(const RSA *a, unsigned char **out); 300int i2d_RSAPublicKey(const RSA *a, unsigned char **out);
299extern const ASN1_ITEM RSAPublicKey_it; 301extern 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 @@
1/* $OpenBSD: rsa_lib.c,v 1.37 2018/04/14 07:09:21 tb Exp $ */ 1/* $OpenBSD: rsa_lib.c,v 1.38 2019/10/24 15:47:15 jsing 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 *
@@ -63,9 +63,12 @@
63#include <openssl/bn.h> 63#include <openssl/bn.h>
64#include <openssl/crypto.h> 64#include <openssl/crypto.h>
65#include <openssl/err.h> 65#include <openssl/err.h>
66#include <openssl/evp.h>
66#include <openssl/lhash.h> 67#include <openssl/lhash.h>
67#include <openssl/rsa.h> 68#include <openssl/rsa.h>
68 69
70#include "evp_locl.h"
71
69#ifndef OPENSSL_NO_ENGINE 72#ifndef OPENSSL_NO_ENGINE
70#include <openssl/engine.h> 73#include <openssl/engine.h>
71#endif 74#endif
@@ -365,3 +368,15 @@ RSA_set_flags(RSA *r, int flags)
365{ 368{
366 r->flags |= flags; 369 r->flags |= flags;
367} 370}
371
372int
373RSA_pkey_ctx_ctrl(EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, void *p2)
374{
375 /* Return an error if the key type is not RSA or RSA-PSS. */
376 if (ctx != NULL && ctx->pmeth != NULL &&
377 ctx->pmeth->pkey_id != EVP_PKEY_RSA &&
378 ctx->pmeth->pkey_id != EVP_PKEY_RSA_PSS)
379 return -1;
380
381 return EVP_PKEY_CTX_ctrl(ctx, -1, optype, cmd, p1, p2);
382}