All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Happe <andreashappe@flatline.ath.cx>
To: Michal Ludvig <michal@logix.cz>
Cc: James Morris <jmorris@redhat.com>,
	cryptoapi@lists.logix.cz, linux-kernel@vger.kernel.org,
	Andreas Happe <crow@old-fsckful.ath.cx>
Subject: Re: [cryptoapi/sysfs] display cipher details in sysfs
Date: Wed, 29 Sep 2004 11:37:32 +0200	[thread overview]
Message-ID: <20040929093732.GC3969@final-judgement.ath.cx> (raw)
In-Reply-To: <20040929093613.GB3969@final-judgement.ath.cx>

[-- Attachment #1: Type: text/plain, Size: 19 bytes --]

*sigh*

	--Andreas

[-- Attachment #2: patch-2.6.9-rc2-cryptoapi_preferences --]
[-- Type: text/plain, Size: 5774 bytes --]

diff -u -r -N linux-2.6.8/crypto/api.c linux-sysfs/crypto/api.c
--- linux-2.6.8/crypto/api.c	2004-09-28 12:52:40.000000000 +0200
+++ linux-sysfs/crypto/api.c	2004-09-28 23:13:57.000000000 +0200
@@ -46,7 +46,7 @@
 
 struct crypto_alg *crypto_alg_lookup(const char *name)
 {
-	struct crypto_alg *q, *alg = NULL;
+	struct crypto_alg *q, *tmp=NULL, *alg = NULL;
 	struct class_device *dev;
 
 	if (!name)
@@ -56,9 +56,15 @@
 	
 	list_for_each_entry(dev, &(cryptoapi_class.children), node) {
 		if (!(strcmp(dev->class_id, name))) {
-			q = (struct crypto_alg *)class_get_devdata(dev);
-			if (crypto_alg_get(q))
-				alg = q;
+			alg = q = class_get_devdata(dev);
+
+			list_for_each_entry(tmp, &(q->cra_family), cra_family) {
+				if(tmp->cra_preference > alg->cra_preference)
+					alg = tmp;
+			}
+
+			if(!crypto_alg_get(alg))
+				alg = NULL;
 			break;
 		}
 	}
@@ -177,13 +183,23 @@
 {
 	int ret = 0;
 	struct class_device *dev;
+	struct crypto_alg *tmp;
+	struct list_head *insert_position=NULL;
 	
 	down_write(&crypto_alg_sem);
 	
+	INIT_LIST_HEAD(&(alg->cra_family));
+
 	list_for_each_entry(dev, &(cryptoapi_class.children), node) {
 		if (!(strcmp(dev->class_id, alg->cra_name))) {
-			ret = -EEXIST;
-			goto out;
+			tmp=class_get_devdata(dev);
+
+			insert_position = &(tmp->cra_family);
+			if(!(strcmp(module_name(tmp->cra_module),\
+				    module_name(alg->cra_module)))) {
+				ret = -EEXIST;
+				goto out;
+			}
 		}
 	}
 	
@@ -196,7 +212,12 @@
 	memset(dev, 0, sizeof(*dev));
 	dev->class = &cryptoapi_class;
 	dev->dev   = NULL;
+
+	/* TODO: what to do if alg->cra_name is already in use? */
 	strncpy(dev->class_id, alg->cra_name, BUS_ID_SIZE);
+
+	if(insert_position)
+		list_add(&(alg->cra_family), insert_position);
 	class_device_register(dev);
 
 #ifdef CONFIG_SYSFS
diff -u -r -N linux-2.6.8/crypto/Kconfig linux-sysfs/crypto/Kconfig
--- linux-2.6.8/crypto/Kconfig	2004-09-28 12:50:31.000000000 +0200
+++ linux-sysfs/crypto/Kconfig	2004-09-28 12:18:25.000000000 +0200
@@ -16,6 +16,15 @@
 	  HMAC: Keyed-Hashing for Message Authentication (RFC2104).
 	  This is required for IPSec.
 
+config CRYPTO_PROC
+	bool "Legacy /proc/crypto interface (OBSOLETE)"
+	depends on PROC_FS && CRYPTO
+	help
+	  Displays cipher specific information via /proc/crypto.
+	  Please use /sysfs/class/crypto instead.
+
+	  When in double say Y.
+
 config CRYPTO_NULL
 	tristate "Null algorithms"
 	depends on CRYPTO
diff -u -r -N linux-2.6.8/crypto/Makefile linux-sysfs/crypto/Makefile
--- linux-2.6.8/crypto/Makefile	2004-09-28 12:52:40.000000000 +0200
+++ linux-sysfs/crypto/Makefile	2004-09-28 12:14:14.000000000 +0200
@@ -2,7 +2,7 @@
 # Cryptographic API
 #
 
-proc-crypto-$(CONFIG_PROC_FS) = proc.o
+proc-crypto-$(CONFIG_CRYPTO_PROC) = proc.o
 sysfs-crypto-$(CONFIG_SYSFS) = sysfs.o
 
 obj-$(CONFIG_CRYPTO) += api.o scatterwalk.o cipher.o digest.o compress.o \
diff -u -r -N linux-2.6.8/crypto/sysfs.c linux-sysfs/crypto/sysfs.c
--- linux-2.6.8/crypto/sysfs.c	2004-09-28 12:52:40.000000000 +0200
+++ linux-sysfs/crypto/sysfs.c	2004-09-28 18:57:48.000000000 +0200
@@ -14,6 +14,7 @@
 	.release = cryptoapi_release,
 };
 
+/* TODO: add cryptoapi_set_preference  */
 static ssize_t cryptoapi_show_name(struct class_device *dev, char *buffer);
 static ssize_t cryptoapi_show_blocksize(struct class_device *dev, char *buffer);
 static ssize_t cryptoapi_show_digestsize(struct class_device *dev, char *buffer);
@@ -21,6 +22,7 @@
 static ssize_t cryptoapi_show_module(struct class_device *dev, char *buffer);
 static ssize_t cryptoapi_show_maxkeysize(struct class_device *dev, char *buffer);
 static ssize_t cryptoapi_show_minkeysize(struct class_device *dev, char *buffer);
+static ssize_t cryptoapi_show_preference(struct class_device *dev, char *buffer);
 
 CLASS_DEVICE_ATTR(blocksize, 0444, cryptoapi_show_blocksize, NULL);
 CLASS_DEVICE_ATTR(digestsize, 0444, cryptoapi_show_digestsize, NULL);
@@ -29,6 +31,7 @@
 CLASS_DEVICE_ATTR(name, 0444, cryptoapi_show_name, NULL);
 CLASS_DEVICE_ATTR(module, 0444, cryptoapi_show_module, NULL);
 CLASS_DEVICE_ATTR(type, 0444, cryptoapi_show_type, NULL);
+CLASS_DEVICE_ATTR(preference, 0444, cryptoapi_show_preference, NULL);
 
 void cryptoapi_release(struct class_device *class_dev) {
 	kfree(class_dev);
@@ -46,6 +49,7 @@
 cryptoapi_show(minkeysize, cipher.cia_min_keysize, %u\n);
 cryptoapi_show(maxkeysize, cipher.cia_max_keysize, %u\n);
 cryptoapi_show(name, name, %s\n);
+cryptoapi_show(preference, preference, %u\n);
 
 #undef cryptoapi_show
 
diff -u -r -N linux-2.6.8/crypto/whirlpool.c linux-sysfs/crypto/whirlpool.c
--- linux-2.6.8/crypto/whirlpool.c	2004-09-28 12:50:31.000000000 +0200
+++ linux-sysfs/crypto/whirlpool.c	2004-09-28 12:24:23.000000000 +0200
@@ -1106,7 +1106,6 @@
 	.cra_blocksize	=	WHIRLPOOL_BLOCK_SIZE,
 	.cra_ctxsize	=	sizeof(struct whirlpool_ctx),
 	.cra_module	=	THIS_MODULE,
-	.cra_list       =       LIST_HEAD_INIT(alg.cra_list),	
 	.cra_u		=	{ .digest = {
 	.dia_digestsize	=	WHIRLPOOL_DIGEST_SIZE,
 	.dia_init   	= 	whirlpool_init,
diff -u -r -N linux-2.6.8/include/linux/crypto.h linux-sysfs/include/linux/crypto.h
--- linux-2.6.8/include/linux/crypto.h	2004-09-28 12:52:40.000000000 +0200
+++ linux-sysfs/include/linux/crypto.h	2004-09-28 23:10:46.000000000 +0200
@@ -56,6 +56,10 @@
 #define CRYPTO_UNSPEC			0
 #define CRYPTO_MAX_ALG_NAME		64
 
+#define CRYPTO_PREF_GENERIC		0
+#define CRYPTO_PREF_OPTIMIZED		10
+#define CRYPTO_PREF_HARDWARE		20
+
 struct scatterlist;
 
 /*
@@ -97,6 +101,7 @@
 	u32 cra_flags;
 	unsigned int cra_blocksize;
 	unsigned int cra_ctxsize;
+	unsigned int cra_preference;
 	const char cra_name[CRYPTO_MAX_ALG_NAME];
 
 	union {
@@ -105,6 +110,7 @@
 		struct compress_alg compress;
 	} cra_u;
 	
+	struct list_head cra_family;
 	struct module *cra_module;
 };
 

  reply	other threads:[~2004-09-29  9:38 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20040831175449.GA2946@final-judgement.ath.cx>
     [not found] ` <Xine.LNX.4.44.0409010043020.30561-100000@thoron.boston.redhat.com>
2004-09-01  8:28   ` [cryptoapi/sysfs] display cipher details in sysfs Andreas Happe
2004-09-06  0:04     ` Greg KH
2004-09-07 16:37       ` James Morris
2004-09-07 16:45         ` Greg KH
2004-09-07 16:47         ` Michal Ludvig
2004-09-07 16:52           ` Greg KH
2004-09-06 18:49     ` Michal Ludvig
2004-09-07 14:35       ` Andreas Happe
2004-09-07 15:49         ` Michal Ludvig
2004-09-07 16:57           ` Andreas Happe
2004-09-10 11:21             ` Andreas Happe
2004-09-10 10:55           ` Andreas Happe
2004-09-27  8:41             ` Andreas Happe
2004-09-27  9:10               ` Michal Ludvig
2004-09-28 12:34                 ` Andreas Happe
2004-09-29  9:36                   ` Andreas Happe
2004-09-29  9:37                     ` Andreas Happe [this message]
2004-09-29 14:13                     ` Michal Ludvig
2004-09-29 13:13                   ` Michal Ludvig
2004-09-27 15:53               ` James Morris
2004-09-28 12:21                 ` [PATCH 2.6.9-rc2 1/2] cryptoapi: update sysfs-patch Andreas Happe
2004-09-28 12:23                   ` [PATCH 2.6.9-rc2 2/2] cryptoapi: make /proc/crypto optional Andreas Happe
2004-09-28 14:32                     ` Sven Schuster
2004-09-29  8:40                       ` Andreas Happe
2004-09-07 16:36       ` [cryptoapi/sysfs] display cipher details in sysfs 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=20040929093732.GC3969@final-judgement.ath.cx \
    --to=andreashappe@flatline.ath.cx \
    --cc=crow@old-fsckful.ath.cx \
    --cc=cryptoapi@lists.logix.cz \
    --cc=jmorris@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal@logix.cz \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.