mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Happe <andreashappe@flatline.ath.cx>
To: Michal Ludvig <michal@logix.cz>
Cc: Andreas Happe <crow@old-fsckful.ath.cx>,
	cryptoapi@lists.logix.cz, linux-kernel@vger.kernel.org,
	James Morris <jmorris@redhat.com>
Subject: Re: [cryptoapi/sysfs] display cipher details in sysfs
Date: Fri, 10 Sep 2004 12:55:02 +0200	[thread overview]
Message-ID: <20040910105502.GA4663@final-judgement.ath.cx> (raw)
In-Reply-To: <Pine.LNX.4.53.0409071659070.19015@maxipes.logix.cz>


[-- Attachment #1.1: Type: text/plain, Size: 686 bytes --]

Michal Ludvig <michal@logix.cz> [040910 12:44]:
>On Tue, 7 Sep 2004, Andreas Happe wrote:
>
>> On Mon, Sep 06, 2004 at 08:49:30PM +0200, Michal Ludvig wrote:
>> > On Wed, 1 Sep 2004, Andreas Happe wrote:
>> > > the attached patch creates a /sys/cryptoapi/<cipher-name>/ hierarchie
>>
>> BTW: the latest incarnation of the patch uses /sys/class/crypto/<cipher-name>.
>
>Where can I get the updated version?

it is attached. The changes to api.c are very small (it just uses the
class_device linked list instead of cra_list).

The only 'drawback' compared to the subsystem - based patch is that I've
got to traverse the list by hand and not by something like
"kset_find_obj".

	--Andreas

[-- Attachment #1.2: patch-2.6.9-rc1-cryptoapi-sysfs-class-2 --]
[-- Type: text/plain, Size: 21764 bytes --]

diff -u -N -r linux-2.6.9-rc1/arch/i386/crypto/aes.c linux-2.6.9-rc1-class/arch/i386/crypto/aes.c
--- linux-2.6.9-rc1/arch/i386/crypto/aes.c	2004-08-28 15:33:41.000000000 +0200
+++ linux-2.6.9-rc1-class/arch/i386/crypto/aes.c	2004-09-06 14:49:20.000000000 +0200
@@ -488,7 +488,6 @@
 	.cra_blocksize		=	AES_BLOCK_SIZE,
 	.cra_ctxsize		=	sizeof(struct aes_ctx),
 	.cra_module		=	THIS_MODULE,
-	.cra_list		=	LIST_HEAD_INIT(aes_alg.cra_list),
 	.cra_u			=	{
 		.cipher = {
 			.cia_min_keysize	=	AES_MIN_KEY_SIZE,
diff -u -N -r linux-2.6.9-rc1/crypto/aes.c linux-2.6.9-rc1-class/crypto/aes.c
--- linux-2.6.9-rc1/crypto/aes.c	2004-08-28 16:20:48.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/aes.c	2004-09-06 14:49:35.000000000 +0200
@@ -437,7 +437,6 @@
 	.cra_blocksize		=	AES_BLOCK_SIZE,
 	.cra_ctxsize		=	sizeof(struct aes_ctx),
 	.cra_module		=	THIS_MODULE,
-	.cra_list		=	LIST_HEAD_INIT(aes_alg.cra_list),
 	.cra_u			=	{
 		.cipher = {
 			.cia_min_keysize	=	AES_MIN_KEY_SIZE,
diff -u -N -r linux-2.6.9-rc1/crypto/api.c linux-2.6.9-rc1-class/crypto/api.c
--- linux-2.6.9-rc1/crypto/api.c	2004-09-06 16:30:33.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/api.c	2004-09-06 23:35:59.000000000 +0200
@@ -18,10 +18,21 @@
 #include <linux/errno.h>
 #include <linux/rwsem.h>
 #include <linux/slab.h>
+#include <linux/device.h>
 #include "internal.h"
 
-LIST_HEAD(crypto_alg_list);
 DECLARE_RWSEM(crypto_alg_sem);
+extern struct class cryptoapi_class;
+
+#ifdef CONFIG_SYSFS
+extern struct class_device_attribute class_device_attr_name;
+extern struct class_device_attribute class_device_attr_module;
+extern struct class_device_attribute class_device_attr_type;
+extern struct class_device_attribute class_device_attr_blocksize;
+extern struct class_device_attribute class_device_attr_digestsize;
+extern struct class_device_attribute class_device_attr_minkeysize;
+extern struct class_device_attribute class_device_attr_maxkeysize;
+#endif
 
 static inline int crypto_alg_get(struct crypto_alg *alg)
 {
@@ -36,14 +47,16 @@
 struct crypto_alg *crypto_alg_lookup(const char *name)
 {
 	struct crypto_alg *q, *alg = NULL;
+	struct class_device *dev;
 
 	if (!name)
 		return NULL;
 	
 	down_read(&crypto_alg_sem);
 	
-	list_for_each_entry(q, &crypto_alg_list, cra_list) {
-		if (!(strcmp(q->cra_name, name))) {
+	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;
 			break;
@@ -163,19 +176,47 @@
 int crypto_register_alg(struct crypto_alg *alg)
 {
 	int ret = 0;
-	struct crypto_alg *q;
+	struct class_device *dev;
 	
 	down_write(&crypto_alg_sem);
 	
-	list_for_each_entry(q, &crypto_alg_list, cra_list) {
-		if (!(strcmp(q->cra_name, alg->cra_name))) {
+	list_for_each_entry(dev, &(cryptoapi_class.children), node) {
+		if (!(strcmp(dev->class_id, alg->cra_name))) {
 			ret = -EEXIST;
 			goto out;
 		}
 	}
 	
-	list_add_tail(&alg->cra_list, &crypto_alg_list);
-out:	
+	dev = (struct class_device*)kmalloc(sizeof(struct class_device), GFP_KERNEL);
+	if(!dev) {
+		ret = -ENOMEM;
+		goto out;
+	}
+	
+	memset(dev, 0, sizeof(*dev));
+	dev->class = &cryptoapi_class;
+	dev->dev   = NULL;
+	strncpy(dev->class_id, alg->cra_name, BUS_ID_SIZE);
+	class_device_register(dev);
+
+#ifdef CONFIG_SYSFS
+	class_set_devdata(dev, alg);
+	WARN_ON(class_device_create_file(dev, &class_device_attr_name));
+	WARN_ON(class_device_create_file(dev, &class_device_attr_module));
+	WARN_ON(class_device_create_file(dev, &class_device_attr_type));
+
+	switch(alg->cra_flags & CRYPTO_ALG_TYPE_MASK) {
+	case CRYPTO_ALG_TYPE_CIPHER:
+		WARN_ON(class_device_create_file(dev, &class_device_attr_blocksize));
+		WARN_ON(class_device_create_file(dev, &class_device_attr_minkeysize));
+		WARN_ON(class_device_create_file(dev, &class_device_attr_maxkeysize));
+		break;
+	case CRYPTO_ALG_TYPE_DIGEST:
+		WARN_ON(class_device_create_file(dev, &class_device_attr_digestsize));
+		break;
+	}
+#endif
+out:
 	up_write(&crypto_alg_sem);
 	return ret;
 }
@@ -184,13 +225,15 @@
 {
 	int ret = -ENOENT;
 	struct crypto_alg *q;
+	struct class_device *dev;
 	
 	BUG_ON(!alg->cra_module);
 	
 	down_write(&crypto_alg_sem);
-	list_for_each_entry(q, &crypto_alg_list, cra_list) {
+	list_for_each_entry(dev, &(cryptoapi_class.children), node) {
+		q = class_get_devdata(dev);
 		if (alg == q) {
-			list_del(&alg->cra_list);
+			class_device_unregister(dev);
 			ret = 0;
 			goto out;
 		}
@@ -216,6 +259,7 @@
 static int __init init_crypto(void)
 {
 	printk(KERN_INFO "Initializing Cryptographic API\n");
+	class_register(&cryptoapi_class);
 	crypto_init_proc();
 	return 0;
 }
diff -u -N -r linux-2.6.9-rc1/crypto/arc4.c linux-2.6.9-rc1-class/crypto/arc4.c
--- linux-2.6.9-rc1/crypto/arc4.c	2004-08-28 16:20:48.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/arc4.c	2004-09-06 14:49:35.000000000 +0200
@@ -75,7 +75,6 @@
 	.cra_blocksize		=	ARC4_BLOCK_SIZE,
 	.cra_ctxsize		=	sizeof(struct arc4_ctx),
 	.cra_module		=	THIS_MODULE,
-	.cra_list		=	LIST_HEAD_INIT(arc4_alg.cra_list),
 	.cra_u			=	{ .cipher = {
 	.cia_min_keysize	=	ARC4_MIN_KEY_SIZE,
 	.cia_max_keysize	=	ARC4_MAX_KEY_SIZE,
diff -u -N -r linux-2.6.9-rc1/crypto/blowfish.c linux-2.6.9-rc1-class/crypto/blowfish.c
--- linux-2.6.9-rc1/crypto/blowfish.c	2004-08-28 16:20:48.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/blowfish.c	2004-09-06 14:49:35.000000000 +0200
@@ -452,7 +452,6 @@
 	.cra_blocksize		=	BF_BLOCK_SIZE,
 	.cra_ctxsize		=	sizeof(struct bf_ctx),
 	.cra_module		=	THIS_MODULE,
-	.cra_list		=	LIST_HEAD_INIT(alg.cra_list),
 	.cra_u			=	{ .cipher = {
 	.cia_min_keysize	=	BF_MIN_KEY_SIZE,
 	.cia_max_keysize	=	BF_MAX_KEY_SIZE,
diff -u -N -r linux-2.6.9-rc1/crypto/cast5.c linux-2.6.9-rc1-class/crypto/cast5.c
--- linux-2.6.9-rc1/crypto/cast5.c	2004-06-16 07:19:29.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/cast5.c	2004-09-06 14:49:35.000000000 +0200
@@ -821,7 +821,6 @@
 	.cra_blocksize 	= CAST5_BLOCK_SIZE,
 	.cra_ctxsize 	= sizeof(struct cast5_ctx),
 	.cra_module 	= THIS_MODULE,
-	.cra_list 	= LIST_HEAD_INIT(alg.cra_list),
 	.cra_u 		= {
 		.cipher = {
 			.cia_min_keysize = CAST5_MIN_KEY_SIZE,
diff -u -N -r linux-2.6.9-rc1/crypto/cast6.c linux-2.6.9-rc1-class/crypto/cast6.c
--- linux-2.6.9-rc1/crypto/cast6.c	2004-06-16 07:19:01.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/cast6.c	2004-09-06 14:49:35.000000000 +0200
@@ -534,7 +534,6 @@
 	.cra_blocksize = CAST6_BLOCK_SIZE,
 	.cra_ctxsize = sizeof(struct cast6_ctx),
 	.cra_module = THIS_MODULE,
-	.cra_list = LIST_HEAD_INIT(alg.cra_list),
 	.cra_u = {
 		  .cipher = {
 			     .cia_min_keysize = CAST6_MIN_KEY_SIZE,
diff -u -N -r linux-2.6.9-rc1/crypto/crc32c.c linux-2.6.9-rc1-class/crypto/crc32c.c
--- linux-2.6.9-rc1/crypto/crc32c.c	2004-06-16 07:19:02.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/crc32c.c	2004-09-06 14:49:35.000000000 +0200
@@ -80,7 +80,6 @@
 	.cra_blocksize	=	CHKSUM_BLOCK_SIZE,
 	.cra_ctxsize	=	sizeof(struct chksum_ctx),
 	.cra_module	=	THIS_MODULE,
-	.cra_list	=	LIST_HEAD_INIT(alg.cra_list),
 	.cra_u		=	{
 		.digest = {
 			 .dia_digestsize=	CHKSUM_DIGEST_SIZE,
diff -u -N -r linux-2.6.9-rc1/crypto/crypto_null.c linux-2.6.9-rc1-class/crypto/crypto_null.c
--- linux-2.6.9-rc1/crypto/crypto_null.c	2004-06-16 07:19:22.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/crypto_null.c	2004-09-06 14:49:35.000000000 +0200
@@ -59,7 +59,6 @@
 	.cra_blocksize		=	NULL_BLOCK_SIZE,
 	.cra_ctxsize		=	0,
 	.cra_module		=	THIS_MODULE,
-	.cra_list		=       LIST_HEAD_INIT(compress_null.cra_list),
 	.cra_u			=	{ .compress = {
 	.coa_compress 		=	null_compress,
 	.coa_decompress		=	null_decompress } }
@@ -71,7 +70,6 @@
 	.cra_blocksize		=	NULL_BLOCK_SIZE,
 	.cra_ctxsize		=	0,
 	.cra_module		=	THIS_MODULE,
-	.cra_list		=       LIST_HEAD_INIT(digest_null.cra_list),	
 	.cra_u			=	{ .digest = {
 	.dia_digestsize		=	NULL_DIGEST_SIZE,
 	.dia_init   		=	null_init,
@@ -85,7 +83,6 @@
 	.cra_blocksize		=	NULL_BLOCK_SIZE,
 	.cra_ctxsize		=	0,
 	.cra_module		=	THIS_MODULE,
-	.cra_list		=	LIST_HEAD_INIT(cipher_null.cra_list),
 	.cra_u			=	{ .cipher = {
 	.cia_min_keysize	=	NULL_KEY_SIZE,
 	.cia_max_keysize	=	NULL_KEY_SIZE,
diff -u -N -r linux-2.6.9-rc1/crypto/deflate.c linux-2.6.9-rc1-class/crypto/deflate.c
--- linux-2.6.9-rc1/crypto/deflate.c	2004-08-28 15:33:46.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/deflate.c	2004-09-06 14:49:35.000000000 +0200
@@ -196,7 +196,6 @@
 	.cra_flags		= CRYPTO_ALG_TYPE_COMPRESS,
 	.cra_ctxsize		= sizeof(struct deflate_ctx),
 	.cra_module		= THIS_MODULE,
-	.cra_list		= LIST_HEAD_INIT(alg.cra_list),
 	.cra_u			= { .compress = {
 	.coa_init		= deflate_init,
 	.coa_exit		= deflate_exit,
diff -u -N -r linux-2.6.9-rc1/crypto/des.c linux-2.6.9-rc1-class/crypto/des.c
--- linux-2.6.9-rc1/crypto/des.c	2004-06-16 07:20:20.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/des.c	2004-09-06 14:49:35.000000000 +0200
@@ -1245,7 +1245,6 @@
 	.cra_blocksize		=	DES_BLOCK_SIZE,
 	.cra_ctxsize		=	sizeof(struct des_ctx),
 	.cra_module		=	THIS_MODULE,
-	.cra_list		=	LIST_HEAD_INIT(des_alg.cra_list),
 	.cra_u			=	{ .cipher = {
 	.cia_min_keysize	=	DES_KEY_SIZE,
 	.cia_max_keysize	=	DES_KEY_SIZE,
@@ -1260,7 +1259,6 @@
 	.cra_blocksize		=	DES3_EDE_BLOCK_SIZE,
 	.cra_ctxsize		=	sizeof(struct des3_ede_ctx),
 	.cra_module		=	THIS_MODULE,
-	.cra_list		=	LIST_HEAD_INIT(des3_ede_alg.cra_list),
 	.cra_u			=	{ .cipher = {
 	.cia_min_keysize	=	DES3_EDE_KEY_SIZE,
 	.cia_max_keysize	=	DES3_EDE_KEY_SIZE,
diff -u -N -r linux-2.6.9-rc1/crypto/khazad.c linux-2.6.9-rc1-class/crypto/khazad.c
--- linux-2.6.9-rc1/crypto/khazad.c	2004-08-28 15:33:46.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/khazad.c	2004-09-06 14:49:35.000000000 +0200
@@ -885,7 +885,6 @@
 	.cra_blocksize		=	KHAZAD_BLOCK_SIZE,
 	.cra_ctxsize		=	sizeof (struct khazad_ctx),
 	.cra_module		=	THIS_MODULE,
-	.cra_list		=	LIST_HEAD_INIT(khazad_alg.cra_list),
 	.cra_u			=	{ .cipher = {
 	.cia_min_keysize	=	KHAZAD_KEY_SIZE,
 	.cia_max_keysize	=	KHAZAD_KEY_SIZE,
diff -u -N -r linux-2.6.9-rc1/crypto/Makefile linux-2.6.9-rc1-class/crypto/Makefile
--- linux-2.6.9-rc1/crypto/Makefile	2004-08-28 15:33:46.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/Makefile	2004-09-06 14:49:35.000000000 +0200
@@ -3,9 +3,10 @@
 #
 
 proc-crypto-$(CONFIG_PROC_FS) = proc.o
+sysfs-crypto-$(CONFIG_SYSFS) = sysfs.o
 
 obj-$(CONFIG_CRYPTO) += api.o scatterwalk.o cipher.o digest.o compress.o \
-			$(proc-crypto-y)
+			$(proc-crypto-y) $(sysfs-crypto-y)
 
 obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
 obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o
diff -u -N -r linux-2.6.9-rc1/crypto/md4.c linux-2.6.9-rc1-class/crypto/md4.c
--- linux-2.6.9-rc1/crypto/md4.c	2004-06-16 07:19:26.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/md4.c	2004-09-06 14:49:35.000000000 +0200
@@ -224,7 +224,6 @@
 	.cra_blocksize	=	MD4_HMAC_BLOCK_SIZE,
 	.cra_ctxsize	=	sizeof(struct md4_ctx),
 	.cra_module	=	THIS_MODULE,
-	.cra_list       =       LIST_HEAD_INIT(alg.cra_list),	
 	.cra_u		=	{ .digest = {
 	.dia_digestsize	=	MD4_DIGEST_SIZE,
 	.dia_init   	= 	md4_init,
diff -u -N -r linux-2.6.9-rc1/crypto/md5.c linux-2.6.9-rc1-class/crypto/md5.c
--- linux-2.6.9-rc1/crypto/md5.c	2004-06-16 07:19:22.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/md5.c	2004-09-06 14:49:35.000000000 +0200
@@ -219,7 +219,6 @@
 	.cra_blocksize	=	MD5_HMAC_BLOCK_SIZE,
 	.cra_ctxsize	=	sizeof(struct md5_ctx),
 	.cra_module	=	THIS_MODULE,
-	.cra_list	=	LIST_HEAD_INIT(alg.cra_list),
 	.cra_u		=	{ .digest = {
 	.dia_digestsize	=	MD5_DIGEST_SIZE,
 	.dia_init   	= 	md5_init,
diff -u -N -r linux-2.6.9-rc1/crypto/michael_mic.c linux-2.6.9-rc1-class/crypto/michael_mic.c
--- linux-2.6.9-rc1/crypto/michael_mic.c	2004-06-16 07:19:37.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/michael_mic.c	2004-09-06 14:49:35.000000000 +0200
@@ -163,7 +163,6 @@
 	.cra_blocksize	= 8,
 	.cra_ctxsize	= sizeof(struct michael_mic_ctx),
 	.cra_module	= THIS_MODULE,
-	.cra_list	= LIST_HEAD_INIT(michael_mic_alg.cra_list),
 	.cra_u		= { .digest = {
 	.dia_digestsize	= 8,
 	.dia_init	= michael_init,
diff -u -N -r linux-2.6.9-rc1/crypto/proc.c linux-2.6.9-rc1-class/crypto/proc.c
--- linux-2.6.9-rc1/crypto/proc.c	2004-06-16 07:19:03.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/proc.c	2004-09-06 16:57:40.000000000 +0200
@@ -16,9 +16,10 @@
 #include <linux/rwsem.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/device.h>
 #include "internal.h"
 
-extern struct list_head crypto_alg_list;
+extern struct class cryptoapi_class;
 extern struct rw_semaphore crypto_alg_sem;
 
 static void *c_start(struct seq_file *m, loff_t *pos)
@@ -27,20 +28,20 @@
 	loff_t n = *pos;
 
 	down_read(&crypto_alg_sem);
-	list_for_each(v, &crypto_alg_list)
+	list_for_each(v, &cryptoapi_class.children)
 		if (!n--)
-			return list_entry(v, struct crypto_alg, cra_list);
+			return list_entry(v, struct class_device, node);
 	return NULL;
 }
 
 static void *c_next(struct seq_file *m, void *p, loff_t *pos)
 {
-	struct list_head *v = p;
-	
+	struct list_head *e = &(((struct class_device*)p)->node);
+
 	(*pos)++;
-	v = v->next;
-	return (v == &crypto_alg_list) ?
-		NULL : list_entry(v, struct crypto_alg, cra_list);
+	e = e->next;
+	return (e == &(cryptoapi_class.children)) ?
+		NULL : list_entry(e, struct class_device, node);
 }
 
 static void c_stop(struct seq_file *m, void *p)
@@ -50,8 +51,8 @@
 
 static int c_show(struct seq_file *m, void *p)
 {
-	struct crypto_alg *alg = (struct crypto_alg *)p;
-	
+	struct crypto_alg *alg = (struct crypt_alg*)class_get_devdata((struct class_device*)p);
+
 	seq_printf(m, "name         : %s\n", alg->cra_name);
 	seq_printf(m, "module       : %s\n", module_name(alg->cra_module));
 	
diff -u -N -r linux-2.6.9-rc1/crypto/serpent.c linux-2.6.9-rc1-class/crypto/serpent.c
--- linux-2.6.9-rc1/crypto/serpent.c	2004-06-16 07:19:09.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/serpent.c	2004-09-06 14:49:35.000000000 +0200
@@ -479,7 +479,6 @@
 	.cra_blocksize		=	SERPENT_BLOCK_SIZE,
 	.cra_ctxsize		=	sizeof(struct serpent_ctx),
 	.cra_module		=	THIS_MODULE,
-	.cra_list		=	LIST_HEAD_INIT(serpent_alg.cra_list),
 	.cra_u			=	{ .cipher = {
 	.cia_min_keysize	=	SERPENT_MIN_KEY_SIZE,
 	.cia_max_keysize	=	SERPENT_MAX_KEY_SIZE,
diff -u -N -r linux-2.6.9-rc1/crypto/sha1.c linux-2.6.9-rc1-class/crypto/sha1.c
--- linux-2.6.9-rc1/crypto/sha1.c	2004-06-16 07:19:02.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/sha1.c	2004-09-06 14:49:35.000000000 +0200
@@ -183,7 +183,6 @@
 	.cra_blocksize	=	SHA1_HMAC_BLOCK_SIZE,
 	.cra_ctxsize	=	sizeof(struct sha1_ctx),
 	.cra_module	=	THIS_MODULE,
-	.cra_list       =       LIST_HEAD_INIT(alg.cra_list),
 	.cra_u		=	{ .digest = {
 	.dia_digestsize	=	SHA1_DIGEST_SIZE,
 	.dia_init   	= 	sha1_init,
diff -u -N -r linux-2.6.9-rc1/crypto/sha256.c linux-2.6.9-rc1-class/crypto/sha256.c
--- linux-2.6.9-rc1/crypto/sha256.c	2004-06-16 07:19:13.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/sha256.c	2004-09-06 14:49:35.000000000 +0200
@@ -337,7 +337,6 @@
 	.cra_blocksize	=	SHA256_HMAC_BLOCK_SIZE,
 	.cra_ctxsize	=	sizeof(struct sha256_ctx),
 	.cra_module	=	THIS_MODULE,
-	.cra_list       =       LIST_HEAD_INIT(alg.cra_list),
 	.cra_u		=	{ .digest = {
 	.dia_digestsize	=	SHA256_DIGEST_SIZE,
 	.dia_init   	= 	sha256_init,
diff -u -N -r linux-2.6.9-rc1/crypto/sha512.c linux-2.6.9-rc1-class/crypto/sha512.c
--- linux-2.6.9-rc1/crypto/sha512.c	2004-06-16 07:20:04.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/sha512.c	2004-09-06 14:49:35.000000000 +0200
@@ -324,7 +324,6 @@
         .cra_blocksize  = SHA512_HMAC_BLOCK_SIZE,
         .cra_ctxsize    = sizeof(struct sha512_ctx),
         .cra_module     = THIS_MODULE,
-        .cra_list       = LIST_HEAD_INIT(sha512.cra_list),
         .cra_u          = { .digest = {
                                 .dia_digestsize = SHA512_DIGEST_SIZE,
                                 .dia_init       = sha512_init,
@@ -339,7 +338,6 @@
         .cra_blocksize  = SHA384_HMAC_BLOCK_SIZE,
         .cra_ctxsize    = sizeof(struct sha512_ctx),
         .cra_module     = THIS_MODULE,
-        .cra_list       = LIST_HEAD_INIT(sha384.cra_list),
         .cra_u          = { .digest = {
                                 .dia_digestsize = SHA384_DIGEST_SIZE,
                                 .dia_init       = sha384_init,
diff -u -N -r linux-2.6.9-rc1/crypto/sysfs.c linux-2.6.9-rc1-class/crypto/sysfs.c
--- linux-2.6.9-rc1/crypto/sysfs.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.9-rc1-class/crypto/sysfs.c	2004-09-06 23:42:00.000000000 +0200
@@ -0,0 +1,75 @@
+#include <linux/init.h>
+#include <linux/crypto.h>
+#include <linux/errno.h>
+#include <linux/rwsem.h>
+#include <linux/slab.h>
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include "internal.h"
+
+void cryptoapi_release(struct class_device *class_dev);
+
+struct class cryptoapi_class = {
+	.name = "crypto",
+	.release = cryptoapi_release,
+};
+
+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);
+static ssize_t cryptoapi_show_type(struct class_device *dev, char *buffer);
+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);
+
+CLASS_DEVICE_ATTR(blocksize, 0444, cryptoapi_show_blocksize, NULL);
+CLASS_DEVICE_ATTR(digestsize, 0444, cryptoapi_show_digestsize, NULL);
+CLASS_DEVICE_ATTR(minkeysize, 0444, cryptoapi_show_minkeysize, NULL);
+CLASS_DEVICE_ATTR(maxkeysize, 0444, cryptoapi_show_maxkeysize, NULL);
+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);
+
+void cryptoapi_release(struct class_device *class_dev) {
+	kfree(class_dev);
+}
+
+#define cryptoapi_show(_name, _attr, _format) \
+	static ssize_t cryptoapi_show_##_name(struct class_device *dev, char *buffer) { \
+		BUG_ON(dev==NULL); \
+		return (snprintf(buffer, PAGE_SIZE, __stringify(_format), \
+				((struct crypto_alg*)class_get_devdata(dev))->cra_##_attr)+1)*sizeof(char); \
+	}
+
+cryptoapi_show(blocksize, blocksize, %u\n);
+cryptoapi_show(digestsize, digest.dia_digestsize, %u\n);
+cryptoapi_show(minkeysize, cipher.cia_min_keysize, %u\n);
+cryptoapi_show(maxkeysize, cipher.cia_max_keysize, %u\n);
+cryptoapi_show(name, name, %s\n);
+
+#undef cryptoapi_show
+
+static ssize_t cryptoapi_show_module(struct class_device *dev, char *buffer) {
+	BUG_ON(dev==NULL);
+	return (snprintf(buffer, PAGE_SIZE, "%s\n",
+			module_name(((struct crypto_alg*)class_get_devdata(dev))->cra_module))+1)*sizeof(char);
+}
+
+static ssize_t cryptoapi_show_type(struct class_device *dev, char *buffer) {
+	struct crypto_alg *tmp = class_get_devdata(dev);
+	
+	switch(tmp->cra_flags & CRYPTO_ALG_TYPE_MASK) {
+	case CRYPTO_ALG_TYPE_CIPHER:
+		strncpy(buffer, "cipher\n", PAGE_SIZE);
+		break;
+	case CRYPTO_ALG_TYPE_DIGEST:
+		strncpy(buffer, "digest\n", PAGE_SIZE);
+		break;
+	case CRYPTO_ALG_TYPE_COMPRESS:
+		strncpy(buffer, "compression\n", PAGE_SIZE);
+		break;
+	default:
+		strncpy(buffer, "unknown\n", PAGE_SIZE);
+	}
+	return (strlen(buffer)+1)*sizeof(char);
+}
diff -u -N -r linux-2.6.9-rc1/crypto/tea.c linux-2.6.9-rc1-class/crypto/tea.c
--- linux-2.6.9-rc1/crypto/tea.c	2004-08-28 15:33:46.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/tea.c	2004-09-06 14:49:35.000000000 +0200
@@ -191,7 +191,6 @@
 	.cra_blocksize		=	TEA_BLOCK_SIZE,
 	.cra_ctxsize		=	sizeof (struct tea_ctx),
 	.cra_module		=	THIS_MODULE,
-	.cra_list		=	LIST_HEAD_INIT(tea_alg.cra_list),
 	.cra_u			=	{ .cipher = {
 	.cia_min_keysize	=	TEA_KEY_SIZE,
 	.cia_max_keysize	=	TEA_KEY_SIZE,
@@ -206,7 +205,6 @@
 	.cra_blocksize		=	XTEA_BLOCK_SIZE,
 	.cra_ctxsize		=	sizeof (struct xtea_ctx),
 	.cra_module		=	THIS_MODULE,
-	.cra_list		=	LIST_HEAD_INIT(xtea_alg.cra_list),
 	.cra_u			=	{ .cipher = {
 	.cia_min_keysize	=	XTEA_KEY_SIZE,
 	.cia_max_keysize	=	XTEA_KEY_SIZE,
diff -u -N -r linux-2.6.9-rc1/crypto/twofish.c linux-2.6.9-rc1-class/crypto/twofish.c
--- linux-2.6.9-rc1/crypto/twofish.c	2004-08-28 16:20:48.000000000 +0200
+++ linux-2.6.9-rc1-class/crypto/twofish.c	2004-09-06 14:49:35.000000000 +0200
@@ -876,7 +876,6 @@
 	.cra_blocksize      =   TF_BLOCK_SIZE,
 	.cra_ctxsize        =   sizeof(struct twofish_ctx),
 	.cra_module         =   THIS_MODULE,
-	.cra_list           =   LIST_HEAD_INIT(alg.cra_list),
 	.cra_u              =   { .cipher = {
 	.cia_min_keysize    =   TF_MIN_KEY_SIZE,
 	.cia_max_keysize    =   TF_MAX_KEY_SIZE,
diff -u -N -r linux-2.6.9-rc1/include/linux/crypto.h linux-2.6.9-rc1-class/include/linux/crypto.h
--- linux-2.6.9-rc1/include/linux/crypto.h	2004-06-16 07:19:03.000000000 +0200
+++ linux-2.6.9-rc1-class/include/linux/crypto.h	2004-09-06 18:01:06.000000000 +0200
@@ -94,7 +94,6 @@
 #define cra_compress	cra_u.compress
 
 struct crypto_alg {
-	struct list_head cra_list;
 	u32 cra_flags;
 	unsigned int cra_blocksize;
 	unsigned int cra_ctxsize;

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  parent reply	other threads:[~2004-09-11 22:32 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   ` 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 [this message]
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
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=20040910105502.GA4663@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome