4c2a8d2ef8
The builtin keyring was exported prior to this which allowed android-verity to simply lookup the key in the builtin keyring and verify the signature of the verity metadata. This is now broken as the kernel expects the signature to be in pkcs#7 format (same used for module signing). Obviously, this doesn't work with the verity metadata as we just append the raw signature in the metadata .. sigh. *This one time*, add an API to accept arbitrary signature and verify that with a key from system's trusted keyring. Bug: 72722987 Test: $ adb push verity_fs.img /data/local/tmp/ $ adb root && adb shell > cd /data/local/tmp > losetup /dev/block/loop0 verity_fs.img > dmctl create verity-fs android-verity 0 4200 Android:#7e4333f9bba00adfe0ede979e28ed1920492b40f 7:0 > mount -t ext4 /dev/block/dm-0 temp/ > cat temp/foo.txt temp/bar.txt Change-Id: I0c14f3cb2b587b73a4c75907367769688756213e Signed-off-by: Sandeep Patil <sspatil@google.com>
59 lines
1.7 KiB
C
59 lines
1.7 KiB
C
/* Signature verification
|
|
*
|
|
* Copyright (C) 2014 Red Hat, Inc. All Rights Reserved.
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public Licence
|
|
* as published by the Free Software Foundation; either version
|
|
* 2 of the Licence, or (at your option) any later version.
|
|
*/
|
|
|
|
#ifndef _LINUX_VERIFICATION_H
|
|
#define _LINUX_VERIFICATION_H
|
|
|
|
/*
|
|
* Indicate that both builtin trusted keys and secondary trusted keys
|
|
* should be used.
|
|
*/
|
|
#define VERIFY_USE_SECONDARY_KEYRING ((struct key *)1UL)
|
|
|
|
/*
|
|
* The use to which an asymmetric key is being put.
|
|
*/
|
|
enum key_being_used_for {
|
|
VERIFYING_MODULE_SIGNATURE,
|
|
VERIFYING_FIRMWARE_SIGNATURE,
|
|
VERIFYING_KEXEC_PE_SIGNATURE,
|
|
VERIFYING_KEY_SIGNATURE,
|
|
VERIFYING_KEY_SELF_SIGNATURE,
|
|
VERIFYING_UNSPECIFIED_SIGNATURE,
|
|
NR__KEY_BEING_USED_FOR
|
|
};
|
|
extern const char *const key_being_used_for[NR__KEY_BEING_USED_FOR];
|
|
|
|
struct key;
|
|
struct public_key_signature;
|
|
|
|
extern int verify_signature_one(const struct public_key_signature *sig,
|
|
struct key *trusted_keys, const char *keyid);
|
|
|
|
#ifdef CONFIG_SYSTEM_DATA_VERIFICATION
|
|
|
|
extern int verify_pkcs7_signature(const void *data, size_t len,
|
|
const void *raw_pkcs7, size_t pkcs7_len,
|
|
struct key *trusted_keys,
|
|
enum key_being_used_for usage,
|
|
int (*view_content)(void *ctx,
|
|
const void *data, size_t len,
|
|
size_t asn1hdrlen),
|
|
void *ctx);
|
|
|
|
#ifdef CONFIG_SIGNED_PE_FILE_VERIFICATION
|
|
extern int verify_pefile_signature(const void *pebuf, unsigned pelen,
|
|
struct key *trusted_keys,
|
|
enum key_being_used_for usage);
|
|
#endif
|
|
|
|
#endif /* CONFIG_SYSTEM_DATA_VERIFICATION */
|
|
#endif /* _LINUX_VERIFY_PEFILE_H */
|