The usual stuff ...
[linux-2.6/linux-mips.git] / crypto / proc.c
blob124a3a2709384f4644dab1aad6d50dc7b81c4eb2
1 /*
2 * Scatterlist Cryptographic API.
4 * Procfs information.
6 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
14 #include <linux/init.h>
15 #include <linux/crypto.h>
16 #include <linux/rwsem.h>
17 #include <linux/proc_fs.h>
18 #include <linux/seq_file.h>
19 #include "internal.h"
21 extern struct list_head crypto_alg_list;
22 extern struct rw_semaphore crypto_alg_sem;
24 static void *c_start(struct seq_file *m, loff_t *pos)
26 struct list_head *v;
27 loff_t n = *pos;
29 down_read(&crypto_alg_sem);
30 list_for_each(v, &crypto_alg_list)
31 if (!n--)
32 return list_entry(v, struct crypto_alg, cra_list);
33 return NULL;
36 static void *c_next(struct seq_file *m, void *p, loff_t *pos)
38 struct list_head *v = p;
40 (*pos)++;
41 v = v->next;
42 return (v == &crypto_alg_list) ?
43 NULL : list_entry(v, struct crypto_alg, cra_list);
46 static void c_stop(struct seq_file *m, void *p)
48 up_read(&crypto_alg_sem);
51 static int c_show(struct seq_file *m, void *p)
53 struct crypto_alg *alg = (struct crypto_alg *)p;
55 seq_printf(m, "name : %s\n", alg->cra_name);
56 seq_printf(m, "module : %s\n", module_name(alg->cra_module));
58 switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) {
59 case CRYPTO_ALG_TYPE_CIPHER:
60 seq_printf(m, "blocksize : %u\n", alg->cra_blocksize);
61 seq_printf(m, "min keysize : %u\n",
62 alg->cra_cipher.cia_min_keysize);
63 seq_printf(m, "max keysize : %u\n",
64 alg->cra_cipher.cia_max_keysize);
65 seq_printf(m, "ivsize : %u\n",
66 alg->cra_cipher.cia_ivsize);
67 break;
69 case CRYPTO_ALG_TYPE_DIGEST:
70 seq_printf(m, "blocksize : %u\n", alg->cra_blocksize);
71 seq_printf(m, "digestsize : %u\n",
72 alg->cra_digest.dia_digestsize);
73 break;
76 seq_putc(m, '\n');
77 return 0;
80 static struct seq_operations crypto_seq_ops = {
81 .start = c_start,
82 .next = c_next,
83 .stop = c_stop,
84 .show = c_show
87 static int crypto_info_open(struct inode *inode, struct file *file)
89 return seq_open(file, &crypto_seq_ops);
92 static struct file_operations proc_crypto_ops = {
93 .open = crypto_info_open,
94 .read = seq_read,
95 .llseek = seq_lseek,
96 .release = seq_release
99 void __init crypto_init_proc(void)
101 struct proc_dir_entry *proc;
103 proc = create_proc_entry("crypto", 0, NULL);
104 if (proc)
105 proc->proc_fops = &proc_crypto_ops;