Пример #1
0
    def test_DecomposeSparseImage(self):
        image_file = sparse_img.SparseImage(self._GenerateImage())

        generator = VerifiedBootVersion1HashtreeInfoGenerator(
            self.partition_size, 4096, True)
        generator.DecomposeSparseImage(image_file)
        self.assertEqual(991232, generator.filesystem_size)
        self.assertEqual(12288, generator.hashtree_size)
        self.assertEqual(32768, generator.metadata_size)
Пример #2
0
  def test_ParseHashtreeMetadata(self):
    image_file = sparse_img.SparseImage(self._generate_image())
    generator = VerifiedBootVersion1HashtreeInfoGenerator(
        self.partition_size, 4096, True)
    generator.DecomposeSparseImage(image_file)

    # pylint: disable=protected-access
    generator._ParseHashtreeMetadata()

    self.assertEqual(
        self.hash_algorithm, generator.hashtree_info.hash_algorithm)
    self.assertEqual(self.fixed_salt, generator.hashtree_info.salt)
    self.assertEqual(self.expected_root_hash, generator.hashtree_info.root_hash)
Пример #3
0
    def test_ValidateHashtree_failure(self):
        generator = VerifiedBootVersion1HashtreeInfoGenerator(
            self.partition_size, 4096, True)
        generator.image = sparse_img.SparseImage(self._GenerateImage())

        generator.hashtree_info = info = HashtreeInfo()
        info.filesystem_range = RangeSet(data=[0, 991232 // 4096])
        info.hashtree_range = RangeSet(
            data=[991232 // 4096, (991232 + 12288) // 4096])
        info.hash_algorithm = self.hash_algorithm
        info.salt = self.fixed_salt
        info.root_hash = "a" + self.expected_root_hash[1:]

        self.assertFalse(generator.ValidateHashtree())