summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2023-12-20 10:14:14 +0000
committertb <>2023-12-20 10:14:14 +0000
commit316b1ed28e5a3c52a29ece57583350d992fbc6c7 (patch)
tree12988ed2dd56c8ca19635ba4d429cab26462e4cf /src
parent06f732c42a4c8787b1b0e1430de5041b9594c882 (diff)
downloadopenbsd-316b1ed28e5a3c52a29ece57583350d992fbc6c7.tar.gz
openbsd-316b1ed28e5a3c52a29ece57583350d992fbc6c7.tar.bz2
openbsd-316b1ed28e5a3c52a29ece57583350d992fbc6c7.zip
Remove preprocessor mess in EVP_PKEY_{de,en}crypt_old()
This was done the worst possible way. It would be much simpler to invert the logic and use a single #ifdef. jsing prefers keeping the current logic and suggested we ditch the preprocessor mess altogether. ok jsing, claudio agreed with the initial diff
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/evp/p_dec.c23
-rw-r--r--src/lib/libcrypto/evp/p_enc.c24
2 files changed, 8 insertions, 39 deletions
diff --git a/src/lib/libcrypto/evp/p_dec.c b/src/lib/libcrypto/evp/p_dec.c
index d55b48b771..2c63fe054e 100644
--- a/src/lib/libcrypto/evp/p_dec.c
+++ b/src/lib/libcrypto/evp/p_dec.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p_dec.c,v 1.15 2023/07/07 19:37:54 beck Exp $ */ 1/* $OpenBSD: p_dec.c,v 1.16 2023/12/20 10:14:14 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 *
@@ -56,18 +56,10 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include <stdio.h>
60
61#include <openssl/opensslconf.h>
62
63#include <openssl/evp.h> 59#include <openssl/evp.h>
64#include <openssl/err.h> 60#include <openssl/err.h>
65#include <openssl/objects.h>
66#include <openssl/x509.h>
67 61
68#ifndef OPENSSL_NO_RSA
69#include <openssl/rsa.h> 62#include <openssl/rsa.h>
70#endif
71 63
72#include "evp_local.h" 64#include "evp_local.h"
73 65
@@ -75,20 +67,11 @@ int
75EVP_PKEY_decrypt_old(unsigned char *key, const unsigned char *ek, int ekl, 67EVP_PKEY_decrypt_old(unsigned char *key, const unsigned char *ek, int ekl,
76 EVP_PKEY *priv) 68 EVP_PKEY *priv)
77{ 69{
78 int ret = -1;
79
80#ifndef OPENSSL_NO_RSA
81 if (priv->type != EVP_PKEY_RSA) { 70 if (priv->type != EVP_PKEY_RSA) {
82#endif
83 EVPerror(EVP_R_PUBLIC_KEY_NOT_RSA); 71 EVPerror(EVP_R_PUBLIC_KEY_NOT_RSA);
84#ifndef OPENSSL_NO_RSA 72 return -1;
85 goto err;
86 } 73 }
87 74
88 ret = RSA_private_decrypt(ekl, ek, key, priv->pkey.rsa, 75 return RSA_private_decrypt(ekl, ek, key, priv->pkey.rsa,
89 RSA_PKCS1_PADDING); 76 RSA_PKCS1_PADDING);
90
91err:
92#endif
93 return (ret);
94} 77}
diff --git a/src/lib/libcrypto/evp/p_enc.c b/src/lib/libcrypto/evp/p_enc.c
index 1abaf0b268..b6346260e5 100644
--- a/src/lib/libcrypto/evp/p_enc.c
+++ b/src/lib/libcrypto/evp/p_enc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p_enc.c,v 1.15 2023/07/07 19:37:54 beck Exp $ */ 1/* $OpenBSD: p_enc.c,v 1.16 2023/12/20 10:14:14 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 *
@@ -56,18 +56,10 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include <stdio.h>
60
61#include <openssl/opensslconf.h>
62
63#include <openssl/err.h> 59#include <openssl/err.h>
64#include <openssl/evp.h> 60#include <openssl/evp.h>
65#include <openssl/objects.h>
66#include <openssl/x509.h>
67 61
68#ifndef OPENSSL_NO_RSA
69#include <openssl/rsa.h> 62#include <openssl/rsa.h>
70#endif
71 63
72#include "evp_local.h" 64#include "evp_local.h"
73 65
@@ -75,17 +67,11 @@ int
75EVP_PKEY_encrypt_old(unsigned char *ek, const unsigned char *key, int key_len, 67EVP_PKEY_encrypt_old(unsigned char *ek, const unsigned char *key, int key_len,
76 EVP_PKEY *pubk) 68 EVP_PKEY *pubk)
77{ 69{
78 int ret = 0;
79
80#ifndef OPENSSL_NO_RSA
81 if (pubk->type != EVP_PKEY_RSA) { 70 if (pubk->type != EVP_PKEY_RSA) {
82#endif
83 EVPerror(EVP_R_PUBLIC_KEY_NOT_RSA); 71 EVPerror(EVP_R_PUBLIC_KEY_NOT_RSA);
84#ifndef OPENSSL_NO_RSA 72 return 0;
85 goto err;
86 } 73 }
87 ret = RSA_public_encrypt(key_len, key, ek, pubk->pkey.rsa, RSA_PKCS1_PADDING); 74
88err: 75 return RSA_public_encrypt(key_len, key, ek, pubk->pkey.rsa,
89#endif 76 RSA_PKCS1_PADDING);
90 return (ret);
91} 77}