Skip to content

Commit a1383cd

Browse files
committed
crypto: skcipher - Add crypto_skcipher_has_setkey
This patch adds a way for skcipher users to determine whether a key is required by a transform. Cc: stable@vger.kernel.org Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 6de62f1 commit a1383cd

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎crypto/skcipher.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ static int crypto_init_skcipher_ops_blkcipher(struct crypto_tfm *tfm)
118118
skcipher->decrypt = skcipher_decrypt_blkcipher;
119119

120120
skcipher->ivsize = crypto_blkcipher_ivsize(blkcipher);
121+
skcipher->has_setkey = calg->cra_blkcipher.max_keysize;
121122

122123
return 0;
123124
}
@@ -210,6 +211,7 @@ static int crypto_init_skcipher_ops_ablkcipher(struct crypto_tfm *tfm)
210211
skcipher->ivsize = crypto_ablkcipher_ivsize(ablkcipher);
211212
skcipher->reqsize = crypto_ablkcipher_reqsize(ablkcipher) +
212213
sizeof(struct ablkcipher_request);
214+
skcipher->has_setkey = calg->cra_ablkcipher.max_keysize;
213215

214216
return 0;
215217
}

‎include/crypto/skcipher.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ struct crypto_skcipher {
6161
unsigned int ivsize;
6262
unsigned int reqsize;
6363

64+
bool has_setkey;
65+
6466
struct crypto_tfm base;
6567
};
6668

@@ -305,6 +307,11 @@ static inline int crypto_skcipher_setkey(struct crypto_skcipher *tfm,
305307
return tfm->setkey(tfm, key, keylen);
306308
}
307309

310+
static inline bool crypto_skcipher_has_setkey(struct crypto_skcipher *tfm)
311+
{
312+
return tfm->has_setkey;
313+
}
314+
308315
/**
309316
* crypto_skcipher_reqtfm() - obtain cipher handle from request
310317
* @req: skcipher_request out of which the cipher handle is to be obtained

0 commit comments

Comments
 (0)