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. # Information specifying the target(s) installed on a given ECU. # This object corresponds to not "ECUVersionManifest" in the Uptane # Implementation Specification, but the signed contents of that object.
TIME_SCHEMA = SCHEMA.RegularExpression( r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} UTC') # 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 KEYIDS_SCHEMA = SCHEMA.ListOf(KEYID_SCHEMA) # The method used for a generated signature (e.g., 'evp'). 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()
DATETIME_SCHEMA = SCHEMA.RegularExpression( r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}') # 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 KEYIDS_SCHEMA = SCHEMA.ListOf(KEYID_SCHEMA) # The method used for a generated signature (e.g., 'evp'). 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 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. KEYIDS_SCHEMA = SCHEMA.ListOf(KEYID_SCHEMA) # The method used for a generated signature (e.g., 'RSASSA-PSS'). 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()