Hello,
I am trying to follow AN12812 to use CST 3.3.2 with softhsm2. Everything completes successfully with the exception of calling CST to do the actual signing, so I am a bit lost at the moment.
I have rebuilt CST and followed the steps in the application note. There is the content of the HSM, imx-boot.csf and the CST output.
I appreciate if additional debug info is needed (please let me know how to get it).
$ pkcs11-tool --module $PKCS11_MODULE -l --pin $USR_PIN --list-objects
Using slot 0 with a present token (0x10)
Certificate Object; type = X.509 cert
label: IMG1_1_sha256_2048_usr
subject: DN: CN=IMG1_1_sha256_2048_usr
ID: 1003
Private Key Object; RSA
label: CA1_sha256_2048_ca
ID: 1000
Usage: decrypt, sign, unwrap
Access: sensitive, always sensitive, never extractable, local
Public Key Object; RSA 2048 bits
label: CSF1_1_sha256_2048_usr
ID: 1002
Usage: encrypt, verify, wrap
Access: local
Public Key Object; RSA 2048 bits
label: CA1_sha256_2048_ca
ID: 1000
Usage: encrypt, verify, wrap
Access: local
Public Key Object; RSA 2048 bits
label: IMG1_1_sha256_2048_usr
ID: 1003
Usage: encrypt, verify, wrap
Access: local
Certificate Object; type = X.509 cert
label: SRK1_sha256_2048_ca
subject: DN: CN=SRK1_sha256_2048_ca
ID: 1001
Private Key Object; RSA
label: SRK1_sha256_2048_ca
ID: 1001
Usage: decrypt, sign, unwrap
Access: sensitive, always sensitive, never extractable, local
Private Key Object; RSA
label: CSF1_1_sha256_2048_usr
ID: 1002
Usage: decrypt, sign, unwrap
Access: sensitive, always sensitive, never extractable, local
Certificate Object; type = X.509 cert
label: CSF1_1_sha256_2048_usr
subject: DN: CN=CSF1_1_sha256_2048_usr
ID: 1002
Public Key Object; RSA 2048 bits
label: SRK1_sha256_2048_ca
ID: 1001
Usage: encrypt, verify, wrap
Access: local
Private Key Object; RSA
label: IMG1_1_sha256_2048_usr
ID: 1003
Usage: decrypt, sign, unwrap
Access: sensitive, always sensitive, never extractable, local
$ cat imx-boot.csf
[Header]
Version = 4.3
Hash Algorithm = sha256
Engine = CAAM
Engine Configuration = 0
Certificate Format = X509
Signature Format = CMS
[Install SRK]
File = "./SRK_1_table.bin"
Source index = 0
[Install CSFK]
File = "pkcs11:token=CST-HSM-DEMO;object=CSF1_1_sha256_2048_usr;type=cert;pin-value=12345678"
[Authenticate CSF]
[Unlock]
Engine = CAAM
Features = MID
[Unlock]
Engine = CAAM
Features = MFG
[Install Key]
Verification index = 0
Target index = 2
File = "pkcs11:token=CST-HSM-DEMO;object=IMG1_1_sha256_2048_usr;type=cert;pin-value=12345678"
[Authenticate Data]
Verification index = 2
Blocks = 0x7e0fc0 0x0 0x2bc00 "flash.bin"
$ cst -i imx-boot.csf -o imx-boot.csf.bin
Public key certificate is invalid in file pkcs11:token=CST-HSM-DEMO;object=CSF1_1_sha256_2048_usr;type=cert;pin-value=12345678
Environment variables are defined like in the AN. I am running an up to date Ubuntu 20.04.
PKCS11_MODULE=/usr/lib/x86_64-linux-gnu/p11-kit-proxy.so
SO_PIN=7635005489180126
USR_PIN=12345678
SRK1_KEY=SRK1_sha256_2048_ca
CSF1_KEY=CSF1_1_sha256_2048_usr
IMG1_KEY=IMG1_1_sha256_2048_usr
Before running the openssl commands, I am using
openssl engine dynamic -pre SO_PATH:/usr/lib/x86_64-linux-gnu/engines-1.1/pkcs11.so -pre ID:pkcs11 -pre LIST_ADD:1 -pre LOAD -pre MODULE_PATH:$PKCS11_MODULE
Any help is appreciated.
Another thing is AN12812 only mentions HABv4, but I am using i.MX8X, which is AHAB.