diff options
| author | James Morris <jmorris@redhat.com> | 2004-03-21 06:36:22 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-03-21 06:36:22 -0800 |
| commit | 5654cd6cccf5d2a1eec0f8d60b5196fd454f523a (patch) | |
| tree | 24e4d4124df920be8916acb43a988468c15b2c5e /include/linux | |
| parent | c81430b50f55670cd5bef96242021943832e4470 (diff) | |
[CRYPTO]: Add setkey operation for digests.
From Jouni Malinen <jkmaline@cc.hut.fi>
Added support for using keyed digest with an optional dit_setkey handler.
This does not change the behavior of the existing digest algorithms, but
allows new ones to add setkey handler that can be used to initialize the
algorithm with a key or seed. setkey is to be called after init, but before
any of the update call(s).
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/crypto.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/crypto.h b/include/linux/crypto.h index 2331966abe8f..0f0d8a9f5b53 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h @@ -76,6 +76,8 @@ struct digest_alg { void (*dia_init)(void *ctx); void (*dia_update)(void *ctx, const u8 *data, unsigned int len); void (*dia_final)(void *ctx, u8 *out); + int (*dia_setkey)(void *ctx, const u8 *key, + unsigned int keylen, u32 *flags); }; struct compress_alg { @@ -157,6 +159,8 @@ struct digest_tfm { void (*dit_final)(struct crypto_tfm *tfm, u8 *out); void (*dit_digest)(struct crypto_tfm *tfm, struct scatterlist *sg, unsigned int nsg, u8 *out); + int (*dit_setkey)(struct crypto_tfm *tfm, + const u8 *key, unsigned int keylen); #ifdef CONFIG_CRYPTO_HMAC void *dit_hmac_block; #endif @@ -282,6 +286,15 @@ static inline void crypto_digest_digest(struct crypto_tfm *tfm, tfm->crt_digest.dit_digest(tfm, sg, nsg, out); } +static inline int crypto_digest_setkey(struct crypto_tfm *tfm, + const u8 *key, unsigned int keylen) +{ + BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST); + if (tfm->crt_digest.dit_setkey == NULL) + return -ENOSYS; + return tfm->crt_digest.dit_setkey(tfm, key, keylen); +} + static inline int crypto_cipher_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) { |
