* [cryptoapi/sysfs] display cipher details in sysfs [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-06 18:49 ` Michal Ludvig 0 siblings, 2 replies; 25+ messages in thread From: Andreas Happe @ 2004-09-01 8:28 UTC (permalink / raw) To: James Morris; +Cc: linux-kernel, cryptoapi [-- Attachment #1.1: Type: text/plain, Size: 1706 bytes --] Hi, following-up to: James Morris <jmorris@redhat.com> [040901 09:35]: >This looks potentially useful, although I'm not sure yet whether the >userland crypto API should be exposed via sysfs or a separate filesystem. > >I suggest you post the patch to linux-kernel and the crypto API list at: >http://lists.logix.cz/pipermail/cryptoapi as an RFC, for wider feedback. the attached patch creates a /sys/cryptoapi/<cipher-name>/ hierarchie which includes all information which is currently offered by /proc/crypto. This was done by embedding a kobject in struct crypto_alg (include/linux/crypto.h) and using a kset/subsystem instead of the currently used list (crypto_alg->cra_list was removed, as it shouldn't be needed anymore). crypto/proc.c was converted to use the subsystem internal rwlock/list for its iteration of ciphers. I think that the place for the cryptoapi-tree in sysfs is wrong (but the others (block, module, bus, class, etc.) seemed worse). But the effort to change this should be neglectable (and centered at syfs.c). Also the different cipher types (digest, compress..) could be seperated into own ksets/directories, but this would make the crypto/proc.c code worse. small example: | bash-2.05b# cd /sys/cryptoapi/ | bash-2.05b# ls | aes blowfish cipher_null compress_null deflate des des3_ede | digest_null md5 serpent sha1 sha256 twofish | bash-2.05b# cd aes/ | bash-2.05b# ls | blocksize maxkeysize minkeysize module name type | bash-2.05b# cat blocksize | 16 | bash-2.05b# cd ./../sha1/ | bash-2.05b# ls | digestsize module name type | bash-2.05b# cat digestsize | 20 | bash-2.05b# cat type | digest --Andreas [-- Attachment #1.2: patch-2.6.9-rc1-cryptoapi-sysfs --] [-- Type: text/plain, Size: 23139 bytes --] diff -u -N -r linux-2.6.9-rc1/arch/i386/crypto/aes.c linux-2.6.9-rc1-sys2/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-sys2/arch/i386/crypto/aes.c 2004-08-31 22:50:01.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-sys2/crypto/aes.c --- linux-2.6.9-rc1/crypto/aes.c 2004-08-28 16:20:48.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/aes.c 2004-08-31 22:29:06.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-sys2/crypto/api.c --- linux-2.6.9-rc1/crypto/api.c 2004-06-16 07:20:04.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/api.c 2004-08-31 22:21:01.000000000 +0200 @@ -18,40 +18,58 @@ #include <linux/errno.h> #include <linux/rwsem.h> #include <linux/slab.h> +#include <linux/kernel.h> #include "internal.h" -LIST_HEAD(crypto_alg_list); -DECLARE_RWSEM(crypto_alg_sem); +#ifdef CONFIG_SYSFS +extern struct sysfs_ops cryptoapi_ops; +extern struct attribute cryptoapi_attr_blocksize; +extern struct attribute cryptoapi_attr_digestsize; +extern struct attribute cryptoapi_attr_minkeysize; +extern struct attribute cryptoapi_attr_maxkeysize; +extern struct attribute *cryptoapi_attributes[]; + +extern ssize_t cryptoapi_show(struct kobject *kobj, struct attribute *attr, char *buffer); +#endif +void cryptoapi_release(struct kobject *kobj); + +static struct kobj_type cryptoapi_type = { + .release = cryptoapi_release, +#ifdef CONFIG_SYSFS + .sysfs_ops = &cryptoapi_ops, + .default_attrs = cryptoapi_attributes +#endif +}; + +decl_subsys(cryptoapi, &cryptoapi_type, NULL); + +void cryptoapi_release(struct kobject *kobj) {} static inline int crypto_alg_get(struct crypto_alg *alg) { + kobject_get(&(alg->cra_obj)); return try_module_get(alg->cra_module); } static inline void crypto_alg_put(struct crypto_alg *alg) { + kobject_put(&(alg->cra_obj)); module_put(alg->cra_module); } struct crypto_alg *crypto_alg_lookup(const char *name) { - struct crypto_alg *q, *alg = NULL; - - if (!name) - return NULL; - - down_read(&crypto_alg_sem); + struct kobject *obj=NULL; + struct crypto_alg *result=NULL; - list_for_each_entry(q, &crypto_alg_list, cra_list) { - if (!(strcmp(q->cra_name, name))) { - if (crypto_alg_get(q)) - alg = q; - break; - } + obj = kset_find_obj(&(cryptoapi_subsys.kset), name); + + if(obj) { + result = container_of(obj, struct crypto_alg, cra_obj); + if(result) + result = (crypto_alg_get(result))?result:NULL; } - - up_read(&crypto_alg_sem); - return alg; + return result; } static int crypto_init_flags(struct crypto_tfm *tfm, u32 flags) @@ -163,40 +181,38 @@ int crypto_register_alg(struct crypto_alg *alg) { int ret = 0; - struct crypto_alg *q; - - down_write(&crypto_alg_sem); - list_for_each_entry(q, &crypto_alg_list, cra_list) { - if (!(strcmp(q->cra_name, alg->cra_name))) { - ret = -EEXIST; - goto out; + if(kset_find_obj(&(cryptoapi_subsys.kset), alg->cra_name)) { + ret = -EEXIST; + } else { + kobject_init(&(alg->cra_obj)); + BUG_ON(kobject_set_name(&(alg->cra_obj), alg->cra_name)); + alg->cra_obj.kset = &cryptoapi_subsys.kset; + BUG_ON(kobject_add(&(alg->cra_obj))); +#ifdef CONFIG_SYSFS + switch(alg->cra_flags & CRYPTO_ALG_TYPE_MASK) { + case CRYPTO_ALG_TYPE_CIPHER: + WARN_ON(sysfs_create_file(&(alg->cra_obj), &cryptoapi_attr_blocksize)); + WARN_ON(sysfs_create_file(&(alg->cra_obj), &cryptoapi_attr_minkeysize)); + WARN_ON(sysfs_create_file(&(alg->cra_obj), &cryptoapi_attr_maxkeysize)); + break; + case CRYPTO_ALG_TYPE_DIGEST: + WARN_ON(sysfs_create_file(&(alg->cra_obj), &cryptoapi_attr_digestsize)); + break; } +#endif } - - list_add_tail(&alg->cra_list, &crypto_alg_list); -out: - up_write(&crypto_alg_sem); return ret; } int crypto_unregister_alg(struct crypto_alg *alg) { int ret = -ENOENT; - struct crypto_alg *q; - - BUG_ON(!alg->cra_module); - - down_write(&crypto_alg_sem); - list_for_each_entry(q, &crypto_alg_list, cra_list) { - if (alg == q) { - list_del(&alg->cra_list); - ret = 0; - goto out; - } + + if(kset_find_obj(&(cryptoapi_subsys.kset), alg->cra_name)) { + kobject_unregister(&(alg->cra_obj)); + ret = 0; } -out: - up_write(&crypto_alg_sem); return ret; } @@ -216,6 +232,7 @@ static int __init init_crypto(void) { printk(KERN_INFO "Initializing Cryptographic API\n"); + subsystem_register(&cryptoapi_subsys); crypto_init_proc(); return 0; } diff -u -N -r linux-2.6.9-rc1/crypto/arc4.c linux-2.6.9-rc1-sys2/crypto/arc4.c --- linux-2.6.9-rc1/crypto/arc4.c 2004-08-28 16:20:48.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/arc4.c 2004-08-31 22:29:13.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-sys2/crypto/blowfish.c --- linux-2.6.9-rc1/crypto/blowfish.c 2004-08-28 16:20:48.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/blowfish.c 2004-08-31 22:29:19.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-sys2/crypto/cast5.c --- linux-2.6.9-rc1/crypto/cast5.c 2004-06-16 07:19:29.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/cast5.c 2004-08-31 22:29:27.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-sys2/crypto/cast6.c --- linux-2.6.9-rc1/crypto/cast6.c 2004-06-16 07:19:01.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/cast6.c 2004-08-31 22:29:37.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-sys2/crypto/crc32c.c --- linux-2.6.9-rc1/crypto/crc32c.c 2004-06-16 07:19:02.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/crc32c.c 2004-08-31 22:29:46.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-sys2/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-sys2/crypto/crypto_null.c 2004-08-31 22:29:59.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-sys2/crypto/deflate.c --- linux-2.6.9-rc1/crypto/deflate.c 2004-08-28 15:33:46.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/deflate.c 2004-08-31 22:30:04.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-sys2/crypto/des.c --- linux-2.6.9-rc1/crypto/des.c 2004-06-16 07:20:20.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/des.c 2004-08-31 22:30:16.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-sys2/crypto/khazad.c --- linux-2.6.9-rc1/crypto/khazad.c 2004-08-28 15:33:46.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/khazad.c 2004-08-31 22:30:22.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-sys2/crypto/Makefile --- linux-2.6.9-rc1/crypto/Makefile 2004-08-28 15:33:46.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/Makefile 2004-08-31 22:21:01.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-sys2/crypto/md4.c --- linux-2.6.9-rc1/crypto/md4.c 2004-06-16 07:19:26.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/md4.c 2004-08-31 22:30:28.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-sys2/crypto/md5.c --- linux-2.6.9-rc1/crypto/md5.c 2004-06-16 07:19:22.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/md5.c 2004-08-31 22:30:34.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-sys2/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-sys2/crypto/michael_mic.c 2004-08-31 22:30:39.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-sys2/crypto/proc.c --- linux-2.6.9-rc1/crypto/proc.c 2004-06-16 07:19:03.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/proc.c 2004-08-31 22:21:01.000000000 +0200 @@ -18,40 +18,39 @@ #include <linux/seq_file.h> #include "internal.h" -extern struct list_head crypto_alg_list; -extern struct rw_semaphore crypto_alg_sem; +extern struct subsystem cryptoapi_subsys; static void *c_start(struct seq_file *m, loff_t *pos) { struct list_head *v; loff_t n = *pos; - down_read(&crypto_alg_sem); - list_for_each(v, &crypto_alg_list) + down_read(&cryptoapi_subsys.rwsem); + list_for_each(v, &cryptoapi_subsys.kset.list) if (!n--) - return list_entry(v, struct crypto_alg, cra_list); + return list_entry(v, struct kobject, entry); 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 kobject*)p)->entry); + (*pos)++; - v = v->next; - return (v == &crypto_alg_list) ? - NULL : list_entry(v, struct crypto_alg, cra_list); + e = e->next; + return (e == &cryptoapi_subsys.kset.list) ? + NULL : list_entry(e, struct kobject, entry); } static void c_stop(struct seq_file *m, void *p) { - up_read(&crypto_alg_sem); + up_read(&cryptoapi_subsys.rwsem); } static int c_show(struct seq_file *m, void *p) { - struct crypto_alg *alg = (struct crypto_alg *)p; - + struct crypto_alg *alg = container_of(p, struct crypto_alg, cra_obj); + 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-sys2/crypto/serpent.c --- linux-2.6.9-rc1/crypto/serpent.c 2004-06-16 07:19:09.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/serpent.c 2004-08-31 22:30:46.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-sys2/crypto/sha1.c --- linux-2.6.9-rc1/crypto/sha1.c 2004-06-16 07:19:02.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/sha1.c 2004-08-31 22:30:52.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-sys2/crypto/sha256.c --- linux-2.6.9-rc1/crypto/sha256.c 2004-06-16 07:19:13.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/sha256.c 2004-08-31 22:31:11.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-sys2/crypto/sha512.c --- linux-2.6.9-rc1/crypto/sha512.c 2004-06-16 07:20:04.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/sha512.c 2004-08-31 22:31:00.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-sys2/crypto/sysfs.c --- linux-2.6.9-rc1/crypto/sysfs.c 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.6.9-rc1-sys2/crypto/sysfs.c 2004-08-31 22:21:01.000000000 +0200 @@ -0,0 +1,95 @@ +#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 "internal.h" + +struct cryptoapi_attribute { + struct attribute attr; + ssize_t (*show)(struct crypto_alg *, char *); +}; + +static ssize_t cryptoapi_show(struct kobject *kobj, struct attribute *attr, char *buffer); + +static ssize_t cryptoapi_show_name(struct crypto_alg *tmp, char *buffer); +static ssize_t cryptoapi_show_blocksize(struct crypto_alg *tmp, char *buffer); +static ssize_t cryptoapi_show_digestsize(struct crypto_alg *tmp, char *buffer); +static ssize_t cryptoapi_show_type(struct crypto_alg *tmp, char *buffer); +static ssize_t cryptoapi_show_module(struct crypto_alg *tmp, char *buffer); +static ssize_t cryptoapi_show_maxkeysize(struct crypto_alg *tmp, char *buffer); +static ssize_t cryptoapi_show_minkeysize(struct crypto_alg *tmp, char *buffer); + +struct sysfs_ops cryptoapi_ops = { + .show = cryptoapi_show, + .store = NULL, +}; + +#define to_cryptoapi_attribute(X) container_of(X, struct cryptoapi_attribute, attr) +#define cryptoapi_attribute(X, Y) { .attr = {__stringify(X), NULL, 0444}, .show = Y } + +struct cryptoapi_attribute cryptoapi_attr_blocksize = cryptoapi_attribute(blocksize, cryptoapi_show_blocksize); +struct cryptoapi_attribute cryptoapi_attr_digestsize = cryptoapi_attribute(digestsize, cryptoapi_show_digestsize); +struct cryptoapi_attribute cryptoapi_attr_minkeysize = cryptoapi_attribute(minkeysize, cryptoapi_show_minkeysize); +struct cryptoapi_attribute cryptoapi_attr_maxkeysize = cryptoapi_attribute(maxkeysize, cryptoapi_show_maxkeysize); +struct cryptoapi_attribute cryptoapi_attr_name = cryptoapi_attribute(name, cryptoapi_show_name); +struct cryptoapi_attribute cryptoapi_attr_module = cryptoapi_attribute(module, cryptoapi_show_module); +struct cryptoapi_attribute cryptoapi_attr_type = cryptoapi_attribute(type, cryptoapi_show_type); + +struct attribute *cryptoapi_attributes[] = { + &cryptoapi_attr_name.attr, + &cryptoapi_attr_type.attr, + &cryptoapi_attr_module.attr, + NULL, +}; + +static ssize_t cryptoapi_show_blocksize(struct crypto_alg *tmp, char *buffer) { + return (snprintf(buffer, PAGE_SIZE, "%u\n", tmp->cra_blocksize)+1)*sizeof(char); +} + +static ssize_t cryptoapi_show_digestsize(struct crypto_alg *tmp, char *buffer) { + return (snprintf(buffer, PAGE_SIZE, "%u\n", tmp->cra_digest.dia_digestsize)+1)*sizeof(char); +} + +static ssize_t cryptoapi_show_minkeysize(struct crypto_alg *tmp, char *buffer) { + return (snprintf(buffer, PAGE_SIZE, "%u\n", tmp->cra_cipher.cia_min_keysize)+1)*sizeof(char); +} + +static ssize_t cryptoapi_show_maxkeysize(struct crypto_alg *tmp, char *buffer) { + return (snprintf(buffer, PAGE_SIZE, "%u\n", tmp->cra_cipher.cia_max_keysize)+1)*sizeof(char); +} + +static ssize_t cryptoapi_show_name(struct crypto_alg *tmp, char *buffer) { + return (snprintf(buffer, PAGE_SIZE, "%s\n", tmp->cra_name)+1)*sizeof(char); +} + +static ssize_t cryptoapi_show_module(struct crypto_alg *tmp, char *buffer) { + return (snprintf(buffer, PAGE_SIZE, "%s\n", module_name(tmp->cra_module))+1)*sizeof(char); +} + +static ssize_t cryptoapi_show_type(struct crypto_alg *tmp, char *buffer) { + 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); +} + +static ssize_t cryptoapi_show(struct kobject *kobj, struct attribute *attr, + char *buffer) { + struct cryptoapi_attribute *ca_attr = to_cryptoapi_attribute(attr); + + if(ca_attr->show) + return ca_attr->show(container_of(kobj, struct crypto_alg, cra_obj), buffer); + return 0; +} diff -u -N -r linux-2.6.9-rc1/crypto/tea.c linux-2.6.9-rc1-sys2/crypto/tea.c --- linux-2.6.9-rc1/crypto/tea.c 2004-08-28 15:33:46.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/tea.c 2004-08-31 22:31:23.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-sys2/crypto/twofish.c --- linux-2.6.9-rc1/crypto/twofish.c 2004-08-28 16:20:48.000000000 +0200 +++ linux-2.6.9-rc1-sys2/crypto/twofish.c 2004-08-31 22:31:32.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-sys2/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-sys2/include/linux/crypto.h 2004-08-31 22:31:49.000000000 +0200 @@ -94,7 +94,7 @@ #define cra_compress cra_u.compress struct crypto_alg { - struct list_head cra_list; + struct kobject cra_obj; u32 cra_flags; unsigned int cra_blocksize; unsigned int cra_ctxsize; [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 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-06 18:49 ` Michal Ludvig 1 sibling, 1 reply; 25+ messages in thread From: Greg KH @ 2004-09-06 0:04 UTC (permalink / raw) To: Andreas Happe; +Cc: James Morris, linux-kernel, cryptoapi On Wed, Sep 01, 2004 at 10:28:19AM +0200, Andreas Happe wrote: > Hi, > > following-up to: James Morris <jmorris@redhat.com> [040901 09:35]: > >This looks potentially useful, although I'm not sure yet whether the > >userland crypto API should be exposed via sysfs or a separate filesystem. > > > >I suggest you post the patch to linux-kernel and the crypto API list at: > >http://lists.logix.cz/pipermail/cryptoapi as an RFC, for wider feedback. > > the attached patch creates a /sys/cryptoapi/<cipher-name>/ hierarchie > which includes all information which is currently offered by > /proc/crypto. This was done by embedding a kobject in struct crypto_alg > (include/linux/crypto.h) and using a kset/subsystem instead of the > currently used list (crypto_alg->cra_list was removed, as it shouldn't > be needed anymore). crypto/proc.c was converted to use the subsystem > internal rwlock/list for its iteration of ciphers. > > I think that the place for the cryptoapi-tree in sysfs is wrong (but the > others (block, module, bus, class, etc.) seemed worse). But the effort > to change this should be neglectable (and centered at syfs.c). Why not use a class instead of a raw kobject? Wouldn't a struct class_device make things easier for you? That would also put the stuff into /sys/class/cryptoapi which I think makes a bit more sense than /sys/cryptoapi. Or how about just /sys/class/crypto ? Other than that, I like this move, /proc/crypto isn't the best thing to have in a proc filesystem :) thanks, greg k-h ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 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 0 siblings, 2 replies; 25+ messages in thread From: James Morris @ 2004-09-07 16:37 UTC (permalink / raw) To: Greg KH; +Cc: Andreas Happe, linux-kernel, cryptoapi On Sun, 5 Sep 2004, Greg KH wrote: > Other than that, I like this move, /proc/crypto isn't the best thing to > have in a proc filesystem :) The only issue is what to do about potentially expanding this into an API (e.g. open() an algorithm and write to it). Does this sort of thing belong in sysfs? - James -- James Morris <jmorris@redhat.com> ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 2004-09-07 16:37 ` James Morris @ 2004-09-07 16:45 ` Greg KH 2004-09-07 16:47 ` Michal Ludvig 1 sibling, 0 replies; 25+ messages in thread From: Greg KH @ 2004-09-07 16:45 UTC (permalink / raw) To: James Morris; +Cc: Andreas Happe, linux-kernel, cryptoapi On Tue, Sep 07, 2004 at 12:37:48PM -0400, James Morris wrote: > On Sun, 5 Sep 2004, Greg KH wrote: > > > Other than that, I like this move, /proc/crypto isn't the best thing to > > have in a proc filesystem :) > > The only issue is what to do about potentially expanding this into an API > (e.g. open() an algorithm and write to it). Does this sort of thing > belong in sysfs? No, not really. That should be in a special fs just for crypto stuff (cryptofs?) sysfs is for displaying and setting single units of kernel information at at time. So for just showing this crypto information, it would be fine to use. thanks, greg k-h ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 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 1 sibling, 1 reply; 25+ messages in thread From: Michal Ludvig @ 2004-09-07 16:47 UTC (permalink / raw) To: James Morris; +Cc: Greg KH, Andreas Happe, cryptoapi, linux-kernel On Tue, 7 Sep 2004, James Morris wrote: > On Sun, 5 Sep 2004, Greg KH wrote: > > > Other than that, I like this move, /proc/crypto isn't the best thing to > > have in a proc filesystem :) > > The only issue is what to do about potentially expanding this into an API > (e.g. open() an algorithm and write to it). Does this sort of thing > belong in sysfs? I already proposed to have a 'cryptoapifs' mounted e.g. under /dev/cryptoapi with the "active" entrypoints while /sys would only hold the "status" of the cryptoapi. Would this be a better approach? Michal Ludvig -- * A mouse is a device used to point at the xterm you want to type in. * Personal homepage - http://www.logix.cz/michal ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 2004-09-07 16:47 ` Michal Ludvig @ 2004-09-07 16:52 ` Greg KH 0 siblings, 0 replies; 25+ messages in thread From: Greg KH @ 2004-09-07 16:52 UTC (permalink / raw) To: Michal Ludvig; +Cc: James Morris, Andreas Happe, cryptoapi, linux-kernel On Tue, Sep 07, 2004 at 06:47:06PM +0200, Michal Ludvig wrote: > On Tue, 7 Sep 2004, James Morris wrote: > > > On Sun, 5 Sep 2004, Greg KH wrote: > > > > > Other than that, I like this move, /proc/crypto isn't the best thing to > > > have in a proc filesystem :) > > > > The only issue is what to do about potentially expanding this into an API > > (e.g. open() an algorithm and write to it). Does this sort of thing > > belong in sysfs? > > I already proposed to have a 'cryptoapifs' mounted e.g. under > /dev/cryptoapi with the "active" entrypoints while /sys would only hold > the "status" of the cryptoapi. Would this be a better approach? That sounds acceptable. thanks, greg k-h ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 2004-09-01 8:28 ` [cryptoapi/sysfs] display cipher details in sysfs Andreas Happe 2004-09-06 0:04 ` Greg KH @ 2004-09-06 18:49 ` Michal Ludvig 2004-09-07 14:35 ` Andreas Happe 2004-09-07 16:36 ` [cryptoapi/sysfs] display cipher details in sysfs James Morris 1 sibling, 2 replies; 25+ messages in thread From: Michal Ludvig @ 2004-09-06 18:49 UTC (permalink / raw) To: Andreas Happe; +Cc: James Morris, cryptoapi, linux-kernel -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Andreas, I really like the patch - I wanted to do quite the same so thanks that you saved me some work ;-) On Wed, 1 Sep 2004, Andreas Happe wrote: > the attached patch creates a /sys/cryptoapi/<cipher-name>/ hierarchie I'd prefer to have the algorithms grouped by "type" ("cipher", "digest", "compress")? Then the apps could easily see only the algos that thay are interested in... > Also the different cipher types (digest, compress..) could be seperated > into own ksets/directories, but this would make the crypto/proc.c code > worse. There could eventually be a separate crypto/sysfs.c, couldn't? > | bash-2.05b# cd aes/ > | bash-2.05b# ls > | blocksize maxkeysize minkeysize module name type Few notes: - - some algorithms allow only discrete set of keysizes (e.g. AES can do 128b, 192b and 256b). Can we instead of min/max have a file 'keysize' with either: minsize-maxsize or size1,size2,size3 ? - - ditto for blocksize? - - With the future support for hardware crypto accelerators it might be possible to have more modules loaded providing the same algorithm. They may have different priorities and one would be treated as "default". Then I expect the syntax of 'module' file to change from a simple module name to something like: # modname:prio:type:whatever aes:0:generic: aes_i586:1:optimized: padlock:2:hardware:default But for now there is probably nothing to do about it. Michal Ludvig - -- * A mouse is a device used to point at the xterm you want to type in. * Personal homepage - http://www.logix.cz/michal -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQFBPLFADDolCcRbIhgRAksyAJ4t+6m6demqQYdlJm3TnKMkLCSa5QCgrset VlNlUPb0517aLARgI6mt8gk= =rjsX -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 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:36 ` [cryptoapi/sysfs] display cipher details in sysfs James Morris 1 sibling, 1 reply; 25+ messages in thread From: Andreas Happe @ 2004-09-07 14:35 UTC (permalink / raw) To: Michal Ludvig; +Cc: Andreas Happe, James Morris, cryptoapi, linux-kernel [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=unknown-8bit, Size: 1683 bytes --] On Mon, Sep 06, 2004 at 08:49:30PM +0200, Michal Ludvig wrote: > I really like the patch - I wanted to do quite the same so thanks that you > saved me some work ;-) thanks ;). > 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>. > I'd prefer to have the algorithms grouped by "type" ("cipher", "digest", > "compress")? Then the apps could easily see only the algos that thay are > interested in... jup, but the seqfile code in proc.c would get a lot more uglier. If we could drop proc.c this wouldn´t be a problem. > There could eventually be a separate crypto/sysfs.c, couldn't? check the patch ;). There's already a sysfs.c with the sysfs-centric stuff. > Few notes: > - - some algorithms allow only discrete set of keysizes (e.g. AES can do > 128b, 192b and 256b). Can we instead of min/max have a file 'keysize' with > either: > minsize-maxsize > or > size1,size2,size3 > ? > > - - ditto for blocksize? how would you implement this in the crypto_alg struture? The sysfs/procfs integration isn't that problem. > - - With the future support for hardware crypto accelerators it > might be possible to have more modules loaded providing the same > algorithm. They may have different priorities and one would be treated as > "default". Then I expect the syntax of 'module' file to change from a > simple module name to something like: > # modname:prio:type:whatever > aes:0:generic: > aes_i586:1:optimized: > padlock:2:hardware:default Isn't this against the "one value per file" - sysfs rule. > Michal Ludvig --Andreas ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 2004-09-07 14:35 ` Andreas Happe @ 2004-09-07 15:49 ` Michal Ludvig 2004-09-07 16:57 ` Andreas Happe 2004-09-10 10:55 ` Andreas Happe 0 siblings, 2 replies; 25+ messages in thread From: Michal Ludvig @ 2004-09-07 15:49 UTC (permalink / raw) To: Andreas Happe; +Cc: Andreas Happe, cryptoapi, linux-kernel, James Morris [-- Attachment #1: Type: TEXT/PLAIN, Size: 2973 bytes --] 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? > > I'd prefer to have the algorithms grouped by "type" ("cipher", "digest", > > "compress")? Then the apps could easily see only the algos that thay are > > interested in... > > jup, but the seqfile code in proc.c would get a lot more uglier. If we could > drop proc.c this wouldn´t be a problem. Hopefully we can ;-) Or does anyone use it? There are not that much userspace programs in any way interacting with the kernel cryptoapi... > > Few notes: > > - - some algorithms allow only discrete set of keysizes (e.g. AES can do > > 128b, 192b and 256b). Can we instead of min/max have a file 'keysize' with > > either: > > minsize-maxsize > > or > > size1,size2,size3 > > ? > > > > - - ditto for blocksize? > > how would you implement this in the crypto_alg struture? The sysfs/procfs > integration isn't that problem. This is a compile time thing, e.g. something like: .cia_min_keysize = 1, .cia_max_keysize = 128 for variable keysizes, and .cia_keysizes = { 128, 192, 256, -1 } for discrete keysizes. typeof(cia_keysizes) would be "int[]". > > - - With the future support for hardware crypto accelerators it > > might be possible to have more modules loaded providing the same > > algorithm. They may have different priorities and one would be treated as > > "default". Then I expect the syntax of 'module' file to change from a > > simple module name to something like: > > # modname:prio:type:whatever > > aes:0:generic: > > aes_i586:1:optimized: > > padlock:2:hardware:default > > Isn't this against the "one value per file" - sysfs rule. I didn't know about such a rule. If it is that strict we could have a subdir modules with a node for each module (aes, aes_i586, padlock, ...) and a symlink (are symlinks allowed in sysfs?) default pointing to the one with highest preference. Attached is my patch introducing preferences for current cryptoapi. How can this be done with the kobject model? - During registration the kobject for a given algo should be looked up. If found (i.e. there already is a module loaded) the new module would be somehow "attached" to it. If not found a new kobject for the algo would be created and then the first module attached to it. - During lookup the kobject for a requested algo will be further examined and the "struct crypto_alg" of the most preferenced module will be returned. Could this be done? (I don't know too much about sysfs and kobjects). Michal Ludvig -- * A mouse is a device used to point at the xterm you want to type in. * Personal homepage - http://www.logix.cz/michal [-- Attachment #2: Type: TEXT/PLAIN, Size: 1659 bytes --] Index: linux-2.6.7/crypto/api.c =================================================================== --- linux-2.6.7.orig/crypto/api.c +++ linux-2.6.7/crypto/api.c @@ -43,14 +43,16 @@ down_read(&crypto_alg_sem); list_for_each_entry(q, &crypto_alg_list, cra_list) { - if (!(strcmp(q->cra_name, name))) { - if (crypto_alg_get(q)) - alg = q; - break; - } + if (!(strcmp(q->cra_name, name)) + && (!alg || alg->cra_preference < q->cra_preference)) + alg = q; } + if (alg && !crypto_alg_get(alg)) + alg = NULL; + up_read(&crypto_alg_sem); + return alg; } @@ -163,20 +165,11 @@ int crypto_register_alg(struct crypto_alg *alg) { int ret = 0; - struct crypto_alg *q; down_write(&crypto_alg_sem); - - list_for_each_entry(q, &crypto_alg_list, cra_list) { - if (!(strcmp(q->cra_name, alg->cra_name))) { - ret = -EEXIST; - goto out; - } - } - list_add_tail(&alg->cra_list, &crypto_alg_list); -out: up_write(&crypto_alg_sem); + return ret; } Index: linux-2.6.7/include/linux/crypto.h =================================================================== --- linux-2.6.7.orig/include/linux/crypto.h +++ linux-2.6.7/include/linux/crypto.h @@ -56,6 +57,10 @@ #define CRYPTO_UNSPEC 0 #define CRYPTO_MAX_ALG_NAME 64 +#define CRYPTO_PREF_GENERIC 0 +#define CRYPTO_PREF_OPTIMIZED 10 +#define CRYPTO_PREF_HARDAWRE 20 + struct scatterlist; /* @@ -99,6 +118,7 @@ unsigned int cra_blocksize; unsigned int cra_ctxsize; const char cra_name[CRYPTO_MAX_ALG_NAME]; + unsigned int cra_preference; union { struct cipher_alg cipher; ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 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 1 sibling, 1 reply; 25+ messages in thread From: Andreas Happe @ 2004-09-07 16:57 UTC (permalink / raw) To: Michal Ludvig; +Cc: Andreas Happe, cryptoapi, linux-kernel, James Morris On Tue, Sep 07, 2004 at 05:49:14PM +0200, Michal Ludvig wrote: > 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: > > BTW: the latest incarnation of the patch uses /sys/class/crypto/<cipher-name>. > > Where can I get the updated version? It's on my home computer (and I'm on vacation quite now ;). will do some additional testing on friday and will post the patch around the weekend. It uses class_device (see include/linux/device.h) instead of kobjects. > This is a compile time thing, e.g. something like: > .cia_min_keysize = 1, > .cia_max_keysize = 128 > for variable keysizes, and > .cia_keysizes = { 128, 192, 256, -1 } > for discrete keysizes. > typeof(cia_keysizes) would be "int[]". can do, but see james morris other patch. > > Isn't this against the "one value per file" - sysfs rule. > > I didn't know about such a rule. yup, is rather strict. > Attached is my patch introducing preferences for current cryptoapi. How > can this be done with the kobject model? will look into it after I'm home from vacation. --AndreaS ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 2004-09-07 16:57 ` Andreas Happe @ 2004-09-10 11:21 ` Andreas Happe 0 siblings, 0 replies; 25+ messages in thread From: Andreas Happe @ 2004-09-10 11:21 UTC (permalink / raw) To: Andreas Happe; +Cc: Michal Ludvig, cryptoapi, linux-kernel, James Morris Andreas Happe <crow@old-fsckful.ath.cx> [040910 12:44]: >On Tue, Sep 07, 2004 at 05:49:14PM +0200, Michal Ludvig wrote: > >> This is a compile time thing, e.g. something like: >> .cia_min_keysize = 1, >> .cia_max_keysize = 128 >> for variable keysizes, and >> .cia_keysizes = { 128, 192, 256, -1 } >> for discrete keysizes. >> typeof(cia_keysizes) would be "int[]". > >can do, but see james morris other patch. *argh* s/patch/post/ --Andreas ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 2004-09-07 15:49 ` Michal Ludvig 2004-09-07 16:57 ` Andreas Happe @ 2004-09-10 10:55 ` Andreas Happe 2004-09-27 8:41 ` Andreas Happe 1 sibling, 1 reply; 25+ messages in thread From: Andreas Happe @ 2004-09-10 10:55 UTC (permalink / raw) To: Michal Ludvig; +Cc: Andreas Happe, cryptoapi, linux-kernel, James Morris [-- 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 --] ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 2004-09-10 10:55 ` Andreas Happe @ 2004-09-27 8:41 ` Andreas Happe 2004-09-27 9:10 ` Michal Ludvig 2004-09-27 15:53 ` James Morris 0 siblings, 2 replies; 25+ messages in thread From: Andreas Happe @ 2004-09-27 8:41 UTC (permalink / raw) To: Michal Ludvig; +Cc: Andreas Happe, cryptoapi, linux-kernel, James Morris Andreas Happe <andreashappe@flatline.ath.cx> [040910 12:55]: > [class - based sysfs patch] hi, just wanted to know if there's any feedback regarding this patch. It still applies to -rc2 without problems. --Andreas ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 2004-09-27 8:41 ` Andreas Happe @ 2004-09-27 9:10 ` Michal Ludvig 2004-09-28 12:34 ` Andreas Happe 2004-09-27 15:53 ` James Morris 1 sibling, 1 reply; 25+ messages in thread From: Michal Ludvig @ 2004-09-27 9:10 UTC (permalink / raw) To: Andreas Happe; +Cc: James Morris, cryptoapi, linux-kernel, Andreas Happe On Mon, 27 Sep 2004, Andreas Happe wrote: > Andreas Happe <andreashappe@flatline.ath.cx> [040910 12:55]: > > [class - based sysfs patch] > > hi, > just wanted to know if there's any feedback regarding this patch. It > still applies to -rc2 without problems. I have it compiled in my kernel and ... yes, it works ;-) One thing that I noticed is that it doesn't complain when loading a second module for the same cipher. Say that you have both aes.ko and aes-i586.ko. You load one of them and it is registered for AES algorithm. Then you modprobe the other one and it doesn't make an error, but the module is not loaded. I'm not 100% sure that it is a fault in your patch, though. I haven't tested it with a clean vanilla+your-patch kernel to avoid other possible culprits. BTW In http://lists.logix.cz/pipermail/cryptoapi/2004/000088.html I described a concept of "preferences" that was done for the current cryptoapi. How to do something similar with your patch applied? If I'd finally have two or more modules for the same algorithm loaded, how should the /sys subtree look like? Michal Ludvig -- * A mouse is a device used to point at the xterm you want to type in. * Personal homepage - http://www.logix.cz/michal ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 2004-09-27 9:10 ` Michal Ludvig @ 2004-09-28 12:34 ` Andreas Happe 2004-09-29 9:36 ` Andreas Happe 2004-09-29 13:13 ` Michal Ludvig 0 siblings, 2 replies; 25+ messages in thread From: Andreas Happe @ 2004-09-28 12:34 UTC (permalink / raw) To: Michal Ludvig; +Cc: James Morris, cryptoapi, linux-kernel, Andreas Happe Michal Ludvig <michal@logix.cz> [040927 11:32]: >BTW In http://lists.logix.cz/pipermail/cryptoapi/2004/000088.html I >described a concept of "preferences" that was done for the current >cryptoapi. How to do something similar with your patch applied? The class - objects are used just for display use.. your patch should apply (sans offsets) without problems.. I don't think that the two different algorithms would be displayed in sysfs as i use the cra_name as directory name (which should be aes for aes and aes-i586). >If I'd finally have two or more modules for the same algorithm loaded, how >should the /sys subtree look like? good one. If there are lots of different implementation for a given algorithm it could be worthwhile to create a algorithm and a implementation - directory e.g. ls /sysfs/class/crypto/implementations would list: aes-i586 aes-c4 md5 sha1 sha256-c4 and: ls /sysfs/class/crypto/algorithms aes with ls /sysfs/class/crypto/algorithms/aes name type implementations where implementations is a directory with links to the given implementations in /sysfs/class/crypto/implementations. Seems like a lot of work if there are only few implementations (like aes and aes-i586). the same could be done without the implementations - directory. If a new algorithm tries to register itself with a already registered name (and the module name isn't known) it is added to the /sysfs/class/crypto/<cra-name>/implementations - directory as <module-name>. All Algorithm - specific data would be displayed in the <cra-name> directory, the rest in the implementations/<module-name> - directory. I'm moving to vienna the day after tomorrow so don't expect too fast response times from me. --Andreas ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 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 1 sibling, 2 replies; 25+ messages in thread From: Andreas Happe @ 2004-09-29 9:36 UTC (permalink / raw) To: Michal Ludvig; +Cc: James Morris, cryptoapi, linux-kernel, Andreas Happe just took a glance at preferences for algorithms yesterday. came up with the attached code (does compile, don't think that it will boot, just attached to illustrade my thinkings). I inserted a cra_family list into cra_alg which stores all algorithms which share the same name but different module names. When selecting an algorithm the preference is looked after (it should be made a writeable sysfs attribute - would make runtime user selection of prefered algorithm very intuitive). Main problems are removal of algorithms (havn't covered that yet) and the display of different algorithms with same names in sysfs as cra_name is the name of the directory (not module_name(alg->cra_module)). Creating a hierarchie cra_alg <>- cra_implementation would be the most clean solution. Just add a kset with the different cra_implementations (which would contain a kobject, preference, module pointer) to any given algorithm (which would contain all blocksize, blah data). --Andreas ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 2004-09-29 9:36 ` Andreas Happe @ 2004-09-29 9:37 ` Andreas Happe 2004-09-29 14:13 ` Michal Ludvig 1 sibling, 0 replies; 25+ messages in thread From: Andreas Happe @ 2004-09-29 9:37 UTC (permalink / raw) To: Michal Ludvig; +Cc: James Morris, cryptoapi, linux-kernel, Andreas Happe [-- 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; }; ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 2004-09-29 9:36 ` Andreas Happe 2004-09-29 9:37 ` Andreas Happe @ 2004-09-29 14:13 ` Michal Ludvig 1 sibling, 0 replies; 25+ messages in thread From: Michal Ludvig @ 2004-09-29 14:13 UTC (permalink / raw) To: Andreas Happe; +Cc: James Morris, cryptoapi, linux-kernel, Andreas Happe On Wed, 29 Sep 2004, Andreas Happe wrote: > just took a glance at preferences for algorithms yesterday. came up with > the attached code (does compile, don't think that it will boot, just > attached to illustrade my thinkings). I'll give it a try and read something more about kobjects and ksets as well ;-) > I inserted a cra_family list into cra_alg which stores all algorithms > which share the same name but different module names. When selecting an > algorithm the preference is looked after (it should be made a writeable > sysfs attribute - would make runtime user selection of prefered > algorithm very intuitive). For now it could be a module option or even hardcoded in the .ko. It won't be user-writable anyway, only root-writable. And if root wouldn't want to use the most preferred module, he could simply not load it... The reason why I wanted the cra_preference is a situation where a given functionality is non-modular and compiled into the kernel and requires an algorithm thet in turn will have to be compiled in as well. Distributors would of course select the pure software implementation for this. But then you install a cryptocard - without preferences you couldn't load a module with driver for it. > Main problems are removal of algorithms (havn't covered that yet) and > the display of different algorithms with same names in sysfs as cra_name > is the name of the directory (not module_name(alg->cra_module)). > > Creating a hierarchie cra_alg <>- cra_implementation would be the most > clean solution. Just add a kset with the different cra_implementations > (which would contain a kobject, preference, module pointer) to any > given algorithm (which would contain all blocksize, blah data). Michal Ludvig -- * A mouse is a device used to point at the xterm you want to type in. * Personal homepage - http://www.logix.cz/michal ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 2004-09-28 12:34 ` Andreas Happe 2004-09-29 9:36 ` Andreas Happe @ 2004-09-29 13:13 ` Michal Ludvig 1 sibling, 0 replies; 25+ messages in thread From: Michal Ludvig @ 2004-09-29 13:13 UTC (permalink / raw) To: Andreas Happe; +Cc: James Morris, cryptoapi, linux-kernel -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Andreas Happe told me that: > Michal Ludvig <michal@logix.cz> [040927 11:32]: > >> If I'd finally have two or more modules for the same algorithm loaded, >> how >> should the /sys subtree look like? > > good one. > > If there are lots of different implementation for a given algorithm it > could be worthwhile to create a algorithm and a implementation - > directory e.g. > > ls /sysfs/class/crypto/implementations would list: > aes-i586 aes-c4 md5 sha1 sha256-c4 > > and: ls /sysfs/class/crypto/algorithms > aes > > with ls /sysfs/class/crypto/algorithms/aes > name type implementations > > where implementations is a directory with links to the given > implementations in /sysfs/class/crypto/implementations. > > Seems like a lot of work if there are only few implementations (like aes > and aes-i586). Once we have a support for hardware cryptocards it will be usefull. I'm already having the VIA PadLock patch that adds yet another AES implementation. For VIA C7 it will also support SHA (one module, two algorithms? why not ;-) IMHO it is worth having it done "right and expandable" since the beginning (changing the /sys tree once it goes mainline will be harder). Michal Ludvig - -- * A mouse is a device used to point at the xterm you want to type in. * Personal homepage - http://www.logix.cz/michal -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFBWrUUDDolCcRbIhgRAqU7AKCCKEUplTD8PJldxT0yodC1M52UjQCg2DSx Im6Amy3cGI+UhUqo4s/4IVk= =fqyy -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 2004-09-27 8:41 ` Andreas Happe 2004-09-27 9:10 ` 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 1 sibling, 1 reply; 25+ messages in thread From: James Morris @ 2004-09-27 15:53 UTC (permalink / raw) To: Andreas Happe; +Cc: Michal Ludvig, Andreas Happe, cryptoapi, linux-kernel On Mon, 27 Sep 2004, Andreas Happe wrote: > just wanted to know if there's any feedback regarding this patch. It > still applies to -rc2 without problems. I'd like to replace /proc/crypto with this, but don't know how to do so with the current development model. Do we start issuing warnings (i.e. "this is going to disappear in one year") via printk now when someone accesses /proc/crypto ? - James -- James Morris <jmorris@redhat.com> ^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH 2.6.9-rc2 1/2] cryptoapi: update sysfs-patch 2004-09-27 15:53 ` James Morris @ 2004-09-28 12:21 ` Andreas Happe 2004-09-28 12:23 ` [PATCH 2.6.9-rc2 2/2] cryptoapi: make /proc/crypto optional Andreas Happe 0 siblings, 1 reply; 25+ messages in thread From: Andreas Happe @ 2004-09-28 12:21 UTC (permalink / raw) To: James Morris; +Cc: Michal Ludvig, Andreas Happe, cryptoapi, linux-kernel [-- Attachment #1: Type: text/plain, Size: 151 bytes --] Just removes the cra_list entry from the whirlpool - cipher. please apply after the old patch. Signed-off-by: Andreas Happe <andreashappe@snikt.net> [-- Attachment #2: patch-2.6.9-rc2-update_cryptoapi_class --] [-- Type: text/plain, Size: 517 bytes --] 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, ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 2.6.9-rc2 2/2] cryptoapi: make /proc/crypto optional 2004-09-28 12:21 ` [PATCH 2.6.9-rc2 1/2] cryptoapi: update sysfs-patch Andreas Happe @ 2004-09-28 12:23 ` Andreas Happe 2004-09-28 14:32 ` Sven Schuster 0 siblings, 1 reply; 25+ messages in thread From: Andreas Happe @ 2004-09-28 12:23 UTC (permalink / raw) To: James Morris; +Cc: Michal Ludvig, Andreas Happe, cryptoapi, linux-kernel [-- Attachment #1: Type: text/plain, Size: 222 bytes --] creates a new Kconfig entry for the /proc/crypto - file and mark it as OBSOLETE. This patch is just compile tested and applies after patch-2.6.9-rc1-cryptoapi-class-2. Signed-of-by: Andreas Happe <andreashappe@snikt.net> [-- Attachment #2: patch-2.6.9-rc2-make_proc_crypto_optional-1 --] [-- Type: text/plain, Size: 1077 bytes --] 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 \ ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 2.6.9-rc2 2/2] cryptoapi: make /proc/crypto optional 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 0 siblings, 1 reply; 25+ messages in thread From: Sven Schuster @ 2004-09-28 14:32 UTC (permalink / raw) To: Andreas Happe; +Cc: James Morris, cryptoapi, Michal Ludvig, linux-kernel [-- Attachment #1: Type: text/plain, Size: 942 bytes --] Hi Andreas, just one little thing I noticed: On Tue, Sep 28, 2004 at 02:23:32PM +0200, Andreas Happe told us: > 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. In double?? Probably should be "in doubt"... Sven -- Linux zion 2.6.9-rc1-mm4 #1 Tue Sep 7 12:57:19 CEST 2004 i686 athlon i386 GNU/Linux 16:31:14 up 2 days, 15:44, 3 users, load average: 0.21, 0.07, 0.02 [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 2.6.9-rc2 2/2] cryptoapi: make /proc/crypto optional 2004-09-28 14:32 ` Sven Schuster @ 2004-09-29 8:40 ` Andreas Happe 0 siblings, 0 replies; 25+ messages in thread From: Andreas Happe @ 2004-09-29 8:40 UTC (permalink / raw) To: Sven Schuster; +Cc: James Morris, cryptoapi, Michal Ludvig, linux-kernel Sven Schuster <schuster.sven@gmx.de> [040929 09:17]: > >Hi Andreas, > >just one little thing I noticed: thanks, >> + When in double say Y. > >In double?? Probably should be "in doubt"... *blink* ähm.. updated patch can be found at: http://snikt.net/kernel/patch-2.6.9-rc2-make_proc_crypto_optional-2 --Andreas ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [cryptoapi/sysfs] display cipher details in sysfs 2004-09-06 18:49 ` Michal Ludvig 2004-09-07 14:35 ` Andreas Happe @ 2004-09-07 16:36 ` James Morris 1 sibling, 0 replies; 25+ messages in thread From: James Morris @ 2004-09-07 16:36 UTC (permalink / raw) To: Michal Ludvig; +Cc: Andreas Happe, cryptoapi, linux-kernel On Mon, 6 Sep 2004, Michal Ludvig wrote: > I'd prefer to have the algorithms grouped by "type" ("cipher", "digest", > "compress")? Then the apps could easily see only the algos that thay are > interested in... This could be done with symlinks. Have a master algorithim directory, and symlinks to different views (e.g. 'ciphers'). > Few notes: > - - some algorithms allow only discrete set of keysizes (e.g. AES can do > 128b, 192b and 256b). Can we instead of min/max have a file 'keysize' with > either: > minsize-maxsize > or > size1,size2,size3 > ? > > - - ditto for blocksize? I don't think it's worth complicating the kernel code just to see that AES does in fact have the three key sizes required by the specification. - James -- James Morris <jmorris@redhat.com> ^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2004-09-29 14:15 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[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
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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox