Nitrokey / nitrokey-start-firmware

A mirror of Gnuk's 1.0.x and 1.2.x branches.
56 stars 15 forks source link

Make sure the serial number is unique on GD32 #70

Closed szszszsz closed 1 year ago

szszszsz commented 1 year ago

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.

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 commented 1 year ago

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 commented 1 year ago

Test release available at:

szszszsz commented 1 year ago

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: