[RFC,02/10] crypto: Export signature encoding information
Commit Message
From: Roberto Sassu <roberto.sassu@huawei.com>
Export the signature encoding identifiers, so that user space can reference
them when passing data to the kernel.
Define and export the sig_enc_name array, so that kernel subsystems can get
the string associated to the signature encoding identifier.
Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
---
crypto/Kconfig | 3 +++
crypto/Makefile | 1 +
crypto/sig_enc_info.c | 16 ++++++++++++++++
include/crypto/sig_enc_info.h | 15 +++++++++++++++
include/uapi/linux/sig_enc_info.h | 18 ++++++++++++++++++
5 files changed, 53 insertions(+)
create mode 100644 crypto/sig_enc_info.c
create mode 100644 include/crypto/sig_enc_info.h
create mode 100644 include/uapi/linux/sig_enc_info.h
@@ -1423,6 +1423,9 @@ config CRYPTO_HASH_INFO
config CRYPTO_PUB_KEY_INFO
bool
+config CRYPTO_SIG_ENC_INFO
+ bool
+
if !KMSAN # avoid false positives from assembly
if ARM
source "arch/arm/crypto/Kconfig"
@@ -207,6 +207,7 @@ 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
+obj-$(CONFIG_CRYPTO_SIG_ENC_INFO) += sig_enc_info.o
crypto_simd-y := simd.o
obj-$(CONFIG_CRYPTO_SIMD) += crypto_simd.o
new file mode 100644
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2023 Huawei Technologies Duesseldorf GmbH
+ *
+ * Sig enc info: Signature encoding information
+ */
+
+#include <linux/export.h>
+#include <crypto/sig_enc_info.h>
+
+const char *const sig_enc_name[SIG_ENC__LAST] = {
+ [SIG_ENC_PKCS1] = "pkcs1",
+ [SIG_ENC_X962] = "x962",
+ [SIG_ENC_RAW] = "raw",
+};
+EXPORT_SYMBOL_GPL(sig_enc_name);
new file mode 100644
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Copyright (C) 2023 Huawei Technologies Duesseldorf GmbH
+ *
+ * Sig enc info: Signature encoding information
+ */
+
+#ifndef _CRYPTO_SIG_ENC_INFO_H
+#define _CRYPTO_SIG_ENC_INFO_H
+
+#include <uapi/linux/sig_enc_info.h>
+
+extern const char *const sig_enc_name[SIG_ENC__LAST];
+
+#endif /* _CRYPTO_SIG_ENC_INFO_H */
new file mode 100644
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Copyright (C) 2023 Huawei Technologies Duesseldorf GmbH
+ *
+ * Sig enc info: Signature encoding information
+ */
+
+#ifndef _UAPI_LINUX_SIG_ENC_INFO_H
+#define _UAPI_LINUX_SIG_ENC_INFO_H
+
+enum sig_enc_info {
+ SIG_ENC_PKCS1,
+ SIG_ENC_X962,
+ SIG_ENC_RAW,
+ SIG_ENC__LAST,
+};
+
+#endif /* _UAPI_LINUX_SIG_ENC_INFO_H */