diff options
| author | jsing <> | 2014-06-24 18:12:09 +0000 |
|---|---|---|
| committer | jsing <> | 2014-06-24 18:12:09 +0000 |
| commit | 125ab32227935a33d4c3ef80e58ed8f9d7cfbe8d (patch) | |
| tree | 77b512bc366b09aa3f9194007a50fa04d944872c /src/lib/libcrypto/chacha/chacha.h | |
| parent | 6769d1991fea1c3627ae6df2bf0232cba30798a8 (diff) | |
| download | openbsd-125ab32227935a33d4c3ef80e58ed8f9d7cfbe8d.tar.gz openbsd-125ab32227935a33d4c3ef80e58ed8f9d7cfbe8d.tar.bz2 openbsd-125ab32227935a33d4c3ef80e58ed8f9d7cfbe8d.zip | |
If a chacha operation does not consume all of the generated key stream,
ensure that we save it and consume it on subsequent writes. Otherwise we
end up discarding part of the key stream and instead generate a new block
at the start of the next write.
This was only an issue for callers that did multiple writes that are not
multiples of 64 bytes - in particular, the ChaCha20Poly1305 usage does not
hit this problem since it performs encryption in a single-shot. For the
same reason, this is also a non-issue when openssl(1) is used to encrypt
with ChaCha.
Issue identified by insane coder; reported to bugs@ by Joseph M. Schwartz.
ok beck@
Diffstat (limited to 'src/lib/libcrypto/chacha/chacha.h')
| -rw-r--r-- | src/lib/libcrypto/chacha/chacha.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lib/libcrypto/chacha/chacha.h b/src/lib/libcrypto/chacha/chacha.h index 636770ad99..a221825d9e 100644 --- a/src/lib/libcrypto/chacha/chacha.h +++ b/src/lib/libcrypto/chacha/chacha.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: chacha.h,v 1.4 2014/06/12 15:49:28 deraadt Exp $ */ | 1 | /* $OpenBSD: chacha.h,v 1.5 2014/06/24 18:12:09 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -32,6 +32,8 @@ extern "C" { | |||
| 32 | 32 | ||
| 33 | typedef struct { | 33 | typedef struct { |
| 34 | unsigned int input[16]; | 34 | unsigned int input[16]; |
| 35 | unsigned char ks[64]; | ||
| 36 | unsigned char unused; | ||
| 35 | } ChaCha_ctx; | 37 | } ChaCha_ctx; |
| 36 | 38 | ||
| 37 | void ChaCha_set_key(ChaCha_ctx *ctx, const unsigned char *key, | 39 | void ChaCha_set_key(ChaCha_ctx *ctx, const unsigned char *key, |
