mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-21 14:59:34 +00:00
appended signatures: Parse PKCS#7 signed data
This code allows us to parse: - PKCS#7 signed data messages. Only a single signer info is supported, which is all that the Linux sign-file utility supports creating out-of-the-box. Only RSA, SHA-256 and SHA-512 are supported. Any certificate embedded in the PKCS#7 message will be ignored. Signed-off-by: Daniel Axtens <dja@axtens.net> Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com> Reviewed-by: Avnish Chouhan <avnish@linux.ibm.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
3e4ff6ffb3
commit
a337549797
2 files changed
+489
No files matched your search
@@ -17,11 +17,48 @@
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/crypto.h>
|
||||
#include <libtasn1.h>
|
||||
|
||||
extern asn1_node grub_gnutls_gnutls_asn;
|
||||
extern asn1_node grub_gnutls_pkix_asn;
|
||||
|
||||
#define GRUB_MAX_OID_LEN 32
|
||||
|
||||
/* A PKCS#7 signed data signer info. */
|
||||
struct pkcs7_signer
|
||||
{
|
||||
const gcry_md_spec_t *hash;
|
||||
gcry_mpi_t sig_mpi;
|
||||
};
|
||||
typedef struct pkcs7_signer grub_pkcs7_signer_t;
|
||||
|
||||
/*
|
||||
* A PKCS#7 signed data message. We make no attempt to match intelligently, so
|
||||
* we don't save any info about the signer.
|
||||
*/
|
||||
struct pkcs7_data
|
||||
{
|
||||
grub_int32_t signer_count;
|
||||
grub_pkcs7_signer_t *signers;
|
||||
};
|
||||
typedef struct pkcs7_data grub_pkcs7_data_t;
|
||||
|
||||
/*
|
||||
* Parse a PKCS#7 message, which must be a signed data message. The message must
|
||||
* be in 'sigbuf' and of size 'data_size'. The result is placed in 'msg', which
|
||||
* must already be allocated.
|
||||
*/
|
||||
extern grub_err_t
|
||||
grub_pkcs7_data_parse (const void *sigbuf, grub_size_t data_size, grub_pkcs7_data_t *msg);
|
||||
|
||||
/*
|
||||
* Release all the storage associated with the PKCS#7 message. If the caller
|
||||
* dynamically allocated the message, it must free it.
|
||||
*/
|
||||
extern void
|
||||
grub_pkcs7_data_release (grub_pkcs7_data_t *msg);
|
||||
|
||||
/* Do libtasn1 init. */
|
||||
extern int
|
||||
grub_asn1_init (void);
|
||||
|
||||
Reference in new issue
Block a user