1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <inttypes.h>
20 #include <lk/compiler.h>
21 #include <stdbool.h>
22 #include <stddef.h>
23 
24 #define APPLOADER_PACKAGE_CBOR_ARRAY_SZ 4
25 
26 __BEGIN_CDECLS
27 
28 /**
29  * struct apploader_package_metadata - Package metadata, parsed from the package
30  * @elf_start:              Pointer to the start of the ELF image
31  * @elf_size:               Size of the embedded ELF image
32  * @elf_is_cose_encrypt:    True iff package contained encrypted ELF image
33  * @manifest_start:         Pointer to the start of the manifest
34  * @manifest_size:          Size of the manifest
35  * @public_key:             Pointer to public key in DER encoding
36  * @public_key_size:        Size of the public key
37  *
38  * This structure contains metadata about the package, parsed from the package
39  * data by the apploader_parse_package_metadata() function.
40  */
41 struct apploader_package_metadata {
42     const uint8_t* elf_start;
43     size_t elf_size;
44     bool elf_is_cose_encrypt;
45 
46     const uint8_t* manifest_start;
47     size_t manifest_size;
48 
49     const uint8_t* public_key;
50     unsigned int public_key_size;
51 };
52 
53 bool apploader_parse_package_metadata(
54         uint8_t* package_start,
55         size_t package_size,
56         struct apploader_package_metadata* metadata);
57 
58 __END_CDECLS
59