Skip to content

Commit

Permalink
crypto: seqiv - Ensure that IV size is at least 8 bytes
Browse files Browse the repository at this point in the history
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>
Acked-by: Maciej ?enczykowski <zenczykowski@gmail.com>
  • Loading branch information
Herbert Xu committed Jan 20, 2015
1 parent 988dc01 commit c0ecf89
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crypto/seqiv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit c0ecf89

Please sign in to comment.