Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1284684 > unrolled thread
| Started by | "Jason A. Donenfeld" <Jason@zx2c4.com> |
|---|---|
| First post | 2015-12-06 03:00 +0100 |
| Last post | 2015-12-09 13:30 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 2/2] chacha20poly1305: Skip encryption/decryption for 0-len "Jason A. Donenfeld" <Jason@zx2c4.com> - 2015-12-06 03:00 +0100
Re: [PATCH 2/2] chacha20poly1305: Skip encryption/decryption for 0-len Herbert Xu <herbert@gondor.apana.org.au> - 2015-12-09 13:30 +0100
| From | "Jason A. Donenfeld" <Jason@zx2c4.com> |
|---|---|
| Date | 2015-12-06 03:00 +0100 |
| Subject | [PATCH 2/2] chacha20poly1305: Skip encryption/decryption for 0-len |
| Message-ID | <qCwMi-nF-7@gated-at.bofh.it> |
If the length of the plaintext is zero, there's no need to waste cycles on encryption and decryption. Using the chacha20poly1305 construction for zero-length plaintexts is a common way of using a shared encryption key for AAD authentication. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Cc: <stable@vger.kernel.org> --- crypto/chacha20poly1305.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crypto/chacha20poly1305.c b/crypto/chacha20poly1305.c index 99c3cce..7b6b935 100644 --- a/crypto/chacha20poly1305.c +++ b/crypto/chacha20poly1305.c @@ -130,6 +130,9 @@ static int chacha_decrypt(struct aead_request *req) struct scatterlist *src, *dst; int err; + if (rctx->cryptlen == 0) + goto skip; + chacha_iv(creq->iv, req, 1); sg_init_table(rctx->src, 2); @@ -150,6 +153,7 @@ static int chacha_decrypt(struct aead_request *req) if (err) return err; +skip: return poly_verify_tag(req); } @@ -415,6 +419,9 @@ static int chacha_encrypt(struct aead_request *req) struct scatterlist *src, *dst; int err; + if (req->cryptlen == 0) + goto skip; + chacha_iv(creq->iv, req, 1); sg_init_table(rctx->src, 2); @@ -435,6 +442,7 @@ static int chacha_encrypt(struct aead_request *req) if (err) return err; +skip: return poly_genkey(req); } -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Herbert Xu <herbert@gondor.apana.org.au> |
|---|---|
| Date | 2015-12-09 13:30 +0100 |
| Subject | Re: [PATCH 2/2] chacha20poly1305: Skip encryption/decryption for 0-len |
| Message-ID | <qDM2C-8kP-19@gated-at.bofh.it> |
| In reply to | #1284684 |
On Sun, Dec 06, 2015 at 02:51:38AM +0100, Jason A. Donenfeld wrote: > If the length of the plaintext is zero, there's no need to waste cycles > on encryption and decryption. Using the chacha20poly1305 construction > for zero-length plaintexts is a common way of using a shared encryption > key for AAD authentication. > > Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Patch applied. Thanks. -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web