Skip to content

Commit

Permalink
evm: key must be set once during initialization
Browse files Browse the repository at this point in the history
On multi-core systems, setting of the key before every caclculation,
causes invalid HMAC calculation for other tfm users, because internal
state (ipad, opad) can be invalid before set key call returns.
It needs to be set only once during initialization.

Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
Acked-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: James Morris <jmorris@namei.org>
  • Loading branch information
Dmitry Kasatkin committed Dec 20, 2011
1 parent 511585a commit d21b594
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions security/integrity/evm/evm_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ static struct shash_desc *init_desc(void)
hmac_tfm = NULL;
return ERR_PTR(rc);
}
rc = crypto_shash_setkey(hmac_tfm, evmkey, evmkey_len);
if (rc) {
crypto_free_shash(hmac_tfm);
hmac_tfm = NULL;
return ERR_PTR(rc);
}
}

desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(hmac_tfm),
Expand All @@ -51,11 +57,7 @@ static struct shash_desc *init_desc(void)
desc->tfm = hmac_tfm;
desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP;

rc = crypto_shash_setkey(hmac_tfm, evmkey, evmkey_len);
if (rc)
goto out;
rc = crypto_shash_init(desc);
out:
if (rc) {
kfree(desc);
return ERR_PTR(rc);
Expand Down

0 comments on commit d21b594

Please sign in to comment.