Skip to content

Commit

Permalink
[IPSEC] ah: Remove keys from ah_data structure
Browse files Browse the repository at this point in the history
The keys are only used during initialisation so we don't need to carry them
in esp_data.  Since we don't have to allocate them again, there is no need
to place a limit on the authentication key length anymore.

Signed-off-by: Herbert Xu <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
herbertx authored and David S. Miller committed Oct 10, 2007
1 parent 4b7137f commit bc31d3b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
2 changes: 0 additions & 2 deletions include/net/ah.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

struct ah_data
{
u8 *key;
int key_len;
u8 *work_icv;
int icv_full_len;
int icv_trunc_len;
Expand Down
9 changes: 2 additions & 7 deletions net/ipv4/ah4.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,25 +219,20 @@ static int ah_init_state(struct xfrm_state *x)
if (!x->aalg)
goto error;

/* null auth can use a zero length key */
if (x->aalg->alg_key_len > 512)
goto error;

if (x->encap)
goto error;

ahp = kzalloc(sizeof(*ahp), GFP_KERNEL);
if (ahp == NULL)
return -ENOMEM;

ahp->key = x->aalg->alg_key;
ahp->key_len = (x->aalg->alg_key_len+7)/8;
tfm = crypto_alloc_hash(x->aalg->alg_name, 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(tfm))
goto error;

ahp->tfm = tfm;
if (crypto_hash_setkey(tfm, ahp->key, ahp->key_len))
if (crypto_hash_setkey(tfm, x->aalg->alg_key,
(x->aalg->alg_key_len + 7) / 8))
goto error;

/*
Expand Down
9 changes: 2 additions & 7 deletions net/ipv6/ah6.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,25 +429,20 @@ static int ah6_init_state(struct xfrm_state *x)
if (!x->aalg)
goto error;

/* null auth can use a zero length key */
if (x->aalg->alg_key_len > 512)
goto error;

if (x->encap)
goto error;

ahp = kzalloc(sizeof(*ahp), GFP_KERNEL);
if (ahp == NULL)
return -ENOMEM;

ahp->key = x->aalg->alg_key;
ahp->key_len = (x->aalg->alg_key_len+7)/8;
tfm = crypto_alloc_hash(x->aalg->alg_name, 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(tfm))
goto error;

ahp->tfm = tfm;
if (crypto_hash_setkey(tfm, ahp->key, ahp->key_len))
if (crypto_hash_setkey(tfm, x->aalg->alg_key,
(x->aalg->alg_key_len + 7) / 8))
goto error;

/*
Expand Down

0 comments on commit bc31d3b

Please sign in to comment.