Skip to content

Conversation

@dengert
Copy link
Member

@dengert dengert commented Jun 1, 2024

(WIP may fix #3159 waiting to download the MSI artifacts for testing.)

PKCS11 supports CKA_ALWAYS_AUTHENTICATE and PKCS15 user_consent Windows minidriver supports PinCacheAlwaysPrompt

Mindriver has MD_ROLE_USER_SIGN for a pin which is taken to be a second user local pin to be used for signing.

A second user local pin was defined in pkcs15-piv.c which is a duplicate of the user pin except the sc_pkcs15_auth_info_auth_method set is set SC_AC_CONTEXT_SPECIFIC So when a key is used that requires "ALWAYS" authentication it will be be handled like framework-pkcs15.c handles CKA_ALWAYS_AUTHENTICATE

On branch minidriver-PinCacheAlwaysPrompt
Changes to be committed:
modified: libopensc/pkcs15-piv.c
modified: minidriver/minidriver.c

Checklist
  • Documentation is added or updated
  • New files have a LGPL 2.1 license statement
  • PKCS#11 module is tested
  • Windows minidriver is tested
  • macOS tokend is tested

@dengert
Copy link
Member Author

dengert commented Jun 1, 2024

This should be a fix for #3159 when PIV is used with the minidriver.
The code in pkcs15-piv.c defines a third pin, which is the same as the first pin, accept the auth_method is set to SC_AC_CONTEXT_SPECIFIC rather then SC_AC_CHV. The 9C key is listed as using the third pin in pkcs15-piv.c

Mindriver looks for a user_pin which is the default first pin in pkcs15-piv.c. It also looks for a sign_pin as the second type of user_pin and finds the new third pin in pkcs15-piv.c Because it is a "sign_pin" the minidriver sets PinCacheAlwaysPrompt for this pin. (This is one area which maybe a problem for other cards.)

So when an application like certutil wants to use the certificate which uses the 9C key, the CSP will always pops up a PIN which says: "Please enter your digital signature pin." The CSP then passes this PIN to minidriver to use the new third pin that has the auth_method = SC_AC_CONTEXT_SPECIFIC;.

(For PKCS11, framework-pkcs15.c also sets auth_method = SC_AC_CONTEXT_SPECIFIC; so that has been around for some time.)

The pkcs15-pin.c routines pass pin request to the card-piv.c which triggers card-piv.c to obtain an additional PC/SC lock so the verify and whatever APDU the application requests next (which should be the crypto instruction) to be in the same SCardTransaction. The PIV card keep track of the last verify it sees is just before the crypto operation as required by the specs.

This has been tested on Windows 11 PRO using an IDEMIA ID-One PIV 2.4.1 test card with ECDSA and RSA keys using certutil -v -scinfo And certutil popup says: ""Please enter your digital signature pin." and certutil says: Private key verifies` for all keys on the card.

I have been using opesc.conf so as to avoid any OpenSC caching and get PIN debugging:

app default {
	 debug = 9;
	 debug_file = \tmp\opensc-debug.txt;
		framework pkcs15 {
		use_pin_caching = false;
		use_file_caching = false;
	}
}

registry was modified like what https://github.com/ckahlo did to use the OpenSC minidriver for a PIV with the correct ATR.

Note that Windows is caching the user_pin and used it several times. There was only one use for the 'sign_pin`

What I have not done is test with others cards, especially with cards that have a user_pin and a sign_pin I don't expect any problems as then have the same restrictions as the PIV specs have.

else if (dwFlags == MD_ROLE_USER_SIGN) {
p->PinPurpose = DigitalSignaturePin;
/* may need to check pin auto_info for auth_method SC_AC_CONTEXT_SPECIFIC */
p->PinCachePolicy.PinCachePolicyType = PinCacheAlwaysPrompt;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this force PIN re-prompts for every MD_ROLE_USER_SIGN PIN, not only the new PIV type?

Minidriver spec says that:

Note: Windows logon may not work properly if a PIN is not cached. This behavior is by design.
Therefore, careful consideration should be given when setting a PIN cache mode to any value other than PinCacheNormal.

I guess it really should be a special PKCS15 API PIN flag that says that this PIN needs re-sending before each operation. Or some other way to retrieve this information about PIN from the particular OpenSC card driver.

And then when this OpenSC API PIN flag is set the Minidriver can return PinCacheAlwaysPrompt for this PIN.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this force PIN re-prompts for every MD_ROLE_USER_SIGN PIN, not only the new PIV type?

Maybe I have taken a different approach with the force push today:

   minidriver.c - Create shadow  MD_ROLE_USER_ALWAYS and MD_ROLE_USER_SIGN_ALWAYS

   PKCS11 defines CKA_ALWAYS_AUTHENTICATE attribute for private keys, which is converted
   to `user_consent` for PKCS15 for private keys. Windows has `PinCacheAlwaysPrompt`
   on PINS to accomplish the same thing - prompt user before using a key.

   But a key "is secured by" only one pin, but a pin may secure multiple keys where only
   a subset of keys need `PinCacheAlwaysPrompt`

   Two new pin roles are defined and use a sc_pkcs15_id auth_id of
   auth_id_md_role_user_always = {"MD_ROLE_USER_ALWAYS", 18};
   and
   auth_id_md_role_user_sign_always = {"MD_ROLE_USER_SIGN_ALWAYS", 18};

   When building containers for pkcs15 key objects, if user_consent > 0, the auth_id
   is set to one of the above. Thus when Windows CSP selects a key, it will find
   a pin that matches the correct role for the key.

This is still being tested. But should work for any card the has PKCS15 user_consent > 0 for
the User key and/or the Sign key.

@dengert dengert force-pushed the minidriver-PinCacheAlwaysPrompt branch 2 times, most recently from ce6d33d to 01c418a Compare June 8, 2024 16:37
@dengert
Copy link
Member Author

dengert commented Jun 8, 2024

Version 3 of this PR... minidriver.c was modified by bd9cdd2 in 2017 to support multiple pins for a card based on framework-pkcs15.c 10e1ad0 from 2012 which tries to create UserPIN, and SignPIN and some others based on pins define in PKCS15 . The concept of Global PIN and Local PIN come into play.

But none of these tried to address the PKCS11 CKA_ALWAYS_AUTHENTICATE attribute of a private key which is true or false, or the PKCS15 user_consent on an object which can define the number of times a pin can be used before it needs to be verified again.

Cards may have multiple pins, which may or may not have a user_consent limit. The general logic above assumes if the card supports more then one normal PIN i.e. not a PUK or SO_USER type PIN, then the first normal PIN is the UserPIN also
referred to as Authentication PIN and never or rarely has a user_consent limit.

pkcs15-esteid2018.c, pkcs15-idprime.c, pkcs15-jpki.c, pkcs15-skeid.c and pkcs15-piv.c all set user_consent for some key which is secured by the second pin i.e. SignPIN which may have a different value the the UserPIN.

The PIV card has just one PIN but if the 9C key is used the verify ADPU must immediately proceed the crytpo ADPU. So it needs CKA_ALWAYS_AUTHENTICATE and user_consent to signal the application to prompt for PIN. With Windows that is the
PinCacheAlwaysPrompt flag of a PIN.

pkcs15-piv.c defined 2 pins, the normal user pin and a PUK/SO_USER pin, but also set the SC_PKCS15_PIN_FLAG_LOCAL
flag on the PUK pin, which caused the minidriver to assume it was a SignPIN which is a bug.

In this version of the PR:

  • pkcs15-piv.c now defines 3 pins, the UserPIN, a SignPIN and a PUK pin.

  • minidriver.c while looking at keys and which PIN "is secured by" the SignPIN, will test if user_consent > 0.and set
    vs->need_pin_alway. Then when CSP picks a key to use, which is secured by the SignPIN i.e. MD_ROLE_USER_SIGN the minidriver.c will set PinCacheAlwaysPrompt causing the CSP to prompt the user for the PIN.

This should also work for the other 4 cards, but they should be tested.

"is secured by" is used in the debug logs with level 7.

@maciejsszmigiero can you have a look at this too?

Should fix #3156 and #3169

@dengert
Copy link
Member Author

dengert commented Jun 15, 2024

The PR has been rebased to a single commit, and tested with two PIV type cards with:

  • certutil -scinfo on Windows 11 Pro
  • pkcs15-tool on Windows with various list options
  • pkcs11-tool --test --login on Windows and Ubuntu

Card drivers that do not use user_consent are not affected. PinCacheAlwaysPrompt is only set on the Sign PIN if there is a key that requires user_consent. There are 5 drivers that use user_consent:

  • pkcs15-piv.c when not being called from minidriver sitll defines a User PIN or Global PIN (based on the cards preference for Global or Local) and a PUK PIN. When ctx->app_name == "cardmod" i.e. minidriver a Sign PIN is defined to be used only with the 9C key so Windows PinCacheAlwaysPrompt can be set on the Sign PIN.
  • pkcs15-esteid.c defines a User PIN and Sign PIN but no PUK.
  • pkcs15-idprime.c defines a User PIN and for 940 type cards a Sign PIN.
  • pkcs15-dnie.c defines a User PIN but has its own dnie_ask_user_consent routine, so should not be affected by this PR.
  • pkcs15-jpki.c defines a User PIN and Sign PIN but there is still the problem that the the public key is private and needs to be read and placed in the CCP_CONTAINER_INFO before the key is selected and PIN verified to allow the public key to be read.

So this PR will be useful for the 5 drivers. But registry entries for OpenSC with PIV are not installed be default and the JPKI still has problems. No bug reports (that I know of) with pkcs15-esteid.c or pkcs15-idprime.c may indicate a lack of use of these drivers with Windows.

dengert added a commit to dengert/OpenSC that referenced this pull request Jun 15, 2024
Add SC_PKCS15_CO_FLAG_PRIVATE on "Digital Signature Public Key" and
set pubkey_obj.flags and pubkey_obj.auth_id to use the Sign KEY
so minidriver.c can request the pin before reading the public key.
Card enforces this as perspecs.

Partial fix for OpenSC#3169 Only pkcs15-jpki.c is changed.

In addition to changes in OpenSC#3167 that address "user_consent" using
"PinCacheAlwaysPrompt", The JPKI card forces the user to verify the Sign PIN
before the public key is read. But to use the Sign KEY,
Windows minidriver specs V7.07 says: the "CCP_CONTAINER_INFO"
contains "cbSigPublicKey" and "pbSigPublicKey"
which is needed before the key is selected.

It might be possible to add bogus information in these and
substitute the real values at a later time. But this will require
someone with a working card.

 On branch minidriver-PinCacheAlwaysPrompt
 Changes to be committed:
	modified:   libopensc/pkcs15-jpki.c

 On branch JPKI-Improvments
 Changes to be committed:
	modified:   libopensc/pkcs15-jpki.c
@maciejsszmigiero
Copy link
Contributor

The changes overall seem reasonable to me, but I don't have the ability to test them - my test setup for OpenSC minidriver is long gone by now

dengert added a commit to dengert/OpenSC that referenced this pull request Jul 1, 2024
@dengert dengert force-pushed the minidriver-PinCacheAlwaysPrompt branch from bc0b511 to b42c507 Compare July 1, 2024 21:03
dengert added 2 commits July 13, 2024 12:24
At least 5 card drivers set user_consent on a sign pin
The user_consent indicates a prompt for the pin should always
be done by minidriver. PKCS15 can also set user_consent and
PKCS11 sets key attribute CKA_ALWAYS_AUTHENTICATE when key has
user_consent, but windows need the PinCacheAlwaysPrompt
flag set on the pin.

pkcs15-piv.c now defines a sign pin which is used only
with the 9C key.

=======

 On branch minidriver-PinCacheAlwaysPrompt
 Changes to be committed:
	modified:   libopensc/pkcs15-piv.c
	modified:   minidriver/minidriver.c
@dengert dengert force-pushed the minidriver-PinCacheAlwaysPrompt branch from b42c507 to d223ee9 Compare July 13, 2024 17:25
Copy link
Member

@Jakuje Jakuje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the status of this PR? I do not have a way to test the windows changes, but the rest looks reasonable and I think we should get it merged for the next release.

@dengert
Copy link
Member Author

dengert commented Aug 16, 2024

I thing it is ready. And I tested it on Windows 11. using PIV card. Note that the registry entries for PIV are not normally added, because most vendors provide their own PIV minidriver via plug-and-play and don't need OpenSC. But there are people loading piv applets on different cards which is the case in #3159

@Jakuje
Copy link
Member

Jakuje commented Aug 16, 2024

Thank you! Merging then.

@Jakuje Jakuje merged commit 3b289b1 into OpenSC:master Aug 16, 2024
xhanulik pushed a commit that referenced this pull request Sep 4, 2024
Add SC_PKCS15_CO_FLAG_PRIVATE on "Digital Signature Public Key" and
set pubkey_obj.flags and pubkey_obj.auth_id to use the Sign KEY
so minidriver.c can request the pin before reading the public key.
Card enforces this as perspecs.

Partial fix for #3169 Only pkcs15-jpki.c is changed.

In addition to changes in #3167 that address "user_consent" using
"PinCacheAlwaysPrompt", The JPKI card forces the user to verify the Sign PIN
before the public key is read. But to use the Sign KEY,
Windows minidriver specs V7.07 says: the "CCP_CONTAINER_INFO"
contains "cbSigPublicKey" and "pbSigPublicKey"
which is needed before the key is selected.

It might be possible to add bogus information in these and
substitute the real values at a later time. But this will require
someone with a working card.

 On branch minidriver-PinCacheAlwaysPrompt
 Changes to be committed:
	modified:   libopensc/pkcs15-jpki.c

 On branch JPKI-Improvments
 Changes to be committed:
	modified:   libopensc/pkcs15-jpki.c
dangowrt added a commit to dangowrt/packages that referenced this pull request Apr 26, 2025
New in 0.26.1; 2025-01-14
General improvements

    Align allocations of sc_mem_secure_alloc (OpenSC/OpenSC#3281)
    Fix -O3 gcc optimization failure on amd64 and ppc64el (OpenSC/OpenSC#3299)

pkcs11-spy

    Avoid crash while spying C_GetInterface() (OpenSC/OpenSC#3275)

TCOS

    Fix reading certificate (OpenSC/OpenSC#3296)

New in 0.26.0; 2024-11-13
Security

    CVE-2024-45615: Usage of uninitialized values in libopensc and pkcs15init (OpenSC/OpenSC#3225)
    CVE-2024-45616: Uninitialized values after incorrect check or usage of APDU response values in libopensc (OpenSC/OpenSC#3225)
    CVE-2024-45617: Uninitialized values after incorrect or missing checking return values of functions in libopensc (OpenSC/OpenSC#3225)
    CVE-2024-45618: Uninitialized values after incorrect or missing checking return values of functions in pkcs15init (OpenSC/OpenSC#3225)
    CVE-2024-45619: Incorrect handling length of buffers or files in libopensc (OpenSC/OpenSC#3225)
    CVE-2024-45620: Incorrect handling of the length of buffers or files in pkcs15init (OpenSC/OpenSC#3225)
    CVE-2024-8443: Heap buffer overflow in OpenPGP driver when generating key (OpenSC/OpenSC#3219)

General improvements

    Fix reselection of DF after error in PKCSOpenSC/OpenSC#15 layer (OpenSC/OpenSC#3067)
    Unify OpenSSL logging throughout code (OpenSC/OpenSC#2922)
    Extend the p11test to support kryoptic (OpenSC/OpenSC#3141)
    Fix for error in PCSC reconnection (OpenSC/OpenSC#3150)
    Fixed various issues reported by OSS-Fuzz and Coverity in drivers, PKCS#11 and PKCS#15 layer

PKCS#15

    Documentation for PKCS#15 profile files (OpenSC/OpenSC#3132)

minidriver

    Support PinCacheAlwaysPrompt usable for PIV cards (OpenSC/OpenSC#3167)

pkcs11-tool

    Show URI when listing token information (OpenSC/OpenSC#3125) and objects (OpenSC/OpenSC#3130)
    Do not limit size of objects to 5000 bytes (OpenSC/OpenSC#3174)
    Add support for AES CMAC (OpenSC/OpenSC#3184)
    Add support for AES GCM encryption (OpenSC/OpenSC#3195)
    Add support for RSA OAEP encryption (OpenSC/OpenSC#3175)
    Add support for HKDF (OpenSC/OpenSC#3193)
    Implement better support for wrapping and unwrapping (OpenSC/OpenSC#3198)
    Add support for EdDSA sign and verify (OpenSC/OpenSC#2979)

pkcs15-crypt

    Fix PKCS#1 encoding function to correctly detect padding type (OpenSC/OpenSC#3075)

piv-tool

    Fix RSA key generation (OpenSC/OpenSC#3158)
    Avoid possible state change when matching unknown card (OpenSC/OpenSC#3112)

sc-hsm-tool

    Cleanse buffer with plaintext key share (OpenSC/OpenSC#3226)

pkcs11-register

    Fix pkcs11-register defaults on macOS and Windows (OpenSC/OpenSC#3053)

IDPrime

    Fix identification of IDPrime 840 cards (OpenSC/OpenSC#3146)
    Fix container mapping for IDPrime 940 cards (OpenSC/OpenSC#3220)
    Reorder ATRs for matching cards (OpenSC/OpenSC#3154)

OpenPGP

    Fix state tracking after erasing card (OpenSC/OpenSC#3024)

Belpic

    Disable Applet V1.8 (OpenSC/OpenSC#3109)

MICARDO

    Deactivate driver (OpenSC/OpenSC#3152)

SmartCard-HSM

    Fix signing with secp521r1 signature (OpenSC/OpenSC#3157)

eOI

    Set model via sc_card_ctl function (OpenSC/OpenSC#3189)

Rutoken

    increase the minimum PIN size to support Rutoken ECP BIO (OpenSC/OpenSC#3208)

JPKI

    Adjust parameters for public key in PKCS#15 emulator (OpenSC/OpenSC#3182)

D-Trust

    Add support for ECDSA signatures and ECDH key agreement for D-Trust Signatures Cards 4.1/4.4 (OpenSC/OpenSC#3240, OpenSC/OpenSC#openwrt#3248)

Signed-off-by: Daniel Golle <[email protected]>
dangowrt added a commit to dangowrt/packages that referenced this pull request Apr 26, 2025
New in 0.26.1; 2025-01-14
General improvements

    Align allocations of sc_mem_secure_alloc (OpenSC/OpenSC#3281)
    Fix -O3 gcc optimization failure on amd64 and ppc64el (OpenSC/OpenSC#3299)

pkcs11-spy

    Avoid crash while spying C_GetInterface() (OpenSC/OpenSC#3275)

TCOS

    Fix reading certificate (OpenSC/OpenSC#3296)

New in 0.26.0; 2024-11-13
Security

    CVE-2024-45615: Usage of uninitialized values in libopensc and pkcs15init (OpenSC/OpenSC#3225)
    CVE-2024-45616: Uninitialized values after incorrect check or usage of APDU response values in libopensc (OpenSC/OpenSC#3225)
    CVE-2024-45617: Uninitialized values after incorrect or missing checking return values of functions in libopensc (OpenSC/OpenSC#3225)
    CVE-2024-45618: Uninitialized values after incorrect or missing checking return values of functions in pkcs15init (OpenSC/OpenSC#3225)
    CVE-2024-45619: Incorrect handling length of buffers or files in libopensc (OpenSC/OpenSC#3225)
    CVE-2024-45620: Incorrect handling of the length of buffers or files in pkcs15init (OpenSC/OpenSC#3225)
    CVE-2024-8443: Heap buffer overflow in OpenPGP driver when generating key (OpenSC/OpenSC#3219)

General improvements

    Fix reselection of DF after error in PKCSOpenSC/OpenSC#15 layer (OpenSC/OpenSC#3067)
    Unify OpenSSL logging throughout code (OpenSC/OpenSC#2922)
    Extend the p11test to support kryoptic (OpenSC/OpenSC#3141)
    Fix for error in PCSC reconnection (OpenSC/OpenSC#3150)
    Fixed various issues reported by OSS-Fuzz and Coverity in drivers, PKCS#11 and PKCS#15 layer

PKCS#15

    Documentation for PKCS#15 profile files (OpenSC/OpenSC#3132)

minidriver

    Support PinCacheAlwaysPrompt usable for PIV cards (OpenSC/OpenSC#3167)

pkcs11-tool

    Show URI when listing token information (OpenSC/OpenSC#3125) and objects (OpenSC/OpenSC#3130)
    Do not limit size of objects to 5000 bytes (OpenSC/OpenSC#3174)
    Add support for AES CMAC (OpenSC/OpenSC#3184)
    Add support for AES GCM encryption (OpenSC/OpenSC#3195)
    Add support for RSA OAEP encryption (OpenSC/OpenSC#3175)
    Add support for HKDF (OpenSC/OpenSC#3193)
    Implement better support for wrapping and unwrapping (OpenSC/OpenSC#3198)
    Add support for EdDSA sign and verify (OpenSC/OpenSC#2979)

pkcs15-crypt

    Fix PKCS#1 encoding function to correctly detect padding type (OpenSC/OpenSC#3075)

piv-tool

    Fix RSA key generation (OpenSC/OpenSC#3158)
    Avoid possible state change when matching unknown card (OpenSC/OpenSC#3112)

sc-hsm-tool

    Cleanse buffer with plaintext key share (OpenSC/OpenSC#3226)

pkcs11-register

    Fix pkcs11-register defaults on macOS and Windows (OpenSC/OpenSC#3053)

IDPrime

    Fix identification of IDPrime 840 cards (OpenSC/OpenSC#3146)
    Fix container mapping for IDPrime 940 cards (OpenSC/OpenSC#3220)
    Reorder ATRs for matching cards (OpenSC/OpenSC#3154)

OpenPGP

    Fix state tracking after erasing card (OpenSC/OpenSC#3024)

Belpic

    Disable Applet V1.8 (OpenSC/OpenSC#3109)

MICARDO

    Deactivate driver (OpenSC/OpenSC#3152)

SmartCard-HSM

    Fix signing with secp521r1 signature (OpenSC/OpenSC#3157)

eOI

    Set model via sc_card_ctl function (OpenSC/OpenSC#3189)

Rutoken

    increase the minimum PIN size to support Rutoken ECP BIO (OpenSC/OpenSC#3208)

JPKI

    Adjust parameters for public key in PKCS#15 emulator (OpenSC/OpenSC#3182)

D-Trust

    Add support for ECDSA signatures and ECDH key agreement for D-Trust Signatures Cards 4.1/4.4 (OpenSC/OpenSC#3240, OpenSC/OpenSC#openwrt#3248)

Signed-off-by: Daniel Golle <[email protected]>
dangowrt added a commit to dangowrt/packages that referenced this pull request Apr 26, 2025
New in 0.26.1; 2025-01-14
General improvements

    Align allocations of sc_mem_secure_alloc (OpenSC/OpenSC#3281)
    Fix -O3 gcc optimization failure on amd64 and ppc64el (OpenSC/OpenSC#3299)

pkcs11-spy

    Avoid crash while spying C_GetInterface() (OpenSC/OpenSC#3275)

TCOS

    Fix reading certificate (OpenSC/OpenSC#3296)

New in 0.26.0; 2024-11-13
Security

    CVE-2024-45615: Usage of uninitialized values in libopensc and pkcs15init (OpenSC/OpenSC#3225)
    CVE-2024-45616: Uninitialized values after incorrect check or usage of APDU response values in libopensc (OpenSC/OpenSC#3225)
    CVE-2024-45617: Uninitialized values after incorrect or missing checking return values of functions in libopensc (OpenSC/OpenSC#3225)
    CVE-2024-45618: Uninitialized values after incorrect or missing checking return values of functions in pkcs15init (OpenSC/OpenSC#3225)
    CVE-2024-45619: Incorrect handling length of buffers or files in libopensc (OpenSC/OpenSC#3225)
    CVE-2024-45620: Incorrect handling of the length of buffers or files in pkcs15init (OpenSC/OpenSC#3225)
    CVE-2024-8443: Heap buffer overflow in OpenPGP driver when generating key (OpenSC/OpenSC#3219)

General improvements

    Fix reselection of DF after error in PKCSOpenSC/OpenSC#15 layer (OpenSC/OpenSC#3067)
    Unify OpenSSL logging throughout code (OpenSC/OpenSC#2922)
    Extend the p11test to support kryoptic (OpenSC/OpenSC#3141)
    Fix for error in PCSC reconnection (OpenSC/OpenSC#3150)
    Fixed various issues reported by OSS-Fuzz and Coverity in drivers, PKCS#11 and PKCS#15 layer

PKCS#15

    Documentation for PKCS#15 profile files (OpenSC/OpenSC#3132)

minidriver

    Support PinCacheAlwaysPrompt usable for PIV cards (OpenSC/OpenSC#3167)

pkcs11-tool

    Show URI when listing token information (OpenSC/OpenSC#3125) and objects (OpenSC/OpenSC#3130)
    Do not limit size of objects to 5000 bytes (OpenSC/OpenSC#3174)
    Add support for AES CMAC (OpenSC/OpenSC#3184)
    Add support for AES GCM encryption (OpenSC/OpenSC#3195)
    Add support for RSA OAEP encryption (OpenSC/OpenSC#3175)
    Add support for HKDF (OpenSC/OpenSC#3193)
    Implement better support for wrapping and unwrapping (OpenSC/OpenSC#3198)
    Add support for EdDSA sign and verify (OpenSC/OpenSC#2979)

pkcs15-crypt

    Fix PKCS#1 encoding function to correctly detect padding type (OpenSC/OpenSC#3075)

piv-tool

    Fix RSA key generation (OpenSC/OpenSC#3158)
    Avoid possible state change when matching unknown card (OpenSC/OpenSC#3112)

sc-hsm-tool

    Cleanse buffer with plaintext key share (OpenSC/OpenSC#3226)

pkcs11-register

    Fix pkcs11-register defaults on macOS and Windows (OpenSC/OpenSC#3053)

IDPrime

    Fix identification of IDPrime 840 cards (OpenSC/OpenSC#3146)
    Fix container mapping for IDPrime 940 cards (OpenSC/OpenSC#3220)
    Reorder ATRs for matching cards (OpenSC/OpenSC#3154)

OpenPGP

    Fix state tracking after erasing card (OpenSC/OpenSC#3024)

Belpic

    Disable Applet V1.8 (OpenSC/OpenSC#3109)

MICARDO

    Deactivate driver (OpenSC/OpenSC#3152)

SmartCard-HSM

    Fix signing with secp521r1 signature (OpenSC/OpenSC#3157)

eOI

    Set model via sc_card_ctl function (OpenSC/OpenSC#3189)

Rutoken

    increase the minimum PIN size to support Rutoken ECP BIO (OpenSC/OpenSC#3208)

JPKI

    Adjust parameters for public key in PKCS#15 emulator (OpenSC/OpenSC#3182)

D-Trust

    Add support for ECDSA signatures and ECDH key agreement for D-Trust Signatures Cards 4.1/4.4 (OpenSC/OpenSC#3240, OpenSC/OpenSC#openwrt#3248)

Signed-off-by: Daniel Golle <[email protected]>
dangowrt added a commit to openwrt/packages that referenced this pull request Apr 27, 2025
New in 0.26.1; 2025-01-14
General improvements

    Align allocations of sc_mem_secure_alloc (OpenSC/OpenSC#3281)
    Fix -O3 gcc optimization failure on amd64 and ppc64el (OpenSC/OpenSC#3299)

pkcs11-spy

    Avoid crash while spying C_GetInterface() (OpenSC/OpenSC#3275)

TCOS

    Fix reading certificate (OpenSC/OpenSC#3296)

New in 0.26.0; 2024-11-13
Security

    CVE-2024-45615: Usage of uninitialized values in libopensc and pkcs15init (OpenSC/OpenSC#3225)
    CVE-2024-45616: Uninitialized values after incorrect check or usage of APDU response values in libopensc (OpenSC/OpenSC#3225)
    CVE-2024-45617: Uninitialized values after incorrect or missing checking return values of functions in libopensc (OpenSC/OpenSC#3225)
    CVE-2024-45618: Uninitialized values after incorrect or missing checking return values of functions in pkcs15init (OpenSC/OpenSC#3225)
    CVE-2024-45619: Incorrect handling length of buffers or files in libopensc (OpenSC/OpenSC#3225)
    CVE-2024-45620: Incorrect handling of the length of buffers or files in pkcs15init (OpenSC/OpenSC#3225)
    CVE-2024-8443: Heap buffer overflow in OpenPGP driver when generating key (OpenSC/OpenSC#3219)

General improvements

    Fix reselection of DF after error in PKCSOpenSC/OpenSC#15 layer (OpenSC/OpenSC#3067)
    Unify OpenSSL logging throughout code (OpenSC/OpenSC#2922)
    Extend the p11test to support kryoptic (OpenSC/OpenSC#3141)
    Fix for error in PCSC reconnection (OpenSC/OpenSC#3150)
    Fixed various issues reported by OSS-Fuzz and Coverity in drivers, PKCS#11 and PKCS#15 layer

PKCS#15

    Documentation for PKCS#15 profile files (OpenSC/OpenSC#3132)

minidriver

    Support PinCacheAlwaysPrompt usable for PIV cards (OpenSC/OpenSC#3167)

pkcs11-tool

    Show URI when listing token information (OpenSC/OpenSC#3125) and objects (OpenSC/OpenSC#3130)
    Do not limit size of objects to 5000 bytes (OpenSC/OpenSC#3174)
    Add support for AES CMAC (OpenSC/OpenSC#3184)
    Add support for AES GCM encryption (OpenSC/OpenSC#3195)
    Add support for RSA OAEP encryption (OpenSC/OpenSC#3175)
    Add support for HKDF (OpenSC/OpenSC#3193)
    Implement better support for wrapping and unwrapping (OpenSC/OpenSC#3198)
    Add support for EdDSA sign and verify (OpenSC/OpenSC#2979)

pkcs15-crypt

    Fix PKCS#1 encoding function to correctly detect padding type (OpenSC/OpenSC#3075)

piv-tool

    Fix RSA key generation (OpenSC/OpenSC#3158)
    Avoid possible state change when matching unknown card (OpenSC/OpenSC#3112)

sc-hsm-tool

    Cleanse buffer with plaintext key share (OpenSC/OpenSC#3226)

pkcs11-register

    Fix pkcs11-register defaults on macOS and Windows (OpenSC/OpenSC#3053)

IDPrime

    Fix identification of IDPrime 840 cards (OpenSC/OpenSC#3146)
    Fix container mapping for IDPrime 940 cards (OpenSC/OpenSC#3220)
    Reorder ATRs for matching cards (OpenSC/OpenSC#3154)

OpenPGP

    Fix state tracking after erasing card (OpenSC/OpenSC#3024)

Belpic

    Disable Applet V1.8 (OpenSC/OpenSC#3109)

MICARDO

    Deactivate driver (OpenSC/OpenSC#3152)

SmartCard-HSM

    Fix signing with secp521r1 signature (OpenSC/OpenSC#3157)

eOI

    Set model via sc_card_ctl function (OpenSC/OpenSC#3189)

Rutoken

    increase the minimum PIN size to support Rutoken ECP BIO (OpenSC/OpenSC#3208)

JPKI

    Adjust parameters for public key in PKCS#15 emulator (OpenSC/OpenSC#3182)

D-Trust

    Add support for ECDSA signatures and ECDH key agreement for D-Trust Signatures Cards 4.1/4.4 (OpenSC/OpenSC#3240, OpenSC/OpenSC##3248)

Signed-off-by: Daniel Golle <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

OpenSC Minidriver with PIVApplet + ECC keys on Win11: error on slot 9c - public key does not match private key

3 participants