1 // SPDX-License-Identifier: GPL-2.0-or-later << 2 /* 1 /* 3 * Scatterlist Cryptographic API. 2 * Scatterlist Cryptographic API. 4 * 3 * 5 * Procfs information. 4 * Procfs information. 6 * 5 * 7 * Copyright (c) 2002 James Morris <jmorris@in 6 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au> 8 * Copyright (c) 2005 Herbert Xu <herbert@gond 7 * Copyright (c) 2005 Herbert Xu <herbert@gondor.apana.org.au> >> 8 * >> 9 * This program is free software; you can redistribute it and/or modify it >> 10 * under the terms of the GNU General Public License as published by the Free >> 11 * Software Foundation; either version 2 of the License, or (at your option) >> 12 * any later version. >> 13 * 9 */ 14 */ 10 15 11 #include <linux/atomic.h> 16 #include <linux/atomic.h> 12 #include <linux/init.h> 17 #include <linux/init.h> 13 #include <linux/crypto.h> 18 #include <linux/crypto.h> 14 #include <linux/fips.h> << 15 #include <linux/module.h> /* for module_ 19 #include <linux/module.h> /* for module_name() */ 16 #include <linux/rwsem.h> 20 #include <linux/rwsem.h> 17 #include <linux/proc_fs.h> 21 #include <linux/proc_fs.h> 18 #include <linux/seq_file.h> 22 #include <linux/seq_file.h> 19 #include "internal.h" 23 #include "internal.h" 20 24 21 static void *c_start(struct seq_file *m, loff_ 25 static void *c_start(struct seq_file *m, loff_t *pos) 22 { 26 { 23 down_read(&crypto_alg_sem); 27 down_read(&crypto_alg_sem); 24 return seq_list_start(&crypto_alg_list 28 return seq_list_start(&crypto_alg_list, *pos); 25 } 29 } 26 30 27 static void *c_next(struct seq_file *m, void * 31 static void *c_next(struct seq_file *m, void *p, loff_t *pos) 28 { 32 { 29 return seq_list_next(p, &crypto_alg_li 33 return seq_list_next(p, &crypto_alg_list, pos); 30 } 34 } 31 35 32 static void c_stop(struct seq_file *m, void *p 36 static void c_stop(struct seq_file *m, void *p) 33 { 37 { 34 up_read(&crypto_alg_sem); 38 up_read(&crypto_alg_sem); 35 } 39 } 36 40 37 static int c_show(struct seq_file *m, void *p) 41 static int c_show(struct seq_file *m, void *p) 38 { 42 { 39 struct crypto_alg *alg = list_entry(p, 43 struct crypto_alg *alg = list_entry(p, struct crypto_alg, cra_list); 40 !! 44 41 seq_printf(m, "name : %s\n", a 45 seq_printf(m, "name : %s\n", alg->cra_name); 42 seq_printf(m, "driver : %s\n", a 46 seq_printf(m, "driver : %s\n", alg->cra_driver_name); 43 seq_printf(m, "module : %s\n", m 47 seq_printf(m, "module : %s\n", module_name(alg->cra_module)); 44 seq_printf(m, "priority : %d\n", a 48 seq_printf(m, "priority : %d\n", alg->cra_priority); 45 seq_printf(m, "refcnt : %u\n", r !! 49 seq_printf(m, "refcnt : %d\n", atomic_read(&alg->cra_refcnt)); 46 seq_printf(m, "selftest : %s\n", 50 seq_printf(m, "selftest : %s\n", 47 (alg->cra_flags & CRYPTO_AL 51 (alg->cra_flags & CRYPTO_ALG_TESTED) ? 48 "passed" : "unknown"); 52 "passed" : "unknown"); 49 seq_printf(m, "internal : %s\n", 53 seq_printf(m, "internal : %s\n", 50 (alg->cra_flags & CRYPTO_AL 54 (alg->cra_flags & CRYPTO_ALG_INTERNAL) ? 51 "yes" : "no"); 55 "yes" : "no"); 52 if (fips_enabled) { << 53 seq_printf(m, "fips : << 54 (alg->cra_flags & C << 55 "no" : "yes"); << 56 } << 57 56 58 if (alg->cra_flags & CRYPTO_ALG_LARVAL 57 if (alg->cra_flags & CRYPTO_ALG_LARVAL) { 59 seq_printf(m, "type : 58 seq_printf(m, "type : larval\n"); 60 seq_printf(m, "flags : 59 seq_printf(m, "flags : 0x%x\n", alg->cra_flags); 61 goto out; 60 goto out; 62 } 61 } 63 62 64 if (alg->cra_type && alg->cra_type->sh 63 if (alg->cra_type && alg->cra_type->show) { 65 alg->cra_type->show(m, alg); 64 alg->cra_type->show(m, alg); 66 goto out; 65 goto out; 67 } 66 } 68 !! 67 69 switch (alg->cra_flags & CRYPTO_ALG_TY !! 68 switch (alg->cra_flags & (CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_LARVAL)) { 70 case CRYPTO_ALG_TYPE_CIPHER: 69 case CRYPTO_ALG_TYPE_CIPHER: 71 seq_printf(m, "type : 70 seq_printf(m, "type : cipher\n"); 72 seq_printf(m, "blocksize : 71 seq_printf(m, "blocksize : %u\n", alg->cra_blocksize); 73 seq_printf(m, "min keysize : 72 seq_printf(m, "min keysize : %u\n", 74 alg->c 73 alg->cra_cipher.cia_min_keysize); 75 seq_printf(m, "max keysize : 74 seq_printf(m, "max keysize : %u\n", 76 alg->c 75 alg->cra_cipher.cia_max_keysize); 77 break; 76 break; 78 case CRYPTO_ALG_TYPE_COMPRESS: 77 case CRYPTO_ALG_TYPE_COMPRESS: 79 seq_printf(m, "type : 78 seq_printf(m, "type : compression\n"); 80 break; 79 break; 81 default: 80 default: 82 seq_printf(m, "type : 81 seq_printf(m, "type : unknown\n"); 83 break; 82 break; 84 } 83 } 85 84 86 out: 85 out: 87 seq_putc(m, '\n'); 86 seq_putc(m, '\n'); 88 return 0; 87 return 0; 89 } 88 } 90 89 91 static const struct seq_operations crypto_seq_ 90 static const struct seq_operations crypto_seq_ops = { 92 .start = c_start, 91 .start = c_start, 93 .next = c_next, 92 .next = c_next, 94 .stop = c_stop, 93 .stop = c_stop, 95 .show = c_show 94 .show = c_show 96 }; 95 }; 97 96 >> 97 static int crypto_info_open(struct inode *inode, struct file *file) >> 98 { >> 99 return seq_open(file, &crypto_seq_ops); >> 100 } >> 101 >> 102 static const struct file_operations proc_crypto_ops = { >> 103 .open = crypto_info_open, >> 104 .read = seq_read, >> 105 .llseek = seq_lseek, >> 106 .release = seq_release >> 107 }; >> 108 98 void __init crypto_init_proc(void) 109 void __init crypto_init_proc(void) 99 { 110 { 100 proc_create_seq("crypto", 0, NULL, &cr !! 111 proc_create("crypto", 0, NULL, &proc_crypto_ops); 101 } 112 } 102 113 103 void __exit crypto_exit_proc(void) 114 void __exit crypto_exit_proc(void) 104 { 115 { 105 remove_proc_entry("crypto", NULL); 116 remove_proc_entry("crypto", NULL); 106 } 117 } 107 118
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.