Can't import secp256k1 key to Nitrokey 3A NFC

Hi! The Nitrokey 3A NFC advertises that it has secp256k1 support, but when you try and use it it says Key length/algorithm not supported by card. From the store page:

Elliptic curves: NIST P-256, P-384, P-521 (secp256r1/prime256v1, secp384r1/prime384v1, secp521r1/prime521v1), Ed25519/Curve25519, Koblitz (192-256 bit), brainpoolP256r1, brainpoolP384r1, brainpoolP512r1

That 256-bit Koblitz curve is what I’m looking for. But when I try and import such a certificate with pkcs15-init, it doesn’t work:

pkcs15-init \
  --delete-objects privkey,pubkey \
    --id 01 \
    --store-private-key secp256k1.p12 \
    --format pkcs12 \
    --auth-id 3 \
    --verify-pin \
    --pin 12345678

Using reader with a card: Nitrokey Nitrokey 3 [CCID/ICCD Interface] 00 00
NOTE: couldn't find privkey 01 to delete
NOTE: couldn't find pubkey 01 to delete
Deleted 0 objects
Importing 1 certificates:
  0: /C=US/ST=CA/L=Somewhere/O=Aquareum/CN=Cert Testing
Failed to store private key: Key length/algorithm not supported by card

By contrast, a prime256v1 key works just fine:

pkcs15-init \
  --delete-objects privkey,pubkey \
  --id 03 \
  --store-private-key prime256v1.p12 \
  --format pkcs12 \
  --auth-id 3 \
  --verify-pin \
  --pin 12345678
Using reader with a card: Nitrokey Nitrokey 3 [CCID/ICCD Interface] 00 00
NOTE: couldn't find privkey 03 to delete
NOTE: couldn't find pubkey 03 to delete
Deleted 0 objects
Importing 1 certificates:
  0: /C=US/ST=CA/L=Somewhere/O=Aquareum/CN=Cert Testing

pkcs11-tool \
  --sign \
  -m ECDSA \
  --id 03 \
  --pin 123456 \
  -f openssl \
  --input-file data.txt.sha256 \
  --output-file data.txt.prime256v1.sig

Using slot 0 with a present token (0x0)
Using signature algorithm ECDSA

openssl pkeyutl \
  -verify \
  -in data.txt \
  -sigfile data.txt.prime256v1.sig \
  -inkey prime256v1-pub.pem \
  -pubin \
  -rawin

Signature Verified Successfully

How can I use an secp256k1 key?

I tried updating to the latest test firmware (v1.7.2-test.20240813) but then it fails with “Incorrect parameters in APDU” even for the prime256v1 key, full logs including OPENSC_DEBUG=9 here: pkcs15-init.txt · GitHub

Tried doing the same thing with pkcs11-tool and got nowhere, added to the end of the same Gist pkcs15-init.txt · GitHub . Comes back with CKR_ARGUMENTS_BAD

Oh hey, the text advertising that it supports Koblitz curves has been removed from the store. How about that? :joy:

Sadly, archive becomes as critical to figure “where the heck did I read that” as secp256k1 is for the blockchain. :man_shrugging:

The SE050 supports secp256k1 and secp256r1 and the websmartcard.nitrokey.com (experimental feature in test firmware releases) uses secp256r1 for now. The Readme mentioned that secp256k1 is still to implement.