Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure the serial number is unique on GD32 #70

Closed
3 of 5 tasks
szszszsz opened this issue Oct 19, 2022 · 3 comments
Closed
3 of 5 tasks

Make sure the serial number is unique on GD32 #70

szszszsz opened this issue Oct 19, 2022 · 3 comments
Labels

Comments

@szszszsz
Copy link
Member

szszszsz commented Oct 19, 2022

User reported, that some of his devices have the same serial number. This could come from GD32 MCU's not behaving according to the STM32 specification, having the same value in the serial number RO register.

  • To investigate, if the serial number does not change at all or changes in different location.
  • Hash the whole register, or randomize if it is constant across GD32 MCUs.
  • This should affect all GD32 devices in the field (non-conservative), regardless of their current SN.
  • This should not affect all STM32 devices in the field.
  • Inform users about need for stub keys removal and required keys import.

Firmware: latest
Hardware: GD32-based, probably latest
GnuPG: 2.2.27

$ gpg --card-status
Reader ...........: Nitrokey Nitrokey Start (FSIJ-1.2.15-34353135) 00 00
Application ID ...: D276000124010200FFFE343531350000
Application type .: OpenPGP
Version ..........: 2.0
Manufacturer .....: unmanaged S/N range
Serial number ....: 34353135
(...)
@szszszsz
Copy link
Member Author

szszszsz commented Nov 3, 2022

With the patch below the full 12 bytes of the MCU ID is now taken into account, instead of only the last 4 bytes.
Note: HW5 only. Does not introduce any changes for HW 1-4.

To retest and reopen in case the XOR method would not suffice.

@szszszsz
Copy link
Member Author

szszszsz commented Nov 3, 2022

szszszsz added a commit that referenced this issue Nov 4, 2022
Use the first 4 bytes of the MCU's ID sha256 hash for the serial number.

Fixes #70
szszszsz added a commit that referenced this issue Nov 5, 2022
Use the new serial number for the GD32-based hardware, HW5

Fixes #70
@szszszsz
Copy link
Member Author

szszszsz commented Nov 5, 2022

New test release available at:

Here a sha256 hash sum is calculated instead of a xor, making change more leveled over all available bytes, instead of a single one.

Test scenario:

  • note the SN, current firmware version and hardware version
  • update the firmware to 12.1-RC2 with nitropy
  • save log from the nitropy update
  • note the SN change (or none - the change happens only on the HW5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant