All of lore.kernel.org
 help / color / mirror / Atom feed
* crypto: seqiv - Ensure that IV size is at least 8 bytes
@ 2015-01-16  8:51 Herbert Xu
  2015-01-16 16:53 ` Maciej Żenczykowski
  0 siblings, 1 reply; 2+ messages in thread
From: Herbert Xu @ 2015-01-16  8:51 UTC (permalink / raw)
  To: Linux Crypto Mailing List, Maciej Żenczykowski

Since seqiv is designed for IPsec we need to be able to accomodate
the whole IPsec sequence number in order to ensure the uniqueness
of the IV.

This patch forbids any algorithm with an IV size of less than 8
from using it.  This should have no impact on existing users since
they all have an IV size of 8.

Reported-by: Maciej Żenczykowski <zenczykowski@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

diff --git a/crypto/seqiv.c b/crypto/seqiv.c
index 9daa854c..b7bb9a2 100644
--- a/crypto/seqiv.c
+++ b/crypto/seqiv.c
@@ -267,6 +267,12 @@ static struct crypto_instance *seqiv_ablkcipher_alloc(struct rtattr **tb)
 	if (IS_ERR(inst))
 		goto out;
 
+	if (inst->alg.cra_ablkcipher.ivsize < sizeof(u64)) {
+		skcipher_geniv_free(inst);
+		inst = ERR_PTR(-EINVAL);
+		goto out;
+	}
+
 	inst->alg.cra_ablkcipher.givencrypt = seqiv_givencrypt_first;
 
 	inst->alg.cra_init = seqiv_init;
@@ -287,6 +293,12 @@ static struct crypto_instance *seqiv_aead_alloc(struct rtattr **tb)
 	if (IS_ERR(inst))
 		goto out;
 
+	if (inst->alg.cra_aead.ivsize < sizeof(u64)) {
+		aead_geniv_free(inst);
+		inst = ERR_PTR(-EINVAL);
+		goto out;
+	}
+
 	inst->alg.cra_aead.givencrypt = seqiv_aead_givencrypt_first;
 
 	inst->alg.cra_init = seqiv_aead_init;
-- 
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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: crypto: seqiv - Ensure that IV size is at least 8 bytes
  2015-01-16  8:51 crypto: seqiv - Ensure that IV size is at least 8 bytes Herbert Xu
@ 2015-01-16 16:53 ` Maciej Żenczykowski
  0 siblings, 0 replies; 2+ messages in thread
From: Maciej Żenczykowski @ 2015-01-16 16:53 UTC (permalink / raw)
  To: Herbert Xu; +Cc: Linux Crypto Mailing List

On Fri, Jan 16, 2015 at 12:51 AM, Herbert Xu
<herbert@gondor.apana.org.au> wrote:
> Since seqiv is designed for IPsec we need to be able to accomodate
> the whole IPsec sequence number in order to ensure the uniqueness
> of the IV.
>
> This patch forbids any algorithm with an IV size of less than 8
> from using it.  This should have no impact on existing users since
> they all have an IV size of 8.
>
> Reported-by: Maciej Żenczykowski <zenczykowski@gmail.com>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
>
> diff --git a/crypto/seqiv.c b/crypto/seqiv.c
> index 9daa854c..b7bb9a2 100644
> --- a/crypto/seqiv.c
> +++ b/crypto/seqiv.c
> @@ -267,6 +267,12 @@ static struct crypto_instance *seqiv_ablkcipher_alloc(struct rtattr **tb)
>         if (IS_ERR(inst))
>                 goto out;
>
> +       if (inst->alg.cra_ablkcipher.ivsize < sizeof(u64)) {
> +               skcipher_geniv_free(inst);
> +               inst = ERR_PTR(-EINVAL);
> +               goto out;
> +       }
> +
>         inst->alg.cra_ablkcipher.givencrypt = seqiv_givencrypt_first;
>
>         inst->alg.cra_init = seqiv_init;
> @@ -287,6 +293,12 @@ static struct crypto_instance *seqiv_aead_alloc(struct rtattr **tb)
>         if (IS_ERR(inst))
>                 goto out;
>
> +       if (inst->alg.cra_aead.ivsize < sizeof(u64)) {
> +               aead_geniv_free(inst);
> +               inst = ERR_PTR(-EINVAL);
> +               goto out;
> +       }
> +
>         inst->alg.cra_aead.givencrypt = seqiv_aead_givencrypt_first;
>
>         inst->alg.cra_init = seqiv_aead_init;
> --
> 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

Acked-by: Maciej Żenczykowski <zenczykowski@gmail.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-16 16:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-16  8:51 crypto: seqiv - Ensure that IV size is at least 8 bytes Herbert Xu
2015-01-16 16:53 ` Maciej Żenczykowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.