]> andersk Git - openssh.git/blobdiff - sshconnect.c
Merged OpenBSD CVS changes that go away
[openssh.git] / sshconnect.c
index 8d74aae182447d895c6b07eb99d08c3d9330102d..7ae49101d61267e06266be8abca2007a7165ad63 100644 (file)
@@ -457,7 +457,10 @@ respond_to_rsa_challenge(BIGNUM *challenge, RSA *prv)
   /* Compute the response. */
   /* The response is MD5 of decrypted challenge plus session id. */
   len = BN_num_bytes(challenge);
-  assert(len <= sizeof(buf) && len);
+  if (len <= 0 || len > sizeof(buf))
+    packet_disconnect("respond_to_rsa_challenge: bad challenge length %d",
+                     len);
+
   memset(buf, 0, sizeof(buf));
   BN_bn2bin(challenge, buf + sizeof(buf) - len);
   MD5_Init(&md);
@@ -1298,8 +1301,14 @@ void ssh_login(int host_key_valid,
   if (BN_cmp(public_key->n, host_key->n) < 0)
     {
       /* Public key has smaller modulus. */
-      assert(BN_num_bits(host_key->n) >= 
-            BN_num_bits(public_key->n) + SSH_KEY_BITS_RESERVED);
+      if (BN_num_bits(host_key->n) < 
+         BN_num_bits(public_key->n) + SSH_KEY_BITS_RESERVED) {
+        fatal("respond_to_rsa_challenge: host_key %d < public_key %d + "
+             "SSH_KEY_BITS_RESERVED %d",
+             BN_num_bits(host_key->n),
+              BN_num_bits(public_key->n),
+             SSH_KEY_BITS_RESERVED);
+      }
 
       rsa_public_encrypt(key, key, public_key);
       rsa_public_encrypt(key, key, host_key);
@@ -1307,8 +1316,14 @@ void ssh_login(int host_key_valid,
   else
     {
       /* Host key has smaller modulus (or they are equal). */
-      assert(BN_num_bits(public_key->n) >=
-            BN_num_bits(host_key->n) + SSH_KEY_BITS_RESERVED);
+      if (BN_num_bits(public_key->n) < 
+         BN_num_bits(host_key->n) + SSH_KEY_BITS_RESERVED) {
+        fatal("respond_to_rsa_challenge: public_key %d < host_key %d + "
+             "SSH_KEY_BITS_RESERVED %d",
+             BN_num_bits(public_key->n),
+              BN_num_bits(host_key->n),
+             SSH_KEY_BITS_RESERVED);
+      }
 
       rsa_public_encrypt(key, key, host_key);
       rsa_public_encrypt(key, key, public_key);
This page took 1.651864 seconds and 4 git commands to generate.