---
name: "Tspi_Key_CreateKey"
section: "3"
platform: "linux"
package: "libtspi-dev"
version: "0.3.15-0.4"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Tspi_Key_CreateKey"
---

# Tspi\_Key\_CreateKey(3)

create a key pair within the TPM, wrapping it with the key addressed by hWrappingKey.

## NAME

Tspi\_Key\_CreateKey - create a key pair within the TPM, wrapping it with the key addressed by hWrappingKey.

## SYNOPSIS

**#include \<tss/platform.h\>** **#include \<tss/tcpa\_defines.h\>** **#include \<tss/tcpa\_typedef.h\>** **#include \<tss/tcpa\_struct.h\>** **#include \<tss/tss\_typedef.h\>** **#include \<tss/tss\_structs.h\>** **#include \<tss/tspi.h\>** **TSS\_RESULT Tspi\_Key\_CreateKey(TSS\_HKEY** *hKey***, TSS\_HKEY** *hWrappingKey***, TSS\_HPCRS** *hPcrComposite***);**

## DESCRIPTION

**TSS\_Key\_CreateKey**   calls the TPM command TPM\_CreateWrapKey. If hPcrComposite is not set to NULL, the created key blob is bound to this PCR values. The key object addressed by hKey must contain the key information needed for the creation.

## PARAMETERS

### hKey

The handle of the key object to create.

### hWrappingKey

The handle to the key used to wrap the newly created key.

### hPcrComposite

The handle to an object, if the value of the handle doesn't equal NULL, the newly create key will be bound ot the PCR values described with this object.

## RETURN CODES

**Tspi\_Key\_CreateKey** returns TSS\_SUCCESS on success, otherwise one of the following values are returned: TSS\_E\_INVALID\_HANDLE - Either *hKey*, *hWrappingKey* or *hPcrComposite* are invalid parameters. TSS\_E\_INTERNAL\_ERROR - An error occurred internal to the TSS.

## CONFORMING TO

**Tspi\_Key\_CreateKey** conforms to the Trusted Computing Group Software Specification version 1.1 Golden

## SEE ALSO

[**Tspi\_Key\_WrapKey**(3)](/Tspi_Key_WrapKey/3.md), [**Tspi\_Key\_CertifyKey**(3)](/Tspi_Key_CertifyKey/3.md), **Tspi\_Key\_RegisterKey**(3).
