Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Pylint

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py')
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ pip install -r requirements.txt
```

## References
* [Specification of Secure Hardware Extensions, AUTOSAR FO R19-11](https://www.autosar.org/fileadmin/user_upload/standards/foundation/19-11/AUTOSAR_TR_SecureHardwareExtensions.pdf)
* [AUTOSAR Specification of Secure Hardware Extensions - R22-11](https://www.autosar.org/fileadmin/standards/R22-11/FO/AUTOSAR_TR_SecureHardwareExtensions.pdf)
* [Description of the M* values](./m_value_description.md)
52 changes: 52 additions & 0 deletions m_value_description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# M1

| UID' | ID | AuthID |
| --- | --- | --- |
| 120 bits | 4 bits | 4 bits |

M1 = UID' | ID | AuthID

# M2

> **Note** K1 is the derived encryption key used in M2

K1 = KDF(K<sub>AuthID</sub>, KEY_UPDATE_ENC_C)

C<sub>ID</sub> = 28 bit counter value for key

F<sub>ID</sub> = 5 bit key flag value

M2 = ENC<sub>CBC,K1,IV=0</sub>(C<sub>ID</sub> | F<sub>ID</sub> | "0...0"<sub>95</sub> | K<sub>ID</sub>)

# M3

> **Note** K2 is the derived CMAC authentication key used in M3.

K2 = KDF(K<sub>AuthID</sub>, KEY_UPDATE_MAC_C)

M3 = CMAC<sub>K2</sub>(M1|M2)

# M4

> **Note** K3 is the derived encryption key used in M4

K3 = KDF(K<sub>ID</sub>, KEY_UPDATE_ENC_C)

> **Note**
> AES ECB mode is used in the spec. Since we are only encrypting 1 block, this is equivalent to CBC mode with an IV=0.

M4 = UID | ID | AuthID | ENC<sub>ECB,K3</sub>(C<sub>ID</sub>)

# M5

K4 = KDF(K<sub>ID</sub>, KEY_UPDATE_MAC_C)

M5 = CMAC<sub>K4</sub>(M4)

# Key Derivation

Keys are derived using the Miyaguchi-Preneel compression algorithm based on [NIST800_108]. Derived
keys are calculated by compressing the correctly preprocessed concatenation of a secret K and
a constant C.

KDF(K,C) = AES-MP(K | C)