aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2016-04-06 11:14:24 -0400
committerDavid Howells <dhowells@redhat.com>2016-04-06 11:14:24 -0400
commite68503bd6836ba765dc8e0ee77ea675fedc07e41 (patch)
tree31ebec81d2f52adc89796dd063468235bfd1cc0e /include
parentad3043fda39db0361d9601685356db4512e914be (diff)
KEYS: Generalise system_verify_data() to provide access to internal content
Generalise system_verify_data() to provide access to internal content through a callback. This allows all the PKCS#7 stuff to be hidden inside this function and removed from the PE file parser and the PKCS#7 test key. If external content is not required, NULL should be passed as data to the function. If the callback is not required, that can be set to NULL. The function is now called verify_pkcs7_signature() to contrast with verify_pefile_signature() and the definitions of both have been moved into linux/verification.h along with the key_being_used_for enum. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/crypto/pkcs7.h3
-rw-r--r--include/crypto/public_key.h14
-rw-r--r--include/keys/asymmetric-type.h1
-rw-r--r--include/keys/system_keyring.h7
-rw-r--r--include/linux/verification.h50
-rw-r--r--include/linux/verify_pefile.h22
6 files changed, 54 insertions, 43 deletions
diff --git a/include/crypto/pkcs7.h b/include/crypto/pkcs7.h
index 441aff9b5aa7..8323e3e57131 100644
--- a/include/crypto/pkcs7.h
+++ b/include/crypto/pkcs7.h
@@ -12,6 +12,7 @@
12#ifndef _CRYPTO_PKCS7_H 12#ifndef _CRYPTO_PKCS7_H
13#define _CRYPTO_PKCS7_H 13#define _CRYPTO_PKCS7_H
14 14
15#include <linux/verification.h>
15#include <crypto/public_key.h> 16#include <crypto/public_key.h>
16 17
17struct key; 18struct key;
@@ -26,7 +27,7 @@ extern void pkcs7_free_message(struct pkcs7_message *pkcs7);
26 27
27extern int pkcs7_get_content_data(const struct pkcs7_message *pkcs7, 28extern int pkcs7_get_content_data(const struct pkcs7_message *pkcs7,
28 const void **_data, size_t *_datalen, 29 const void **_data, size_t *_datalen,
29 bool want_wrapper); 30 size_t *_headerlen);
30 31
31/* 32/*
32 * pkcs7_trust.c 33 * pkcs7_trust.c
diff --git a/include/crypto/public_key.h b/include/crypto/public_key.h
index 2f5de5c1a3a0..b3928e801b8c 100644
--- a/include/crypto/public_key.h
+++ b/include/crypto/public_key.h
@@ -15,20 +15,6 @@
15#define _LINUX_PUBLIC_KEY_H 15#define _LINUX_PUBLIC_KEY_H
16 16
17/* 17/*
18 * The use to which an asymmetric key is being put.
19 */
20enum key_being_used_for {
21 VERIFYING_MODULE_SIGNATURE,
22 VERIFYING_FIRMWARE_SIGNATURE,
23 VERIFYING_KEXEC_PE_SIGNATURE,
24 VERIFYING_KEY_SIGNATURE,
25 VERIFYING_KEY_SELF_SIGNATURE,
26 VERIFYING_UNSPECIFIED_SIGNATURE,
27 NR__KEY_BEING_USED_FOR
28};
29extern const char *const key_being_used_for[NR__KEY_BEING_USED_FOR];
30
31/*
32 * Cryptographic data for the public-key subtype of the asymmetric key type. 18 * Cryptographic data for the public-key subtype of the asymmetric key type.
33 * 19 *
34 * Note that this may include private part of the key as well as the public 20 * Note that this may include private part of the key as well as the public
diff --git a/include/keys/asymmetric-type.h b/include/keys/asymmetric-type.h
index 70a8775bb444..d1e23dda4363 100644
--- a/include/keys/asymmetric-type.h
+++ b/include/keys/asymmetric-type.h
@@ -15,6 +15,7 @@
15#define _KEYS_ASYMMETRIC_TYPE_H 15#define _KEYS_ASYMMETRIC_TYPE_H
16 16
17#include <linux/key-type.h> 17#include <linux/key-type.h>
18#include <linux/verification.h>
18 19
19extern struct key_type key_type_asymmetric; 20extern struct key_type key_type_asymmetric;
20 21
diff --git a/include/keys/system_keyring.h b/include/keys/system_keyring.h
index 39fd38cfa8c9..b2d645ac35a0 100644
--- a/include/keys/system_keyring.h
+++ b/include/keys/system_keyring.h
@@ -15,6 +15,7 @@
15#ifdef CONFIG_SYSTEM_TRUSTED_KEYRING 15#ifdef CONFIG_SYSTEM_TRUSTED_KEYRING
16 16
17#include <linux/key.h> 17#include <linux/key.h>
18#include <linux/verification.h>
18#include <crypto/public_key.h> 19#include <crypto/public_key.h>
19 20
20extern struct key *system_trusted_keyring; 21extern struct key *system_trusted_keyring;
@@ -29,12 +30,6 @@ static inline struct key *get_system_trusted_keyring(void)
29} 30}
30#endif 31#endif
31 32
32#ifdef CONFIG_SYSTEM_DATA_VERIFICATION
33extern int system_verify_data(const void *data, unsigned long len,
34 const void *raw_pkcs7, size_t pkcs7_len,
35 enum key_being_used_for usage);
36#endif
37
38#ifdef CONFIG_IMA_MOK_KEYRING 33#ifdef CONFIG_IMA_MOK_KEYRING
39extern struct key *ima_mok_keyring; 34extern struct key *ima_mok_keyring;
40extern struct key *ima_blacklist_keyring; 35extern struct key *ima_blacklist_keyring;
diff --git a/include/linux/verification.h b/include/linux/verification.h
new file mode 100644
index 000000000000..bb0fcf941cb7
--- /dev/null
+++ b/include/linux/verification.h
@@ -0,0 +1,50 @@
1/* Signature verification
2 *
3 * Copyright (C) 2014 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#ifndef _LINUX_VERIFICATION_H
13#define _LINUX_VERIFICATION_H
14
15/*
16 * The use to which an asymmetric key is being put.
17 */
18enum key_being_used_for {
19 VERIFYING_MODULE_SIGNATURE,
20 VERIFYING_FIRMWARE_SIGNATURE,
21 VERIFYING_KEXEC_PE_SIGNATURE,
22 VERIFYING_KEY_SIGNATURE,
23 VERIFYING_KEY_SELF_SIGNATURE,
24 VERIFYING_UNSPECIFIED_SIGNATURE,
25 NR__KEY_BEING_USED_FOR
26};
27extern const char *const key_being_used_for[NR__KEY_BEING_USED_FOR];
28
29#ifdef CONFIG_SYSTEM_DATA_VERIFICATION
30
31struct key;
32
33extern int verify_pkcs7_signature(const void *data, size_t len,
34 const void *raw_pkcs7, size_t pkcs7_len,
35 struct key *trusted_keys,
36 int untrusted_error,
37 enum key_being_used_for usage,
38 int (*view_content)(void *ctx,
39 const void *data, size_t len,
40 size_t asn1hdrlen),
41 void *ctx);
42
43#ifdef CONFIG_SIGNED_PE_FILE_VERIFICATION
44extern int verify_pefile_signature(const void *pebuf, unsigned pelen,
45 struct key *trusted_keys,
46 enum key_being_used_for usage);
47#endif
48
49#endif /* CONFIG_SYSTEM_DATA_VERIFICATION */
50#endif /* _LINUX_VERIFY_PEFILE_H */
diff --git a/include/linux/verify_pefile.h b/include/linux/verify_pefile.h
deleted file mode 100644
index da2049b5161c..000000000000
--- a/include/linux/verify_pefile.h
+++ /dev/null
@@ -1,22 +0,0 @@
1/* Signed PE file verification
2 *
3 * Copyright (C) 2014 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#ifndef _LINUX_VERIFY_PEFILE_H
13#define _LINUX_VERIFY_PEFILE_H
14
15#include <crypto/public_key.h>
16
17extern int verify_pefile_signature(const void *pebuf, unsigned pelen,
18 struct key *trusted_keyring,
19 enum key_being_used_for usage,
20 bool *_trusted);
21
22#endif /* _LINUX_VERIFY_PEFILE_H */