aboutsummaryrefslogtreecommitdiff
path: root/lib/hcrypto/rsa.c
diff options
context:
space:
mode:
authorCy Schubert <cy@FreeBSD.org>2023-06-26 22:56:52 +0000
committerCy Schubert <cy@FreeBSD.org>2023-06-26 22:56:52 +0000
commitb6a943f7197af1a5eb6bb028b9b808ec5016e30c (patch)
treecfbb91e940dd89d0e1d46095f43c228d7d079fa0 /lib/hcrypto/rsa.c
parent6f4e10db3298f6d65e1e646fe52aaafc3682b788 (diff)
Heimdal 7.8.0 does not support OpenSSL 3.0. 7.9.0 will but it hasn't been released yet. We are importing f62e2f278 for its OpenSSL 3.0 support.
Diffstat (limited to 'lib/hcrypto/rsa.c')
-rw-r--r--lib/hcrypto/rsa.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/hcrypto/rsa.c b/lib/hcrypto/rsa.c
index c99b2b6cbe95..31470d0069a3 100644
--- a/lib/hcrypto/rsa.c
+++ b/lib/hcrypto/rsa.c
@@ -114,7 +114,7 @@ RSA_new_method(ENGINE *engine)
if (rsa->engine) {
rsa->meth = ENGINE_get_RSA(rsa->engine);
if (rsa->meth == NULL) {
- ENGINE_finish(engine);
+ ENGINE_finish(rsa->engine);
free(rsa);
return 0;
}
@@ -160,7 +160,7 @@ RSA_free(RSA *rsa)
free_if(rsa->iqmp);
#undef free_if
- memset(rsa, 0, sizeof(*rsa));
+ memset_s(rsa, sizeof(*rsa), 0, sizeof(*rsa));
free(rsa);
}
@@ -272,7 +272,10 @@ RSA_check_key(const RSA *key)
* and then decrypt/verify.
*/
- if ((rsa->d == NULL || rsa->n == NULL) &&
+ if (rsa->n == NULL)
+ return 0;
+
+ if (rsa->d == NULL &&
(rsa->p == NULL || rsa->q || rsa->dmp1 == NULL || rsa->dmq1 == NULL || rsa->iqmp == NULL))
return 0;
@@ -423,7 +426,7 @@ RSA_verify(int type, const unsigned char *from, unsigned int flen,
return -4;
}
- if (flen != di.digest.length || memcmp(di.digest.data, from, flen) != 0) {
+ if (flen != di.digest.length || ct_memcmp(di.digest.data, from, flen) != 0) {
free_DigestInfo(&di);
return -5;
}