diff mbox series

[RFC,01/10] crypto: Export public key algorithm information

Message ID 20230706144225.1046544-2-roberto.sassu@huaweicloud.com (mailing list archive)
State RFC
Headers show
Series KEYS: Introduce user asymmetric keys and signatures | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-4 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-5 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-6 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-27 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-28 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-29 success Logs for veristat
bpf/vmtest-bpf-next-VM_Test-7 success Logs for test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-14 success Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-15 fail Logs for test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-18 success Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-19 success Logs for test_progs_no_alu32_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-20 success Logs for test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-21 success Logs for test_progs_no_alu32_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-22 success Logs for test_progs_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-24 success Logs for test_progs_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-26 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-PR fail PR summary
bpf/vmtest-bpf-next-VM_Test-8 success Logs for test_maps on s390x with gcc
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1341 this patch: 1341
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 1364 this patch: 1364
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1364 this patch: 1364
netdev/checkpatch warning WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Roberto Sassu July 6, 2023, 2:42 p.m. UTC
From: Roberto Sassu <roberto.sassu@huawei.com>

Export the public keys algorithm identifiers, so that user space can
reference them when passing data to the kernel.

Define and export the pub_key_algo_name array, so that kernel subsystems
can get the string associated to the public key algorithm identifier.

Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
---
 crypto/Kconfig                    |  3 +++
 crypto/Makefile                   |  1 +
 crypto/pub_key_info.c             | 20 ++++++++++++++++++++
 include/crypto/pub_key_info.h     | 15 +++++++++++++++
 include/uapi/linux/pub_key_info.h | 22 ++++++++++++++++++++++
 5 files changed, 61 insertions(+)
 create mode 100644 crypto/pub_key_info.c
 create mode 100644 include/crypto/pub_key_info.h
 create mode 100644 include/uapi/linux/pub_key_info.h
diff mbox series

Patch

diff --git a/crypto/Kconfig b/crypto/Kconfig
index 650b1b3620d..2558025461b 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -1420,6 +1420,9 @@  endmenu
 config CRYPTO_HASH_INFO
 	bool
 
+config CRYPTO_PUB_KEY_INFO
+	bool
+
 if !KMSAN # avoid false positives from assembly
 if ARM
 source "arch/arm/crypto/Kconfig"
diff --git a/crypto/Makefile b/crypto/Makefile
index 953a7e105e5..fcdb5918e58 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -206,6 +206,7 @@  obj-$(CONFIG_XOR_BLOCKS) += xor.o
 obj-$(CONFIG_ASYNC_CORE) += async_tx/
 obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys/
 obj-$(CONFIG_CRYPTO_HASH_INFO) += hash_info.o
+obj-$(CONFIG_CRYPTO_PUB_KEY_INFO) += pub_key_info.o
 crypto_simd-y := simd.o
 obj-$(CONFIG_CRYPTO_SIMD) += crypto_simd.o
 
diff --git a/crypto/pub_key_info.c b/crypto/pub_key_info.c
new file mode 100644
index 00000000000..d12a08e5972
--- /dev/null
+++ b/crypto/pub_key_info.c
@@ -0,0 +1,20 @@ 
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2023 Huawei Technologies Duesseldorf GmbH
+ *
+ * Public key info: Public key algorithms information
+ */
+
+#include <linux/export.h>
+#include <crypto/pub_key_info.h>
+
+const char *const pub_key_algo_name[PKEY_ALGO__LAST] = {
+	[PKEY_ALGO_RSA]		= "rsa",
+	[PKEY_ALGO_ECDSA]	= "ecdsa",
+	[PKEY_ALGO_ECDSA_P192]	= "ecdsa-nist-p192",
+	[PKEY_ALGO_ECDSA_P256]	= "ecdsa-nist-p256",
+	[PKEY_ALGO_ECDSA_P384]	= "ecdsa-nist-p384",
+	[PKEY_ALGO_ECRDSA]	= "ecrdsa",
+	[PKEY_ALGO_SM2]		= "sm2",
+};
+EXPORT_SYMBOL_GPL(pub_key_algo_name);
diff --git a/include/crypto/pub_key_info.h b/include/crypto/pub_key_info.h
new file mode 100644
index 00000000000..ea411792778
--- /dev/null
+++ b/include/crypto/pub_key_info.h
@@ -0,0 +1,15 @@ 
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Copyright (C) 2023 Huawei Technologies Duesseldorf GmbH
+ *
+ * Public key info: Public key algorithms information
+ */
+
+#ifndef _CRYPTO_PUB_KEY_INFO_H
+#define _CRYPTO_PUB_KEY_INFO_H
+
+#include <uapi/linux/pub_key_info.h>
+
+extern const char *const pub_key_algo_name[PKEY_ALGO__LAST];
+
+#endif /* _CRYPTO_PUB_KEY_INFO_H */
diff --git a/include/uapi/linux/pub_key_info.h b/include/uapi/linux/pub_key_info.h
new file mode 100644
index 00000000000..a5595969156
--- /dev/null
+++ b/include/uapi/linux/pub_key_info.h
@@ -0,0 +1,22 @@ 
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Copyright (C) 2023 Huawei Technologies Duesseldorf GmbH
+ *
+ * Public key info: Public key algorithms information
+ */
+
+#ifndef _UAPI_LINUX_PUB_KEY_INFO_H
+#define _UAPI_LINUX_PUB_KEY_INFO_H
+
+enum pub_key_algo {
+	PKEY_ALGO_RSA,
+	PKEY_ALGO_ECDSA,
+	PKEY_ALGO_ECDSA_P192,
+	PKEY_ALGO_ECDSA_P256,
+	PKEY_ALGO_ECDSA_P384,
+	PKEY_ALGO_ECRDSA,
+	PKEY_ALGO_SM2,
+	PKEY_ALGO__LAST,
+};
+
+#endif /* _UAPI_LINUX_PUB_KEY_INFO_H */