コード例 #1
0
ファイル: test_apex_utils.py プロジェクト: Blaze-AOSP/build
    def setUp(self):
        self.testdata_dir = test_utils.get_testdata_dir()
        # The default payload signing key.
        self.payload_key = os.path.join(self.testdata_dir, 'testkey.key')
        self.apex_with_apk = os.path.join(self.testdata_dir, 'has_apk.apex')

        common.OPTIONS.search_path = test_utils.get_search_path()
コード例 #2
0
 def test_Build_SanityCheck(self):
   # A sanity check for the test itself: the image shouldn't be verifiable
   # with wrong key.
   self.assertRaises(
       common.ExternalError,
       self._BuildAndVerify,
       self.DEFAULT_PROP_DICT,
       os.path.join(get_testdata_dir(), 'verity_mincrypt'))
コード例 #3
0
 def test_Build_SanityCheck(self):
   # A sanity check for the test itself: the image shouldn't be verifiable
   # with wrong key.
   self.assertRaises(
       common.ExternalError,
       self._BuildAndVerify,
       self.DEFAULT_PROP_DICT,
       os.path.join(get_testdata_dir(), 'verity_mincrypt'))
コード例 #4
0
  def setUp(self):
    self.testdata_dir = test_utils.get_testdata_dir()
    self.assertTrue(os.path.exists(self.testdata_dir))

    common.OPTIONS.payload_signer = None
    common.OPTIONS.payload_signer_args = []
    common.OPTIONS.package_key = os.path.join(self.testdata_dir, 'testkey')
    common.OPTIONS.key_passwords = {
        common.OPTIONS.package_key : None,
    }
コード例 #5
0
  def setUp(self):
    self.testdata_dir = test_utils.get_testdata_dir()
    self.assertTrue(os.path.exists(self.testdata_dir))

    common.OPTIONS.payload_signer = None
    common.OPTIONS.payload_signer_args = []
    common.OPTIONS.package_key = os.path.join(self.testdata_dir, 'testkey')
    common.OPTIONS.key_passwords = {
        common.OPTIONS.package_key : None,
    }
コード例 #6
0
  def test_Build_SquashFs(self):
    verity_image_builder = CreateVerityImageBuilder(self.DEFAULT_PROP_DICT)
    verity_image_builder.CalculateMaxImageSize()

    # Build the sparse image with verity metadata.
    input_dir = common.MakeTempDir()
    image = common.MakeTempFile(suffix='.img')
    cmd = ['mksquashfsimage.sh', input_dir, image, '-s']
    common.RunAndCheckOutput(cmd)
    verity_image_builder.PadSparseImage(image)
    verity_image_builder.Build(image)

    # Verify the verity metadata.
    cmd = ["verity_verifier", image, '-mincrypt',
           os.path.join(get_testdata_dir(), 'testkey_mincrypt')]
    common.RunAndCheckOutput(cmd)
コード例 #7
0
  def setUp(self):
    self.testdata_dir = get_testdata_dir()

    self.partition_size = 1024 * 1024
    self.prop_dict = {
        'verity': 'true',
        'verity_fec': 'true',
        'system_verity_block_device': '/dev/block/system',
        'system_size': self.partition_size
    }

    self.hash_algorithm = "sha256"
    self.fixed_salt = \
        "aee087a5be3b982978c923f566a94613496b417f2af592639bc80d141e34dfe7"
    self.expected_root_hash = \
        "0b7c4565e87b1026e11fbab91c0bc29e185c847a5b44d40e6e86e461e8adf80d"
コード例 #8
0
    def setUp(self):
        self.testdata_dir = get_testdata_dir()

        self.partition_size = 1024 * 1024
        self.prop_dict = {
            'verity': 'true',
            'verity_fec': 'true',
            'system_verity_block_device': '/dev/block/system',
            'system_size': self.partition_size
        }

        self.hash_algorithm = "sha256"
        self.fixed_salt = (
            "aee087a5be3b982978c923f566a94613496b417f2af592639bc80d141e34dfe7")
        self.expected_root_hash = (
            "0b7c4565e87b1026e11fbab91c0bc29e185c847a5b44d40e6e86e461e8adf80d")
