Blame view

crypto/proc.c 2.49 KB
2874c5fd2   Thomas Gleixner   treewide: Replace...
1
  // SPDX-License-Identifier: GPL-2.0-or-later
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
4
5
6
7
  /*
   * Scatterlist Cryptographic API.
   *
   * Procfs information.
   *
   * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
5cb1454b8   Herbert Xu   [CRYPTO] Allow mu...
8
   * Copyright (c) 2005 Herbert Xu <herbert@gondor.apana.org.au>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
9
   */
6521f3027   Herbert Xu   [CRYPTO] api: Add...
10

60063497a   Arun Sharma   atomic: use <linu...
11
  #include <linux/atomic.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
12
13
  #include <linux/init.h>
  #include <linux/crypto.h>
4bb33cc89   Paul Gortmaker   crypto: add modul...
14
  #include <linux/module.h>	/* for module_name() */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
15
16
17
18
  #include <linux/rwsem.h>
  #include <linux/proc_fs.h>
  #include <linux/seq_file.h>
  #include "internal.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
19
20
  static void *c_start(struct seq_file *m, loff_t *pos)
  {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
21
  	down_read(&crypto_alg_sem);
13d31894b   Pavel Emelianov   Make crypto API u...
22
  	return seq_list_start(&crypto_alg_list, *pos);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
23
24
25
26
  }
  
  static void *c_next(struct seq_file *m, void *p, loff_t *pos)
  {
13d31894b   Pavel Emelianov   Make crypto API u...
27
  	return seq_list_next(p, &crypto_alg_list, pos);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
28
29
30
31
32
33
34
35
36
  }
  
  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)
  {
13d31894b   Pavel Emelianov   Make crypto API u...
37
  	struct crypto_alg *alg = list_entry(p, struct crypto_alg, cra_list);
fde2f57c2   Corentin Labbe   crypto: proc - Re...
38

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
39
40
  	seq_printf(m, "name         : %s
  ", alg->cra_name);
5cb1454b8   Herbert Xu   [CRYPTO] Allow mu...
41
42
  	seq_printf(m, "driver       : %s
  ", alg->cra_driver_name);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
43
44
  	seq_printf(m, "module       : %s
  ", module_name(alg->cra_module));
5cb1454b8   Herbert Xu   [CRYPTO] Allow mu...
45
46
  	seq_printf(m, "priority     : %d
  ", alg->cra_priority);
ce8614a31   Eric Biggers   crypto: algapi - ...
47
48
  	seq_printf(m, "refcnt       : %u
  ", refcount_read(&alg->cra_refcnt));
73d3864a4   Herbert Xu   crypto: api - Use...
49
50
51
52
  	seq_printf(m, "selftest     : %s
  ",
  		   (alg->cra_flags & CRYPTO_ALG_TESTED) ?
  		   "passed" : "unknown");
b0cda2ba1   Stephan Mueller   crypto: proc - id...
53
54
55
56
  	seq_printf(m, "internal     : %s
  ",
  		   (alg->cra_flags & CRYPTO_ALG_INTERNAL) ?
  		   "yes" : "no");
67cd080c5   Herbert Xu   crypto: api - Cal...
57
58
59
60
61
62
63
64
65
66
67
68
69
  
  	if (alg->cra_flags & CRYPTO_ALG_LARVAL) {
  		seq_printf(m, "type         : larval
  ");
  		seq_printf(m, "flags        : 0x%x
  ", alg->cra_flags);
  		goto out;
  	}
  
  	if (alg->cra_type && alg->cra_type->show) {
  		alg->cra_type->show(m, alg);
  		goto out;
  	}
fde2f57c2   Corentin Labbe   crypto: proc - Re...
70

7f1cfe41c   Tianjia Zhang   crypto: proc - si...
71
  	switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
72
73
74
75
76
77
78
79
80
81
82
83
  	case CRYPTO_ALG_TYPE_CIPHER:
  		seq_printf(m, "type         : cipher
  ");
  		seq_printf(m, "blocksize    : %u
  ", alg->cra_blocksize);
  		seq_printf(m, "min keysize  : %u
  ",
  					alg->cra_cipher.cia_min_keysize);
  		seq_printf(m, "max keysize  : %u
  ",
  					alg->cra_cipher.cia_max_keysize);
  		break;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
84
85
86
87
88
  	case CRYPTO_ALG_TYPE_COMPRESS:
  		seq_printf(m, "type         : compression
  ");
  		break;
  	default:
67cd080c5   Herbert Xu   crypto: api - Cal...
89
90
  		seq_printf(m, "type         : unknown
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
91
92
  		break;
  	}
67cd080c5   Herbert Xu   crypto: api - Cal...
93
  out:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
94
95
96
97
  	seq_putc(m, '
  ');
  	return 0;
  }
48c8949ea   Jan Engelhardt   [CRYPTO] api: Con...
98
  static const struct seq_operations crypto_seq_ops = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
99
100
101
102
103
  	.start		= c_start,
  	.next		= c_next,
  	.stop		= c_stop,
  	.show		= c_show
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
104
105
  void __init crypto_init_proc(void)
  {
fddda2b7b   Christoph Hellwig   proc: introduce p...
106
  	proc_create_seq("crypto", 0, NULL, &crypto_seq_ops);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
107
  }
cce9e06d1   Herbert Xu   [CRYPTO] api: Spl...
108
109
110
111
112
  
  void __exit crypto_exit_proc(void)
  {
  	remove_proc_entry("crypto", NULL);
  }