From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:21:21
From: Andrei Botila <redacted>
This patch set is a follow-up on the previous RFC discussion which can be found
here: https://lore.kernel.org/r/4145904.A5P2xsN9yQ@tauon.chronox.de
This series converts all XTS implementations to return 0 when the input length
is equal to 0. This change is necessary in order to standardize the way
skcipher algorithms handle this corner case. This check is made for other
algorithms such as CBC, ARC4, CFB, OFB, SALSA20, CTR, ECB and PCBC, XTS being
the outlier here.
Although some drivers do not explicitly check for requests with zero input
length, their implementations might be able to deal with this case.
Since we don't have the HW to test which ones are able and which ones are not
we rely on the maintainers of these drivers to verify and comment if the changes
are necessary in their driver or not.
One important thing to keep in mind is that in some implementations we make
this check only for XTS algorithms although probably all skcipher algorithms
should return 0 in case of zero input length.
This fix has been tested only on ARMv8 CE, the rest of the patches have
been build tested *only*, and should be tested on actual hardware before
being merged.
Andrei Botila (22):
crypto: arm/aes-ce - add check for xts input length equal to zero
crypto: arm/aes-neonbs - add check for xts input length equal to zero
crypto: arm64/aes - add check for xts input length equal to zero
crypto: arm64/aes-neonbs - add check for xts input length equal to
zero
crypto: powerpc/aes-spe - add check for xts input length equal to zero
crypto: s390/aes - add check for xts input length equal to zero
crypto: s390/paes - add check for xts input length equal to zero
crypto: x86/glue_helper - add check for xts input length equal to zero
crypto: xts - add check for block length equal to zero
crypto: atmel-aes - add check for xts input length equal to zero
crypto: artpec6 - add check for xts input length equal to zero
crypto: bcm - add check for xts input length equal to zero
crypto: cavium/cpt - add check for xts input length equal to zero
crypto: cavium/nitrox - add check for xts input length equal to zero
crypto: ccp - add check for xts input length equal to zero
crypto: ccree - add check for xts input length equal to zero
crypto: chelsio - add check for xts input length equal to zero
crypto: hisilicon/sec - add check for xts input length equal to zero
crypto: inside-secure - add check for xts input length equal to zero
crypto: octeontx - add check for xts input length equal to zero
crypto: qce - add check for xts input length equal to zero
crypto: vmx - add check for xts input length equal to zero
arch/arm/crypto/aes-ce-glue.c | 6 ++++++
arch/arm/crypto/aes-neonbs-glue.c | 3 +++
arch/arm64/crypto/aes-glue.c | 6 ++++++
arch/arm64/crypto/aes-neonbs-glue.c | 3 +++
arch/powerpc/crypto/aes-spe-glue.c | 6 ++++++
arch/s390/crypto/aes_s390.c | 3 +++
arch/s390/crypto/paes_s390.c | 3 +++
arch/x86/crypto/glue_helper.c | 3 +++
crypto/xts.c | 6 ++++++
drivers/crypto/atmel-aes.c | 4 ++++
drivers/crypto/axis/artpec6_crypto.c | 6 ++++++
drivers/crypto/bcm/cipher.c | 3 +++
drivers/crypto/cavium/cpt/cptvf_algs.c | 4 ++++
drivers/crypto/cavium/nitrox/nitrox_skcipher.c | 6 ++++++
drivers/crypto/ccp/ccp-crypto-aes-xts.c | 3 +++
drivers/crypto/ccree/cc_cipher.c | 11 ++++++-----
drivers/crypto/chelsio/chcr_algo.c | 4 ++++
drivers/crypto/hisilicon/sec/sec_algs.c | 4 ++++
drivers/crypto/inside-secure/safexcel_cipher.c | 6 ++++++
drivers/crypto/marvell/octeontx/otx_cptvf_algs.c | 5 +++++
drivers/crypto/qce/skcipher.c | 3 +++
drivers/crypto/vmx/aes_xts.c | 3 +++
22 files changed, 96 insertions(+), 5 deletions(-)
--
2.17.1
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:21:51
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Andrei Botila <redacted>
---
arch/arm/crypto/aes-neonbs-glue.c | 3 +++
1 file changed, 3 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:21:56
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrei Botila <redacted>
---
arch/arm64/crypto/aes-glue.c | 6 ++++++
1 file changed, 6 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:21:59
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrei Botila <redacted>
---
arch/arm64/crypto/aes-neonbs-glue.c | 3 +++
1 file changed, 3 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:22:03
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <redacted>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Andrei Botila <redacted>
---
arch/powerpc/crypto/aes-spe-glue.c | 6 ++++++
1 file changed, 6 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:22:07
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Cc: Heiko Carstens <redacted>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <redacted>
Signed-off-by: Andrei Botila <redacted>
---
arch/s390/crypto/aes_s390.c | 3 +++
1 file changed, 3 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:22:15
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Cc: Heiko Carstens <redacted>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <redacted>
Signed-off-by: Andrei Botila <redacted>
---
arch/s390/crypto/paes_s390.c | 3 +++
1 file changed, 3 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:22:19
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Signed-off-by: Andrei Botila <redacted>
---
crypto/xts.c | 6 ++++++
1 file changed, 6 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:22:21
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Lars Persson <lars.persson@axis.com>
Signed-off-by: Andrei Botila <redacted>
---
drivers/crypto/axis/artpec6_crypto.c | 6 ++++++
1 file changed, 6 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:22:34
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Cc: Srikanth Jampala <redacted>
Cc: Nagadheeraj Rottela <redacted>
Signed-off-by: Andrei Botila <redacted>
---
drivers/crypto/cavium/nitrox/nitrox_skcipher.c | 6 ++++++
1 file changed, 6 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:22:37
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: Andrei Botila <redacted>
---
drivers/crypto/atmel-aes.c | 4 ++++
1 file changed, 4 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:22:42
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Cc: Thomas Gleixner <redacted>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Andrei Botila <redacted>
---
arch/x86/crypto/glue_helper.c | 3 +++
1 file changed, 3 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:22:45
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: John Allen <john.allen@amd.com>
Signed-off-by: Andrei Botila <redacted>
---
drivers/crypto/ccp/ccp-crypto-aes-xts.c | 3 +++
1 file changed, 3 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:22:46
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Signed-off-by: Andrei Botila <redacted>
---
drivers/crypto/hisilicon/sec/sec_algs.c | 4 ++++
1 file changed, 4 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:22:49
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Cc: Boris Brezillon <bbrezillon@kernel.org>
Cc: Arnaud Ebalard <redacted>
Cc: Srujana Challa <schalla@marvell.com>
Signed-off-by: Andrei Botila <redacted>
---
drivers/crypto/marvell/octeontx/otx_cptvf_algs.c | 5 +++++
1 file changed, 5 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:22:55
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Cc: "Breno Leitão" <leitao@debian.org>
Cc: Nayna Jain <nayna@linux.ibm.com>
Cc: Paulo Flabiano Smorigo <pfsmorigo@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <redacted>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Andrei Botila <redacted>
---
drivers/crypto/vmx/aes_xts.c | 3 +++
1 file changed, 3 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:22:58
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Cc: Zhang Shengju <redacted>
Cc: Tang Bin <redacted>
Signed-off-by: Andrei Botila <redacted>
---
drivers/crypto/bcm/cipher.c | 3 +++
1 file changed, 3 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:23:04
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Signed-off-by: Andrei Botila <redacted>
---
drivers/crypto/qce/skcipher.c | 3 +++
1 file changed, 3 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:23:06
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Cc: George Cherian <gcherian@marvell.com>
Signed-off-by: Andrei Botila <redacted>
---
drivers/crypto/cavium/cpt/cptvf_algs.c | 4 ++++
1 file changed, 4 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:23:08
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Cc: Antoine Tenart <redacted>
Signed-off-by: Andrei Botila <redacted>
---
drivers/crypto/inside-secure/safexcel_cipher.c | 6 ++++++
1 file changed, 6 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:23:11
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Cc: Ayush Sawal <ayush.sawal@chelsio.com>
Cc: Vinay Kumar Yadav <redacted>
Cc: Rohit Maheshwari <redacted>
Signed-off-by: Andrei Botila <redacted>
---
drivers/crypto/chelsio/chcr_algo.c | 4 ++++
1 file changed, 4 insertions(+)
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:23:21
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
This change has implications not only for xts(aes) but also for cts(cbc(aes))
and cts(cbc(paes)).
Cc: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Andrei Botila <redacted>
---
drivers/crypto/ccree/cc_cipher.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
@@ -912,17 +912,18 @@ static int cc_cipher_process(struct skcipher_request *req,/* STAT_PHASE_0: Init and sanity checks */-if(validate_data_size(ctx_p,nbytes)){-dev_dbg(dev,"Unsupported data size %d.\n",nbytes);-rc=-EINVAL;-gotoexit_process;-}if(nbytes==0){/* No data to process is valid */rc=0;gotoexit_process;}+if(validate_data_size(ctx_p,nbytes)){+dev_dbg(dev,"Unsupported data size %d.\n",nbytes);+rc=-EINVAL;+gotoexit_process;+}+if(ctx_p->fallback_on){structskcipher_request*subreq=skcipher_request_ctx(req);
From: Andrei Botila <andrei.botila@oss.nxp.com> Date: 2020-08-07 16:23:28
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Andrei Botila <redacted>
---
arch/arm/crypto/aes-ce-glue.c | 6 ++++++
1 file changed, 6 insertions(+)
Hi,
Thanks for the patch!
On 8/7/20 7:20 PM, Andrei Botila wrote:
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Signed-off-by: Andrei Botila <redacted>
---
drivers/crypto/qce/skcipher.c | 3 +++
1 file changed, 3 insertions(+)
On Fri, Aug 7, 2020 at 7:22 PM Andrei Botila [off-list ref] wrote:
quoted hunk
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
This change has implications not only for xts(aes) but also for cts(cbc(aes))
and cts(cbc(paes)).
Cc: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Andrei Botila <redacted>
---
drivers/crypto/ccree/cc_cipher.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
@@ -912,17 +912,18 @@ static int cc_cipher_process(struct skcipher_request *req,/* STAT_PHASE_0: Init and sanity checks */-if(validate_data_size(ctx_p,nbytes)){-dev_dbg(dev,"Unsupported data size %d.\n",nbytes);-rc=-EINVAL;-gotoexit_process;-}if(nbytes==0){/* No data to process is valid */rc=0;gotoexit_process;}+if(validate_data_size(ctx_p,nbytes)){+dev_dbg(dev,"Unsupported data size %d.\n",nbytes);+rc=-EINVAL;+gotoexit_process;+}+if(ctx_p->fallback_on){structskcipher_request*subreq=skcipher_request_ctx(req);--
2.17.1
Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>
Thanks,
Gilad
--
Gilad Ben-Yossef
Chief Coffee Drinker
values of β will give rise to dom!
From: Van Leeuwen, Pascal <hidden> Date: 2020-08-10 10:27:08
quoted hunk
-----Original Message-----
From: linux-crypto-owner@vger.kernel.org <redacted> On Behalf Of Andrei Botila
Sent: Friday, August 7, 2020 6:20 PM
To: Herbert Xu <herbert@gondor.apana.org.au>; David S. Miller <davem@davemloft.net>
Cc: linux-crypto@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; linuxppc-dev@lists.ozlabs.org;
linux-s390@vger.kernel.org; x86@kernel.org; linux-arm-kernel@axis.com; Andrei Botila [off-list ref]; Antoine Tenart
[off-list ref]
Subject: [PATCH 19/22] crypto: inside-secure - add check for xts input length equal to zero
<<< External Email >>>
From: Andrei Botila <redacted>
Standardize the way input lengths equal to 0 are handled in all skcipher
algorithms. All the algorithms return 0 for input lengths equal to zero.
Cc: Antoine Tenart <redacted>
Signed-off-by: Andrei Botila <redacted>
---
drivers/crypto/inside-secure/safexcel_cipher.c | 6 ++++++
1 file changed, 6 insertions(+)
@@ -2533,6 +2533,9 @@ static int safexcel_skcipher_aes_xts_cra_init(struct crypto_tfm *tfm)staticintsafexcel_encrypt_xts(structskcipher_request*req){+if(!req->cryptlen)+return0;+if(req->cryptlen<XTS_BLOCK_SIZE)return-EINVAL;returnsafexcel_queue_req(&req->base,skcipher_request_ctx(req),
@@ -2541,6 +2544,9 @@ static int safexcel_encrypt_xts(struct skcipher_request *req)staticintsafexcel_decrypt_xts(structskcipher_request*req){+if(!req->cryptlen)+return0;+if(req->cryptlen<XTS_BLOCK_SIZE)return-EINVAL;returnsafexcel_queue_req(&req->base,skcipher_request_ctx(req),--
2.17.1
With all due respect, but this makes no sense.
For XTS, any length below 16 is illegal, as applying CTS in order to handle non-cipher
block multiples (16 bytes in case of AES) requires _more_ data than 1 cipher block.
There is no benefit to explicitly check for zero length if there is already a check for
less-than-16. That's just wasting CPU cycles and a branch predictor entry, for no
benefit whatsoever. (except for academic "alignment with other ciphers").
XTS has very specific use cases. No one in their right mind would call it for a
situation where it can't be applied in the first place, e.g. anything < 16 bytes.
Regards,
Pascal van Leeuwen
Silicon IP Architect Multi-Protocol Engines, Rambus Security
Rambus ROTW Holding BV
+31-73 6581953
Note: The Inside Secure/Verimatrix Silicon IP team was recently acquired by Rambus.
Please be so kind to update your e-mail address book with my new e-mail address.
** This message and any attachments are for the sole use of the intended recipient(s). It may contain information that is confidential and privileged. If you are not the intended recipient of this message, you are prohibited from printing, copying, forwarding or saving it. Please delete the message and attachments and notify the sender immediately. **
Rambus Inc.<http://www.rambus.com>
On Mon, Aug 10, 2020 at 10:20:20AM +0000, Van Leeuwen, Pascal wrote:
quoted
With all due respect, but this makes no sense.
I agree. This is a lot of churn for no gain.
I would say the gain is that all skcipher algorithms would behave the same
when input length equals zero - i.e. treat the request as a no-op.
We can't say "no input" has any meaning to the other skcipher algorithms,
but the convention is to accept this case and just return 0.
I don't see why XTS has to be handled differently.
Thanks,
Horia
From: Eric Biggers <ebiggers@kernel.org> Date: 2020-08-10 17:03:09
On Mon, Aug 10, 2020 at 05:33:39PM +0300, Horia Geantă wrote:
On 8/10/2020 4:45 PM, Herbert Xu wrote:
quoted
On Mon, Aug 10, 2020 at 10:20:20AM +0000, Van Leeuwen, Pascal wrote:
quoted
With all due respect, but this makes no sense.
I agree. This is a lot of churn for no gain.
I would say the gain is that all skcipher algorithms would behave the same
when input length equals zero - i.e. treat the request as a no-op.
We can't say "no input" has any meaning to the other skcipher algorithms,
but the convention is to accept this case and just return 0.
I don't see why XTS has to be handled differently.
CTS also rejects empty inputs.
The rule it follows is just that all input lengths >= blocksize are allowed.
Input lengths < blocksize aren't allowed.
- Eric
From: Van Leeuwen, Pascal <hidden> Date: 2020-08-10 21:38:04
-----Original Message-----
From: Horia Geantă <horia.geanta@nxp.com>
Sent: Monday, August 10, 2020 4:34 PM
To: Herbert Xu <herbert@gondor.apana.org.au>; Van Leeuwen, Pascal <redacted>
Cc: Andrei Botila (OSS) <andrei.botila@oss.nxp.com>; David S. Miller <davem@davemloft.net>; linux-crypto@vger.kernel.org; linux-
arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; linux-s390@vger.kernel.org;
x86@kernel.org; linux-arm-kernel@axis.com; Andrei Botila [off-list ref]; Antoine Tenart [off-list ref]
Subject: Re: [PATCH 19/22] crypto: inside-secure - add check for xts input length equal to zero
<<< External Email >>>
On 8/10/2020 4:45 PM, Herbert Xu wrote:
quoted
On Mon, Aug 10, 2020 at 10:20:20AM +0000, Van Leeuwen, Pascal wrote:
quoted
With all due respect, but this makes no sense.
I agree. This is a lot of churn for no gain.
I would say the gain is that all skcipher algorithms would behave the same
when input length equals zero - i.e. treat the request as a no-op.
XTS already behaves differently because it can accept any byte amount as long
as it is not in the range 0 -16. So far, you got an EINVAL error for lengths < 16.
The special exception on top of that for length 0 does not improve anything.
Treating a request of length 0 as a no-op is not a useful feature here, as there
is no use case where that would make sense. XTS encrypts blocks (usually disk
sectors), and cannot be chained. So an attempt to encrypt a zero length block
is most certainly some kind of error (e.g. trying to use XTS for something it
was not designed to do - big security mistake!).
We can't say "no input" has any meaning to the other skcipher algorithms,
but the convention is to accept this case and just return 0.
I don't see why XTS has to be handled differently.
I don't see why you would blindly follow some historical convention ...
unless maybe there was some existing real use case that would benefit?
BTW: for generic ciphers I could think of some use cases where the zero
length request being a no-op makes sense if the application does not
bother to check how much data it has gathered to process (which may be
nothing), but I can't see how this could apply to XTS, being block-based.
Thanks,
Horia
Regards,
Pascal van Leeuwen
Silicon IP Architect Multi-Protocol Engines, Rambus Security
Rambus ROTW Holding BV
+31-73 6581953
Note: The Inside Secure/Verimatrix Silicon IP team was recently acquired by Rambus.
Please be so kind to update your e-mail address book with my new e-mail address.
** This message and any attachments are for the sole use of the intended recipient(s). It may contain information that is confidential and privileged. If you are not the intended recipient of this message, you are prohibited from printing, copying, forwarding or saving it. Please delete the message and attachments and notify the sender immediately. **
Rambus Inc.<http://www.rambus.com>
On Mon, Aug 10, 2020 at 05:33:39PM +0300, Horia Geantă wrote:
quoted
On 8/10/2020 4:45 PM, Herbert Xu wrote:
quoted
On Mon, Aug 10, 2020 at 10:20:20AM +0000, Van Leeuwen, Pascal wrote:
quoted
With all due respect, but this makes no sense.
I agree. This is a lot of churn for no gain.
I would say the gain is that all skcipher algorithms would behave the same
when input length equals zero - i.e. treat the request as a no-op.
We can't say "no input" has any meaning to the other skcipher algorithms,
but the convention is to accept this case and just return 0.
I don't see why XTS has to be handled differently.
CTS also rejects empty inputs.
The rule it follows is just that all input lengths >= blocksize are allowed.
Input lengths < blocksize aren't allowed.
Indeed, thanks.
What about, for example, CBC?
AFAICT cbc(aes) with input length = 0 is valid.
Same for CTR (with the note that blocksize = 1) and several other algorithms
mentioned in the cover letter.
What's the rule in these cases?
Thanks,
Horia