tpm2-pkcs11 icon indicating copy to clipboard operation
tpm2-pkcs11 copied to clipboard

tpm2-ptool import error

Open MrDuartePT opened this issue 6 months ago • 2 comments

When I try to import my new created ssh key with ou withouth password I allways get this error:

Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.11/tpm2_ptool", line 6, in <module>
    tool.main()
  File "/usr/lib/python3.11/site-packages/tpm2_pkcs11/tpm2_ptool.py", line 26, in main
    commandlet.init('A tool for manipulating the tpm2-pkcs11 database')
  File "/usr/lib/python3.11/site-packages/tpm2_pkcs11/command.py", line 102, in init
    commandlet.get()[d['which']](d)
  File "/usr/lib/python3.11/site-packages/tpm2_pkcs11/commandlets_keys.py", line 265, in __call__
    objects = super(ImportCommand, self).__call__(args)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/tpm2_pkcs11/commandlets_keys.py", line 202, in __call__
    tertiarypriv, tertiarypub, tertiarypubdata = self.new_key_create(
                                                 ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/tpm2_pkcs11/commandlets_keys.py", line 255, in new_key_create
    tertiarypriv, tertiarypub, tertiarypubdata = tpm2.importkey(
                                                 ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/tpm2_pkcs11/tpm2.py", line 353, in importkey
    raise RuntimeError("Could not execute tpm2_import: %s" %
RuntimeError: Could not execute tpm2_import: b'INFO on line: "45" in file: "lib/tpm2_capability.c": GetCapability: capability: 0x0, property: 0x0\nINFO on line: "430" in file: "lib/files.c": Assuming tpm context file\nWARNING:esys:/var/tmp/portage/app-crypt/tpm2-tss-4.0.1/work/tpm2-tss-4.0.1/src/tss2-esys/api/Esys_Import.c:323:Esys_Import_Finish() Received TPM Error \nERROR:esys:/var/tmp/portage/app-crypt/tpm2-tss-4.0.1/work/tpm2-tss-4.0.1/src/tss2-esys/api/Esys_Import.c:110:Esys_Import() Esys Finish ErrorCode (0x000002e6) \nERROR on line: "53" in file: "lib/log.h": Esys_HMAC(0x2E6) - tpm:parameter(2):curve not supported\nERROR on line: "274" in file: "tools/tpm2_tool.c": Unable to run tpm2_import\n'
mrduarte@GentooLegion ~ $ tpm2_ptool import --label sshtpm --key-label aur --userpin 158916 --privkey /tmp/sshkeys/aur
command: tpm2_import -V -C /tmp/tmpv9jumbwv/primary.handle -i /tmp/sshkeys/aur -u /tmp/tmpv9jumbwv/qcc_0row.pub -r /tmp/tmpv9jumbwv/voyxr7ou.priv -p 00987f3bd3ebfff2c7fadb37709341b7 -G ecc
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.11/tpm2_ptool", line 6, in <module>
    tool.main()
  File "/usr/lib/python3.11/site-packages/tpm2_pkcs11/tpm2_ptool.py", line 26, in main
    commandlet.init('A tool for manipulating the tpm2-pkcs11 database')
  File "/usr/lib/python3.11/site-packages/tpm2_pkcs11/command.py", line 102, in init
    commandlet.get()[d['which']](d)
  File "/usr/lib/python3.11/site-packages/tpm2_pkcs11/commandlets_keys.py", line 265, in __call__
    objects = super(ImportCommand, self).__call__(args)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/tpm2_pkcs11/commandlets_keys.py", line 202, in __call__
    tertiarypriv, tertiarypub, tertiarypubdata = self.new_key_create(
                                                 ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/tpm2_pkcs11/commandlets_keys.py", line 255, in new_key_create
    tertiarypriv, tertiarypub, tertiarypubdata = tpm2.importkey(
                                                 ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/tpm2_pkcs11/tpm2.py", line 353, in importkey
    raise RuntimeError("Could not execute tpm2_import: %s" %
RuntimeError: Could not execute tpm2_import: b'INFO on line: "45" in file: "lib/tpm2_capability.c": GetCapability: capability: 0x0, property: 0x0\nINFO on line: "430" in file: "lib/files.c": Assuming tpm context file\nWARNING:esys:/var/tmp/portage/app-crypt/tpm2-tss-4.0.1/work/tpm2-tss-4.0.1/src/tss2-esys/api/Esys_Import.c:323:Esys_Import_Finish() Received TPM Error \nERROR:esys:/var/tmp/portage/app-crypt/tpm2-tss-4.0.1/work/tpm2-tss-4.0.1/src/tss2-esys/api/Esys_Import.c:110:Esys_Import() Esys Finish ErrorCode (0x000002e6) \nERROR on line: "53" in file: "lib/log.h": Esys_HMAC(0x2E6) - tpm:parameter(2):curve not supported\nERROR on line: "274" in file: "tools/tpm2_tool.c": Unable to run tpm2_import\n'

MrDuartePT avatar Dec 17 '23 20:12 MrDuartePT

I have a similar error from just running tpm2_ptool:

$ tpm2_ptool
Traceback (most recent call last):
  File "/usr/bin/tpm2_ptool", line 5, in <module>
    from tpm2_pkcs11.tpm2_ptool import main
  File "/usr/lib/python3.11/site-packages/tpm2_pkcs11/tpm2_ptool.py", line 6, in <module>
    from .commandlets_store import InitCommand  # pylint: disable=unused-import # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/tpm2_pkcs11/commandlets_store.py", line 13, in <module>
    from .utils import bytes_to_file
  File "/usr/lib/python3.11/site-packages/tpm2_pkcs11/utils.py", line 21, in <module>
    from tpm2_pytss.ESAPI import ESAPI
  File "/usr/lib/python3.11/site-packages/tpm2_pytss/__init__.py", line 2, in <module>
    from .ESAPI import ESAPI
  File "/usr/lib/python3.11/site-packages/tpm2_pytss/ESAPI.py", line 2, in <module>
    from .types import *
  File "/usr/lib/python3.11/site-packages/tpm2_pytss/types.py", line 24, in <module>
    from tpm2_pytss.internal.crypto import (
  File "/usr/lib/python3.11/site-packages/tpm2_pytss/internal/crypto.py", line 223, in <module>
    class _MyRSAPrivateNumbers(rsa.RSAPrivateNumbers):
TypeError: type 'cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateNumbers' is not an acceptable base type
$ pacman -Q | grep 'pytss|cryptography|tpm2'
python-cryptography 42.0.5-1
python-tpm2-pytss 2.1.0-3
tpm2-openssl 1.2.0-1
tpm2-pkcs11 1.9.0-1
tpm2-tools 5.6-1
tpm2-totp 0.3.0-2
tpm2-tss 4.0.1-1
tpm2-tss-engine 1.1.0-2

k1gen avatar Apr 15 '24 22:04 k1gen