summaryrefslogtreecommitdiff
path: root/include/crypto
diff options
context:
space:
mode:
authorOleksandr Suvorov <oleksandr.suvorov@toradex.com>2020-03-26 12:44:27 +0200
committerOleksandr Suvorov <oleksandr.suvorov@toradex.com>2020-03-26 12:46:50 +0200
commit87d308708712ff6075c4dd54b0519b47fdad8816 (patch)
tree2fb6458b1db7dd21be2648f42412dd2485846c76 /include/crypto
Backports v5.4.27
Backports generated by toradex backports f6e8852f1ef28e6d3c9bae8400eb6a87a6b0c3e7 against mainline kernel tag v5.4.27 Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
Diffstat (limited to 'include/crypto')
-rw-r--r--include/crypto/arc4.h10
-rw-r--r--include/crypto/backport-arc4.h23
-rw-r--r--include/crypto/backport-pkcs7.h47
-rw-r--r--include/crypto/backport-public_key.h56
-rw-r--r--include/crypto/pkcs7.h11
-rw-r--r--include/crypto/public_key.h6
6 files changed, 153 insertions, 0 deletions
diff --git a/include/crypto/arc4.h b/include/crypto/arc4.h
new file mode 100644
index 0000000..30e582d
--- /dev/null
+++ b/include/crypto/arc4.h
@@ -0,0 +1,10 @@
+/* Automatically created during backport process */
+#ifndef CPTCFG_BPAUTO_BUILD_CRYPTO_LIB_ARC4
+#include_next <crypto/arc4.h>
+#else
+#undef arc4_setkey
+#define arc4_setkey LINUX_BACKPORT(arc4_setkey)
+#undef arc4_crypt
+#define arc4_crypt LINUX_BACKPORT(arc4_crypt)
+#include <crypto/backport-arc4.h>
+#endif /* CPTCFG_BPAUTO_BUILD_CRYPTO_LIB_ARC4 */
diff --git a/include/crypto/backport-arc4.h b/include/crypto/backport-arc4.h
new file mode 100644
index 0000000..f3c22fe
--- /dev/null
+++ b/include/crypto/backport-arc4.h
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Common values for ARC4 Cipher Algorithm
+ */
+
+#ifndef _CRYPTO_ARC4_H
+#define _CRYPTO_ARC4_H
+
+#include <linux/types.h>
+
+#define ARC4_MIN_KEY_SIZE 1
+#define ARC4_MAX_KEY_SIZE 256
+#define ARC4_BLOCK_SIZE 1
+
+struct arc4_ctx {
+ u32 S[256];
+ u32 x, y;
+};
+
+int arc4_setkey(struct arc4_ctx *ctx, const u8 *in_key, unsigned int key_len);
+void arc4_crypt(struct arc4_ctx *ctx, u8 *out, const u8 *in, unsigned int len);
+
+#endif /* _CRYPTO_ARC4_H */
diff --git a/include/crypto/backport-pkcs7.h b/include/crypto/backport-pkcs7.h
new file mode 100644
index 0000000..38ec7f5
--- /dev/null
+++ b/include/crypto/backport-pkcs7.h
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/* PKCS#7 crypto data parser
+ *
+ * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ */
+
+#ifndef _CRYPTO_PKCS7_H
+#define _CRYPTO_PKCS7_H
+
+#include <linux/verification.h>
+#include <linux/hash_info.h>
+#include <crypto/public_key.h>
+
+struct key;
+struct pkcs7_message;
+
+/*
+ * pkcs7_parser.c
+ */
+extern struct pkcs7_message *pkcs7_parse_message(const void *data,
+ size_t datalen);
+extern void pkcs7_free_message(struct pkcs7_message *pkcs7);
+
+extern int pkcs7_get_content_data(const struct pkcs7_message *pkcs7,
+ const void **_data, size_t *_datalen,
+ size_t *_headerlen);
+
+/*
+ * pkcs7_trust.c
+ */
+extern int pkcs7_validate_trust(struct pkcs7_message *pkcs7,
+ struct key *trust_keyring);
+
+/*
+ * pkcs7_verify.c
+ */
+extern int pkcs7_verify(struct pkcs7_message *pkcs7,
+ enum key_being_used_for usage);
+
+extern int pkcs7_supply_detached_data(struct pkcs7_message *pkcs7,
+ const void *data, size_t datalen);
+
+extern int pkcs7_get_digest(struct pkcs7_message *pkcs7, const u8 **buf,
+ u32 *len, enum hash_algo *hash_algo);
+
+#endif /* _CRYPTO_PKCS7_H */
diff --git a/include/crypto/backport-public_key.h b/include/crypto/backport-public_key.h
new file mode 100644
index 0000000..1107db7
--- /dev/null
+++ b/include/crypto/backport-public_key.h
@@ -0,0 +1,56 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/* Asymmetric public-key algorithm definitions
+ *
+ * See Documentation/crypto/asymmetric-keys.txt
+ *
+ * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ */
+
+#ifndef _LINUX_PUBLIC_KEY_H
+#define _LINUX_PUBLIC_KEY_H
+
+#include <linux/keyctl.h>
+#include <linux/oid_registry.h>
+
+/*
+ * Cryptographic data for the public-key subtype of the asymmetric key type.
+ *
+ * Note that this may include private part of the key as well as the public
+ * part.
+ */
+struct public_key {
+ void *key;
+ u32 keylen;
+ enum OID algo;
+ void *params;
+ u32 paramlen;
+ bool key_is_private;
+ const char *id_type;
+ const char *pkey_algo;
+};
+
+extern void public_key_free(struct public_key *key);
+
+/*
+ * Public key cryptography signature data
+ */
+struct public_key_signature {
+ struct asymmetric_key_id *auth_ids[2];
+ u8 *s; /* Signature */
+ u32 s_size; /* Number of bytes in signature */
+ u8 *digest;
+ u8 digest_size; /* Number of bytes in digest */
+ const char *pkey_algo;
+ const char *hash_algo;
+ const char *encoding;
+};
+
+extern void public_key_signature_free(struct public_key_signature *sig);
+
+extern struct asymmetric_key_subtype public_key_subtype;
+
+int public_key_verify_signature(const struct public_key *pkey,
+ const struct public_key_signature *sig);
+
+#endif /* _LINUX_PUBLIC_KEY_H */
diff --git a/include/crypto/pkcs7.h b/include/crypto/pkcs7.h
new file mode 100644
index 0000000..c6e6e69
--- /dev/null
+++ b/include/crypto/pkcs7.h
@@ -0,0 +1,11 @@
+/* Automatically created during backport process */
+#ifndef CPTCFG_BPAUTO_PKCS7
+#include_next <crypto/pkcs7.h>
+#else
+#define pkcs7_verify LINUX_BACKPORT(pkcs7_verify)
+#define pkcs7_get_content_data LINUX_BACKPORT(pkcs7_get_content_data)
+#define pkcs7_parse_message LINUX_BACKPORT(pkcs7_parse_message)
+#define pkcs7_free_message LINUX_BACKPORT(pkcs7_free_message)
+#define pkcs7_validate_trust LINUX_BACKPORT(pkcs7_validate_trust)
+#include <crypto/backport-pkcs7.h>
+#endif /* CPTCFG_BPAUTO_PKCS7 */
diff --git a/include/crypto/public_key.h b/include/crypto/public_key.h
new file mode 100644
index 0000000..35c0b37
--- /dev/null
+++ b/include/crypto/public_key.h
@@ -0,0 +1,6 @@
+/* Automatically created during backport process */
+#ifndef CPTCFG_BPAUTO_PUBLIC_KEY
+#include_next <crypto/public_key.h>
+#else
+#include <crypto/backport-public_key.h>
+#endif /* CPTCFG_BPAUTO_PUBLIC_KEY */