tpm2-software / tpm2-openssl

OpenSSL Provider for TPM2 integration
BSD 3-Clause "New" or "Revised" License
88 stars 37 forks source link

Tests fail on RPi 4 #3

Closed ViSilver closed 3 years ago

ViSilver commented 3 years ago

Today I tried for the first time to build tpm2-openssl. I have installed all the requirements, especially:

After following the installation steps I decided to run the tests. And they failed.

I have attached the content of test-suite.log:

==========================================
   tpm2-openssl 2.0.0: ./test-suite.log
==========================================

# TOTAL: 33
# PASS:  3
# SKIP:  5
# XFAIL: 0
# FAIL:  25
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

FAIL: test/list
===============

Starting /home/pi/tpm/tpm2-openssl/test/list.sh
+ for command in -providers -encoders -decoders -public-key-algorithms -public-key-methods -random-generators -digest-algorithms -cipher-algorithms -key-exchange-algorithms -signature-algorithms -asymcipher-algorithms
+ openssl list -providers -provider tpm2 -verbose
Providers:
  tpm2
    name: TPM 2.0 Provider
    version: 2.0.0
    status: active
    build info: BETA
    gettable provider parameters:
      name: pointer to a UTF8 encoded string (arbitrary size)
      version: pointer to a UTF8 encoded string (arbitrary size)
      buildinfo: pointer to a UTF8 encoded string (arbitrary size)
      status: integer (arbitrary size)
+ for command in -providers -encoders -decoders -public-key-algorithms -public-key-methods -random-generators -digest-algorithms -cipher-algorithms -key-exchange-algorithms -signature-algorithms -asymcipher-algorithms
+ openssl list -encoders -provider tpm2 -verbose
Provided ENCODERs:
  { 1.2.840.113549.1.1.1, 2.5.8.1.1, RSA, rsaEncryption } @ tpm2 (provider=tpm2,output=der,structure=pkcs8)
  { 1.2.840.113549.1.1.1, 2.5.8.1.1, RSA, rsaEncryption } @ tpm2 (provider=tpm2,output=pem,structure=pkcs8)
  { 1.2.840.113549.1.1.1, 2.5.8.1.1, RSA, rsaEncryption } @ tpm2 (provider=tpm2,output=der,structure=pkcs1)
  { 1.2.840.113549.1.1.1, 2.5.8.1.1, RSA, rsaEncryption } @ tpm2 (provider=tpm2,output=pem,structure=pkcs1)
  { 1.2.840.113549.1.1.1, 2.5.8.1.1, RSA, rsaEncryption } @ tpm2 (provider=tpm2,output=der,structure=SubjectPublicKeyInfo)
  { 1.2.840.113549.1.1.1, 2.5.8.1.1, RSA, rsaEncryption } @ tpm2 (provider=tpm2,output=pem,structure=SubjectPublicKeyInfo)
  { 1.2.840.113549.1.1.1, 2.5.8.1.1, RSA, rsaEncryption } @ tpm2 (provider=tpm2,output=text)
  { 1.2.840.10045.2.1, EC, id-ecPublicKey } @ tpm2 (provider=tpm2,output=der,structure=pkcs8)
  { 1.2.840.10045.2.1, EC, id-ecPublicKey } @ tpm2 (provider=tpm2,output=pem,structure=pkcs8)
  { 1.2.840.10045.2.1, EC, id-ecPublicKey } @ tpm2 (provider=tpm2,output=der,structure=SubjectPublicKeyInfo)
  { 1.2.840.10045.2.1, EC, id-ecPublicKey } @ tpm2 (provider=tpm2,output=pem,structure=SubjectPublicKeyInfo)
  { 1.2.840.10045.2.1, EC, id-ecPublicKey } @ tpm2 (provider=tpm2,output=text)
  { 1.2.840.113549.1.1.10, RSA-PSS, RSASSA-PSS, rsassaPss } @ tpm2 (provider=tpm2,output=der,structure=pkcs8)
  { 1.2.840.113549.1.1.10, RSA-PSS, RSASSA-PSS, rsassaPss } @ tpm2 (provider=tpm2,output=pem,structure=pkcs8)
  { 1.2.840.113549.1.1.10, RSA-PSS, RSASSA-PSS, rsassaPss } @ tpm2 (provider=tpm2,output=der,structure=pkcs1)
  { 1.2.840.113549.1.1.10, RSA-PSS, RSASSA-PSS, rsassaPss } @ tpm2 (provider=tpm2,output=pem,structure=pkcs1)
  { 1.2.840.113549.1.1.10, RSA-PSS, RSASSA-PSS, rsassaPss } @ tpm2 (provider=tpm2,output=der,structure=SubjectPublicKeyInfo)
  { 1.2.840.113549.1.1.10, RSA-PSS, RSASSA-PSS, rsassaPss } @ tpm2 (provider=tpm2,output=pem,structure=SubjectPublicKeyInfo)
  { 1.2.840.113549.1.1.10, RSA-PSS, RSASSA-PSS, rsassaPss } @ tpm2 (provider=tpm2,output=text)
+ for command in -providers -encoders -decoders -public-key-algorithms -public-key-methods -random-generators -digest-algorithms -cipher-algorithms -key-exchange-algorithms -signature-algorithms -asymcipher-algorithms
+ openssl list -decoders -provider tpm2 -verbose
Provided DECODERs:
  { 1.2.840.113549.1.1.1, 2.5.8.1.1, RSA, rsaEncryption } @ tpm2 (provider=tpm2,input=der,structure=TSS2)
  DER @ tpm2 (provider=tpm2,input=pem)
