Follows conventions from tuf. See tuf.formats. """ from __future__ import print_function from __future__ import unicode_literals import uptane # Import before TUF modules; may change tuf.conf values. # We will have a superset of formats in TUF from tuf.formats import * import tuf.schema as SCHEMA # Constitutes a nonce used by e.g. ECUs to help defend their validation of # responses from the timeserver against replay attacks. NONCE_LOWER_BOUND = 0 NONCE_UPPER_BOUND = 2147483647 NONCE_SCHEMA = SCHEMA.Integer(lo=NONCE_LOWER_BOUND, hi=NONCE_UPPER_BOUND) # A list of nonces to be bundled in the primary's request to the timeserver # for a signed and nonce-incorporating time datum. NONCE_LIST_SCHEMA = SCHEMA.ListOf(NONCE_SCHEMA) # Uniquely identifies a vehicle. VIN_SCHEMA = SCHEMA.AnyString() # Information characterizing and identifying an ECU. # ECU_SCHEMA = SCHEMA.Object( # ecu_id = SCHEMA.AnyString(), # ecu_type = SCHEMA.AnyString(), # vin = VIN_SCHEMA) ECU_SERIAL_SCHEMA = SCHEMA.AnyString( ) # Instead, for now, we'll go with an ecu serial number.
# Note that in the schema definitions below, the 'SCHEMA.Object' types allow # additional keys which are not defined. Thus, any additions to them will be # easily backwards compatible with clients that are already deployed. # A datetime in 'YYYY-MM-DDTHH:MM:SSZ' ISO 8601 format. The "Z" zone designator # for the zero UTC offset is always used (i.e., a numerical offset is not # supported.) Example: '2015-10-21T13:20:00Z'. Note: This is a simple format # check, and an ISO8601 string should be fully verified when it is parsed. ISO8601_DATETIME_SCHEMA = SCHEMA.RegularExpression( r'\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z') # A Unix/POSIX time format. An integer representing the number of seconds # since the epoch (January 1, 1970.) Metadata uses this format for the # 'expires' field. Set 'hi' to the upper timestamp limit (year 2038), the max # value of an int. UNIX_TIMESTAMP_SCHEMA = SCHEMA.Integer(lo=0, hi=2147483647) # A hexadecimal value in '23432df87ab..' format. HASH_SCHEMA = SCHEMA.RegularExpression(r'[a-fA-F0-9]+') # A dict in {'sha256': '23432df87ab..', 'sha512': '34324abc34df..', ...} format. HASHDICT_SCHEMA = SCHEMA.DictOf(key_schema=SCHEMA.AnyString(), value_schema=HASH_SCHEMA) # A hexadecimal value in '23432df87ab..' format. HEX_SCHEMA = SCHEMA.RegularExpression(r'[a-fA-F0-9]+') # A key identifier (e.g., a hexadecimal value identifying an RSA key). KEYID_SCHEMA = HASH_SCHEMA # A list of KEYID_SCHEMA.
SIG_METHOD_SCHEMA = SCHEMA.AnyString() # A relative file path (e.g., 'metadata/root/'). RELPATH_SCHEMA = SCHEMA.AnyString() RELPATHS_SCHEMA = SCHEMA.ListOf(RELPATH_SCHEMA) # An absolute path. PATH_SCHEMA = SCHEMA.AnyString() PATHS_SCHEMA = SCHEMA.ListOf(PATH_SCHEMA) # Uniform Resource Locator identifier (e.g., 'https://www.updateframework.com/'). URL_SCHEMA = SCHEMA.AnyString() # A dictionary holding version information. VERSION_SCHEMA = SCHEMA.Object(object_name='version', major=SCHEMA.Integer(lo=0), minor=SCHEMA.Integer(lo=0), fix=SCHEMA.Integer(lo=0)) # An integer representing the numbered version of a metadata file. # Must be 1, or greater. METADATAVERSION_SCHEMA = SCHEMA.Integer(lo=1) # An integer representing length. Must be 0, or greater. LENGTH_SCHEMA = SCHEMA.Integer(lo=0) # A string representing a named object. NAME_SCHEMA = SCHEMA.AnyString() # A value that is either True or False, on or off, etc. TOGGLE_SCHEMA = SCHEMA.Boolean()
SIG_METHOD_SCHEMA = SCHEMA.AnyString() # A relative file path (e.g., 'metadata/root/'). RELPATH_SCHEMA = SCHEMA.AnyString() RELPATHS_SCHEMA = SCHEMA.ListOf(RELPATH_SCHEMA) # An absolute path. PATH_SCHEMA = SCHEMA.AnyString() PATHS_SCHEMA = SCHEMA.ListOf(PATH_SCHEMA) # Uniform Resource Locator identifier (e.g., 'https://www.updateframework.com/'). URL_SCHEMA = SCHEMA.AnyString() # A dictionary holding version information. VERSION_SCHEMA = SCHEMA.Object(object_name='VERSION_SCHEMA', major=SCHEMA.Integer(lo=0), minor=SCHEMA.Integer(lo=0), fix=SCHEMA.Integer(lo=0)) # An integer representing the numbered version of a metadata file. # Must be 1, or greater. METADATAVERSION_SCHEMA = SCHEMA.Integer(lo=1) # An integer representing length. Must be 0, or greater. LENGTH_SCHEMA = SCHEMA.Integer(lo=0) # An integer representing logger levels, such as logging.CRITICAL (=50). # Must be between 0 and 50. LOGLEVEL_SCHEMA = SCHEMA.Integer(lo=0, hi=50) # A string representing a named object.