aboutsummaryrefslogtreecommitdiffstats
path: root/security/integrity/evm
diff options
context:
space:
mode:
authorDmitry Kasatkin <dmitry.kasatkin@intel.com>2011-12-05 06:17:41 -0500
committerDmitry Kasatkin <dmitry.kasatkin@intel.com>2011-12-20 10:45:45 -0500
commitd21b59451886cb82448302f8d6f9ac87c3bd56cf (patch)
treef2842dca9ee3c2c3febbe2f6984bb2c5e2a34c28 /security/integrity/evm
parent511585a28e5b5fd1cac61e601e42efc4c5dd64b5 (diff)
evm: key must be set once during initialization
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>
Diffstat (limited to 'security/integrity/evm')
-rw-r--r--security/integrity/evm/evm_crypto.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c
index 5dd5b140242c..4ad657d88097 100644
--- a/security/integrity/evm/evm_crypto.c
+++ b/security/integrity/evm/evm_crypto.c
@@ -41,6 +41,12 @@ static struct shash_desc *init_desc(void)
41 hmac_tfm = NULL; 41 hmac_tfm = NULL;
42 return ERR_PTR(rc); 42 return ERR_PTR(rc);
43 } 43 }
44 rc = crypto_shash_setkey(hmac_tfm, evmkey, evmkey_len);
45 if (rc) {
46 crypto_free_shash(hmac_tfm);
47 hmac_tfm = NULL;
48 return ERR_PTR(rc);
49 }
44 } 50 }
45 51
46 desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(hmac_tfm), 52 desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(hmac_tfm),
@@ -51,11 +57,7 @@ static struct shash_desc *init_desc(void)
51 desc->tfm = hmac_tfm; 57 desc->tfm = hmac_tfm;
52 desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP; 58 desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP;
53 59
54 rc = crypto_shash_setkey(hmac_tfm, evmkey, evmkey_len);
55 if (rc)
56 goto out;
57 rc = crypto_shash_init(desc); 60 rc = crypto_shash_init(desc);
58out:
59 if (rc) { 61 if (rc) {
60 kfree(desc); 62 kfree(desc);
61 return ERR_PTR(rc); 63 return ERR_PTR(rc);