+ for command in -providers -encoders -decoders -public-key-algorithms -public-key-methods -random-generators -digest-algorithms -cipher-algorithms -key-exchange-algorithms -signature-algorithms -asymcipher-algorithms
+ openssl list -public-key-algorithms -provider tpm2 -verbose
free(): invalid pointer
/home/pi/tpm/tpm2-openssl/test/list.sh: line 4:  8116 Aborted                 openssl list $command -provider tpm2 -verbose
FAIL test/list.sh (exit status: 134)

FAIL: test/rsa_genrsa_check
===========================

Starting /home/pi/tpm/tpm2-openssl/test/rsa_genrsa_check.sh
+ openssl genrsa -provider tpm2 -verbose -out pubkey.pem 1024
free(): invalid pointer
/home/pi/tpm/tpm2-openssl/test/rsa_genrsa_check.sh: line 5:  8144 Aborted                 openssl genrsa -provider tpm2 -verbose -out pubkey.pem 1024
FAIL test/rsa_genrsa_check.sh (exit status: 134)

FAIL: test/rsa_genpkey_sign
===========================

Starting /home/pi/tpm/tpm2-openssl/test/rsa_genpkey_sign.sh
+ echo -n abcde12345abcde12345abcde12345ab
+ openssl genpkey -provider tpm2 -algorithm RSA -pkeyopt bits:1024 -out testkey.priv
free(): invalid pointer
/home/pi/tpm/tpm2-openssl/test/rsa_genpkey_sign.sh: line 8:  8158 Aborted                 openssl genpkey -provider tpm2 -algorithm RSA -pkeyopt bits:1024 -out testkey.priv
FAIL test/rsa_genpkey_sign.sh (exit status: 134)

FAIL: test/rsa_genpkey_sign_rawin
=================================

Starting /home/pi/tpm/tpm2-openssl/test/rsa_genpkey_sign_rawin.sh
+ echo -n abcde12345abcde12345
+ openssl genpkey -provider tpm2 -algorithm RSA -pkeyopt bits:1024 -out testkey.priv
free(): invalid pointer
/home/pi/tpm/tpm2-openssl/test/rsa_genpkey_sign_rawin.sh: line 7:  8172 Aborted                 openssl genpkey -provider tpm2 -algorithm RSA -pkeyopt bits:1024 -out testkey.priv
FAIL test/rsa_genpkey_sign_rawin.sh (exit status: 134)

FAIL: test/rsa_genpkey_auth_parent
==================================

Starting /home/pi/tpm/tpm2-openssl/test/rsa_genpkey_auth_parent.sh
+ echo -n abcde12345abcde12345
+ tpm2_createprimary -G rsa -g sha256 -c parent.ctx
name-alg:
  value: sha256
  raw: 0xb
attributes:
  value: fixedtpm|fixedparent|sensitivedataorigin|userwithauth|restricted|decrypt
  raw: 0x30072
type:
  value: rsa
  raw: 0x1
exponent: 65537
bits: 2048
scheme:
  value: null
  raw: 0x10
scheme-halg:
  value: (null)
  raw: 0x0
sym-alg:
  value: aes
  raw: 0x6
sym-mode:
  value: cfb
  raw: 0x43
sym-keybits: 128
rsa: cf2fa386b18626faf46c9a0fc515e8c50e69299d57ff31fd359581711621e3a613078c2be2a0cc506f74aa110bc62c06cd393cbe392b1eedec61e7edf901295916f98b1b585cf3506ff420370b6ed1e2a10c8fa9623cea6af0b50946088e95f7926ad469a4441201c1a91983d2bf461d396544b9fd8a1baa951b94ba8bc02c4a0b84586ef6d7cf6ac8efd995d5f12b2e2cc692d489fdea18accc64658afb78f78981f3156c69031bea44daa9f5a6ca22280b0249429e81f492bc9a66e7b33ddba394e0a3a0aaf399cdd746b40cadc838ee32176816870041ae8b78295dc52d27815d1e0d0dbfea885ceaf29bd60f7af302fd4f6e5d73126276fce0af3996ab17
++ tpm2_evictcontrol -c parent.ctx
++ cut -d ' ' -f 2
++ head -n 1
WARNING:esys:src/tss2-esys/api/Esys_EvictControl.c:330:Esys_EvictControl_Finish() Received TPM Error 
ERROR:esys:src/tss2-esys/api/Esys_EvictControl.c:114:Esys_EvictControl() Esys Finish ErrorCode (0x0000014b) 
ERROR: Esys_EvictControl(0x14B) - tpm:error(2.0): insufficient space for NV allocation
ERROR:esys:src/tss2-esys/esys_tr.c:357:Esys_TR_Close() Error: Esys handle does not exist (70018). 
ERROR: Esys_TR_Close(0x70018) - esapi:The ESYS_TR resource object is bad
ERROR: Unable to run tpm2_evictcontrol
+ HANDLE=
+ openssl genpkey -provider tpm2 -algorithm RSA -out testkey.priv -pkeyopt parent: -pkeyopt user-auth:abc -pkeyopt bits:1024
free(): invalid pointer
/home/pi/tpm/tpm2-openssl/test/rsa_genpkey_auth_parent.sh: line 14:  8265 Aborted                 openssl genpkey -provider tpm2 -algorithm RSA -out testkey.priv -pkeyopt parent:${HANDLE} -pkeyopt user-auth:abc -pkeyopt bits:1024
FAIL test/rsa_genpkey_auth_parent.sh (exit status: 134)

FAIL: test/rsa_createak_auth
============================

Starting /home/pi/tpm/tpm2-openssl/test/rsa_createak_auth.sh
+ echo -n abcde12345abcde12345
+ tpm2_createek -G rsa -c ek_rsa.ctx
+ tpm2_createak -C ek_rsa.ctx -G rsa -g sha256 -s rsassa -p abc -c ak_rsa.ctx
loaded-key:
  name: 000bafd362d9bee12df0913a58bee8698dc587fca1c6d38891babd8d966c953ed320
  qualified name: 000b1cc54a78b3b8b68db95ee73f7def8a735ffb60ec7879c81b879487d1dd70a7ec
++ tpm2_evictcontrol -c ak_rsa.ctx
++ cut -d ' ' -f 2
++ head -n 1
WARNING:esys:src/tss2-esys/api/Esys_EvictControl.c:330:Esys_EvictControl_Finish() Received TPM Error 
ERROR:esys:src/tss2-esys/api/Esys_EvictControl.c:114:Esys_EvictControl() Esys Finish ErrorCode (0x0000014b) 
ERROR: Esys_EvictControl(0x14B) - tpm:error(2.0): insufficient space for NV allocation
ERROR:esys:src/tss2-esys/esys_tr.c:357:Esys_TR_Close() Error: Esys handle does not exist (70018). 
ERROR: Esys_TR_Close(0x70018) - esapi:The ESYS_TR resource object is bad
ERROR: Unable to run tpm2_evictcontrol
+ HANDLE=
+ openssl pkeyutl -provider tpm2 -inkey 'handle:?pass' -sign -rawin -in testdata -passin pass:abc -out testdata.sig
WARNING:esys:src/tss2-esys/api/Esys_ReadPublic.c:320:Esys_ReadPublic_Finish() Received TPM Error 
ERROR:esys:src/tss2-esys/esys_tr.c:231:Esys_TR_FromTPMPublic_Finish() Error ReadPublic ErrorCode (0x00000184) 
ERROR:esys:src/tss2-esys/esys_tr.c:321:Esys_TR_FromTPMPublic() Error TR FromTPMPublic ErrorCode (0x00000184) 
Could not read private key from handle:?pass
1020FAB6:error:4180000C:tpm2::cannot load key::-1:388 tpm:handle(1):value is out of range or is not correct for the context
pkeyutl: Error initializing context
FAIL test/rsa_createak_auth.sh (exit status: 1)

FAIL: test/rsa_createak_sign_object
===================================

Starting /home/pi/tpm/tpm2-openssl/test/rsa_createak_sign_object.sh
+ echo -n abcde12345abcde12345
+ tpm2_createek -G rsa -c ek_rsa.ctx
+ tpm2_createak -C ek_rsa.ctx -G rsa -g sha256 -s rsassa -c ak_rsa.ctx
loaded-key:
  name: 000bb1fb58fe88a9ab868bdcd8bc8585390145323e876ae75837e4f0f6095f56c567
  qualified name: 000bf6a56de169921631753395239aed47fee32a8ed48272ba2ca09a0caff8faba3b
++ tpm2_evictcontrol -c ak_rsa.ctx -o ak_rsa.obj
++ cut -d ' ' -f 2
++ head -n 1
WARNING:esys:src/tss2-esys/api/Esys_EvictControl.c:330:Esys_EvictControl_Finish() Received TPM Error 
ERROR:esys:src/tss2-esys/api/Esys_EvictControl.c:114:Esys_EvictControl() Esys Finish ErrorCode (0x0000014b) 
ERROR: Esys_EvictControl(0x14B) - tpm:error(2.0): insufficient space for NV allocation
ERROR:esys:src/tss2-esys/esys_tr.c:357:Esys_TR_Close() Error: Esys handle does not exist (70018). 
ERROR: Esys_TR_Close(0x70018) - esapi:The ESYS_TR resource object is bad
ERROR: Unable to run tpm2_evictcontrol
+ HANDLE=
+ openssl pkeyutl -provider tpm2 -inkey object:ak_rsa.obj -sign -rawin -in testdata -out testdata.sig
free(): invalid pointer
/home/pi/tpm/tpm2-openssl/test/rsa_createak_sign_object.sh: line 17:  8320 Aborted                 openssl pkeyutl -provider tpm2 -inkey object:ak_rsa.obj -sign -rawin -in testdata -out testdata.sig
FAIL test/rsa_createak_sign_object.sh (exit status: 134)

FAIL: test/rsa_createak_sign_handle
===================================

Starting /home/pi/tpm/tpm2-openssl/test/rsa_createak_sign_handle.sh
+ echo -n abcde12345abcde12345
+ tpm2_createek -G rsa -c ek_rsa.ctx
+ tpm2_createak -C ek_rsa.ctx -G rsa -g sha256 -s rsassa -c ak_rsa.ctx
loaded-key:
  name: 000bfdbaa23ffe6eed72eee53fa35c0f65abee2df2784656c13bd81a70a3ee6a695e
  qualified name: 000b86a68b37a7f837b4d217fa098353bfe2468d41edca0e563ec46935fa7e7e8873
