Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Scatterlist Cryptographic API.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Procfs information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Copyright (c) 2005 Herbert Xu <herbert@gondor.apana.org.au>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/atomic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/crypto.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/module.h>	/* for module_name() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/rwsem.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/proc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include "internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) static void *c_start(struct seq_file *m, loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	down_read(&crypto_alg_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	return seq_list_start(&crypto_alg_list, *pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) static void *c_next(struct seq_file *m, void *p, loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	return seq_list_next(p, &crypto_alg_list, pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) static void c_stop(struct seq_file *m, void *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	up_read(&crypto_alg_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) static int c_show(struct seq_file *m, void *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	struct crypto_alg *alg = list_entry(p, struct crypto_alg, cra_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	seq_printf(m, "name         : %s\n", alg->cra_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	seq_printf(m, "driver       : %s\n", alg->cra_driver_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	seq_printf(m, "module       : %s\n", module_name(alg->cra_module));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	seq_printf(m, "priority     : %d\n", alg->cra_priority);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	seq_printf(m, "refcnt       : %u\n", refcount_read(&alg->cra_refcnt));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	seq_printf(m, "selftest     : %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		   (alg->cra_flags & CRYPTO_ALG_TESTED) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		   "passed" : "unknown");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	seq_printf(m, "internal     : %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		   (alg->cra_flags & CRYPTO_ALG_INTERNAL) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		   "yes" : "no");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	if (alg->cra_flags & CRYPTO_ALG_LARVAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		seq_printf(m, "type         : larval\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		seq_printf(m, "flags        : 0x%x\n", alg->cra_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	if (alg->cra_type && alg->cra_type->show) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		alg->cra_type->show(m, alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	case CRYPTO_ALG_TYPE_CIPHER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		seq_printf(m, "type         : cipher\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		seq_printf(m, "blocksize    : %u\n", alg->cra_blocksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		seq_printf(m, "min keysize  : %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 					alg->cra_cipher.cia_min_keysize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		seq_printf(m, "max keysize  : %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 					alg->cra_cipher.cia_max_keysize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	case CRYPTO_ALG_TYPE_COMPRESS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		seq_printf(m, "type         : compression\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		seq_printf(m, "type         : unknown\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) static const struct seq_operations crypto_seq_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	.start		= c_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	.next		= c_next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	.stop		= c_stop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	.show		= c_show
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) void __init crypto_init_proc(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	proc_create_seq("crypto", 0, NULL, &crypto_seq_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) void __exit crypto_exit_proc(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	remove_proc_entry("crypto", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }