]> andersk Git - openssh.git/commitdiff
- Merged OpenBSD CVS changes:
authordamien <damien>
Mon, 8 Nov 1999 23:35:52 +0000 (23:35 +0000)
committerdamien <damien>
Mon, 8 Nov 1999 23:35:52 +0000 (23:35 +0000)
   - [rsa.c] bugfix: use correct size for memset()
   - [sshconnect.c] warn if announced size of modulus 'n' != real size

ChangeLog
rsa.c
sshconnect.c

index 368f1f6745c9f72a89e231c7eb958ff96c2f8ffb..47f90bc2fcfffe8d3e6f5fce23408df260cf9960 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,9 @@
  - Integrated Makefile patch from Niels Kristian Bech Jensen <nkbj@image.dk>
  - Autodetection of RSAref library for US users
  - Minor doc updates
+ - Merged OpenBSD CVS changes:
+   - [rsa.c] bugfix: use correct size for memset()
+   - [sshconnect.c] warn if announced size of modulus 'n' != real size
 
 19991108
  - Removed debian/ directory. This is now being maintained separately.
diff --git a/rsa.c b/rsa.c
index 77002d18c9cb681fd7aee3f8a75542a1824d694f..def0ec18bbb64e6176d40f77faeb437c89e550e5 100644 (file)
--- a/rsa.c
+++ b/rsa.c
@@ -110,28 +110,26 @@ void
 rsa_public_encrypt(BIGNUM *out, BIGNUM *in, RSA* key)
 {
   char *inbuf, *outbuf;
-  int in_len;
-  int out_len;
-  int len;
+  int len, ilen, olen;
 
   if (BN_num_bits(key->e) < 2 || !BN_is_odd(key->e))
     fatal("rsa_public_encrypt() exponent too small or not odd");
 
-  out_len = BN_num_bytes(key->n);
-  outbuf = xmalloc(out_len);
+  olen = BN_num_bytes(key->n);
+  outbuf = xmalloc(olen);
 
-  in_len = BN_num_bytes(in);
-  inbuf = xmalloc(in_len);
+  ilen = BN_num_bytes(in);
+  inbuf = xmalloc(ilen);
   BN_bn2bin(in, inbuf);
 
-  if ((len = RSA_public_encrypt(in_len, inbuf, outbuf, key,
+  if ((len = RSA_public_encrypt(ilen, inbuf, outbuf, key,
                                RSA_PKCS1_PADDING)) <= 0)
     fatal("rsa_public_encrypt() failed");
 
   BN_bin2bn(outbuf, len, out);
 
-  memset(outbuf, 0, out_len);
-  memset(inbuf, 0, in_len);
+  memset(outbuf, 0, olen);
+  memset(inbuf, 0, ilen);
   xfree(outbuf);
   xfree(inbuf);
 }
@@ -140,25 +138,23 @@ void
 rsa_private_decrypt(BIGNUM *out, BIGNUM *in, RSA *key)
 {
   char *inbuf, *outbuf;
-  int in_len;
-  int out_len;
-  int len;
+  int len, ilen, olen;
 
-  out_len = BN_num_bytes(key->n);
-  outbuf = xmalloc(out_len);
+  olen = BN_num_bytes(key->n);
+  outbuf = xmalloc(olen);
 
-  in_len = BN_num_bytes(in);
-  inbuf = xmalloc(in_len);
+  ilen = BN_num_bytes(in);
+  inbuf = xmalloc(ilen);
   BN_bn2bin(in, inbuf);
 
-  if ((len = RSA_private_decrypt(in_len, inbuf, outbuf, key,
+  if ((len = RSA_private_decrypt(ilen, inbuf, outbuf, key,
                                 RSA_SSLV23_PADDING)) <= 0)
     fatal("rsa_private_decrypt() failed");
 
   BN_bin2bn(outbuf, len, out);
 
-  memset(outbuf, 0, out_len);
-  memset(inbuf, 0, in_len);
+  memset(outbuf, 0, olen);
+  memset(inbuf, 0, ilen);
   xfree(outbuf);
   xfree(inbuf);
 }
index 7ae49101d61267e06266be8abca2007a7165ad63..2d7a1b5e7914c686fdac23ae0a19865b635d90d1 100644 (file)
@@ -1022,6 +1022,7 @@ void ssh_login(int host_key_valid,
   BIGNUM *key;
   RSA *host_key, *file_key;
   RSA *public_key;
+  int bits, rbits;
   unsigned char session_key[SSH_SESSION_KEY_LENGTH];
   const char *server_user, *local_user;
   char *cp, *host, *ip = NULL;
@@ -1068,7 +1069,7 @@ void ssh_login(int host_key_valid,
 
   /* Get the public key. */
   public_key = RSA_new();
-  packet_get_int();    /* bits */
+  bits = packet_get_int();     /* bits */
   public_key->e = BN_new();
   packet_get_bignum(public_key->e, &clen);
   sum_len += clen;
@@ -1076,9 +1077,16 @@ void ssh_login(int host_key_valid,
   packet_get_bignum(public_key->n, &clen);
   sum_len += clen;
 
+  rbits = BN_num_bits(public_key->n);
+  if (bits != rbits) {
+    log("Warning: Server lies about size of server public key,");
+    log("Warning: this may be due to an old implementation of ssh.");
+    log("Warning: (actual size %d bits, announced size %d bits)", rbits, bits);
+  }
+
   /* Get the host key. */
   host_key = RSA_new();
-  packet_get_int();    /* bits */
+  bits = packet_get_int();     /* bits */
   host_key->e = BN_new();
   packet_get_bignum(host_key->e, &clen);
   sum_len += clen;
@@ -1086,6 +1094,13 @@ void ssh_login(int host_key_valid,
   packet_get_bignum(host_key->n, &clen);
   sum_len += clen;
 
+  rbits = BN_num_bits(host_key->n);
+  if (bits != rbits) {
+    log("Warning: Server lies about size of server host key,");
+    log("Warning: this may be due to an old implementation of ssh.");
+    log("Warning: (actual size %d bits, announced size %d bits)", rbits, bits);
+  }
+
   /* Store the host key from the known host file in here
    * so that we can compare it with the key for the IP
    * address. */
This page took 0.064082 seconds and 5 git commands to generate.