++ tpm2_evictcontrol -c ak_rsa.ctx
++ cut -d ' ' -f 2
++ head -n 1
WARNING:esys:src/tss2-esys/api/Esys_EvictControl.c:330:Esys_EvictControl_Finish() Received TPM Error 
ERROR:esys:src/tss2-esys/api/Esys_EvictControl.c:114:Esys_EvictControl() Esys Finish ErrorCode (0x0000014b) 
ERROR: Esys_EvictControl(0x14B) - tpm:error(2.0): insufficient space for NV allocation
ERROR:esys:src/tss2-esys/esys_tr.c:357:Esys_TR_Close() Error: Esys handle does not exist (70018). 
ERROR: Esys_TR_Close(0x70018) - esapi:The ESYS_TR resource object is bad
ERROR: Unable to run tpm2_evictcontrol
+ HANDLE=
+ openssl pkeyutl -provider tpm2 -inkey handle: -sign -rawin -in testdata -out testdata.sig
WARNING:esys:src/tss2-esys/api/Esys_ReadPublic.c:320:Esys_ReadPublic_Finish() Received TPM Error 
ERROR:esys:src/tss2-esys/esys_tr.c:231:Esys_TR_FromTPMPublic_Finish() Error ReadPublic ErrorCode (0x00000184) 
ERROR:esys:src/tss2-esys/esys_tr.c:321:Esys_TR_FromTPMPublic() Error TR FromTPMPublic ErrorCode (0x00000184) 
Could not read private key from handle:
10D0FDB6:error:4180000C:tpm2::cannot load key::-1:388 tpm:handle(1):value is out of range or is not correct for the context
pkeyutl: Error initializing context
FAIL test/rsa_createak_sign_handle.sh (exit status: 1)

FAIL: test/rsa_create_decrypt
=============================

Starting /home/pi/tpm/tpm2-openssl/test/rsa_create_decrypt.sh
+ echo -n abcde12345abcde12345
+ tpm2_createprimary -c primary.ctx
name-alg:
  value: sha256
  raw: 0xb
attributes:
  value: fixedtpm|fixedparent|sensitivedataorigin|userwithauth|restricted|decrypt
  raw: 0x30072
type:
  value: rsa
  raw: 0x1
exponent: 65537
bits: 2048
scheme:
  value: null
  raw: 0x10
scheme-halg:
  value: (null)
  raw: 0x0
sym-alg:
  value: aes
  raw: 0x6
sym-mode:
  value: cfb
  raw: 0x43
sym-keybits: 128
rsa: cf2fa386b18626faf46c9a0fc515e8c50e69299d57ff31fd359581711621e3a613078c2be2a0cc506f74aa110bc62c06cd393cbe392b1eedec61e7edf901295916f98b1b585cf3506ff420370b6ed1e2a10c8fa9623cea6af0b50946088e95f7926ad469a4441201c1a91983d2bf461d396544b9fd8a1baa951b94ba8bc02c4a0b84586ef6d7cf6ac8efd995d5f12b2e2cc692d489fdea18accc64658afb78f78981f3156c69031bea44daa9f5a6ca22280b0249429e81f492bc9a66e7b33ddba394e0a3a0aaf399cdd746b40cadc838ee32176816870041ae8b78295dc52d27815d1e0d0dbfea885ceaf29bd60f7af302fd4f6e5d73126276fce0af3996ab17
+ tpm2_create -C primary.ctx -u key.pub -r key.priv
name-alg:
  value: sha256
  raw: 0xb
attributes:
  value: fixedtpm|fixedparent|sensitivedataorigin|userwithauth|decrypt|sign
  raw: 0x60072
type:
  value: rsa
  raw: 0x1
exponent: 65537
bits: 2048
scheme:
  value: null
  raw: 0x10
scheme-halg:
  value: (null)
  raw: 0x0
sym-alg:
  value: null
  raw: 0x10
sym-mode:
  value: (null)
  raw: 0x0
sym-keybits: 0
rsa: b5ae48592296eb7b2b40d40d9cba838ee70a6b23590b793599ef3a3be12799fd06c5bc062572484c477335df8d4fa9ac629a8908eb693f97785a9d4978deb1c9eb7cd6abb21572aee77ea53f2016ad05d6063f4a054b322c39d6e9e380f72fea789d99115d3a37751d4a5a3c950576a04ee0df11606daadb498c481d7488ef0141875e319d98d4eeea0bfacbc5f0d58d91e497ee4acb319dcf996017f1c44d5feeae49c9d4d9cb4a86248e5a67917ba3cd360e23df247a6153cadafbfac752ce3b40b4aad26a986b2f2e3e55557189967f4396bc954225f26b1bb58e38e1f3e8522726fea2cb8ddf400b138ba6f0e8b3ab3d9ac9e43018b7555557580430f861
+ tpm2_load -C primary.ctx -u key.pub -r key.priv -c testkey.ctx
name: 000b11cf5fcf4b335faec067e31cd5c83f3114b1b3c8197296bcf18e9faceacd8d2c
++ tpm2_evictcontrol -c testkey.ctx
++ cut -d ' ' -f 2
++ head -n 1
WARNING:esys:src/tss2-esys/api/Esys_EvictControl.c:330:Esys_EvictControl_Finish() Received TPM Error 
ERROR:esys:src/tss2-esys/api/Esys_EvictControl.c:114:Esys_EvictControl() Esys Finish ErrorCode (0x0000014b) 
ERROR: Esys_EvictControl(0x14B) - tpm:error(2.0): insufficient space for NV allocation
ERROR:esys:src/tss2-esys/esys_tr.c:357:Esys_TR_Close() Error: Esys handle does not exist (70018). 
ERROR: Esys_TR_Close(0x70018) - esapi:The ESYS_TR resource object is bad
ERROR: Unable to run tpm2_evictcontrol
+ HANDLE=
+ openssl pkey -provider tpm2 -in handle: -pubout -out testkey.pub
WARNING:esys:src/tss2-esys/api/Esys_ReadPublic.c:320:Esys_ReadPublic_Finish() Received TPM Error 
ERROR:esys:src/tss2-esys/esys_tr.c:231:Esys_TR_FromTPMPublic_Finish() Error ReadPublic ErrorCode (0x00000184) 
ERROR:esys:src/tss2-esys/esys_tr.c:321:Esys_TR_FromTPMPublic() Error TR FromTPMPublic ErrorCode (0x00000184) 
Could not read key from handle:
1050FDB6:error:4180000C:tpm2::cannot load key::-1:388 tpm:handle(1):value is out of range or is not correct for the context
FAIL test/rsa_create_decrypt.sh (exit status: 1)

