|
| 1 | +$NetBSD$ |
| 2 | + |
| 3 | +Fedora openssh-7.3p1-openssl-1.1.0.patch |
| 4 | + |
| 5 | +--- authfd.c.orig 2020-11-11 11:16:04.000000000 +0000 |
| 6 | ++++ authfd.c |
| 7 | +@@ -207,15 +207,22 @@ deserialise_identity1(struct sshbuf *ids |
| 8 | + int r, keybits; |
| 9 | + u_int32_t bits; |
| 10 | + char *comment = NULL; |
| 11 | ++ BIGNUM *e = NULL, *n = NULL; |
| 12 | + |
| 13 | + if ((key = sshkey_new(KEY_RSA1)) == NULL) |
| 14 | + return SSH_ERR_ALLOC_FAIL; |
| 15 | +- if ((r = sshbuf_get_u32(ids, &bits)) != 0 || |
| 16 | +- (r = sshbuf_get_bignum1(ids, key->rsa->e)) != 0 || |
| 17 | +- (r = sshbuf_get_bignum1(ids, key->rsa->n)) != 0 || |
| 18 | +- (r = sshbuf_get_cstring(ids, &comment, NULL)) != 0) |
| 19 | ++ if ((e = BN_new()) == NULL || |
| 20 | ++ (n = BN_new()) == NULL || |
| 21 | ++ (r = sshbuf_get_u32(ids, &bits)) != 0 || |
| 22 | ++ (r = sshbuf_get_bignum1(ids, e)) != 0 || |
| 23 | ++ (r = sshbuf_get_bignum1(ids, n)) != 0 || |
| 24 | ++ (r = sshbuf_get_cstring(ids, &comment, NULL)) != 0 || |
| 25 | ++ (RSA_set0_key(key->rsa, n, e, NULL) == 0)) { |
| 26 | ++ BN_free(n); |
| 27 | ++ BN_free(e); |
| 28 | + goto out; |
| 29 | +- keybits = BN_num_bits(key->rsa->n); |
| 30 | ++ } |
| 31 | ++ keybits = BN_num_bits(n); |
| 32 | + /* XXX previously we just warned here. I think we should be strict */ |
| 33 | + if (keybits < 0 || bits != (u_int)keybits) { |
| 34 | + r = SSH_ERR_KEY_BITS_MISMATCH; |
| 35 | +@@ -393,15 +400,17 @@ ssh_decrypt_challenge(int sock, struct s |
| 36 | + struct sshbuf *msg; |
| 37 | + int r; |
| 38 | + u_char type; |
| 39 | ++ const BIGNUM *e, *n; |
| 40 | + |
| 41 | + if (key->type != KEY_RSA1) |
| 42 | + return SSH_ERR_INVALID_ARGUMENT; |
| 43 | + if ((msg = sshbuf_new()) == NULL) |
| 44 | + return SSH_ERR_ALLOC_FAIL; |
| 45 | ++ RSA_get0_key(key->rsa, &n, &e, NULL); |
| 46 | + if ((r = sshbuf_put_u8(msg, SSH_AGENTC_RSA_CHALLENGE)) != 0 || |
| 47 | +- (r = sshbuf_put_u32(msg, BN_num_bits(key->rsa->n))) != 0 || |
| 48 | +- (r = sshbuf_put_bignum1(msg, key->rsa->e)) != 0 || |
| 49 | +- (r = sshbuf_put_bignum1(msg, key->rsa->n)) != 0 || |
| 50 | ++ (r = sshbuf_put_u32(msg, BN_num_bits(n))) != 0 || |
| 51 | ++ (r = sshbuf_put_bignum1(msg, e)) != 0 || |
| 52 | ++ (r = sshbuf_put_bignum1(msg, n)) != 0 || |
| 53 | + (r = sshbuf_put_bignum1(msg, challenge)) != 0 || |
| 54 | + (r = sshbuf_put(msg, session_id, 16)) != 0 || |
| 55 | + (r = sshbuf_put_u32(msg, 1)) != 0) /* Response type for proto 1.1 */ |
| 56 | +@@ -499,15 +508,19 @@ static int |
| 57 | + ssh_encode_identity_rsa1(struct sshbuf *b, RSA *key, const char *comment) |
| 58 | + { |
| 59 | + int r; |
| 60 | ++ const BIGNUM *n, *e, *d, *q, *p, *iqmp; |
| 61 | + |
| 62 | ++ RSA_get0_key(key, &n, &e, &d); |
| 63 | ++ RSA_get0_factors(key, &p, &q); |
| 64 | ++ RSA_get0_crt_params(key, NULL, NULL, &iqmp); |
| 65 | + /* To keep within the protocol: p < q for ssh. in SSL p > q */ |
| 66 | +- if ((r = sshbuf_put_u32(b, BN_num_bits(key->n))) != 0 || |
| 67 | +- (r = sshbuf_put_bignum1(b, key->n)) != 0 || |
| 68 | +- (r = sshbuf_put_bignum1(b, key->e)) != 0 || |
| 69 | +- (r = sshbuf_put_bignum1(b, key->d)) != 0 || |
| 70 | +- (r = sshbuf_put_bignum1(b, key->iqmp)) != 0 || |
| 71 | +- (r = sshbuf_put_bignum1(b, key->q)) != 0 || |
| 72 | +- (r = sshbuf_put_bignum1(b, key->p)) != 0 || |
| 73 | ++ if ((r = sshbuf_put_u32(b, BN_num_bits(n))) != 0 || |
| 74 | ++ (r = sshbuf_put_bignum1(b, n)) != 0 || |
| 75 | ++ (r = sshbuf_put_bignum1(b, e)) != 0 || |
| 76 | ++ (r = sshbuf_put_bignum1(b, d)) != 0 || |
| 77 | ++ (r = sshbuf_put_bignum1(b, iqmp)) != 0 || |
| 78 | ++ (r = sshbuf_put_bignum1(b, q)) != 0 || |
| 79 | ++ (r = sshbuf_put_bignum1(b, p)) != 0 || |
| 80 | + (r = sshbuf_put_cstring(b, comment)) != 0) |
| 81 | + return r; |
| 82 | + return 0; |
| 83 | +@@ -622,11 +635,13 @@ ssh_remove_identity(int sock, struct ssh |
| 84 | + |
| 85 | + #ifdef WITH_SSH1 |
| 86 | + if (key->type == KEY_RSA1) { |
| 87 | ++ const BIGNUM *e, *n; |
| 88 | ++ RSA_get0_key(key->rsa, &n, &e, NULL); |
| 89 | + if ((r = sshbuf_put_u8(msg, |
| 90 | + SSH_AGENTC_REMOVE_RSA_IDENTITY)) != 0 || |
| 91 | +- (r = sshbuf_put_u32(msg, BN_num_bits(key->rsa->n))) != 0 || |
| 92 | +- (r = sshbuf_put_bignum1(msg, key->rsa->e)) != 0 || |
| 93 | +- (r = sshbuf_put_bignum1(msg, key->rsa->n)) != 0) |
| 94 | ++ (r = sshbuf_put_u32(msg, BN_num_bits(n))) != 0 || |
| 95 | ++ (r = sshbuf_put_bignum1(msg, e)) != 0 || |
| 96 | ++ (r = sshbuf_put_bignum1(msg, n)) != 0) |
| 97 | + goto out; |
| 98 | + } else |
| 99 | + #endif |
0 commit comments