]> git.hungrycats.org Git - linux/commitdiff
[CRYPTO]: Eliminate crypto_tfm.crt_ctx, from Adam Richter.
authorJames Morris <jmorris@intercode.com.au>
Sat, 8 Mar 2003 03:46:27 +0000 (19:46 -0800)
committerDavid S. Miller <davem@nuts.ninka.net>
Sat, 8 Mar 2003 03:46:27 +0000 (19:46 -0800)
crypto/api.c
crypto/cipher.c
crypto/digest.c
crypto/internal.h
include/linux/crypto.h

index 386b04ae587e1a1b332965bef3284d7fa2dd7d4a..53c7ff8393a2173cec94a9cebb4629d039065132 100644 (file)
@@ -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))
index 335ff51a3d47626311b99c157702bf58e696ca9b..064a158d830ccccc6d10600124561cc5a8151ca5 100644 (file)
@@ -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);
 }
 
index 9e7c4bb417ab5ad799ecdc74b1de390a087ba2c9..400f23566f699936c27b41f0b942d946389e075d 100644 (file)
@@ -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);
index 72558dbc0730fab5904956dc3fbcaeb984c3007e..a19fdb1de503b50e4cb55e5211bd43ef5fdeb0d8 100644 (file)
@@ -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
index 5083e6b9c3b0a2abcd04db9f3cfbca3fcc7b42e2..e7c775fb160a6744d6f32b0219e0361782ef97e2 100644 (file)
@@ -172,7 +172,6 @@ struct compress_tfm {
 
 struct crypto_tfm {
 
-       void *crt_ctx;
        u32 crt_flags;
        
        union {