FAIL: test/rsa_genpkey_x509_cert
================================

Starting /home/pi/tpm/tpm2-openssl/test/rsa_genpkey_x509_cert.sh
+ cat
+ openssl req -provider tpm2 -x509 -sigopt pad-mode:pss -config testcert.conf -out testcert.pem
free(): invalid pointer
/home/pi/tpm/tpm2-openssl/test/rsa_genpkey_x509_cert.sh: line 19:  8476 Aborted                 openssl req -provider tpm2 -x509 -sigopt pad-mode:pss -config testcert.conf -out testcert.pem
FAIL test/rsa_genpkey_x509_cert.sh (exit status: 134)

FAIL: test/rsa_genpkey_tls_server
=================================

Starting /home/pi/tpm/tpm2-openssl/test/rsa_genpkey_tls_server.sh
+ cat
+ openssl req -provider tpm2 -x509 -config testcert.conf -out testcert.pem
free(): invalid pointer
/home/pi/tpm/tpm2-openssl/test/rsa_genpkey_tls_server.sh: line 33:  8491 Aborted                 openssl req -provider tpm2 -x509 -config testcert.conf -out testcert.pem
FAIL test/rsa_genpkey_tls_server.sh (exit status: 134)

FAIL: test/rsa_createak_x509_csr
================================

Starting /home/pi/tpm/tpm2-openssl/test/rsa_createak_x509_csr.sh
+ tpm2_createek -G rsa -c ek_rsa.ctx
+ tpm2_createak -C ek_rsa.ctx -G rsa -g sha256 -s rsassa -c ak_rsa.ctx
loaded-key:
  name: 000bf694d82bff2a473aa23f9d31d2f20e9ea140bb4e5b82c8f4c2683e0a4bb8037d
  qualified name: 000b439ed7c9e74c59aba3148f75f3dcb5ec77706db1e63336cd720e3a2150ec7da3
++ tpm2_evictcontrol -c ak_rsa.ctx
++ cut -d ' ' -f 2
++ head -n 1
WARNING:esys:src/tss2-esys/api/Esys_EvictControl.c:330:Esys_EvictControl_Finish() Received TPM Error 
ERROR:esys:src/tss2-esys/api/Esys_EvictControl.c:114:Esys_EvictControl() Esys Finish ErrorCode (0x0000014b) 
ERROR: Esys_EvictControl(0x14B) - tpm:error(2.0): insufficient space for NV allocation
ERROR:esys:src/tss2-esys/esys_tr.c:357:Esys_TR_Close() Error: Esys handle does not exist (70018). 
ERROR: Esys_TR_Close(0x70018) - esapi:The ESYS_TR resource object is bad
ERROR: Unable to run tpm2_evictcontrol
+ HANDLE=
+ cat
+ openssl req -provider tpm2 -new -config testcert.conf -key handle: -out testcsr.pem
WARNING:esys:src/tss2-esys/api/Esys_ReadPublic.c:320:Esys_ReadPublic_Finish() Received TPM Error 
ERROR:esys:src/tss2-esys/esys_tr.c:231:Esys_TR_FromTPMPublic_Finish() Error ReadPublic ErrorCode (0x00000184) 
ERROR:esys:src/tss2-esys/esys_tr.c:321:Esys_TR_FromTPMPublic() Error TR FromTPMPublic ErrorCode (0x00000184) 
Could not read private key from handle:
10B0F7B6:error:4180000C:tpm2::cannot load key::-1:388 tpm:handle(1):value is out of range or is not correct for the context
FAIL test/rsa_createak_x509_csr.sh (exit status: 1)

FAIL: test/rsapss_genpkey_sign_rawin
====================================

Starting /home/pi/tpm/tpm2-openssl/test/rsapss_genpkey_sign_rawin.sh
+ echo -n abcde12345abcde12345
+ for HASH in sha1 sha256 sha384 sha512
+ tpm2_getcap algorithms
+ grep sha1
sha1:
+ openssl genpkey -provider tpm2 -algorithm RSA-PSS -pkeyopt bits:1024 -pkeyopt digest:sha1 -out testkey.priv
free(): invalid pointer
/home/pi/tpm/tpm2-openssl/test/rsapss_genpkey_sign_rawin.sh: line 7:  8537 Aborted                 openssl genpkey -provider tpm2 -algorithm RSA-PSS -pkeyopt bits:1024 -pkeyopt digest:$HASH -out testkey.priv
FAIL test/rsapss_genpkey_sign_rawin.sh (exit status: 134)

FAIL: test/rsapss_createak_tls_server
=====================================

