Closed mouse07410 closed 8 months ago
Looking at som of the spy traces in referenced cases it seems we are running into thee different issues here.
yubihsm_pkcs11 requires PIN to be verified before being able to do (almost) anything
Yes, and I don't see it as a problem.
yubihsm_pkcs11 doesn't support EC keys for encryption / decryption
I don't think any of my traces involved EC - RSA only.
Regardless, I know that there's no EC encryption or decryption (aka, El Gamal) support - but doesn't yubihsm_pkcs11 support ECDH? (Not that it's crucial, given that CNSA-2.0 guidance suggests moving to PQ algorithms, and staying with RSA-3072+ in the meanwhile.)
From what I see here and in the other cases i would agree we are trying to use openssl while it is being deinitialized. I will look into using a non-default library context.
Yes please! This is a big problem that can be solved (IMHO) only in your library.
I only mentioned the nonexistent EC support because I found traces where that was the issue. But they may not have been yours. The YubiHSM does support ecdh so implementing something like ECIES is quite possible in the module, but is not implemented at this time, i.e. C_EncryptInit / C_DecryptInit will simply fail for non-RSA keys (it also supports AES / and wrap keys)
The YubiHSM does support
ECDH
so implementing something like ECIES is quite possible in the module, but is not implemented at this time, i.e.C_EncryptInit
/C_DecryptInit
will simply fail for non-RSA keys (it also supports AES / and wrap keys)
I'd like to see it implemented for the sake of completeness (and it would only require some extra code in the software module, no changes to YubiHSM2 itself), but as I said before - support for Post-Quantum algorithms (Kyber key encapsulation, Dilithium signature, SPHINCS+ signature) is more important on my priority scale.
yubihsm_pkcs11 requires PIN to be verified before being able to do (almost) anything
Yes, and I don't see it as a problem.
yubihsm_pkcs11 doesn't support EC keys for encryption / decryption
I don't think any of my traces involved EC - RSA only.
Regardless, I know that there's no EC encryption or decryption (aka, El Gamal) support - but doesn't yubihsm_pkcs11 support ECDH? (Not that it's crucial, given that CNSA-2.0 guidance suggests moving to PQ algorithms, and staying with RSA-3072+ in the meanwhile.)
From what I see here and in the other cases i would agree we are trying to use openssl while it is being deinitialized. I will look into using a non-default library context.
Yes please! This is a big problem that can be solved (IMHO) only in your library.
Ping? Any chance to get this addressed any time soon? Thanks!
To reproduce this I'd like to ask for some context in terms of config files, installed packages etc, that is required to load the pkcs11 engine & pkcs11 module
to reproduce this I'd like to ask for some context in terms of config files, installed packages etc, that is required to load the pkcs11 engine & pkcs11 module
MacOS 13.3.1, Xcode-14.3, Macports-installed OpenSSL-3.1.0 and p11-kit 0.24.1. OpenSC compiled from source of master branch. pkcs11-provider compiled from main branch of https://github.com/latchset/pkcs11-provider, libp11 compiled from the master branch of https://github.com/OpenSC/libp11
p11-kit config is shown here https://github.com/latchset/pkcs11-provider/issues/198#issuecomment-1510034294
openssl.cnf
(relevant parts):
[openssl_init]
providers = provider_sect
engines = engine_sect
[provider_sect]
default = default_sect
legacy = legacy_sect
pkcs11 = pkcs11_sect
#gost = gost_sect
base = base_sect
oqs = oqs_sect
[default_sect]
activate = 1
[legacy_sect]
activate = 1
[pkcs11_sect]
module = /opt/local/libexec/openssl3/lib/ossl-modules/pkcs11.dylib
#pkcs11-module-path = /Library/OpenSC/lib/opensc-pkcs11.so
pkcs11-module-path = /usr/local/lib/libykcs11.dylib
activate = 1
[gost_sect]
module = /opt/local/libexec/openssl3/lib/ossl-modules/gostprov.dylib
activate = 1
[base_sect]
activate = 1
[oqs_sect]
module = /opt/local/libexec/openssl3/lib/ossl-modules/oqsprovider.dylib
activate = 1
[engine_sect]
#pkcs11 = pkcs11_section
#gost = gost_section
[pkcs11_section]
engine_id = pkcs11
dynamic_path = /opt/local/libexec/openssl3/lib/engines-3/pkcs11.so
MODULE_PATH = /Library/OpenSC/lib/opensc-pkcs11.so
init = 0
[gost_section]
engine_id = gost
dynamic_path = /opt/local/libexec/openssl3/lib/engines-3/gost.dylib
default_algorithms = ALL
#CRYPT_PARAMS = id-Gost28147-89-CryptoPro-A-ParamSet
#CRYPT-PARAMS = id-GostR3410-2001-CryptoPro-A-ParamSet
PBE_PARAMS = "gost12_512"
init = 0
Ping?
@qpernil ping?
Apple Silicon M2 MacBook Pro, MacOS Ventura 13.6.2, Xcode-15.0.1, OpenSSL-3.2.0, current master.
$ openssl version
OpenSSL 3.2.0 23 Nov 2023 (Library: OpenSSL 3.2.0 23 Nov 2023)
$ openssl pkeyutl -decrypt -inkey "pkcs11:model=YubiHSM;token=YubiHSM;id=%04%02;type=private" -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:sha384 -pkeyopt rsa_mgf1_md:sha384 -in /tmp/key.enc1 -out /tmp/key.dec1
Enter pass phrase for PKCS#11 Token (Slot 20 - YubiHSM Connector 0.0.0.0):
$
$ cat /tmp/key.dec1 /tmp/key.txt
e73555df0a8808a070a39e491d49859e
e73555df0a8808a070a39e491d49859e
$
Seems to be working now, closing.
MacOS Ventura 13.2.1, Xcode-14.2, OpenSSL-3.0.8, current master of
yubihsm-shell
.Symptoms
Decryption succeeds (plaintext verified).
Crash report:
Suspected cause
As discussed in https://github.com/latchset/pkcs11-provider/issues/196#issuecomment-1429952478: