I am trying to sign some data with a symmetric key AES128 on the TPM2. However, I get this error during the signing

ERROR: Unknown key type, got: 0x25 ERROR: bad signature scheme for key type! ERROR: Unable to run tpm2_sign

primary key creation command: tpm2_createprimary -C o -g sha256 -G rsa -c primary.ctx

AES key creation command: tpm2_create -C primary.ctx -g sha256 -G aes128 -r AESkey.prv -u AESkey.pub -a "sensitivedataorigin|userwithauth|decrypt|sign"

So, the problem as I understood is related to the signature scheme, but how can I determine a functional scheme to achieve the signing?


AES is a symmetric block cipher. Like most block ciphers, it is typically used for encrypting data, although it can be used in constructions such as CMAC (or other block cipher-based MACs) for creating message authentication codes (MACs). Since these MACs use a symmetric key, that same key is necessarily required to verify the MAC. Also, none of these block cipher-based MACs are available with tpm2_create.

While people do sometimes refer to the process of creating a MAC as "signing", more properly that term refers to algorithms that are used in digital signatures, such as RSA, ECDSA, or EdDSA. All of these algorithms are asymmetric, containing a public key and a private key. The private key is required to sign, and the public key is required to verify. There is no way to turn a symmetric key into an asymmetric key of this type.

So what you're asking to do is functionally impossible. You can't use an AES key to sign anything, since AES cannot be used to create a digital signature. Depending on your TPM, you can use several different options for signatures, as outlined in the tpm2_create(1) manual page, but AES is not one of them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.