Starting /home/pi/tpm/tpm2-openssl/test/rsapss_createak_tls_server.sh
+ tpm2_createek -G rsa -c ek_rsa.ctx
+ tpm2_createak -C ek_rsa.ctx -G rsa -g sha256 -s rsapss -c ak_rsa.ctx
loaded-key:
  name: 000b66f1d3447960e1c86ba4d3066215a2c9e9ec38a3c9a7b703d4d359865a963903
  qualified name: 000b182bb6ac268450ee9a8df29d908a5bf98a667889645e030a3da234852fe75331
++ tpm2_evictcontrol -c ak_rsa.ctx
++ cut -d ' ' -f 2
++ head -n 1
WARNING:esys:src/tss2-esys/api/Esys_EvictControl.c:330:Esys_EvictControl_Finish() Received TPM Error 
ERROR:esys:src/tss2-esys/api/Esys_EvictControl.c:114:Esys_EvictControl() Esys Finish ErrorCode (0x0000014b) 
ERROR: Esys_EvictControl(0x14B) - tpm:error(2.0): insufficient space for NV allocation
ERROR:esys:src/tss2-esys/esys_tr.c:357:Esys_TR_Close() Error: Esys handle does not exist (70018). 
ERROR: Esys_TR_Close(0x70018) - esapi:The ESYS_TR resource object is bad
ERROR: Unable to run tpm2_evictcontrol
+ HANDLE=
+ cat
+ openssl req -provider tpm2 -x509 -config testcert.conf -key handle: -out testcert.pem
WARNING:esys:src/tss2-esys/api/Esys_ReadPublic.c:320:Esys_ReadPublic_Finish() Received TPM Error 
ERROR:esys:src/tss2-esys/esys_tr.c:231:Esys_TR_FromTPMPublic_Finish() Error ReadPublic ErrorCode (0x00000184) 
ERROR:esys:src/tss2-esys/esys_tr.c:321:Esys_TR_FromTPMPublic() Error TR FromTPMPublic ErrorCode (0x00000184) 
Could not read private key from handle:
1060F1B6:error:4180000C:tpm2::cannot load key::-1:388 tpm:handle(1):value is out of range or is not correct for the context
FAIL test/rsapss_createak_tls_server.sh (exit status: 1)

FAIL: test/rsa_pki/rsa_pki
==========================

Starting /home/pi/tpm/tpm2-openssl/test/rsa_pki/rsa_pki.sh
++ dirname /home/pi/tpm/tpm2-openssl/test/rsa_pki/rsa_pki.sh
+ export PKIDIR=/home/pi/tpm/tpm2-openssl/test/rsa_pki
+ PKIDIR=/home/pi/tpm/tpm2-openssl/test/rsa_pki
+ mkdir -p testdb/ca/root-ca/private testdb/ca/root-ca/db testdb/crl testdb/certs
+ chmod 700 testdb/ca/root-ca/private
+ cp /dev/null testdb/ca/root-ca/db/root-ca.db
+ cp /dev/null testdb/ca/root-ca/db/root-ca.db.attr
+ echo 01
+ echo 01
+ openssl req -provider tpm2 -new -config /home/pi/tpm/tpm2-openssl/test/rsa_pki/etc/root-ca.conf -out testdb/ca/root-ca.csr -keyout testdb/ca/root-ca/private/root-ca.key
free(): invalid pointer
/home/pi/tpm/tpm2-openssl/test/rsa_pki/rsa_pki.sh: line 30:  8596 Aborted                 openssl req -provider tpm2 -new -config $PKIDIR/etc/root-ca.conf -out testdb/ca/root-ca.csr -keyout testdb/ca/root-ca/private/root-ca.key
FAIL test/rsa_pki/rsa_pki.sh (exit status: 134)

FAIL: test/ec_genpkey_check
===========================

Starting /home/pi/tpm/tpm2-openssl/test/ec_genpkey_check.sh
+ openssl genpkey -provider tpm2 -algorithm EC -pkeyopt group:P-256 -out testkey.pem
free(): invalid pointer
/home/pi/tpm/tpm2-openssl/test/ec_genpkey_check.sh: line 5:  8610 Aborted                 openssl genpkey -provider tpm2 -algorithm EC -pkeyopt group:P-256 -out testkey.pem
FAIL test/ec_genpkey_check.sh (exit status: 134)

FAIL: test/ec_genpkey_parameters
================================

Starting /home/pi/tpm/tpm2-openssl/test/ec_genpkey_parameters.sh
+ openssl ecparam -name prime256v1 -out testparam.pem
+ openssl genpkey -provider tpm2 -paramfile testparam.pem -out testkey.pem
free(): invalid pointer
/home/pi/tpm/tpm2-openssl/test/ec_genpkey_parameters.sh: line 8:  8625 Aborted                 openssl genpkey -provider tpm2 -paramfile testparam.pem -out testkey.pem
FAIL test/ec_genpkey_parameters.sh (exit status: 134)

FAIL: test/ecdsa_genpkey_auth
=============================

Starting /home/pi/tpm/tpm2-openssl/test/ecdsa_genpkey_auth.sh
+ echo -n abcde12345abcde12345abcde12345ab
+ openssl genpkey -provider tpm2 -algorithm EC -pkeyopt group:P-256 -pkeyopt user-auth:abc -pkeyopt digest:sha256 -out testkey.priv
free(): invalid pointer
/home/pi/tpm/tpm2-openssl/test/ecdsa_genpkey_auth.sh: line 9:  8639 Aborted                 openssl genpkey -provider tpm2 -algorithm EC -pkeyopt group:P-256 -pkeyopt user-auth:abc -pkeyopt digest:sha256 -out testkey.priv
FAIL test/ecdsa_genpkey_auth.sh (exit status: 134)

