-
Notifications
You must be signed in to change notification settings - Fork 0
/
ECUModule.py
executable file
·51 lines (41 loc) · 1.96 KB
/
ECUModule.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
# 2nd-party imports.
import CommonModule
import TargetsModule
def ECUVersionManifests(num_of_ecus=1, num_of_keys_per_secondary=1):
'''https://github.com/uptane/asn1/blob/master/ECUModule.asn1'''
signatures = CommonModule.Signatures(num_of_keys_per_secondary)
numberOfSignatures = CommonModule.LENGTH_SIZE_IN_BYTES
ecuIdentifier = CommonModule.IDENTIFIER_SIZE_IN_BYTES
previousTime = CommonModule.UTCDATETIME_SIZE_IN_BYTES
currentTime = CommonModule.UTCDATETIME_SIZE_IN_BYTES
securityAttack = 1024 #bytes
installedImage = TargetsModule.Target()
signed = ecuIdentifier + previousTime + currentTime + securityAttack + \
installedImage
ECUVersionManifest = signatures + numberOfSignatures + signed
CommonModule.log('ECUVersionManifest', ECUVersionManifest)
ECUVersionManifests = num_of_ecus * ECUVersionManifest
CommonModule.log('# of secondaries', num_of_ecus, unit=' secondaries')
CommonModule.log('ECUVersionManifests', ECUVersionManifests)
return ECUVersionManifests
def VehicleVersionManifest(num_of_primary_keys=1, num_of_ecus=1):
'''https://github.com/uptane/asn1/blob/master/ECUModule.asn1'''
signatures = CommonModule.Signatures(num_of_primary_keys)
numberOfSignatures = CommonModule.LENGTH_SIZE_IN_BYTES
vehicleIdentifier = CommonModule.IDENTIFIER_SIZE_IN_BYTES
primaryIdentifier = CommonModule.IDENTIFIER_SIZE_IN_BYTES
numberOfECUVersionManifests = CommonModule.LENGTH_SIZE_IN_BYTES
ecuVersionManifests = ECUVersionManifests(num_of_ecus)
securityAttack = 1024 #bytes
signed = vehicleIdentifier + primaryIdentifier + \
numberOfECUVersionManifests + ecuVersionManifests + securityAttack
vehicleVersionManifest = signatures + numberOfSignatures + signed
CommonModule.log('VehicleVersionManifest', vehicleVersionManifest)
return vehicleVersionManifest
if __name__ == '__main__':
CommonModule.time(
CommonModule.iso_tp_overhead(
VehicleVersionManifest(num_of_ecus=100)
)
)