Merge "Build libavb as a static library"
diff --git a/avbtool b/avbtool
index 9561988..599100b 100755
--- a/avbtool
+++ b/avbtool
@@ -989,7 +989,8 @@
"""
TAG = 1
- SIZE = 116
+ RESERVED = 64
+ SIZE = 116 + RESERVED
FORMAT_STRING = ('!QQ' # tag, num_bytes_following (descriptor header)
'L' # dm-verity version used
'Q' # image size (bytes)
@@ -1003,7 +1004,8 @@
'32s' # hash algorithm used
'L' # partition name (bytes)
'L' # salt length (bytes)
- 'L') # root digest length (bytes)
+ 'L' + # root digest length (bytes)
+ str(RESERVED) + 's') # reserved
def __init__(self, data=None):
"""Initializes a new hashtree descriptor.
@@ -1022,7 +1024,8 @@
self.tree_offset, self.tree_size, self.data_block_size,
self.hash_block_size, self.fec_num_roots, self.fec_offset, self.fec_size,
self.hash_algorithm, partition_name_len, salt_len,
- root_digest_len) = struct.unpack(self.FORMAT_STRING, data[0:self.SIZE])
+ root_digest_len, _) = struct.unpack(self.FORMAT_STRING,
+ data[0:self.SIZE])
expected_size = round_to_multiple(
self.SIZE - 16 + partition_name_len + salt_len + root_digest_len, 8)
if tag != self.TAG or num_bytes_following != expected_size:
@@ -1098,7 +1101,8 @@
self.tree_offset, self.tree_size, self.data_block_size,
self.hash_block_size, self.fec_num_roots,
self.fec_offset, self.fec_size, self.hash_algorithm,
- len(encoded_name), len(self.salt), len(self.root_digest))
+ len(encoded_name), len(self.salt), len(self.root_digest),
+ self.RESERVED*'\0')
padding = struct.pack(str(padding_size) + 'x')
ret = desc + encoded_name + self.salt + self.root_digest + padding
return bytearray(ret)
@@ -1118,13 +1122,15 @@
"""
TAG = 2
- SIZE = 68
+ RESERVED = 64
+ SIZE = 68 + RESERVED
FORMAT_STRING = ('!QQ' # tag, num_bytes_following (descriptor header)
'Q' # image size (bytes)
'32s' # hash algorithm used
'L' # partition name (bytes)
'L' # salt length (bytes)
- 'L') # digest length (bytes)
+ 'L' + # digest length (bytes)
+ str(RESERVED) + 's') # reserved
def __init__(self, data=None):
"""Initializes a new hash descriptor.
@@ -1141,7 +1147,7 @@
if data:
(tag, num_bytes_following, self.image_size, self.hash_algorithm,
partition_name_len, salt_len,
- digest_len) = struct.unpack(self.FORMAT_STRING, data[0:self.SIZE])
+ digest_len, _) = struct.unpack(self.FORMAT_STRING, data[0:self.SIZE])
expected_size = round_to_multiple(
self.SIZE - 16 + partition_name_len + salt_len + digest_len, 8)
if tag != self.TAG or num_bytes_following != expected_size:
@@ -1195,7 +1201,7 @@
padding_size = nbf_with_padding - num_bytes_following
desc = struct.pack(self.FORMAT_STRING, self.TAG, nbf_with_padding,
self.image_size, self.hash_algorithm, len(encoded_name),
- len(self.salt), len(self.digest))
+ len(self.salt), len(self.digest), self.RESERVED*'\0')
padding = struct.pack(str(padding_size) + 'x')
ret = desc + encoded_name + self.salt + self.digest + padding
return bytearray(ret)
@@ -1282,11 +1288,13 @@
"""
TAG = 4
- SIZE = 28
+ RESERVED = 64
+ SIZE = 28 + RESERVED
FORMAT_STRING = ('!QQ' # tag, num_bytes_following (descriptor header)
'L' # rollback_index_slot
'L' # partition_name_size (bytes)
- 'L') # public_key_size (bytes)
+ 'L' + # public_key_size (bytes)
+ str(RESERVED) + 's') # reserved
def __init__(self, data=None):
"""Initializes a new chain partition descriptor.
@@ -1302,7 +1310,7 @@
if data:
(tag, num_bytes_following, self.rollback_index_slot, partition_name_len,
- public_key_len) = struct.unpack(self.FORMAT_STRING, data[0:self.SIZE])
+ public_key_len, _) = struct.unpack(self.FORMAT_STRING, data[0:self.SIZE])
expected_size = round_to_multiple(
self.SIZE - 16 + partition_name_len + public_key_len, 8)
if tag != self.TAG or num_bytes_following != expected_size:
@@ -1348,7 +1356,7 @@
padding_size = nbf_with_padding - num_bytes_following
desc = struct.pack(self.FORMAT_STRING, self.TAG, nbf_with_padding,
self.rollback_index_slot, len(encoded_name),
- len(self.public_key))
+ len(self.public_key), self.RESERVED*'\0')
padding = struct.pack(str(padding_size) + 'x')
ret = desc + encoded_name + self.public_key + padding
return bytearray(ret)
diff --git a/libavb/avb_chain_partition_descriptor.h b/libavb/avb_chain_partition_descriptor.h
index 714f4e6..817f74f 100644
--- a/libavb/avb_chain_partition_descriptor.h
+++ b/libavb/avb_chain_partition_descriptor.h
@@ -44,12 +44,16 @@
* Following this struct are |partition_name_len| bytes of the
* partition name (UTF-8 encoded) and |public_key_len| bytes of the
* public key.
+ *
+ * The |reserved| field is for future expansion and must be set to NUL
+ * bytes.
*/
typedef struct AvbChainPartitionDescriptor {
AvbDescriptor parent_descriptor;
uint32_t rollback_index_slot;
uint32_t partition_name_len;
uint32_t public_key_len;
+ uint8_t reserved[64];
} AVB_ATTR_PACKED AvbChainPartitionDescriptor;
/* Copies |src| to |dest| and validates, byte-swapping fields in the
diff --git a/libavb/avb_hash_descriptor.h b/libavb/avb_hash_descriptor.h
index c884167..2668118 100644
--- a/libavb/avb_hash_descriptor.h
+++ b/libavb/avb_hash_descriptor.h
@@ -43,6 +43,9 @@
* Following this struct are |partition_name_len| bytes of the
* partition name (UTF-8 encoded), |salt_len| bytes of salt, and then
* |digest_len| bytes of the digest.
+ *
+ * The |reserved| field is for future expansion and must be set to NUL
+ * bytes.
*/
typedef struct AvbHashDescriptor {
AvbDescriptor parent_descriptor;
@@ -51,6 +54,7 @@
uint32_t partition_name_len;
uint32_t salt_len;
uint32_t digest_len;
+ uint8_t reserved[64];
} AVB_ATTR_PACKED AvbHashDescriptor;
/* Copies |src| to |dest| and validates, byte-swapping fields in the
diff --git a/libavb/avb_hashtree_descriptor.h b/libavb/avb_hashtree_descriptor.h
index 06e7d37..a5aafbf 100644
--- a/libavb/avb_hashtree_descriptor.h
+++ b/libavb/avb_hashtree_descriptor.h
@@ -45,6 +45,9 @@
* Following this struct are |partition_name_len| bytes of the
* partition name (UTF-8 encoded), |salt_len| bytes of salt, and then
* |root_digest_len| bytes of the root digest.
+ *
+ * The |reserved| field is for future expansion and must be set to NUL
+ * bytes.
*/
typedef struct AvbHashtreeDescriptor {
AvbDescriptor parent_descriptor;
@@ -61,6 +64,7 @@
uint32_t partition_name_len;
uint32_t salt_len;
uint32_t root_digest_len;
+ uint8_t reserved[64];
} AVB_ATTR_PACKED AvbHashtreeDescriptor;
/* Copies |src| to |dest| and validates, byte-swapping fields in the
diff --git a/test/avb_slot_verify_unittest.cc b/test/avb_slot_verify_unittest.cc
index accf00a..2052bc7 100644
--- a/test/avb_slot_verify_unittest.cc
+++ b/test/avb_slot_verify_unittest.cc
@@ -204,7 +204,7 @@
"VBMeta image version: 1.0\n"
"Header Block: 256 bytes\n"
"Authentication Block: 576 bytes\n"
- "Auxiliary Block: 768 bytes\n"
+ "Auxiliary Block: 832 bytes\n"
"Algorithm: SHA256_RSA2048\n"
"Rollback Index: 4\n"
"Descriptors:\n"
@@ -261,9 +261,9 @@
"cmdline in hash footer 1234-fake-guid-for:system_a "
"androidboot.slot_suffix=_a "
"androidboot.vbmeta.device_state=locked "
- "androidboot.vbmeta.hash_alg=sha256 androidboot.vbmeta.size=1600 "
+ "androidboot.vbmeta.hash_alg=sha256 androidboot.vbmeta.size=1664 "
"androidboot.vbmeta.digest="
- "844308149e43d5db7b14cd5747def40aadf2f0e4716d6435242f90aac9d883d6",
+ "76b7864c5ff10ed816d9fa973db2abec562badf1e5a0488d8f0240921ad0606a",
std::string(slot_data->cmdline));
EXPECT_EQ(4UL, slot_data->rollback_indexes[0]);
for (size_t n = 1; n < AVB_MAX_NUMBER_OF_ROLLBACK_INDEX_SLOTS; n++) {
@@ -348,7 +348,7 @@
"VBMeta image version: 1.0\n"
"Header Block: 256 bytes\n"
"Authentication Block: 576 bytes\n"
- "Auxiliary Block: 1664 bytes\n"
+ "Auxiliary Block: 1728 bytes\n"
"Algorithm: SHA256_RSA2048\n"
"Rollback Index: 11\n"
"Descriptors:\n"
@@ -386,9 +386,9 @@
"cmdline2 in hash footer cmdline2 in vbmeta "
"androidboot.slot_suffix=_a "
"androidboot.vbmeta.device_state=locked "
- "androidboot.vbmeta.hash_alg=sha256 androidboot.vbmeta.size=2496 "
+ "androidboot.vbmeta.hash_alg=sha256 androidboot.vbmeta.size=2560 "
"androidboot.vbmeta.digest="
- "3924a4e4cdf9a4e6e77b0d87e6e9b4648621e43c2a20988a86c1eb9a56bef338",
+ "b77c1d6e09dad41563334c605cc0f565b2be221dcd523267a94b9e8ec3aba5f7",
std::string(slot_data->cmdline));
EXPECT_EQ(11UL, slot_data->rollback_indexes[0]);
EXPECT_EQ(12UL, slot_data->rollback_indexes[1]);
@@ -567,7 +567,7 @@
"VBMeta image version: 1.0\n"
"Header Block: 256 bytes\n"
"Authentication Block: 576 bytes\n"
- "Auxiliary Block: 1664 bytes\n"
+ "Auxiliary Block: 1728 bytes\n"
"Algorithm: SHA256_RSA2048\n"
"Rollback Index: 11\n"
"Descriptors:\n"
@@ -606,9 +606,9 @@
EXPECT_EQ(
"cmdline2 in hash footer cmdline2 in vbmeta "
"androidboot.vbmeta.device_state=locked "
- "androidboot.vbmeta.hash_alg=sha256 androidboot.vbmeta.size=2496 "
+ "androidboot.vbmeta.hash_alg=sha256 androidboot.vbmeta.size=2560 "
"androidboot.vbmeta.digest="
- "3924a4e4cdf9a4e6e77b0d87e6e9b4648621e43c2a20988a86c1eb9a56bef338",
+ "b77c1d6e09dad41563334c605cc0f565b2be221dcd523267a94b9e8ec3aba5f7",
std::string(slot_data->cmdline));
EXPECT_EQ(11UL, slot_data->rollback_indexes[0]);
EXPECT_EQ(12UL, slot_data->rollback_indexes[1]);
diff --git a/test/avbtool_unittest.cc b/test/avbtool_unittest.cc
index fc03b4d..2a1ea93 100644
--- a/test/avbtool_unittest.cc
+++ b/test/avbtool_unittest.cc
@@ -300,12 +300,12 @@
"Image size: 1572864 bytes\n"
"Original image size: 1052672 bytes\n"
"VBMeta offset: 1052672\n"
- "VBMeta size: 1472 bytes\n"
+ "VBMeta size: 1536 bytes\n"
"--\n"
"VBMeta image version: 1.0%s\n"
"Header Block: 256 bytes\n"
"Authentication Block: 576 bytes\n"
- "Auxiliary Block: 640 bytes\n"
+ "Auxiliary Block: 704 bytes\n"
"Algorithm: SHA256_RSA2048\n"
"Rollback Index: 0\n"
"Descriptors:\n"
@@ -356,7 +356,7 @@
EXPECT_EQ(AVB_FOOTER_MINOR_VERSION, (int)f.version_minor);
EXPECT_EQ(1052672UL, f.original_image_size);
EXPECT_EQ(1052672UL, f.vbmeta_offset);
- EXPECT_EQ(1472UL, f.vbmeta_size);
+ EXPECT_EQ(1536UL, f.vbmeta_size);
// Check that the vbmeta image at |f.vbmeta_offset| checks out.
const uint8_t* vbmeta_data =
@@ -453,12 +453,12 @@
"Image size: 10485760 bytes\n"
"Original image size: 10354688 bytes\n"
"VBMeta offset: 10354688\n"
- "VBMeta size: 1472 bytes\n"
+ "VBMeta size: 1536 bytes\n"
"--\n"
"VBMeta image version: 1.0 (Sparse)\n"
"Header Block: 256 bytes\n"
"Authentication Block: 576 bytes\n"
- "Auxiliary Block: 640 bytes\n"
+ "Auxiliary Block: 704 bytes\n"
"Algorithm: SHA256_RSA2048\n"
"Rollback Index: 0\n"
"Descriptors:\n"
@@ -511,12 +511,12 @@
"Image size: 1572864 bytes\n"
"Original image size: 1052672 bytes\n"
"VBMeta offset: 1069056\n"
- "VBMeta size: 1536 bytes\n"
+ "VBMeta size: 1600 bytes\n"
"--\n"
"VBMeta image version: 1.0%s\n"
"Header Block: 256 bytes\n"
"Authentication Block: 576 bytes\n"
- "Auxiliary Block: 704 bytes\n"
+ "Auxiliary Block: 768 bytes\n"
"Algorithm: SHA256_RSA2048\n"
"Rollback Index: 0\n"
"Descriptors:\n"
@@ -582,7 +582,7 @@
EXPECT_EQ(AVB_FOOTER_MINOR_VERSION, (int)f.version_minor);
EXPECT_EQ(1052672UL, f.original_image_size);
EXPECT_EQ(1069056UL, f.vbmeta_offset);
- EXPECT_EQ(1536UL, f.vbmeta_size);
+ EXPECT_EQ(1600UL, f.vbmeta_size);
// Check that the vbmeta image at |f.vbmeta_offset| checks out.
const uint8_t* vbmeta_data =
@@ -699,12 +699,12 @@
"Image size: 1572864 bytes\n"
"Original image size: 1052672 bytes\n"
"VBMeta offset: 1085440\n"
- "VBMeta size: 1536 bytes\n"
+ "VBMeta size: 1600 bytes\n"
"--\n"
"VBMeta image version: 1.0%s\n"
"Header Block: 256 bytes\n"
"Authentication Block: 576 bytes\n"
- "Auxiliary Block: 704 bytes\n"
+ "Auxiliary Block: 768 bytes\n"
"Algorithm: SHA256_RSA2048\n"
"Rollback Index: 0\n"
"Descriptors:\n"
@@ -754,7 +754,7 @@
EXPECT_EQ(AVB_FOOTER_MINOR_VERSION, (int)f.version_minor);
EXPECT_EQ(1052672UL, f.original_image_size);
EXPECT_EQ(1085440UL, f.vbmeta_offset);
- EXPECT_EQ(1536UL, f.vbmeta_size);
+ EXPECT_EQ(1600UL, f.vbmeta_size);
// Check that the vbmeta image at |f.vbmeta_offset| checks out.
const uint8_t* vbmeta_data =
@@ -1042,7 +1042,7 @@
"VBMeta image version: 1.0\n"
"Header Block: 256 bytes\n"
"Authentication Block: 576 bytes\n"
- "Auxiliary Block: 1088 bytes\n"
+ "Auxiliary Block: 1152 bytes\n"
"Algorithm: SHA256_RSA2048\n"
"Rollback Index: 0\n"
"Descriptors:\n"