Commit 16ffa71a authored by James Morris's avatar James Morris Committed by David S. Miller

[CRYPTO]: Eliminate crypto_tfm.crt_ctx, from Adam Richter.

parent c7870e13
......@@ -128,8 +128,6 @@ struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
memset(tfm, 0, sizeof(*tfm));
tfm->crt_ctx = (void*) &tfm[1];
tfm->__crt_alg = alg;
if (crypto_init_flags(tfm, flags))
......
......@@ -223,14 +223,14 @@ static void cbc_process(struct crypto_tfm *tfm,
if (enc) {
tfm->crt_u.cipher.cit_xor_block(iv, src);
fn(tfm->crt_ctx, dst, iv);
fn(crypto_tfm_ctx(tfm), dst, iv);
memcpy(iv, dst, crypto_tfm_alg_blocksize(tfm));
} else {
const int need_stack = (src == dst);
u8 stack[need_stack ? crypto_tfm_alg_blocksize(tfm) : 0];
u8 *buf = need_stack ? stack : dst;
fn(tfm->crt_ctx, buf, src);
fn(crypto_tfm_ctx(tfm), buf, src);
tfm->crt_u.cipher.cit_xor_block(buf, iv);
memcpy(iv, src, crypto_tfm_alg_blocksize(tfm));
if (buf != dst)
......@@ -241,7 +241,7 @@ static void cbc_process(struct crypto_tfm *tfm,
static void ecb_process(struct crypto_tfm *tfm, u8 *dst, u8 *src,
cryptfn_t fn, int enc, void *info)
{
fn(tfm->crt_ctx, dst, src);
fn(crypto_tfm_ctx(tfm), dst, src);
}
static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
......@@ -252,7 +252,7 @@ static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
return -EINVAL;
} else
return cia->cia_setkey(tfm->crt_ctx, key, keylen,
return cia->cia_setkey(crypto_tfm_ctx(tfm), key, keylen,
&tfm->crt_flags);
}
......
......@@ -19,7 +19,7 @@
static void init(struct crypto_tfm *tfm)
{
tfm->__crt_alg->cra_digest.dia_init(tfm->crt_ctx);
tfm->__crt_alg->cra_digest.dia_init(crypto_tfm_ctx(tfm));
}
static void update(struct crypto_tfm *tfm,
......@@ -29,7 +29,7 @@ static void update(struct crypto_tfm *tfm,
for (i = 0; i < nsg; i++) {
char *p = crypto_kmap(sg[i].page, 0) + sg[i].offset;
tfm->__crt_alg->cra_digest.dia_update(tfm->crt_ctx,
tfm->__crt_alg->cra_digest.dia_update(crypto_tfm_ctx(tfm),
p, sg[i].length);
crypto_kunmap(p, 0);
crypto_yield(tfm);
......@@ -38,7 +38,7 @@ static void update(struct crypto_tfm *tfm,
static void final(struct crypto_tfm *tfm, u8 *out)
{
tfm->__crt_alg->cra_digest.dia_final(tfm->crt_ctx, out);
tfm->__crt_alg->cra_digest.dia_final(crypto_tfm_ctx(tfm), out);
}
static void digest(struct crypto_tfm *tfm,
......@@ -50,7 +50,7 @@ static void digest(struct crypto_tfm *tfm,
for (i = 0; i < nsg; i++) {
char *p = crypto_kmap(sg[i].page, 0) + sg[i].offset;
tfm->__crt_alg->cra_digest.dia_update(tfm->crt_ctx,
tfm->__crt_alg->cra_digest.dia_update(crypto_tfm_ctx(tfm),
p, sg[i].length);
crypto_kunmap(p, 0);
crypto_yield(tfm);
......
......@@ -46,6 +46,11 @@ static inline u32 crypto_cipher_flags(u32 flags)
return flags & (CRYPTO_TFM_MODE_MASK|CRYPTO_TFM_REQ_WEAK_KEY);
}
static inline void *crypto_tfm_ctx(struct crypto_tfm *tfm)
{
return (void *)&tfm[1];
}
struct crypto_alg *crypto_alg_lookup(const char *name);
#ifdef CONFIG_KMOD
......
......@@ -172,7 +172,6 @@ struct compress_tfm {
struct crypto_tfm {
void *crt_ctx;
u32 crt_flags;
union {
......
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