Lines Matching refs:self
38 def __init__(self, message): argument
39 Exception.__init__(self, message)
217 def CalculateMaxImageSize(self, partition_size): argument
221 def CalculateDynamicPartitionSize(self, image_size): argument
225 def PadSparseImage(self, out_file): argument
229 def Build(self, out_file): argument
237 def __init__(self, partition_size, block_dev, fec_supported, signer_path, argument
239 self.version = 1
240 self.partition_size = partition_size
241 self.block_device = block_dev
242 self.fec_supported = fec_supported
243 self.signer_path = signer_path
244 self.signer_key = signer_key
245 self.signer_args = signer_args
246 self.verity_disable = verity_disable
247 self.image_size = None
248 self.verity_size = None
250 def CalculateDynamicPartitionSize(self, image_size): argument
255 def CalculateMaxImageSize(self, partition_size=None): argument
266 partition_size = self.partition_size
276 verity_size = GetVeritySize(hi, self.fec_supported)
283 v = GetVeritySize(i, self.fec_supported)
292 self.image_size = result
293 self.verity_size = verity_size
300 def Build(self, out_file): argument
310 image_size = int(self.image_size)
322 image_size, verity_metadata_path, root_hash, salt, self.block_device,
323 self.signer_path, self.signer_key, self.signer_args,
324 self.verity_disable)
326 padding_size = self.partition_size - self.image_size - self.verity_size
334 if self.fec_supported:
344 def PadSparseImage(self, out_file): argument
346 if sparse_image_size > self.image_size:
349 "{}".format(sparse_image_size, self.image_size))
350 ZeroPadSimg(out_file, self.image_size - sparse_image_size)
359 def __init__(self, partition_name, partition_size, footer_type, avbtool, argument
361 self.version = 2
362 self.partition_name = partition_name
363 self.partition_size = partition_size
364 self.footer_type = footer_type
365 self.avbtool = avbtool
366 self.algorithm = algorithm
367 self.key_path = key_path
368 self.salt = salt
369 self.signing_args = signing_args
370 self.image_size = None
372 def CalculateMinPartitionSize(self, image_size, size_calculator=None): argument
388 size_calculator = self.CalculateMaxImageSize
435 def CalculateDynamicPartitionSize(self, image_size): argument
436 self.partition_size = self.CalculateMinPartitionSize(image_size)
437 return self.partition_size
439 def CalculateMaxImageSize(self, partition_size=None): argument
453 partition_size = self.partition_size
457 add_footer = ("add_hash_footer" if self.footer_type == self.AVB_HASH_FOOTER
459 cmd = [self.avbtool, add_footer, "--partition_size",
461 cmd.extend(shlex.split(self.signing_args))
472 self.image_size = image_size
475 def PadSparseImage(self, out_file): argument
479 def Build(self, out_file): argument
485 add_footer = ("add_hash_footer" if self.footer_type == self.AVB_HASH_FOOTER
487 cmd = [self.avbtool, add_footer,
488 "--partition_size", str(self.partition_size),
489 "--partition_name", self.partition_name,
491 if self.key_path and self.algorithm:
492 cmd.extend(["--key", self.key_path, "--algorithm", self.algorithm])
493 if self.salt:
494 cmd.extend(["--salt", self.salt])
495 cmd.extend(shlex.split(self.signing_args))
506 def __init__(self, message): argument
507 Exception.__init__(self, message)
511 def __init__(self): argument
512 self.hashtree_range = None
513 self.filesystem_range = None
514 self.hash_algorithm = None
515 self.salt = None
516 self.root_hash = None
532 def Generate(self, image): argument
535 def DecomposeSparseImage(self, image): argument
538 def ValidateHashtree(self): argument
545 def __init__(self, partition_size, block_size, fec_supported): argument
555 self.block_size = block_size
556 self.partition_size = partition_size
557 self.fec_supported = fec_supported
559 self.image = None
560 self.filesystem_size = None
561 self.hashtree_size = None
562 self.metadata_size = None
576 self.verity_image_builder = CreateVerityImageBuilder(prop_dict)
578 self.hashtree_info = HashtreeInfo()
580 def DecomposeSparseImage(self, image): argument
588 self.image = image
589 assert self.block_size == image.blocksize
590 assert self.partition_size == image.total_blocks * self.block_size, \
592 " total_blocks: {}".format(self.partition_size, image.total_blocks)
594 adjusted_size = self.verity_image_builder.CalculateMaxImageSize()
595 assert adjusted_size % self.block_size == 0
598 assert verity_tree_size % self.block_size == 0
601 assert metadata_size % self.block_size == 0
603 self.filesystem_size = adjusted_size
604 self.hashtree_size = verity_tree_size
605 self.metadata_size = metadata_size
607 self.hashtree_info.filesystem_range = RangeSet(
608 data=[0, adjusted_size / self.block_size])
609 self.hashtree_info.hashtree_range = RangeSet(
610 data=[adjusted_size / self.block_size,
611 (adjusted_size + verity_tree_size) / self.block_size])
613 def _ParseHashtreeMetadata(self): argument
616 metadata_start = self.filesystem_size + self.hashtree_size
618 data=[metadata_start / self.block_size,
619 (metadata_start + self.metadata_size) / self.block_size])
620 meta_data = ''.join(self.image.ReadRangeSet(metadata_range))
638 assert (int(table_entries[3]) == self.block_size and
639 int(table_entries[4]) == self.block_size)
640 assert (int(table_entries[5]) * self.block_size == self.filesystem_size and
641 int(table_entries[6]) * self.block_size == self.filesystem_size)
643 self.hashtree_info.hash_algorithm = table_entries[7]
644 self.hashtree_info.root_hash = table_entries[8]
645 self.hashtree_info.salt = table_entries[9]
647 def ValidateHashtree(self): argument
654 self.image.WriteRangeDataToFd(self.hashtree_info.filesystem_range, fd)
660 assert salt == self.hashtree_info.salt, \
662 salt, self.hashtree_info.salt)
664 if root_hash != self.hashtree_info.root_hash:
667 root_hash, self.hashtree_info.root_hash)
673 return fd.read() == ''.join(self.image.ReadRangeSet(
674 self.hashtree_info.hashtree_range))
676 def Generate(self, image): argument
687 self.DecomposeSparseImage(image)
688 self._ParseHashtreeMetadata()
690 if not self.ValidateHashtree():
693 return self.hashtree_info