A set of tools for AUTOSAR Secure Hardware Extension.
Project description
Secure Hardware Extension
A set of tools for AUTOSAR Secure Hardware Extension.
Available features:
- Generate SHE Memory update protocol messages (M1 M2 M3 M4 M5).
- Parse M1 M2 Memory update protocol messages in order to get the update information.
Disclaimer
Vector's related specification specifies different layout of flags - it uses 5 flags instead of 6, described in AUTOSAR specs as this repo fully follows. Please adjust script accordingly then, I would be glad to some PR propositions if you have anything working. Enjoy!
Prerequisites
With using Python greater than 3.8 install package to your environment.
pip install SecureHardwareExtension
Examples
Calculate M1 - M5 messages by using update info
from secure_hardware_extension.datatypes import MemoryUpdateInfo, SecurityFlags
from secure_hardware_extension.key_slots.autosar import AutosarKeySlots
from secure_hardware_extension.memory_update import MemoryUpdateProtocol
update_info = MemoryUpdateInfo(
new_key="0f0e0d0c0b0a09080706050403020100", # Hex string or bytes
auth_key="000102030405060708090a0b0c0d0e0f", # Hex string or bytes
new_key_id=AutosarKeySlots.KEY_1, # Enum or integer
auth_key_id=AutosarKeySlots.MASTER_ECU_KEY, # Enum or integer
counter=1,
uid="00" * 14 + "01", # Hex string or bytes
flags=SecurityFlags(),
)
protocol = MemoryUpdateProtocol(update_info)
protocol.m1
>>> b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01A'
protocol.m2
>>> b'+\x11\x1e-\x93\xf4\x86Vk\xcb\xba\x1d\x7fz\x97\x97\xc9FC\xb0P\xfc]M}\xe1L\xffh"\x03\xc3'
Select apprioprate key slot flags
flags = SecurityFlags()
flags.boot_protection = True
update_info = MemoryUpdateInfo(
...
flags=flags,
)
flags = SecurityFlags(fid=20)
update_info = MemoryUpdateInfo(
...
flags=flags,
)
Get update info from M1 and M2 messages
from secure_hardware_extension.datatypes import MemoryUpdateMessages, she_bytes
from secure_hardware_extension.memory_update import MemoryUpdateProtocol
messages = MemoryUpdateMessages(
auth_key=she_bytes.fromhex("000102030405060708090a0b0c0d0e0f"),
m1=she_bytes.fromhex("00000000000000000000000000000141"),
m2=she_bytes.fromhex(
"2b111e2d93f486566bcbba1d7f7a9797c94643b050fc5d4d7de14cff682203c3"
),
)
update_protocol = MemoryUpdateProtocol(messages)
update_protocol.update_info.new_key
>>> b'\x0f\x0e\r\x0c\x0b\n\t\x08\x07\x06\x05\x04\x03\x02\x01\x0
Sources
Accessed 26.07.2025.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file securehardwareextension-1.0.1.tar.gz.
File metadata
- Download URL: securehardwareextension-1.0.1.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02f98e25e3ec1f6e047aa27c77b54d9ea1421a209c1fc36751211a3153deb538
|
|
| MD5 |
69d4ef498be71234a03ffe2fefd1362e
|
|
| BLAKE2b-256 |
ed04745ef5e6a78bf4eb9a1fbf3cd3860b6692ca3cf01eb97405b4291663d8b6
|
File details
Details for the file securehardwareextension-1.0.1-py3-none-any.whl.
File metadata
- Download URL: securehardwareextension-1.0.1-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2d04fb25da0b3bea4f0c21874e50fe22c6b05fb3d6d0d8f3a3d6de0a14c403b
|
|
| MD5 |
088c9a5cbac9f6d535c0e47d62266208
|
|
| BLAKE2b-256 |
f9b0d7de5c416b4a9e5dbf1193108b928909b672e53624ab78e75b95c3ae47d0
|