diff options
author | James Morris <jmorris@intercode.com.au> | 2002-12-05 19:04:03 -0800 |
---|---|---|
committer | James Morris <jmorris@intercode.com.au> | 2002-12-05 19:04:03 -0800 |
commit | f1853422bfddde6e25868ef280f96752e71e5dec (patch) | |
tree | 7a746bf19fc25c5346e57ed6b38be81da3ed30ae /crypto | |
parent | 7ac20748d507220d1e737382d0e9727c65c16ec1 (diff) | |
download | history-f1853422bfddde6e25868ef280f96752e71e5dec.tar.gz |
[CRYPTO]: Dont compile procfs stuff if procfs is not enabled.
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/Makefile | 4 | ||||
-rw-r--r-- | crypto/api.c | 88 | ||||
-rw-r--r-- | crypto/internal.h | 8 | ||||
-rw-r--r-- | crypto/proc.c | 105 |
4 files changed, 119 insertions, 86 deletions
diff --git a/crypto/Makefile b/crypto/Makefile index 13415dce518104..9bbb7ac45d5633 100644 --- a/crypto/Makefile +++ b/crypto/Makefile @@ -5,8 +5,10 @@ export-objs := api.o hmac.o autoload-crypto-$(CONFIG_KMOD) = autoload.o +proc-crypto-$(CONFIG_PROC_FS) = proc.o -obj-$(CONFIG_CRYPTO) += api.o cipher.o digest.o compress.o $(autoload-crypto-y) +obj-$(CONFIG_CRYPTO) += api.o cipher.o digest.o compress.o \ + $(autoload-crypto-y) $(proc-crypto-y) obj-$(CONFIG_CRYPTO_HMAC) += hmac.o obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o diff --git a/crypto/api.c b/crypto/api.c index c903f2b39da2ec..f41d1437a4dad5 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -16,12 +16,11 @@ #include <linux/init.h> #include <linux/crypto.h> #include <linux/rwsem.h> -#include <linux/proc_fs.h> -#include <linux/seq_file.h> +#include <linux/slab.h> #include "internal.h" -static LIST_HEAD(crypto_alg_list); -static DECLARE_RWSEM(crypto_alg_sem); +LIST_HEAD(crypto_alg_list); +DECLARE_RWSEM(crypto_alg_sem); static inline int crypto_alg_get(struct crypto_alg *alg) { @@ -240,89 +239,10 @@ int crypto_alg_available(const char *name, u32 flags) return ret; } -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) - if (!n--) - return list_entry(v, struct crypto_alg, cra_list); - return NULL; -} - -static void *c_next(struct seq_file *m, void *p, loff_t *pos) -{ - struct list_head *v = p; - - (*pos)++; - v = v->next; - return (v == &crypto_alg_list) ? - NULL : list_entry(v, struct crypto_alg, cra_list); -} - -static void c_stop(struct seq_file *m, void *p) -{ - up_read(&crypto_alg_sem); -} - -static int c_show(struct seq_file *m, void *p) -{ - struct crypto_alg *alg = (struct crypto_alg *)p; - - seq_printf(m, "name : %s\n", alg->cra_name); - seq_printf(m, "module : %s\n", module_name(alg->cra_module)); - seq_printf(m, "blocksize : %u\n", alg->cra_blocksize); - - switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) { - case CRYPTO_ALG_TYPE_CIPHER: - seq_printf(m, "min keysize : %u\n", - alg->cra_cipher.cia_min_keysize); - seq_printf(m, "max keysize : %u\n", - alg->cra_cipher.cia_max_keysize); - seq_printf(m, "ivsize : %u\n", - alg->cra_cipher.cia_ivsize); - break; - - case CRYPTO_ALG_TYPE_DIGEST: - seq_printf(m, "digestsize : %u\n", - alg->cra_digest.dia_digestsize); - break; - } - - seq_putc(m, '\n'); - return 0; -} - -static struct seq_operations crypto_seq_ops = { - .start = c_start, - .next = c_next, - .stop = c_stop, - .show = c_show -}; - -static int crypto_info_open(struct inode *inode, struct file *file) -{ - return seq_open(file, &crypto_seq_ops); -} - -struct file_operations proc_crypto_ops = { - .open = crypto_info_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release -}; - static int __init init_crypto(void) { - struct proc_dir_entry *proc; - printk(KERN_INFO "Initializing Cryptographic API\n"); - proc = create_proc_entry("crypto", 0, NULL); - if (proc) - proc->proc_fops = &proc_crypto_ops; - + crypto_init_proc(); return 0; } diff --git a/crypto/internal.h b/crypto/internal.h index 408bc1bb5b0c6a..35bd91128aeb20 100644 --- a/crypto/internal.h +++ b/crypto/internal.h @@ -11,7 +11,6 @@ */ #ifndef _CRYPTO_INTERNAL_H #define _CRYPTO_INTERNAL_H - #include <linux/mm.h> #include <linux/highmem.h> #include <asm/hardirq.h> @@ -65,6 +64,13 @@ static inline void crypto_free_hmac_block(struct crypto_tfm *tfm) { } #endif +#ifdef CONFIG_PROC_FS +void __init crypto_init_proc(void); +#else +static inline void crypto_init_proc(void) +{ } +#endif + int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags); int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags); int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags); diff --git a/crypto/proc.c b/crypto/proc.c new file mode 100644 index 00000000000000..f51a3ccf52dba8 --- /dev/null +++ b/crypto/proc.c @@ -0,0 +1,105 @@ +/* + * Scatterlist Cryptographic API. + * + * Procfs information. + * + * Copyright (c) 2002 James Morris <jmorris@intercode.com.au> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + */ +#include <linux/init.h> +#include <linux/crypto.h> +#include <linux/rwsem.h> +#include <linux/proc_fs.h> +#include <linux/seq_file.h> +#include "internal.h" + +extern struct list_head crypto_alg_list; +extern struct rw_semaphore crypto_alg_sem; + +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) + if (!n--) + return list_entry(v, struct crypto_alg, cra_list); + return NULL; +} + +static void *c_next(struct seq_file *m, void *p, loff_t *pos) +{ + struct list_head *v = p; + + (*pos)++; + v = v->next; + return (v == &crypto_alg_list) ? + NULL : list_entry(v, struct crypto_alg, cra_list); +} + +static void c_stop(struct seq_file *m, void *p) +{ + up_read(&crypto_alg_sem); +} + +static int c_show(struct seq_file *m, void *p) +{ + struct crypto_alg *alg = (struct crypto_alg *)p; + + seq_printf(m, "name : %s\n", alg->cra_name); + seq_printf(m, "module : %s\n", module_name(alg->cra_module)); + seq_printf(m, "blocksize : %u\n", alg->cra_blocksize); + + switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) { + case CRYPTO_ALG_TYPE_CIPHER: + seq_printf(m, "min keysize : %u\n", + alg->cra_cipher.cia_min_keysize); + seq_printf(m, "max keysize : %u\n", + alg->cra_cipher.cia_max_keysize); + seq_printf(m, "ivsize : %u\n", + alg->cra_cipher.cia_ivsize); + break; + + case CRYPTO_ALG_TYPE_DIGEST: + seq_printf(m, "digestsize : %u\n", + alg->cra_digest.dia_digestsize); + break; + } + + seq_putc(m, '\n'); + return 0; +} + +static struct seq_operations crypto_seq_ops = { + .start = c_start, + .next = c_next, + .stop = c_stop, + .show = c_show +}; + +static int crypto_info_open(struct inode *inode, struct file *file) +{ + return seq_open(file, &crypto_seq_ops); +} + +static struct file_operations proc_crypto_ops = { + .open = crypto_info_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release +}; + +void __init crypto_init_proc(void) +{ + struct proc_dir_entry *proc; + + proc = create_proc_entry("crypto", 0, NULL); + if (proc) + proc->proc_fops = &proc_crypto_ops; +} |