コード例 #9
0
  def test_Build_SquashFs(self):
    verity_image_builder = CreateVerityImageBuilder(self.DEFAULT_PROP_DICT)
    verity_image_builder.CalculateMaxImageSize()

    # Build the sparse image with verity metadata.
    input_dir = common.MakeTempDir()
    image = common.MakeTempFile(suffix='.img')
    cmd = ['mksquashfsimage.sh', input_dir, image, '-s']
    common.RunAndCheckOutput(cmd)
    verity_image_builder.PadSparseImage(image)
    verity_image_builder.Build(image)

    # Verify the verity metadata.
    cmd = ["verity_verifier", image, '-mincrypt',
           os.path.join(get_testdata_dir(), 'testkey_mincrypt')]
    common.RunAndCheckOutput(cmd)
コード例 #10
0
  def setUp(self):
    self.testdata_dir = test_utils.get_testdata_dir()
    self.assertTrue(os.path.exists(self.testdata_dir))

    # Reset the global options as in ota_from_target_files.py.
    common.OPTIONS.incremental_source = None
    common.OPTIONS.downgrade = False
    common.OPTIONS.retrofit_dynamic_partitions = False
    common.OPTIONS.timestamp = False
    common.OPTIONS.wipe_user_data = False
    common.OPTIONS.no_signing = False
    common.OPTIONS.package_key = os.path.join(self.testdata_dir, 'testkey')
    common.OPTIONS.key_passwords = {
        common.OPTIONS.package_key : None,
    }

    common.OPTIONS.search_path = test_utils.get_search_path()
コード例 #11
0
  def setUp(self):
    self.testdata_dir = test_utils.get_testdata_dir()
    self.assertTrue(os.path.exists(self.testdata_dir))

    # Reset the global options as in ota_from_target_files.py.
    common.OPTIONS.incremental_source = None
    common.OPTIONS.downgrade = False
    common.OPTIONS.timestamp = False
    common.OPTIONS.wipe_user_data = False
    common.OPTIONS.no_signing = False
    common.OPTIONS.package_key = os.path.join(self.testdata_dir, 'testkey')
    common.OPTIONS.key_passwords = {
        common.OPTIONS.package_key : None,
    }

    common.OPTIONS.search_path = test_utils.get_search_path()
    self.assertIsNotNone(common.OPTIONS.search_path)
コード例 #12
0
 def test_AppendVBMetaArgsForPartition_vendorAsChainedPartition(self):
   testdata_dir = test_utils.get_testdata_dir()
   pubkey = os.path.join(testdata_dir, 'testkey.pubkey.pem')
   OPTIONS.info_dict = {
       'avb_avbtool': 'avbtool',
       'avb_vendor_key_path': pubkey,
       'avb_vendor_rollback_index_location': 5,
   }
   cmd = []
   AppendVBMetaArgsForPartition(cmd, 'vendor', '/path/to/vendor.img')
   self.assertEqual(2, len(cmd))
   self.assertEqual('--chain_partition', cmd[0])
   chained_partition_args = cmd[1].split(':')
   self.assertEqual(3, len(chained_partition_args))
   self.assertEqual('vendor', chained_partition_args[0])
   self.assertEqual('5', chained_partition_args[1])
   self.assertTrue(os.path.exists(chained_partition_args[2]))
