-
Notifications
You must be signed in to change notification settings - Fork 48
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
Setting serial number? #52
Comments
Ahh, sorry for the confusing question. Looks like it is actually in the AID per the OpenPGP card spec, go figure. Do you have any sample command lines to correctly install the applet with a non-zero serial number? |
With
|
The shorthand which should be:
|
Awesome, thanks both of you so much! I used the following Python script, though it does make a hex serial number instead of a BCD one like appears to be typical. It doesn't seem to break GPG, though. #!/usr/bin/env python3
# Copyright 2023, Collabora, Ltd.
# SPDX-License-Identifier: MIT
#
# Original author: Rylie Pavlik <rylie.pavlik@collabora.com>
#
# Install SmartPGP to a JavaCard with GlobalPlatformPro,
# assigning a random serial number in one of the unmanaged ranges.
# If you are actually manufacturing OpenPGP cards based on this applet,
# you should get your own manufacturer ID and correctly assign serial
# numbers: do not use this script.
import secrets
import subprocess
# anything in fff0 to fffe is for unmanaged random assignment of serial numbers
_MANUFACTURER = "fff5"
# _CAPFILE = "SmartPGP-v1.22.2-jc304-rsa_up_to_4096.cap"
_CAPFILE = "SmartPGP-v1.22.2-jc304-without_sm-rsa_up_to_4096.cap"
def _make_card():
# SN is 8 digits, so 4 bytes shown as hex
sn = secrets.token_hex(4)
aid = f"d276000124010304{_MANUFACTURER}{sn}0000"
print(f"Assigning serial number {sn} for manufacturer {_MANUFACTURER}")
# Assumes GlobalPlatformPro is callable with just "gp"
subprocess.check_call(["gp", "--install", _CAPFILE, "--create", aid])
if __name__ == "__main__":
_make_card() |
I can't seem to figure out how to set the serial number or get it to generate one. As such I assume it won't work very well if I have more than one of these cards. I'm using a J3R180 card, and as long as I manage gpg and pcscd fighting, I can get this output:
I searched the repo but could not find references to card serial number other than in some test scripts. Is this something set with install parameters? custom APDUs? Theoretically generated from some unique on-card value?
I do see that gpg thinks the AID is D276000124010304AFAF000000000000 which ends in a lot of zeroes - do I customize the app AID to set the serial?
I am installing with
gp --load ~/Downloads/SmartPGP-v1.22.2-jc304-rsa_up_to_4096.cap
The text was updated successfully, but these errors were encountered: