Skip to content

Commit 60050ff

Browse files
committed
certs: Move load_certificate_list() to be with the asymmetric keys code
Move load_certificate_list(), which loads a series of binary X.509 certificates from a blob and inserts them as keys into a keyring, to be with the asymmetric keys code that it drives. This makes it easier to add FIPS selftest code in which we need to load up a private keyring for the tests to use. Signed-off-by: David Howells <[email protected]> Reviewed-by: Simo Sorce <[email protected]> Reviewed-by: Herbert Xu <[email protected]> cc: [email protected] cc: [email protected] Link: https://lore.kernel.org/r/165515742145.1554877.13488098107542537203.stgit@warthog.procyon.org.uk/
1 parent b13bacc commit 60050ff

File tree

7 files changed

+17
-22
lines changed

7 files changed

+17
-22
lines changed

certs/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# Makefile for the linux kernel signature checking certificates.
44
#
55

6-
obj-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += system_keyring.o system_certificates.o common.o
7-
obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist.o common.o
6+
obj-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += system_keyring.o system_certificates.o
7+
obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist.o
88
obj-$(CONFIG_SYSTEM_REVOCATION_LIST) += revocation_certificates.o
99
ifneq ($(CONFIG_SYSTEM_BLACKLIST_HASH_LIST),)
1010
quiet_cmd_check_blacklist_hashes = CHECK $(patsubst "%",%,$(2))

certs/blacklist.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
#include <linux/err.h>
1616
#include <linux/seq_file.h>
1717
#include <linux/uidgid.h>
18-
#include <linux/verification.h>
18+
#include <keys/asymmetric-type.h>
1919
#include <keys/system_keyring.h>
2020
#include "blacklist.h"
21-
#include "common.h"
2221

2322
/*
2423
* According to crypto/asymmetric_keys/x509_cert_parser.c:x509_note_pkey_algo(),
@@ -365,8 +364,9 @@ static __init int load_revocation_certificate_list(void)
365364
if (revocation_certificate_list_size)
366365
pr_notice("Loading compiled-in revocation X.509 certificates\n");
367366

368-
return load_certificate_list(revocation_certificate_list, revocation_certificate_list_size,
369-
blacklist_keyring);
367+
return x509_load_certificate_list(revocation_certificate_list,
368+
revocation_certificate_list_size,
369+
blacklist_keyring);
370370
}
371371
late_initcall(load_revocation_certificate_list);
372372
#endif

certs/common.h

Lines changed: 0 additions & 9 deletions
This file was deleted.

certs/system_keyring.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <keys/asymmetric-type.h>
1717
#include <keys/system_keyring.h>
1818
#include <crypto/pkcs7.h>
19-
#include "common.h"
2019

2120
static struct key *builtin_trusted_keys;
2221
#ifdef CONFIG_SECONDARY_TRUSTED_KEYRING
@@ -183,7 +182,8 @@ __init int load_module_cert(struct key *keyring)
183182

184183
pr_notice("Loading compiled-in module X.509 certificates\n");
185184

186-
return load_certificate_list(system_certificate_list, module_cert_size, keyring);
185+
return x509_load_certificate_list(system_certificate_list,
186+
module_cert_size, keyring);
187187
}
188188

189189
/*
@@ -204,7 +204,7 @@ static __init int load_system_certificate_list(void)
204204
size = system_certificate_list_size - module_cert_size;
205205
#endif
206206

207-
return load_certificate_list(p, size, builtin_trusted_keys);
207+
return x509_load_certificate_list(p, size, builtin_trusted_keys);
208208
}
209209
late_initcall(load_system_certificate_list);
210210

crypto/asymmetric_keys/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ x509_key_parser-y := \
2020
x509.asn1.o \
2121
x509_akid.asn1.o \
2222
x509_cert_parser.o \
23+
x509_loader.o \
2324
x509_public_key.o
2425

2526
$(obj)/x509_cert_parser.o: \

certs/common.c renamed to crypto/asymmetric_keys/x509_loader.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
#include <linux/kernel.h>
44
#include <linux/key.h>
5-
#include "common.h"
5+
#include <keys/asymmetric-type.h>
66

7-
int load_certificate_list(const u8 cert_list[],
8-
const unsigned long list_size,
9-
const struct key *keyring)
7+
int x509_load_certificate_list(const u8 cert_list[],
8+
const unsigned long list_size,
9+
const struct key *keyring)
1010
{
1111
key_ref_t key;
1212
const u8 *p, *end;

include/keys/asymmetric-type.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ extern struct key *find_asymmetric_key(struct key *keyring,
8484
const struct asymmetric_key_id *id_2,
8585
bool partial);
8686

87+
int x509_load_certificate_list(const u8 cert_list[], const unsigned long list_size,
88+
const struct key *keyring);
89+
8790
/*
8891
* The payload is at the discretion of the subtype.
8992
*/

0 commit comments

Comments
 (0)