コード例 #13
0
 def test_AppendVBMetaArgsForPartition_vendorAsChainedPartition(self):
     testdata_dir = test_utils.get_testdata_dir()
     pubkey = os.path.join(testdata_dir, 'testkey.pubkey.pem')
     OPTIONS.info_dict = {
         'avb_avbtool': 'avbtool',
         'avb_vendor_key_path': pubkey,
         'avb_vendor_rollback_index_location': 5,
     }
     cmd = []
     AppendVBMetaArgsForPartition(cmd, 'vendor', '/path/to/vendor.img')
     self.assertEqual(2, len(cmd))
     self.assertEqual('--chain_partition', cmd[0])
     chained_partition_args = cmd[1].split(':')
     self.assertEqual(3, len(chained_partition_args))
     self.assertEqual('vendor', chained_partition_args[0])
     self.assertEqual('5', chained_partition_args[1])
     self.assertTrue(os.path.exists(chained_partition_args[2]))
コード例 #14
0
class VerifiedBootVersion1VerityImageBuilderTest(ReleaseToolsTestCase):

    DEFAULT_PARTITION_SIZE = 4096 * 1024
    DEFAULT_PROP_DICT = {
        'partition_size': str(DEFAULT_PARTITION_SIZE),
        'verity': 'true',
        'verity_block_device': '/dev/block/system',
        'verity_key': os.path.join(get_testdata_dir(), 'testkey'),
        'verity_fec': 'true',
        'verity_signer_cmd': 'verity_signer',
    }

    def test_init(self):
        prop_dict = copy.deepcopy(self.DEFAULT_PROP_DICT)
        verity_image_builder = CreateVerityImageBuilder(prop_dict)
        self.assertIsNotNone(verity_image_builder)
        self.assertEqual(1, verity_image_builder.version)

    def test_init_MissingProps(self):
        prop_dict = copy.deepcopy(self.DEFAULT_PROP_DICT)
        del prop_dict['verity']
        self.assertIsNone(CreateVerityImageBuilder(prop_dict))

        prop_dict = copy.deepcopy(self.DEFAULT_PROP_DICT)
        del prop_dict['verity_block_device']
        self.assertIsNone(CreateVerityImageBuilder(prop_dict))

    @SkipIfExternalToolsUnavailable()
    def test_CalculateMaxImageSize(self):
        verity_image_builder = CreateVerityImageBuilder(self.DEFAULT_PROP_DICT)
        size = verity_image_builder.CalculateMaxImageSize()
        self.assertLess(size, self.DEFAULT_PARTITION_SIZE)

        # Same result by explicitly passing the partition size.
        self.assertEqual(
            verity_image_builder.CalculateMaxImageSize(),
            verity_image_builder.CalculateMaxImageSize(
                self.DEFAULT_PARTITION_SIZE))

    @staticmethod
    def _BuildAndVerify(prop, verify_key):
        verity_image_builder = CreateVerityImageBuilder(prop)
        image_size = verity_image_builder.CalculateMaxImageSize()

        # Build the sparse image with verity metadata.
        input_dir = common.MakeTempDir()
        image = common.MakeTempFile(suffix='.img')
        cmd = [
            'mkuserimg_mke2fs', input_dir, image, 'ext4', '/system',
            str(image_size), '-j', '0', '-s'
        ]
        common.RunAndCheckOutput(cmd)
        verity_image_builder.Build(image)

        # Verify the verity metadata.
        cmd = ['verity_verifier', image, '-mincrypt', verify_key]
        common.RunAndCheckOutput(cmd)

    @SkipIfExternalToolsUnavailable()
    def test_Build(self):
        self._BuildAndVerify(
            self.DEFAULT_PROP_DICT,
            os.path.join(get_testdata_dir(), 'testkey_mincrypt'))

    @SkipIfExternalToolsUnavailable()
    def test_Build_ValidationCheck(self):
        # A validity check for the test itself: the image shouldn't be verifiable
        # with wrong key.
        self.assertRaises(common.ExternalError, self._BuildAndVerify,
                          self.DEFAULT_PROP_DICT,
                          os.path.join(get_testdata_dir(), 'verity_mincrypt'))

    @SkipIfExternalToolsUnavailable()
    def test_Build_FecDisabled(self):
        prop_dict = copy.deepcopy(self.DEFAULT_PROP_DICT)
        del prop_dict['verity_fec']
        self._BuildAndVerify(
            prop_dict, os.path.join(get_testdata_dir(), 'testkey_mincrypt'))

    @SkipIfExternalToolsUnavailable()
    def test_Build_SquashFs(self):
        verity_image_builder = CreateVerityImageBuilder(self.DEFAULT_PROP_DICT)
        verity_image_builder.CalculateMaxImageSize()

        # Build the sparse image with verity metadata.
        input_dir = common.MakeTempDir()
        image = common.MakeTempFile(suffix='.img')
        cmd = ['mksquashfsimage.sh', input_dir, image, '-s']
        common.RunAndCheckOutput(cmd)
        verity_image_builder.PadSparseImage(image)
        verity_image_builder.Build(image)

        # Verify the verity metadata.
        cmd = [
            "verity_verifier", image, '-mincrypt',
            os.path.join(get_testdata_dir(), 'testkey_mincrypt')
        ]
        common.RunAndCheckOutput(cmd)
