diff options
author | Colin Watson <cjwatson@debian.org> | 2014-10-07 13:33:15 +0100 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2014-10-07 14:27:30 +0100 |
commit | f0b009aea83e9ff3a50be30f51012099a5143c16 (patch) | |
tree | 3825e6f7e3b7ea4481d06ed89aba9a7a95150df5 /cipher-chachapoly.c | |
parent | 47f0bad4330b16ec3bad870fcf9839c196e42c12 (diff) | |
parent | 762c062828f5a8f6ed189ed6e44ad38fd92f8b36 (diff) |
Merge 6.7p1.
* New upstream release (http://www.openssh.com/txt/release-6.7):
- sshd(8): The default set of ciphers and MACs has been altered to
remove unsafe algorithms. In particular, CBC ciphers and arcfour* are
disabled by default. The full set of algorithms remains available if
configured explicitly via the Ciphers and MACs sshd_config options.
- ssh(1), sshd(8): Add support for Unix domain socket forwarding. A
remote TCP port may be forwarded to a local Unix domain socket and
vice versa or both ends may be a Unix domain socket (closes: #236718).
- ssh(1), ssh-keygen(1): Add support for SSHFP DNS records for ED25519
key types.
- sftp(1): Allow resumption of interrupted uploads.
- ssh(1): When rekeying, skip file/DNS lookups of the hostkey if it is
the same as the one sent during initial key exchange.
- sshd(8): Allow explicit ::1 and 127.0.0.1 forwarding bind addresses
when GatewayPorts=no; allows client to choose address family.
- sshd(8): Add a sshd_config PermitUserRC option to control whether
~/.ssh/rc is executed, mirroring the no-user-rc authorized_keys
option.
- ssh(1): Add a %C escape sequence for LocalCommand and ControlPath that
expands to a unique identifer based on a hash of the tuple of (local
host, remote user, hostname, port). Helps avoid exceeding miserly
pathname limits for Unix domain sockets in multiplexing control paths.
- sshd(8): Make the "Too many authentication failures" message include
the user, source address, port and protocol in a format similar to the
authentication success / failure messages.
- Use CLOCK_BOOTTIME in preference to CLOCK_MONOTONIC when it is
available. It considers time spent suspended, thereby ensuring
timeouts (e.g. for expiring agent keys) fire correctly (closes:
#734553).
- Use prctl() to prevent sftp-server from accessing
/proc/self/{mem,maps}.
* Restore TCP wrappers support, removed upstream in 6.7. It is true that
dropping this reduces preauth attack surface in sshd. On the other
hand, this support seems to be quite widely used, and abruptly dropping
it (from the perspective of users who don't read openssh-unix-dev) could
easily cause more serious problems in practice. It's not entirely clear
what the right long-term answer for Debian is, but it at least probably
doesn't involve dropping this feature shortly before a freeze.
* Replace patch to disable OpenSSL version check with an updated version
of Kurt Roeckx's patch from #732940 to just avoid checking the status
field.
Diffstat (limited to 'cipher-chachapoly.c')
-rw-r--r-- | cipher-chachapoly.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/cipher-chachapoly.c b/cipher-chachapoly.c index 251b94ec8..8665b41a3 100644 --- a/cipher-chachapoly.c +++ b/cipher-chachapoly.c | |||
@@ -14,7 +14,7 @@ | |||
14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | /* $OpenBSD: cipher-chachapoly.c,v 1.4 2014/01/31 16:39:19 tedu Exp $ */ | 17 | /* $OpenBSD: cipher-chachapoly.c,v 1.6 2014/07/03 12:42:16 jsing Exp $ */ |
18 | 18 | ||
19 | #include "includes.h" | 19 | #include "includes.h" |
20 | 20 | ||
@@ -24,16 +24,18 @@ | |||
24 | #include <stdio.h> /* needed for misc.h */ | 24 | #include <stdio.h> /* needed for misc.h */ |
25 | 25 | ||
26 | #include "log.h" | 26 | #include "log.h" |
27 | #include "misc.h" | 27 | #include "sshbuf.h" |
28 | #include "ssherr.h" | ||
28 | #include "cipher-chachapoly.h" | 29 | #include "cipher-chachapoly.h" |
29 | 30 | ||
30 | void chachapoly_init(struct chachapoly_ctx *ctx, | 31 | int chachapoly_init(struct chachapoly_ctx *ctx, |
31 | const u_char *key, u_int keylen) | 32 | const u_char *key, u_int keylen) |
32 | { | 33 | { |
33 | if (keylen != (32 + 32)) /* 2 x 256 bit keys */ | 34 | if (keylen != (32 + 32)) /* 2 x 256 bit keys */ |
34 | fatal("%s: invalid keylen %u", __func__, keylen); | 35 | return SSH_ERR_INVALID_ARGUMENT; |
35 | chacha_keysetup(&ctx->main_ctx, key, 256); | 36 | chacha_keysetup(&ctx->main_ctx, key, 256); |
36 | chacha_keysetup(&ctx->header_ctx, key + 32, 256); | 37 | chacha_keysetup(&ctx->header_ctx, key + 32, 256); |
38 | return 0; | ||
37 | } | 39 | } |
38 | 40 | ||
39 | /* | 41 | /* |
@@ -52,33 +54,37 @@ chachapoly_crypt(struct chachapoly_ctx *ctx, u_int seqnr, u_char *dest, | |||
52 | u_char seqbuf[8]; | 54 | u_char seqbuf[8]; |
53 | const u_char one[8] = { 1, 0, 0, 0, 0, 0, 0, 0 }; /* NB little-endian */ | 55 | const u_char one[8] = { 1, 0, 0, 0, 0, 0, 0, 0 }; /* NB little-endian */ |
54 | u_char expected_tag[POLY1305_TAGLEN], poly_key[POLY1305_KEYLEN]; | 56 | u_char expected_tag[POLY1305_TAGLEN], poly_key[POLY1305_KEYLEN]; |
55 | int r = -1; | 57 | int r = SSH_ERR_INTERNAL_ERROR; |
56 | 58 | ||
57 | /* | 59 | /* |
58 | * Run ChaCha20 once to generate the Poly1305 key. The IV is the | 60 | * Run ChaCha20 once to generate the Poly1305 key. The IV is the |
59 | * packet sequence number. | 61 | * packet sequence number. |
60 | */ | 62 | */ |
61 | memset(poly_key, 0, sizeof(poly_key)); | 63 | memset(poly_key, 0, sizeof(poly_key)); |
62 | put_u64(seqbuf, seqnr); | 64 | POKE_U64(seqbuf, seqnr); |
63 | chacha_ivsetup(&ctx->main_ctx, seqbuf, NULL); | 65 | chacha_ivsetup(&ctx->main_ctx, seqbuf, NULL); |
64 | chacha_encrypt_bytes(&ctx->main_ctx, | 66 | chacha_encrypt_bytes(&ctx->main_ctx, |
65 | poly_key, poly_key, sizeof(poly_key)); | 67 | poly_key, poly_key, sizeof(poly_key)); |
66 | /* Set Chacha's block counter to 1 */ | ||
67 | chacha_ivsetup(&ctx->main_ctx, seqbuf, one); | ||
68 | 68 | ||
69 | /* If decrypting, check tag before anything else */ | 69 | /* If decrypting, check tag before anything else */ |
70 | if (!do_encrypt) { | 70 | if (!do_encrypt) { |
71 | const u_char *tag = src + aadlen + len; | 71 | const u_char *tag = src + aadlen + len; |
72 | 72 | ||
73 | poly1305_auth(expected_tag, src, aadlen + len, poly_key); | 73 | poly1305_auth(expected_tag, src, aadlen + len, poly_key); |
74 | if (timingsafe_bcmp(expected_tag, tag, POLY1305_TAGLEN) != 0) | 74 | if (timingsafe_bcmp(expected_tag, tag, POLY1305_TAGLEN) != 0) { |
75 | r = SSH_ERR_MAC_INVALID; | ||
75 | goto out; | 76 | goto out; |
77 | } | ||
76 | } | 78 | } |
79 | |||
77 | /* Crypt additional data */ | 80 | /* Crypt additional data */ |
78 | if (aadlen) { | 81 | if (aadlen) { |
79 | chacha_ivsetup(&ctx->header_ctx, seqbuf, NULL); | 82 | chacha_ivsetup(&ctx->header_ctx, seqbuf, NULL); |
80 | chacha_encrypt_bytes(&ctx->header_ctx, src, dest, aadlen); | 83 | chacha_encrypt_bytes(&ctx->header_ctx, src, dest, aadlen); |
81 | } | 84 | } |
85 | |||
86 | /* Set Chacha's block counter to 1 */ | ||
87 | chacha_ivsetup(&ctx->main_ctx, seqbuf, one); | ||
82 | chacha_encrypt_bytes(&ctx->main_ctx, src + aadlen, | 88 | chacha_encrypt_bytes(&ctx->main_ctx, src + aadlen, |
83 | dest + aadlen, len); | 89 | dest + aadlen, len); |
84 | 90 | ||
@@ -88,7 +94,6 @@ chachapoly_crypt(struct chachapoly_ctx *ctx, u_int seqnr, u_char *dest, | |||
88 | poly_key); | 94 | poly_key); |
89 | } | 95 | } |
90 | r = 0; | 96 | r = 0; |
91 | |||
92 | out: | 97 | out: |
93 | explicit_bzero(expected_tag, sizeof(expected_tag)); | 98 | explicit_bzero(expected_tag, sizeof(expected_tag)); |
94 | explicit_bzero(seqbuf, sizeof(seqbuf)); | 99 | explicit_bzero(seqbuf, sizeof(seqbuf)); |
@@ -104,11 +109,11 @@ chachapoly_get_length(struct chachapoly_ctx *ctx, | |||
104 | u_char buf[4], seqbuf[8]; | 109 | u_char buf[4], seqbuf[8]; |
105 | 110 | ||
106 | if (len < 4) | 111 | if (len < 4) |
107 | return -1; /* Insufficient length */ | 112 | return SSH_ERR_MESSAGE_INCOMPLETE; |
108 | put_u64(seqbuf, seqnr); | 113 | POKE_U64(seqbuf, seqnr); |
109 | chacha_ivsetup(&ctx->header_ctx, seqbuf, NULL); | 114 | chacha_ivsetup(&ctx->header_ctx, seqbuf, NULL); |
110 | chacha_encrypt_bytes(&ctx->header_ctx, cp, buf, 4); | 115 | chacha_encrypt_bytes(&ctx->header_ctx, cp, buf, 4); |
111 | *plenp = get_u32(buf); | 116 | *plenp = PEEK_U32(buf); |
112 | return 0; | 117 | return 0; |
113 | } | 118 | } |
114 | 119 | ||