From 6a04f4d8657ad8fa07912edd06830f4d3ddf4283 Mon Sep 17 00:00:00 2001 From: hexsecs <89217603+hexsecs@users.noreply.github.com> Date: Thu, 15 Dec 2022 18:45:28 -0500 Subject: [PATCH 1/7] Create M_Value_Description.md added description of keys --- M_Value_Description.md | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 M_Value_Description.md diff --git a/M_Value_Description.md b/M_Value_Description.md new file mode 100644 index 0000000..b7d9998 --- /dev/null +++ b/M_Value_Description.md @@ -0,0 +1,49 @@ +# M1 + +| UID' | ID | AuthID | +| --- | --- | --- | +| 120 bits | 4 bits | 4 bits | + +M1 = UID' | ID | AuthID + +# M2 + +K1 is the derived encryption key used in M2 + +K1 = KDF(KAuthID, KEY_UPDATE_ENC_C) + +CID = 28 bit counter value for key + +FID = 5 bit key flag value + +M2 = ENCCBC,K1,IV=0(CID|FID|"0...0"95|KID) + +# M3 + +K2 is the derived CMAC authentication key used in M3. + +K2 = KDF(KAuthID, KEY_UPDATE_MAC_C) + +M3 = CMACK2(M1|M2) + +# M4 + +K3 is the derived encryption key used for + +K3 = KDF(KID, KEY_UPDATE_ENC_C) + +M4 = UID | ID | AuthID | ENCCBC,K3,IV=0(CID) + +# M5 + +K4 = KDF(KID, KEY_UPDATE_MAC_C) + +M5 = CMACK4(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) From 6b49fa2c8eea059c3d614b08e38014c39d60deda Mon Sep 17 00:00:00 2001 From: hexsecs <89217603+hexsecs@users.noreply.github.com> Date: Thu, 15 Dec 2022 18:46:48 -0500 Subject: [PATCH 2/7] Update M_Value_Description.md --- M_Value_Description.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/M_Value_Description.md b/M_Value_Description.md index b7d9998..426c300 100644 --- a/M_Value_Description.md +++ b/M_Value_Description.md @@ -16,7 +16,7 @@ CID = 28 bit counter value for key FID = 5 bit key flag value -M2 = ENCCBC,K1,IV=0(CID|FID|"0...0"95|KID) +M2 = ENCCBC,K1,IV=0(CID | FID | "0...0"95 | KID) # M3 From 01274b6e0b2bc95c1330711018aed2b8ec4a72f7 Mon Sep 17 00:00:00 2001 From: hexsecs <89217603+hexsecs@users.noreply.github.com> Date: Thu, 15 Dec 2022 18:57:16 -0500 Subject: [PATCH 3/7] Update M_Value_Description.md --- M_Value_Description.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/M_Value_Description.md b/M_Value_Description.md index 426c300..92e3624 100644 --- a/M_Value_Description.md +++ b/M_Value_Description.md @@ -8,7 +8,7 @@ M1 = UID' | ID | AuthID # M2 -K1 is the derived encryption key used in M2 +> **Note** K1 is the derived encryption key used in M2 K1 = KDF(KAuthID, KEY_UPDATE_ENC_C) @@ -20,7 +20,7 @@ M2 = ENCCBC,K1,IV=0(CID | FID | "0...0"95< # M3 -K2 is the derived CMAC authentication key used in M3. +> **Note** K2 is the derived CMAC authentication key used in M3. K2 = KDF(KAuthID, KEY_UPDATE_MAC_C) @@ -28,11 +28,14 @@ M3 = CMACK2(M1|M2) # M4 -K3 is the derived encryption key used for +> **Note** K3 is the derived encryption key used in M4 K3 = KDF(KID, KEY_UPDATE_ENC_C) -M4 = UID | ID | AuthID | ENCCBC,K3,IV=0(CID) +> **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 | ENCECB,K3(CID) # M5 From 5c294a6f581aa8f324cff5af375a5fd08897dc28 Mon Sep 17 00:00:00 2001 From: hexsecs <89217603+hexsecs@users.noreply.github.com> Date: Thu, 15 Dec 2022 19:01:17 -0500 Subject: [PATCH 4/7] Rename M_Value_Description.md to m_value_description.md --- M_Value_Description.md => m_value_description.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename M_Value_Description.md => m_value_description.md (100%) diff --git a/M_Value_Description.md b/m_value_description.md similarity index 100% rename from M_Value_Description.md rename to m_value_description.md From 511ca4155d4dd5f9ff3f49a57bb90175d56e8b57 Mon Sep 17 00:00:00 2001 From: hexsecs <89217603+hexsecs@users.noreply.github.com> Date: Thu, 15 Dec 2022 19:02:02 -0500 Subject: [PATCH 5/7] Update README.md Added reference to the M value description --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 88788ab..7524bd1 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,4 @@ 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) +* [Description of the M* values](./m_value_description.md) From 6f064f28c91203f3a4d94cad380c6fa063a9802c Mon Sep 17 00:00:00 2001 From: hexsecs <89217603+hexsecs@users.noreply.github.com> Date: Wed, 11 Oct 2023 11:10:54 -0400 Subject: [PATCH 6/7] Update README.md Fixed broken SHE spec link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7524bd1..e6aad0b 100644 --- a/README.md +++ b/README.md @@ -12,5 +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) From e35f332c868b5e2b97cdcca7d864f5b1f45ddb65 Mon Sep 17 00:00:00 2001 From: Philip Lapczynski <89217603+hexsecs@users.noreply.github.com> Date: Thu, 30 Nov 2023 09:47:23 -0500 Subject: [PATCH 7/7] Create pylint.yml adding linter --- .github/workflows/pylint.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/pylint.yml diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml new file mode 100644 index 0000000..383e65c --- /dev/null +++ b/.github/workflows/pylint.yml @@ -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')