Esempio n. 1
0
import tuf
import tuf.schema as SCHEMA

# 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 date in 'YYYY-MM-DD HH:MM:SS UTC' format.
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)
Esempio n. 2
0
    signatures=SCHEMA.ListOf(SIGNATURE_SCHEMA))

# Anything encoded as DER is not readily inspected. Its encoding can be checked
# this way, and conversion back from ASN.1/DER to a Python dictionary should be
# performed before a thorough check of the contents.
DER_DATA_SCHEMA = SCHEMA.AnyBytes()

# Manifest detailing the targets installed on all ECUs in a vehicle for which
# Uptane is responsible.
# This object corresponds to not "VehicleVersionManifest" in the Uptane
# Implementation Specification, but the signed contents of that object.
VEHICLE_VERSION_MANIFEST_SCHEMA = SCHEMA.Object(
    vin=VIN_SCHEMA,  # Spec: vehicleIdentifier
    primary_ecu_serial=ECU_SERIAL_SCHEMA,  # Spec: primaryIdentifier
    ecu_version_manifests=SCHEMA.DictOf(
        key_schema=ECU_SERIAL_SCHEMA,
        value_schema=SCHEMA.ListOf(SIGNABLE_ECU_VERSION_MANIFEST_SCHEMA)))

# This object corresponds to "VehicleVersionManifest" in ASN.1 in the Uptane
# Implementation Specification.
SIGNABLE_VEHICLE_VERSION_MANIFEST_SCHEMA = SCHEMA.Object(
    object_name='SIGNABLE_VEHICLE_VERSION_MANIFEST_SCHEMA',
    signed=VEHICLE_VERSION_MANIFEST_SCHEMA,
    signatures=SCHEMA.ListOf(SIGNATURE_SCHEMA))

# Information sent to the director by the primary.
# There probably will be additional fields here.
VEHICLE_REPORT_TO_DIRECTOR_SCHEMA = SCHEMA.Object(
    vin=VIN_SCHEMA, software_manifest=VEHICLE_VERSION_MANIFEST_SCHEMA)

DESCRIPTION_OF_ATTACKS_SCHEMA = SCHEMA.AnyString()
Esempio n. 3
0
# 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.
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()