tpm2-software / tpm2-tss-engine

OpenSSL Engine for TPM2 devices
https://tpm2-software.github.io
BSD 3-Clause "New" or "Revised" License
151 stars 100 forks source link

openssl reports TPM error 0x1c4 when generating ECC CSR from TPM handle #146

Closed stevealx closed 5 years ago

stevealx commented 5 years ago

$ openssl req -new -engine tpm2tss -keyform engine -key 0x81800003 -out csr1 -subj /CN=test engine "tpm2tss" set. Enter password for user key: WARNING:esys:src/tss2-esys/api/Esys_FlushContext.c:234:Esys_FlushContext_Finish() Received TPM Error ERROR:esys:src/tss2-esys/api/Esys_FlushContext.c:89:Esys_FlushContext() Esys Finish ErrorCode (0x000001c4) $

Copying the KEY_TYPE_HANDLE logic from rsa_priv_enc) to ecdsa_sign() seems to fix the issue.

(with patch applied)

$ openssl req -new -engine tpm2tss -keyform engine -key 0x81800003 -out csr1 -subj /CN=test engine "tpm2tss" set. Enter password for user key: $

If this seems reasonable, I can submit a PR with the change.

AndreasFuchsTPM commented 5 years ago

Thanks for the observation. Could you point out what exactly you copied ? Also, PR is always appreciated ! Best if it has a test-case that uncovers the problem being fixed...