Skip to content

Conversation

@dlegaultbbry
Copy link
Contributor

Secret keys can be used for signing in algorithms like HMAC and CMAC so they should display their CKA_SIGN attribute value when listing object attributes

Before

echo -n "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b" | xxd -r -p - > key.bin
pkcs11-tool --module=... --write-object key.bin --usage-sign --type secrkey --label hmackey --id 1234
Using slot 0 with a present token (0x0)
Created secret key:
Secret Key Object; Generic secret length 20
VALUE: 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
label: hmackey
ID: 1234
Usage: verify
Access: never extractable

After

echo -n "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b" | xxd -r -p - > key.bin
pkcs11-tool --module=... --write-object key.bin --usage-sign --type secrkey --label hmackey --id 1234
Using slot 0 with a present token (0x0)
Created secret key:
Secret Key Object; Generic secret length 20
VALUE: 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
label: hmackey
ID: 1234
Usage: sign, verify
Access: never extractable

Fixes #2851

Checklist
  • PKCS#11 module is tested (tested with my own custom PKCS#11 module)

Secret keys can be used for signing in algorithms like HMAC and
CMAC so they should display their CKA_SIGN attribute value
when listing object attributes

Fixes OpenSC#2851
@mouse07410
Copy link
Contributor

Keyed hash (HMAC, NMAC, CMAC) is a MAC, not a signature.

Therefore, I don't think attribute CKA_SIGN belongs there.

@dlegaultbbry
Copy link
Contributor Author

Well obviously, the people that wrote the spec had a different opinion and this is all related to the spec. MACs are done using the signature API.

CKA_SIGN | CK_BBOOL | CK_TRUE if key supports signatures (i.e., authentication codes) where the signature is an appendix to the data

CKA_VERIFY | CK_BBOOL | CK_TRUE if key supports verification (i.e., of authentication codes) where the signature is an appendix to the data

@frankmorgner
Copy link
Member

@Jakuje Jakuje merged commit 05c7bff into OpenSC:master Sep 22, 2023
@Jakuje
Copy link
Member

Jakuje commented Sep 22, 2023

Thank you!

@xhanulik xhanulik mentioned this pull request Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pkcs11-tool: object usage - secret key + getSIGN

4 participants