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.
Metadata
Release files for SecureHardwareExtension 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| securehardwareextension-1.0.1.tar.gz | 7.7 kB | Without provenance | Details for securehardwareextension-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| securehardwareextension-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for securehardwareextension-1.0.1-py3-none-any.whl |
Total release size: 17.8 kB
Release files / securehardwareextension-1.0.1.tar.gz
| Download URL | securehardwareextension-1.0.1.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
02f98e25e3ec1f6e047aa27c77b54d9ea1421a209c1fc36751211a3153deb538
|
|
BLAKE2b-256 checksum How to use checksums |
ed04745ef5e6a78bf4eb9a1fbf3cd3860b6692ca3cf01eb97405b4291663d8b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Release files / securehardwareextension-1.0.1-py3-none-any.whl
| Download URL | securehardwareextension-1.0.1-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d2d04fb25da0b3bea4f0c21874e50fe22c6b05fb3d6d0d8f3a3d6de0a14c403b
|
|
BLAKE2b-256 checksum How to use checksums |
f9b0d7de5c416b4a9e5dbf1193108b928909b672e53624ab78e75b95c3ae47d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Security for SecureHardwareExtension 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.