summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/rsa/rsa_sign.c
diff options
context:
space:
mode:
authordjm <>2018-09-05 00:55:33 +0000
committerdjm <>2018-09-05 00:55:33 +0000
commit500c35c4f020d87efbd1b5f638d51d78cce1b5ea (patch)
treee041735a97a92c3a22eab8257b329a2e73d4f9b0 /src/lib/libcrypto/rsa/rsa_sign.c
parenta707e9b3b7839a52fa4e75b9c174d23c7dd8b683 (diff)
downloadopenbsd-500c35c4f020d87efbd1b5f638d51d78cce1b5ea.tar.gz
openbsd-500c35c4f020d87efbd1b5f638d51d78cce1b5ea.tar.bz2
openbsd-500c35c4f020d87efbd1b5f638d51d78cce1b5ea.zip
use timing-safe compares for checking results in signature verification
(there are no known attacks, this is just inexpensive prudence) feedback and ok tb@ jsing@
Diffstat (limited to 'src/lib/libcrypto/rsa/rsa_sign.c')
-rw-r--r--src/lib/libcrypto/rsa/rsa_sign.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_sign.c b/src/lib/libcrypto/rsa/rsa_sign.c
index 2383259dda..50e07f4f1e 100644
--- a/src/lib/libcrypto/rsa/rsa_sign.c
+++ b/src/lib/libcrypto/rsa/rsa_sign.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_sign.c,v 1.30 2018/07/23 17:37:17 tb Exp $ */ 1/* $OpenBSD: rsa_sign.c,v 1.31 2018/09/05 00:55:33 djm 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 *
@@ -214,7 +214,8 @@ int_rsa_verify(int type, const unsigned char *m, unsigned int m_len,
214 RSAerror(RSA_R_INVALID_MESSAGE_LENGTH); 214 RSAerror(RSA_R_INVALID_MESSAGE_LENGTH);
215 goto err; 215 goto err;
216 } 216 }
217 if (memcmp(decrypt_buf, m, SSL_SIG_LENGTH) != 0) { 217 if (timingsafe_bcmp(decrypt_buf,
218 m, SSL_SIG_LENGTH) != 0) {
218 RSAerror(RSA_R_BAD_SIGNATURE); 219 RSAerror(RSA_R_BAD_SIGNATURE);
219 goto err; 220 goto err;
220 } 221 }
@@ -244,7 +245,7 @@ int_rsa_verify(int type, const unsigned char *m, unsigned int m_len,
244 goto err; 245 goto err;
245 246
246 if (encoded_len != decrypt_len || 247 if (encoded_len != decrypt_len ||
247 memcmp(encoded, decrypt_buf, encoded_len) != 0) { 248 timingsafe_bcmp(encoded, decrypt_buf, encoded_len) != 0) {
248 RSAerror(RSA_R_BAD_SIGNATURE); 249 RSAerror(RSA_R_BAD_SIGNATURE);
249 goto err; 250 goto err;
250 } 251 }