summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2015-03-26 07:00:04 +0000
committerDamien Miller <djm@mindrot.org>2015-03-27 12:02:27 +1100
commitf9b78852379b74a2d14e6fc94fe52af30b7e9c31 (patch)
tree8e6c292cf61656a0be2f744be2155956f0142fbf
parentb8afbe2c1aaf573565e4da775261dfafc8b1ba9c (diff)
upstream commit
ban all-zero curve25519 keys as recommended by latest CFRG curves draft; ok markus
-rw-r--r--kexc25519.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/kexc25519.c b/kexc25519.c
index b6e6c4010..8d8cd4a2b 100644
--- a/kexc25519.c
+++ b/kexc25519.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexc25519.c,v 1.8 2015/01/19 20:16:15 markus Exp $ */ 1/* $OpenBSD: kexc25519.c,v 1.9 2015/03/26 07:00:04 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001, 2013 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001, 2013 Markus Friedl. All rights reserved.
4 * Copyright (c) 2010 Damien Miller. All rights reserved. 4 * Copyright (c) 2010 Damien Miller. All rights reserved.
@@ -66,6 +66,11 @@ kexc25519_shared_key(const u_char key[CURVE25519_SIZE],
66 u_char shared_key[CURVE25519_SIZE]; 66 u_char shared_key[CURVE25519_SIZE];
67 int r; 67 int r;
68 68
69 /* Check for all-zero public key */
70 explicit_bzero(shared_key, CURVE25519_SIZE);
71 if (timingsafe_bcmp(pub, shared_key, CURVE25519_SIZE) == 0)
72 return SSH_ERR_KEY_INVALID_EC_VALUE;
73
69 crypto_scalarmult_curve25519(shared_key, key, pub); 74 crypto_scalarmult_curve25519(shared_key, key, pub);
70#ifdef DEBUG_KEXECDH 75#ifdef DEBUG_KEXECDH
71 dump_digest("shared secret", shared_key, CURVE25519_SIZE); 76 dump_digest("shared secret", shared_key, CURVE25519_SIZE);