FAIL: test/ecdsa_genpkey_sign_rawin
===================================

Starting /home/pi/tpm/tpm2-openssl/test/ecdsa_genpkey_sign_rawin.sh
+ echo -n abcde12345abcde12345
+ openssl genpkey -provider tpm2 -algorithm EC -pkeyopt group:P-256 -out testkey.priv
free(): invalid pointer
/home/pi/tpm/tpm2-openssl/test/ecdsa_genpkey_sign_rawin.sh: line 7:  8653 Aborted                 openssl genpkey -provider tpm2 -algorithm EC -pkeyopt group:P-256 -out testkey.priv
FAIL test/ecdsa_genpkey_sign_rawin.sh (exit status: 134)

FAIL: test/ecdsa_createak_sign_handle
=====================================

Starting /home/pi/tpm/tpm2-openssl/test/ecdsa_createak_sign_handle.sh
+ echo -n abcde12345abcde12345
+ tpm2_createek -G ecc -c ek_rsa.ctx
+ tpm2_createak -C ek_rsa.ctx -G ecc -g sha256 -s ecdsa -c ak_rsa.ctx
loaded-key:
  name: 000b9341cbbf4044a89fa30b45585d78fd697a2c95376535a0a1e1e960d1650062f3
  qualified name: 000bb402b14879dd4351898b4060eeb332fc21198b8c697dbe31fe5c578ae04bc75e
++ tpm2_evictcontrol -c ak_rsa.ctx
++ cut -d ' ' -f 2
++ head -n 1
WARNING:esys:src/tss2-esys/api/Esys_EvictControl.c:330:Esys_EvictControl_Finish() Received TPM Error 
ERROR:esys:src/tss2-esys/api/Esys_EvictControl.c:114:Esys_EvictControl() Esys Finish ErrorCode (0x0000014b) 
ERROR: Esys_EvictControl(0x14B) - tpm:error(2.0): insufficient space for NV allocation
ERROR:esys:src/tss2-esys/esys_tr.c:357:Esys_TR_Close() Error: Esys handle does not exist (70018). 
ERROR: Esys_TR_Close(0x70018) - esapi:The ESYS_TR resource object is bad
ERROR: Unable to run tpm2_evictcontrol
+ HANDLE=
+ openssl pkeyutl -provider tpm2 -inkey handle: -sign -rawin -in testdata -out testdata.sig
WARNING:esys:src/tss2-esys/api/Esys_ReadPublic.c:320:Esys_ReadPublic_Finish() Received TPM Error 
ERROR:esys:src/tss2-esys/esys_tr.c:231:Esys_TR_FromTPMPublic_Finish() Error ReadPublic ErrorCode (0x00000184) 
ERROR:esys:src/tss2-esys/esys_tr.c:321:Esys_TR_FromTPMPublic() Error TR FromTPMPublic ErrorCode (0x00000184) 
Could not read private key from handle:
10D0F8B6:error:4180000C:tpm2::cannot load key::-1:388 tpm:handle(1):value is out of range or is not correct for the context
pkeyutl: Error initializing context
FAIL test/ecdsa_createak_sign_handle.sh (exit status: 1)

FAIL: test/ecdh_genpkey_keyexch
===============================

Starting /home/pi/tpm/tpm2-openssl/test/ecdh_genpkey_keyexch.sh
+ openssl genpkey -provider tpm2 -algorithm EC -pkeyopt group:P-256 -out testkey1.priv
free(): invalid pointer
/home/pi/tpm/tpm2-openssl/test/ecdh_genpkey_keyexch.sh: line 5:  8693 Aborted                 openssl genpkey -provider tpm2 -algorithm EC -pkeyopt group:P-256 -out testkey1.priv
FAIL test/ecdh_genpkey_keyexch.sh (exit status: 134)

FAIL: test/ec_createak_x509_csr
===============================

Starting /home/pi/tpm/tpm2-openssl/test/ec_createak_x509_csr.sh
+ tpm2_createek -G ecc -c ek_rsa.ctx
+ tpm2_createak -C ek_rsa.ctx -G ecc -g sha256 -s ecdsa -c ak_rsa.ctx
loaded-key:
  name: 000bc88e902d51af8e956f465d9e94ebf1078eec076f11c84f0f74a3ee4f600fc70d
  qualified name: 000bed99366c747b18c017de48dce41c02edc5bdcfff12b92c6e4b24eedcff022d2d
++ tpm2_evictcontrol -c ak_rsa.ctx
++ cut -d ' ' -f 2
++ head -n 1
WARNING:esys:src/tss2-esys/api/Esys_EvictControl.c:330:Esys_EvictControl_Finish() Received TPM Error 
ERROR:esys:src/tss2-esys/api/Esys_EvictControl.c:114:Esys_EvictControl() Esys Finish ErrorCode (0x0000014b) 
ERROR: Esys_EvictControl(0x14B) - tpm:error(2.0): insufficient space for NV allocation
ERROR:esys:src/tss2-esys/esys_tr.c:357:Esys_TR_Close() Error: Esys handle does not exist (70018). 
ERROR: Esys_TR_Close(0x70018) - esapi:The ESYS_TR resource object is bad
ERROR: Unable to run tpm2_evictcontrol
+ HANDLE=
+ cat
+ openssl req -provider tpm2 -new -config testcert.conf -key handle: -out testcsr.pem
WARNING:esys:src/tss2-esys/api/Esys_ReadPublic.c:320:Esys_ReadPublic_Finish() Received TPM Error 
ERROR:esys:src/tss2-esys/esys_tr.c:231:Esys_TR_FromTPMPublic_Finish() Error ReadPublic ErrorCode (0x00000184) 
ERROR:esys:src/tss2-esys/esys_tr.c:321:Esys_TR_FromTPMPublic() Error TR FromTPMPublic ErrorCode (0x00000184) 
Could not read private key from handle:
10C0FDB6:error:4180000C:tpm2::cannot load key::-1:388 tpm:handle(1):value is out of range or is not correct for the context
FAIL test/ec_createak_x509_csr.sh (exit status: 1)