コード例 #15
0
ファイル: test_sign_apex.py プロジェクト: UltraAOSP/build
    def setUp(self):
        self.testdata_dir = test_utils.get_testdata_dir()
        self.assertTrue(os.path.exists(self.testdata_dir))

        common.OPTIONS.search_path = test_utils.get_search_path()
コード例 #16
0
 def test_ExtractPublicKey(self):
     testdata_dir = test_utils.get_testdata_dir()
     cert = os.path.join(testdata_dir, 'testkey.x509.pem')
     pubkey = os.path.join(testdata_dir, 'testkey.pubkey.pem')
     with open(pubkey, 'rb') as pubkey_fp:
         self.assertEqual(pubkey_fp.read(), common.ExtractPublicKey(cert))
コード例 #17
0
 def test_Build_FecDisabled(self):
   prop_dict = copy.deepcopy(self.DEFAULT_PROP_DICT)
   del prop_dict['verity_fec']
   self._BuildAndVerify(
       prop_dict,
       os.path.join(get_testdata_dir(), 'testkey_mincrypt'))
コード例 #18
0
ファイル: test_apex_utils.py プロジェクト: UltraAOSP/build
 def setUp(self):
     self.testdata_dir = test_utils.get_testdata_dir()
     # The default payload signing key.
     self.payload_key = os.path.join(self.testdata_dir, 'testkey.key')
コード例 #19
0
 def test_Build(self):
   self._BuildAndVerify(
       self.DEFAULT_PROP_DICT,
       os.path.join(get_testdata_dir(), 'testkey_mincrypt'))
コード例 #20
0
 def test_ExtractPublicKey_invalidInput(self):
     testdata_dir = test_utils.get_testdata_dir()
     wrong_input = os.path.join(testdata_dir, 'testkey.pk8')
     self.assertRaises(AssertionError, common.ExtractPublicKey, wrong_input)
コード例 #21
0
 def test_Build(self):
     self._BuildAndVerify(
         self.DEFAULT_PROP_DICT,
         os.path.join(get_testdata_dir(), 'testkey_mincrypt'))
コード例 #22
0
 def test_Build_FecDisabled(self):
     prop_dict = copy.deepcopy(self.DEFAULT_PROP_DICT)
     del prop_dict['verity_fec']
     self._BuildAndVerify(
         prop_dict, os.path.join(get_testdata_dir(), 'testkey_mincrypt'))
コード例 #23
0
 def setUp(self):
   self.testdata_dir = test_utils.get_testdata_dir()
   # The default payload signing key.
   self.payload_key = os.path.join(self.testdata_dir, 'testkey.key')
コード例 #24
0
 def setUp(self):
     self.testdata_dir = test_utils.get_testdata_dir()
コード例 #25
0
 def setUp(self):
   self.testdata_dir = test_utils.get_testdata_dir()