---
name: "Tspi_Context_CreateObject"
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_Context_CreateObject"
---

# Tspi\_Context\_CreateObject(3)

create an empty object and return a handle to that object.

## NAME

Tspi\_Context\_CreateObject - create an empty object and return a handle to that object.

## 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\_Context\_CreateObject(TSS\_HCONTEXT** *hContext***,  TSS\_FLAG**     *objectType***,**                                      **TSS\_FLAG**     *initFlags***, TSS\_HOBJECT\*** *phObject***);**

## DESCRIPTION

**TSS\_Context\_CreateObject** creates and initializes an empty object of the specified type and returns a handle addressing that object. The object is bound to an already opened context *hContext*.

## PARAMETERS

### hContext

The handle of the context object.

### objectType

Flag indicating the object type to create. Possible types are: TSS\_OBJECT\_TYPE\_POLICY - a policy object. TSS\_OBJECT\_TYPE\_ENCDATA - an encrypted data object (either sealed or bound data). TSS\_OBJECT\_TYPE\_RSAKEY - an RSA key. TSS\_OBJECT\_TYPE\_PCRS - a PCR composite object. TSS\_OBJECT\_TYPE\_HASH - a hash object.

### initFlags

Flag indicating the default attributes of the object. Attributes for each type of object are: Policy:\
  **TSS\_POLICY\_USAGE** - a usage policy (for authorization to use an object).\
  **TSS\_POLICY\_MIGRATION** - a migration policy. Encrypted data objects:\
  **TSS\_ENCDATA\_SEAL** - A data object used for a Seal operation.\
  **TSS\_ENCDATA\_BIND** - A data object used for a Bind operation.\
  **TSS\_ENCDATA\_LEGACY** - A data object for a bind operation using a legacy key. RSA Keys:\
  **TSS\_KEY\_SIZE\_DEFAULT** - Use the default key size of the TCS you're connected to.\
  **TSS\_KEY\_SIZE\_512** - Create a 512 bit key.\
  **TSS\_KEY\_SIZE\_1024** - Create a 1024 bit key.\
  **TSS\_KEY\_SIZE\_2048** - Create a 2048 bit key.\
  **TSS\_KEY\_SIZE\_4096** - Create a 4096 bit key.\
  **TSS\_KEY\_SIZE\_8192** - Create a 8192 bit key.\
  **TSS\_KEY\_SIZE\_16384** - Create a 16384 bit key.\
  **TSS\_KEY\_TYPE\_STORAGE** - Create a storage key. (Used to wrap other keys).\
  **TSS\_KEY\_TYPE\_SIGNING** - Create a signing key.\
  **TSS\_KEY\_TYPE\_BIND** - Create a binding key. (Used to encrypt data).\
  **TSS\_KEY\_TYPE\_IDENTITY** - Create an identity key. (Used for an identity).\
  **TSS\_KEY\_TYPE\_LEGACY** - Create a legacy key. (Can be used for signing and binding, created from data external to a TSS).\
  **TSS\_KEY\_TYPE\_AUTHCHANGE** - Create an ephemeral key used to change authorization values.\
  **TSS\_KEY\_VOLATILE** - Create a volatile key. (Must be unloaded at startup).\
  **TSS\_KEY\_NON\_VOLATILE** - Create a non-volatile key. (May be unloaded at startup).\
  **TSS\_KEY\_MIGRATABLE** - Create a migratable key.\
  **TSS\_KEY\_NOT\_MIGRATABLE** - Create a non-migratable key. \[DEFAULT\]\
  **TSS\_KEY\_AUTHORIZATION** - Key will require authorization.\
  **TSS\_KEY\_NO\_AUTHORIZATION** - Key will not require authorization. \[DEFAULT\]\
  **TSS\_KEY\_EMPTY\_KEY** - Key template which will be returned as an object with very few attributes.

PCR composite objects:\
  None. Hash objects:\
  **TSS\_HASH\_SHA1** - a hash object of type SHA-1.\
  **TSS\_HASH\_OTHER** - a hash object of type other than SHA-1.

### phObject

The handle of the object to be created.

## RETURN CODES

**Tspi\_Context\_CreateObject** returns TSS\_SUCCESS on success, otherwise one of the following values are returned: TSS\_E\_INVALID\_HANDLE - Either *hContext* or *phObject* is an invalid handle.  TSS\_E\_INTERNAL\_ERROR - An error occurred internal to the TSS.

## CONFORMING TO

**Tspi\_Context\_CreateObject** conforms to the Trusted Computing Group Software Specification version 1.1 Golden

## SEE ALSO

[**Tspi\_Context\_CloseObject**(3)](/Tspi_Context_CloseObject/3.md).
