Commit 176a7ba7 authored by Herbert Xu's avatar Herbert Xu Committed by Kamal Mostafa

crypto: skcipher - Add crypto_skcipher_has_setkey

commit a1383cd8 upstream.

This patch adds a way for skcipher users to determine whether a key
is required by a transform.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
[bwh: Backported to 3.2: add to ablkcipher API instead]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
[kamal: plus bwh http://article.gmane.org/gmane.linux.kernel.stable/169083]
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent 031bc9fb
...@@ -375,6 +375,7 @@ static int crypto_init_ablkcipher_ops(struct crypto_tfm *tfm, u32 type, ...@@ -375,6 +375,7 @@ static int crypto_init_ablkcipher_ops(struct crypto_tfm *tfm, u32 type,
} }
crt->base = __crypto_ablkcipher_cast(tfm); crt->base = __crypto_ablkcipher_cast(tfm);
crt->ivsize = alg->ivsize; crt->ivsize = alg->ivsize;
crt->has_setkey = alg->max_keysize;
return 0; return 0;
} }
...@@ -456,6 +457,7 @@ static int crypto_init_givcipher_ops(struct crypto_tfm *tfm, u32 type, ...@@ -456,6 +457,7 @@ static int crypto_init_givcipher_ops(struct crypto_tfm *tfm, u32 type,
crt->givdecrypt = alg->givdecrypt ?: no_givdecrypt; crt->givdecrypt = alg->givdecrypt ?: no_givdecrypt;
crt->base = __crypto_ablkcipher_cast(tfm); crt->base = __crypto_ablkcipher_cast(tfm);
crt->ivsize = alg->ivsize; crt->ivsize = alg->ivsize;
crt->has_setkey = alg->max_keysize;
return 0; return 0;
} }
......
...@@ -471,6 +471,7 @@ static int crypto_init_blkcipher_ops_async(struct crypto_tfm *tfm) ...@@ -471,6 +471,7 @@ static int crypto_init_blkcipher_ops_async(struct crypto_tfm *tfm)
} }
crt->base = __crypto_ablkcipher_cast(tfm); crt->base = __crypto_ablkcipher_cast(tfm);
crt->ivsize = alg->ivsize; crt->ivsize = alg->ivsize;
crt->has_setkey = alg->max_keysize;
return 0; return 0;
} }
......
...@@ -594,6 +594,7 @@ struct ablkcipher_tfm { ...@@ -594,6 +594,7 @@ struct ablkcipher_tfm {
unsigned int ivsize; unsigned int ivsize;
unsigned int reqsize; unsigned int reqsize;
bool has_setkey;
}; };
struct aead_tfm { struct aead_tfm {
...@@ -997,6 +998,13 @@ static inline int crypto_ablkcipher_setkey(struct crypto_ablkcipher *tfm, ...@@ -997,6 +998,13 @@ static inline int crypto_ablkcipher_setkey(struct crypto_ablkcipher *tfm,
return crt->setkey(crt->base, key, keylen); return crt->setkey(crt->base, key, keylen);
} }
static inline bool crypto_ablkcipher_has_setkey(struct crypto_ablkcipher *tfm)
{
struct ablkcipher_tfm *crt = crypto_ablkcipher_crt(tfm);
return crt->has_setkey;
}
/** /**
* crypto_ablkcipher_reqtfm() - obtain cipher handle from request * crypto_ablkcipher_reqtfm() - obtain cipher handle from request
* @req: ablkcipher_request out of which the cipher handle is to be obtained * @req: ablkcipher_request out of which the cipher handle is to be obtained
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment