// SPDX-License-Identifier: GPL-2.0+ /* EFI signature/key/certificate list parser * * Copyright (C) 2012, 2016 Red Hat, Inc. All Rights Reserved. * Written by David Howells ([email protected]) */ #define pr_fmt(fmt) … #include <linux/module.h> #include <linux/printk.h> #include <linux/err.h> #include <linux/efi.h> /** * parse_efi_signature_list - Parse an EFI signature list for certificates * @source: The source of the key * @data: The data blob to parse * @size: The size of the data blob * @get_handler_for_guid: Get the handler func for the sig type (or NULL) * * Parse an EFI signature list looking for elements of interest. A list is * made up of a series of sublists, where all the elements in a sublist are of * the same type, but sublists can be of different types. * * For each sublist encountered, the @get_handler_for_guid function is called * with the type specifier GUID and returns either a pointer to a function to * handle elements of that type or NULL if the type is not of interest. * * If the sublist is of interest, each element is passed to the handler * function in turn. * * Error EBADMSG is returned if the list doesn't parse correctly and 0 is * returned if the list was parsed correctly. No error can be returned from * the @get_handler_for_guid function or the element handler function it * returns. */ int __init parse_efi_signature_list( const char *source, const void *data, size_t size, efi_element_handler_t (*get_handler_for_guid)(const efi_guid_t *)) { … }