FAIL: test/ec_genpkey_tls_server
================================

Starting /home/pi/tpm/tpm2-openssl/test/ec_genpkey_tls_server.sh
+ cat
+ openssl req -provider tpm2 -x509 -config testcert.conf -new -newkey ec -pkeyopt group:P-256 -out testcert.pem
free(): invalid pointer
/home/pi/tpm/tpm2-openssl/test/ec_genpkey_tls_server.sh: line 32:  8735 Aborted                 openssl req -provider tpm2 -x509 -config testcert.conf -new -newkey ec -pkeyopt group:P-256 -out testcert.pem
FAIL test/ec_genpkey_tls_server.sh (exit status: 134)

FAIL: test/ec_pki/ec_pki
========================

Starting /home/pi/tpm/tpm2-openssl/test/ec_pki/ec_pki.sh
++ dirname /home/pi/tpm/tpm2-openssl/test/ec_pki/ec_pki.sh
+ export PKIDIR=/home/pi/tpm/tpm2-openssl/test/ec_pki
+ PKIDIR=/home/pi/tpm/tpm2-openssl/test/ec_pki
+ tpm2_getcap algorithms
+ grep TPM2_ECC_NIST_P384
+ CURVE=secp256r1
+ mkdir -p testdb/root/certs testdb/root/crl testdb/root/csr testdb/root/newcerts testdb/root/private testdb/intermediate/certs testdb/intermediate/crl testdb/intermediate/csr testdb/intermediate/newcerts testdb/intermediate/private
+ mkdir -p testdb/client/certs testdb/client/csr testdb/client/pfx testdb/client/private testdb/server/certs testdb/server/csr testdb/server/pfx testdb/server/private
+ touch testdb/root/database testdb/intermediate/database
+ echo 1000
+ tee testdb/root/serial testdb/root/crlnumber testdb/intermediate/serial testdb/intermediate/crlnumber
1000
+ chmod 700 testdb/root/private testdb/intermediate/private testdb/client/private testdb/server/private
+ openssl ecparam -provider tpm2 -name secp256r1 -genkey -out testdb/root/private/root.key.pem
using curve name prime256v1 instead of secp256r1
free(): invalid pointer
/home/pi/tpm/tpm2-openssl/test/ec_pki/ec_pki.sh: line 21:  8760 Aborted                 openssl ecparam -provider tpm2 -name $CURVE -genkey -out testdb/root/private/root.key.pem
FAIL test/ec_pki/ec_pki.sh (exit status: 134)

FAIL: test/digest
=================

Starting /home/pi/tpm/tpm2-openssl/test/digest.sh
+ echo -n abcde12345abcde12345
+ for HASH in sha1 sha256 sha384 sha512
+ tpm2_getcap algorithms
+ grep sha1
sha1:
+ openssl dgst -provider tpm2 -sha1 -out digest1 testdata
free(): invalid pointer
/home/pi/tpm/tpm2-openssl/test/digest.sh: line 6:  8820 Aborted                 openssl dgst -provider tpm2 -$HASH -out digest1 testdata
FAIL test/digest.sh (exit status: 134)

SKIP: test/cipher_aes128_ecb
============================

Starting /home/pi/tpm/tpm2-openssl/test/cipher_aes128_ecb.sh
+ tpm2_getcap commands
+ grep EncryptDecrypt
+ exit 77
SKIP test/cipher_aes128_ecb.sh (exit status: 77)

SKIP: test/cipher_aes128_cbc
============================

Starting /home/pi/tpm/tpm2-openssl/test/cipher_aes128_cbc.sh
+ tpm2_getcap commands
+ grep EncryptDecrypt
+ exit 77
SKIP test/cipher_aes128_cbc.sh (exit status: 77)

SKIP: test/cipher_aes256
========================

Starting /home/pi/tpm/tpm2-openssl/test/cipher_aes256.sh
+ tpm2_getcap commands
+ grep EncryptDecrypt
+ exit 77
SKIP test/cipher_aes256.sh (exit status: 77)

SKIP: test/cipher_aes256_nopad
==============================

Starting /home/pi/tpm/tpm2-openssl/test/cipher_aes256_nopad.sh
+ tpm2_getcap commands
+ grep EncryptDecrypt
+ exit 77
SKIP test/cipher_aes256_nopad.sh (exit status: 77)

SKIP: test/cipher_camellia128
=============================

Starting /home/pi/tpm/tpm2-openssl/test/cipher_camellia128.sh
+ tpm2_getcap commands
+ grep EncryptDecrypt
+ exit 77
SKIP test/cipher_camellia128.sh (exit status: 77)
gotthardp commented 3 years ago

Thanks for trying it. Please use the latest openssl master, not the tagged alfa release. There was a bug in openssl fixed today and my latest commit relies on that.

ViSilver commented 3 years ago

Thank you for the reply. Will try with the latest master of openssl.