Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tpm2-ptool import error #853

Open
MrDuartePT opened this issue Dec 17, 2023 · 2 comments
Open

tpm2-ptool import error #853

MrDuartePT opened this issue Dec 17, 2023 · 2 comments

Comments

@MrDuartePT
Copy link

MrDuartePT commented Dec 17, 2023

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'
@k1gen
Copy link

k1gen commented Apr 15, 2024

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

@billohanlon
Copy link

billohanlon commented Jun 14, 2024

Re: RSAPrivateNumbers error
Me, too.

Works fine on one machine, always fails on another. Both are running the same distro, Debian bookworm.

I'm damned if I can see the difference between the two systems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants