mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fruhwirth Clemens <clemens-dated-1107431785.31e3@endorphin.org>
To: akpm@osdl.org, jmorris@redhat.com, linux-kernel@vger.kernel.org
Subject: [PATCH 01/04] Adding cipher mode context information to crypto_tfm
Date: Mon, 24 Jan 2005 12:56:24 +0100	[thread overview]
Message-ID: <20050124115624.GA21457@ghanima.endorphin.org> (raw)

This patch adds the ability for a cipher mode to store cipher mode specific
information in crypto_tfm. This is necessary for LRW's precomputed
GF-multiplication tables.

Signed-off-by: Fruhwirth Clemens <clemens@endorphin.org>
 
--- 0/crypto/api.c	2005-01-20 10:15:22.000000000 +0100
+++ 1/crypto/api.c	2005-01-20 10:15:40.000000000 +0100
@@ -3,6 +3,7 @@
  *
  * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
  * Copyright (c) 2002 David S. Miller (davem@redhat.com)
+ * Copyright (c) 2004 Clemens Fruhwirth <clemens@endorphin.org>
  *
  * Portions derived from Cryptoapi, by Alexander Kjeldaas <astor@fast.no>
  * and Nettle, by Niels M�ller.
@@ -23,6 +24,14 @@
 LIST_HEAD(crypto_alg_list);
 DECLARE_RWSEM(crypto_alg_sem);
 
+static inline int crypto_cmctx_size(u32 flags) 
+{
+	switch(flags & CRYPTO_TFM_MODE_MASK) {
+		default:
+			return 0;
+	}
+}
+
 static inline int crypto_alg_get(struct crypto_alg *alg)
 {
 	return try_module_get(alg->cra_module);
@@ -121,16 +130,18 @@
 {
 	struct crypto_tfm *tfm = NULL;
 	struct crypto_alg *alg;
+	int tfm_size;
 
 	alg = crypto_alg_mod_lookup(name);
 	if (alg == NULL)
 		goto out;
 	
-	tfm = kmalloc(sizeof(*tfm) + alg->cra_ctxsize, GFP_KERNEL);
+	tfm_size = sizeof(*tfm) + alg->cra_ctxsize + crypto_cmctx_size(flags);
+	tfm = kmalloc(tfm_size, GFP_KERNEL);
 	if (tfm == NULL)
 		goto out_put;
 
-	memset(tfm, 0, sizeof(*tfm) + alg->cra_ctxsize);
+	memset(tfm, 0, tfm_size);
 	
 	tfm->__crt_alg = alg;
 	
@@ -156,7 +167,7 @@
 void crypto_free_tfm(struct crypto_tfm *tfm)
 {
 	struct crypto_alg *alg = tfm->__crt_alg;
-	int size = sizeof(*tfm) + alg->cra_ctxsize;
+	int size = sizeof(*tfm) + alg->cra_ctxsize + crypto_cmctx_size(tfm->crt_cipher.cit_mode);
 
 	crypto_exit_ops(tfm);
 	crypto_alg_put(alg);
--- 0/crypto/internal.h	2005-01-20 10:15:22.000000000 +0100
+++ 1/crypto/internal.h	2005-01-20 10:15:40.000000000 +0100
@@ -47,6 +47,11 @@
 	return (void *)&tfm[1];
 }
 
+static inline void *crypto_tfm_cmctx(struct crypto_tfm *tfm)
+{
+	return ((char *)&tfm[1]) + tfm->__crt_alg->cra_ctxsize;
+}
+
 struct crypto_alg *crypto_alg_lookup(const char *name);
 
 /* A far more intelligent version of this is planned.  For now, just

             reply	other threads:[~2005-01-24 11:56 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-24 11:56 Fruhwirth Clemens [this message]
2005-01-24 12:31 ` James Morris
2005-01-24 22:31 ` Andrew Morton
2005-01-24 23:12   ` Fruhwirth Clemens
2005-01-25 15:52   ` James Morris
2005-01-25 17:38     ` Fruhwirth Clemens
2005-01-25 18:56       ` James Morris
2005-01-29 18:13     ` Fruhwirth Clemens
2005-01-29 18:23       ` Andrew Morton
2005-01-30 18:07         ` Fruhwirth Clemens
2005-02-02 22:46           ` James Morris
2005-02-02 23:28             ` Fruhwirth Clemens
2005-02-02 23:34               ` David S. Miller
2005-02-03  0:21                 ` Fruhwirth Clemens
2005-02-03  0:29                   ` David S. Miller
2005-02-03  0:40                   ` Michal Ludvig
2005-02-03  8:55                     ` Fruhwirth Clemens
2005-02-02 23:46               ` James Morris
2005-02-02 23:47                 ` James Morris
2005-02-03 11:47             ` Fruhwirth Clemens
2005-02-08 14:14               ` James Morris
2005-02-05  9:23             ` Fruhwirth Clemens
2005-02-08 14:48               ` James Morris
2005-02-08 16:08                 ` Fruhwirth Clemens
2005-02-08 16:39                   ` Fruhwirth Clemens
2005-02-08 23:30                     ` James Morris
2005-02-08 23:53                       ` Fruhwirth Clemens
2005-02-09  0:09                         ` James Morris
2005-02-09  9:14                           ` Fruhwirth Clemens
2005-02-10  0:30                             ` James Morris
2005-02-10  1:02                               ` Fruhwirth Clemens
2005-02-10  1:19                                 ` Andrew Morton
2005-02-10  1:37                                   ` Christophe Saout
2005-02-10  9:48                                   ` Fruhwirth Clemens
2005-02-10 10:33                                     ` Andrew Morton
2005-02-10 11:17                                       ` Fruhwirth Clemens
2005-02-10 17:02                                         ` James Morris
2005-02-10 17:29                                           ` Fruhwirth Clemens
2005-02-10 17:54                                             ` James Morris
2005-02-14 13:20                                               ` Fruhwirth Clemens
2005-02-14 15:56                                                 ` David S. Miller
2005-02-14 17:06                                                   ` Fruhwirth Clemens
2005-02-14 17:07                                                     ` David S. Miller
2005-02-14 17:28                                                       ` Fruhwirth Clemens
2005-02-14 18:16                                                         ` Andrew Morton
2005-02-22 19:16                                                           ` Fruhwirth Clemens
2005-02-12  0:24                                         ` Matt Mackall
2005-02-10 20:30                                       ` David S. Miller
2005-02-10  1:42                                 ` James Morris
2005-02-10  9:50                                   ` Fruhwirth Clemens
2005-02-02 23:00 ` James Morris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050124115624.GA21457@ghanima.endorphin.org \
    --to=clemens-dated-1107431785.31e3@endorphin.org \
    --cc=akpm@osdl.org \
    --cc=jmorris@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome