1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Permission is hereby granted, free of charge, to any person
5  * obtaining a copy of this software and associated documentation
6  * files (the "Software"), to deal in the Software without
7  * restriction, including without limitation the rights to use, copy,
8  * modify, merge, publish, distribute, sublicense, and/or sell copies
9  * of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 
25 #if !defined(AVB_INSIDE_LIBAVB_AFTL_H) && !defined(AVB_COMPILATION)
26 #error "Never include this file directly, include libavb_aftl/libavb_aftl.h."
27 #endif
28 
29 #ifndef AVB_AFTL_VALIDATE_H_
30 #define AVB_AFTL_VALIDATE_H_
31 
32 #include <libavb/libavb.h>
33 #include "avb_aftl_types.h"
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 /* Verifies that the logged vbmeta hash matches the one on device. */
40 bool avb_aftl_verify_vbmeta_hash(
41     uint8_t* vbmeta,          /* Buffer containing the vbmeta data. */
42     size_t vbmeta_size,       /* Size of the vbmeta buffer. */
43     AftlIcpEntry* icp_entry); /* Pointer to the AftlIcpEntry to verify. */
44 
45 /* Verifies the Merkle tree root hash. */
46 bool avb_aftl_verify_icp_root_hash(
47     AftlIcpEntry* icp_entry); /* Pointer to the AftlIcpEntry to verify. */
48 
49 /* Verifies the log root signature for the transparency log submission. */
50 bool avb_aftl_verify_entry_signature(
51     const uint8_t* key,       /* Transparency log public key data. */
52     size_t key_num_bytes,     /* Size of the key data. */
53     AftlIcpEntry* icp_entry); /* Pointer to the AftlIcpEntry to verify. */
54 
55 #ifdef __cplusplus
56 }
57 #endif
58 
59 #endif /* AVB_AFTL_VALIDATE_H_ */
60