#include <crypto/internal/hash.h>
#include <crypto/scatterwalk.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/scatterlist.h>
#include <linux/string.h>
struct crypto_shash *hash;
static inline void *align_ptr(void *p, unsigned int align)
return (void *)ALIGN((unsigned long)p, align);
static inline struct hmac_ctx *hmac_ctx(struct crypto_shash *tfm)
return align_ptr(crypto_shash_ctx_aligned(tfm) +
crypto_shash_statesize(tfm) * 2,
crypto_tfm_ctx_alignment());
static int hmac_setkey(struct crypto_shash *parent,
const u8 *inkey, unsigned int keylen)
int bs = crypto_shash_blocksize(parent);
int ds = crypto_shash_digestsize(parent);
int ss = crypto_shash_statesize(parent);
char *ipad = crypto_shash_ctx_aligned(parent);
struct hmac_ctx *ctx = align_ptr(opad + ss,
crypto_tfm_ctx_alignment());
struct crypto_shash *hash = ctx->hash;
SHASH_DESC_ON_STACK(shash, hash);
shash->flags = crypto_shash_get_flags(parent)
& CRYPTO_TFM_REQ_MAY_SLEEP;