Beispiel #1
0
def GetByteStringFromFingerprint(fingerprint):
  """Helper function to create a byte string from a SHA fingerprint.

  Args:
    fingerprint: The fingerprint to transform in the form of
                 "12:34:56:78:90:...:EF".

  Returns:
    The fingerprint converted to a byte string (excluding the colons).
  """
  if not ValidateFingerprint(fingerprint):
    raise exceptions.FingerprintError('Invalid fingerprint')
  byte_tokens = fingerprint.split(':')
  return str(bytearray([int(b, 16) for b in byte_tokens]))
Beispiel #2
0
    def _VerifyAndroidPackageArgs(self, allowed_entities):
        # Verify that each Android package is in the correct format
        for package in allowed_entities:
            try:
                _, fingerprint = package.split(',', 1)
            except ValueError:
                raise exceptions.InvalidConditionError(
                    'Package %s has incorrect format. It should be of the form '
                    '\'[PACKAGE_NAME],[FINGERPRINT]\'.' % package)

            # Validate the fingerprint against the regex
            if not services_util.ValidateFingerprint(fingerprint):
                raise exceptions.FingerprintError(
                    'Invalid SHA fingerprint provided (%s).' % fingerprint)