lkml.org 
[lkml]   [2022]   [Sep]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH HBK: 8/8] dm-crypt: consumer-app setting the flag-is_hbk
Date
Consumer application:
- Adding a flag 'is_hbk', in its "struct crypto_config".

- After fetching the keys, it is setting the above
mentioned flag, based on the key fetched.
-- Note: Supported for trusted keys only.

- After allocating the tfm, and before calling
crypto_xxx_setkey(), setting the tfm flag 'is_hbk':
cc->cipher_tfm.tfms[i]->base.is_hbk = cc->is_hbk;
-- Note: Supported for symmetric-key ciphers only.

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
---
drivers/md/dm-crypt.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 159c6806c19b..12b400e06cbf 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -221,6 +221,7 @@ struct crypt_config {
struct mutex bio_alloc_lock;

u8 *authenc_key; /* space for keys in authenc() format (if used) */
+ unsigned int is_hbk;
u8 key[];
};

@@ -2397,10 +2398,12 @@ static int crypt_setkey(struct crypt_config *cc)
r = crypto_aead_setkey(cc->cipher_tfm.tfms_aead[i],
cc->key + (i * subkey_size),
subkey_size);
- else
+ else {
+ cc->cipher_tfm.tfms[i]->base.is_hbk = cc->is_hbk;
r = crypto_skcipher_setkey(cc->cipher_tfm.tfms[i],
cc->key + (i * subkey_size),
subkey_size);
+ }
if (r)
err = r;
}
@@ -2461,6 +2464,7 @@ static int set_key_trusted(struct crypt_config *cc, struct key *key)
if (!tkp)
return -EKEYREVOKED;

+ cc->is_hbk = tkp->is_hw_bound;
if (cc->key_size != tkp->key_len)
return -EINVAL;

--
2.17.1
\
 
 \ /
  Last update: 2022-09-06 07:53    [W:0.134 / U:3.876 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site