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