Skip to content

Commit

Permalink
Aligned to new default volatile KEY_ID for native_posix
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Hadasz <artur.hadasz@nordicsemi.no>
  • Loading branch information
ahasztag committed Oct 8, 2024
1 parent 11ac20f commit f61ca32
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions ncs/sign_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@
from collections import defaultdict
from enum import Enum, unique

import logging

logger = logging.getLogger(__name__)

#
# User note:
# Rename the files to 'key_private_<KEY>.der' if you are using keys in DER format.
#
DEFAULT_PRIVATE_KEY = Path(__file__).parent / "key_private.pem"

PRIVATE_KEYS = {
0x7FFFFFE0: Path(__file__).parent / "key_private.pem",
0x40000000: Path(__file__).parent / "key_private.pem",
0x4000AA00: Path(__file__).parent / "key_private_OEM_ROOT_GEN1.pem",
0x40022100: Path(__file__).parent / "key_private_APPLICATION_GEN1.pem",
0x40032100: Path(__file__).parent / "key_private_RADIO_GEN1.pem",
Expand Down Expand Up @@ -68,13 +74,13 @@ class SuitIds(Enum):
SUIT_MANIFEST_COMPONENT_ID = 5


DEFAULT_KEY_ID = 0x7FFFFFE0
DEFAULT_KEY_ID = 0x40000000

KEY_IDS = {
"nRF54H20_sample_root": 0x4000AA00, # MANIFEST_PUBKEY_OEM_ROOT_GEN1
"nRF54H20_sample_app": 0x40022100, # MANIFEST_PUBKEY_APPLICATION_GEN1
"nRF54H20_sample_rad": 0x40032100,
} # MANIFEST_PUBKEY_RADIO_GEN1
"nRF54H20_sample_rad": 0x40032100, # MANIFEST_PUBKEY_RADIO_GEN1
}

DOMAIN_NAME = "nordicsemi.com"

Expand Down Expand Up @@ -176,7 +182,14 @@ def _get_key_id_for_manifest_class(self):

def _get_private_key_path_for_manifest_class(self) -> Path:
key_id = self._key_ids[self._get_manifest_class_id()]
return PRIVATE_KEYS[key_id]
key_path = PRIVATE_KEYS[key_id]
if not key_path.exists():
logger.warning(
f"Private key {key_path} not found. Using default key path {DEFAULT_PRIVATE_KEY}. "
"This is only for Nordic testing purposes - please provide the {key_path} file."
)
key_path = DEFAULT_PRIVATE_KEY
return key_path

def sign(self, private_key_path: Path = None) -> None:
"""Add signature to the envelope."""
Expand Down

0 comments on commit f61ca32

Please sign in to comment.