xref: /aosp_15_r20/external/avb/rust/tests/test_data.rs (revision d289c2ba6de359471b23d594623b906876bc48a0)
1 // Copyright 2024, The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 //! Test data used in libavb_rs tests.
16 //!
17 //! These constants must match the values used to create the images in Android.bp.
18 
19 pub const TEST_IMAGE_PATH: &str = "test_image.img";
20 pub const TEST_IMAGE_SIZE: usize = 16 * 1024;
21 pub const TEST_IMAGE_SALT_HEX: &str = "1000";
22 pub const TEST_HASHTREE_SALT_HEX: &str = "B000";
23 pub const TEST_VBMETA_PATH: &str = "test_vbmeta.img";
24 pub const TEST_VBMETA_2_PARTITIONS_PATH: &str = "test_vbmeta_2_parts.img";
25 pub const TEST_VBMETA_PERSISTENT_DIGEST_PATH: &str = "test_vbmeta_persistent_digest.img";
26 pub const TEST_VBMETA_WITH_PROPERTY_PATH: &str = "test_vbmeta_with_property.img";
27 pub const TEST_VBMETA_WITH_HASHTREE_PATH: &str = "test_vbmeta_with_hashtree.img";
28 pub const TEST_VBMETA_WITH_COMMANDLINE_PATH: &str = "test_vbmeta_with_commandline.img";
29 pub const TEST_VBMETA_WITH_CHAINED_PARTITION_PATH: &str = "test_vbmeta_with_chained_partition.img";
30 pub const TEST_IMAGE_WITH_VBMETA_FOOTER_PATH: &str = "avbrs_test_image_with_vbmeta_footer.img";
31 pub const TEST_IMAGE_WITH_VBMETA_FOOTER_FOR_BOOT_PATH: &str =
32     "avbrs_test_image_with_vbmeta_footer_for_boot.img";
33 pub const TEST_IMAGE_WITH_VBMETA_FOOTER_FOR_TEST_PART_2: &str =
34     "avbrs_test_image_with_vbmeta_footer_for_test_part_2.img";
35 pub const TEST_PUBLIC_KEY_PATH: &str = "data/testkey_rsa4096_pub.bin";
36 pub const TEST_PUBLIC_KEY_RSA8192_PATH: &str = "data/testkey_rsa8192_pub.bin";
37 pub const TEST_PARTITION_NAME: &str = "test_part";
38 pub const TEST_PARTITION_SLOT_C_NAME: &str = "test_part_c";
39 pub const TEST_PARTITION_2_NAME: &str = "test_part_2";
40 pub const TEST_PARTITION_PERSISTENT_DIGEST_NAME: &str = "test_part_persistent_digest";
41 pub const TEST_PARTITION_HASH_TREE_NAME: &str = "test_part_hashtree";
42 pub const TEST_VBMETA_ROLLBACK_LOCATION: usize = 0; // Default value, we don't explicitly set this.
43 pub const TEST_PROPERTY_KEY: &str = "test_prop_key";
44 pub const TEST_PROPERTY_VALUE: &[u8] = b"test_prop_value";
45 pub const TEST_KERNEL_COMMANDLINE: &str = "test_cmdline_key=test_cmdline_value";
46 pub const TEST_CHAINED_PARTITION_ROLLBACK_LOCATION: usize = 4;
47 pub const TEST_CHAINED_PARTITION_ROLLBACK_INDEX: u64 = 7;
48 
49 // Expected values determined by examining the vbmeta image with `avbtool info_image`.
50 // Images can be found in <out>/soong/.intermediates/external/avb/rust/.
51 pub const TEST_IMAGE_DIGEST_HEX: &str =
52     "89e6fd3142917b8c34ac7d30897a907a71bd3bf5d9b39d00bf938b41dcf3b84f";
53 pub const TEST_IMAGE_HASH_ALGO: &str = "sha256";
54 pub const TEST_HASHTREE_DIGEST_HEX: &str = "5373fc4ee3dd898325eeeffb5a1dbb041900c5f1";
55 pub const TEST_HASHTREE_ALGORITHM: &str = "sha1";
56 
57 // Certificate test data.
58 pub const TEST_CERT_PERMANENT_ATTRIBUTES_PATH: &str = "data/cert_permanent_attributes.bin";
59 pub const TEST_CERT_VBMETA_PATH: &str = "test_vbmeta_cert.img";
60 pub const TEST_CERT_UNLOCK_CHALLENGE_RNG_PATH: &str = "data/cert_unlock_challenge.bin";
61 pub const TEST_CERT_UNLOCK_CREDENTIAL_PATH: &str = "data/cert_unlock_credential.bin";
62 
63 // The cert test keys were both generated with rollback version 42.
64 pub const TEST_CERT_PIK_VERSION: u64 = 42;
65 pub const TEST_CERT_PSK_VERSION: u64 = 42;
66 
67 // $ sha256sum external/avb/test/data/cert_permanent_attributes.bin
68 pub const TEST_CERT_PERMANENT_ATTRIBUTES_HASH_HEX: &str =
69     "55419e1affff153b58f65ce8a5313a71d2a83a00d0abae10a25b9a8e493d04f7";
70 
71 // $ sha256sum external/avb/test/data/cert_product_id.bin
72 pub const TEST_CERT_PRODUCT_ID_HASH_HEX: &str =
73     "374708fff7719dd5979ec875d56cd2286f6d3cf7ec317a3b25632aab28ec37bb";
74