TSPI_CONTEXT_REGISTERKEY(3)
π Tspi_Context_RegisterKey(3) π
Library Functions Manual β¨ TCG Software Stack Developers Reference
okay bestie, we're deep in the TCG Software Stack docs now, and this one is a whole moment. sit down, hydrate, and let's get into it π«Ά
β¨ NAME β¨
Tspi_Context_RegisterKey β register a key in the TSS Persistent Storage database π
πΈ 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_RegisterKey(TSS_HCONTEXT hContext, TSS_HKEY hKey,
TSS_FLAG persistentStorageType, TSS_UUID uuidKey,
TSS_FLAG persistentStorageTypeParent, TSS_UUID uuidParentKey);
like yes, that's a lot of headers, and yes, you need all of them. we don't make the rules π
π¦ DESCRIPTION π¦
So, Tspi_Context_RegisterKey is the API that registers a key with the TSS Persistent Storage database, so that it can be loaded as necessary. it's giving "save your fave so you can summon it later" β¨
and it doesn't just drop the name in there β it also includes all the info required for loading the key, plus information about its parent key. full context, no crumbs. periodt.
π PARAMETERS π
hContext
the hContext parameter is the handle of the context object. your whole vibe starts here.
hKey
the hKey parameter is the handle of the key object addressing the key to be registered. this is the key that's getting its moment π
persistentStorageType
the persistentStorageType parameter indicates the persistent storage the key is registered in. telling us where the key lives, basically.
uuidKey
the uuidKey parameter is the UUID by which the key is registered in persistent storage. its little name tag π·οΈ
persistentStorageTypeParent
the persistentStorageTypeParent parameter indicates the persistent storage that the parent key is registered in. yes, the parent gets its own storage-type argument. family matters π
uuidParentKey
the uuidParentKey parameter is the UUID by which the parent key is registered in persistent storage. the parent's name tag, separately specified, because of course.
π RETURN CODES π
Tspi_Context_RegisterKey returns TSS_SUCCESS on success β slay β otherwise one of the following values is returned:
TSS_E_INVALID_HANDLEβhContextis not a valid handle. the handle said "not today" πTSS_E_PS_KEY_NOTFOUNDβ the key cannot be found in the persistent storage database. it's not there, bestie, we looked everywhere πTSS_E_INTERNAL_ERRORβ an internal SW error has been detected. not us, it's an internal thing πTSS_E_BAD_PARAMETERβ one or more parameters is bad. something in the argument list is misbehaving π©
π EXAMPLE π
here's the whole storyline, top to bottom:
#include <trousers/tss.h>
int
main(void)
{
TSS_FLAGS initFlags = ...;
TSS_HKEY hKey, hSRK;
TSS_UUID keyUUID = {...};
// Create a TSP handle
result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS)
Error_Path();
// Connect to the TCSD
result = Tspi_Context_Connect(hContext, GLOBALSERVER);
if (result != TSS_SUCCESS)
Error_Path();
// Create the Key Object
result = Tspi_Context_CreateObject(hContext,
TSS_OBJECT_TYPE_RSAKEY,
initFlags, &hKey);
if (result != TSS_SUCCESS)
Error_Path();
// Load parent Key by UUID
result = Tspi_Context_LoadKeyByUUID(hContext, TSS_PS_TYPE_SYSTEM,
SRK_UUID, &hSRK);
if (result != TSS_SUCCESS)
Error_Path();
// Do policy/secret handling here
result = Tspi_Key_CreateKey(hKey, hSRK, 0);
if (result != TSS_SUCCESS)
Error_Path();
// Register the Key in System PS (on the TCSD's platform)
result = Tspi_Context_RegisterKey(hContext, hKey, TSS_PS_TYPE_SYSTEM,
keyUUID, TSS_PS_TYPE_SYSTEM,
SRK_UUID);
if (result != TSS_SUCCESS)
Error_Path();
/* ...
*
* Use the key as needed, exiting the program if necessary, reloading
* the key using Tspi_Context_LoadKeyByUUID() after each restart. Once
* the key is no longer useful, unregister it from system PS as part
* of clean up.
*/
// Unregister the Key
result = Tspi_Context_UnregisterKey(hContext, TSS_PS_TYPE_SYSTEM,
migratableSignUUID, &hKey);
if (result != TSS_SUCCESS)
Error_Path();
// exit, discarding hKey
}
see how it flows? create the context, connect to the TCSD, make the key object, load the parent by UUID, do your policy/secret handling, create the key, register it, use it, then unregister on the way out. that's the whole arc, main character energy from start to finish π
β CONFORMING TO β
Tspi_Context_RegisterKey conforms to the Trusted Computing Group Software Specification version 1.1 Golden. certified iconic, no notes.
π SEE ALSO π
Tspi_Context_UnregisterKey(3)Tspi_Context_LoadKeyByUUID(3)Tspi_Context_GetRegisteredKeyByUUID(3)
and that's the page, bestie π«Ά this was TSS 1.1, dated 2004-05-25, and it lives in Tspi_Context_RegisterKey(3). go register something πβ¨π
π¦ where this page comes from
- debian bookworm: libtspi-dev 0.3.15-0.3 Β· BSD-3-Clause
- debian trixie: libtspi-dev 0.3.15-0.4 Β· BSD-3-Clause
- epel 10: trousers-devel 0.3.15-11.el10_0 Β· BSD
- epel 9: trousers-devel 0.3.15-5.el9 Β· BSD
- fedora 43: trousers-devel 0.3.15-15.fc43 Β· LicenseRef-Callaway-BSD
- fedora 43: trousers-devel 0.3.15-15.fc43 Β· LicenseRef-Callaway-BSD
- fedora 43: trousers-devel 0.3.15-16.fc43 Β· LicenseRef-Callaway-BSD
- fedora 43: trousers-devel 0.3.15-16.fc43 Β· LicenseRef-Callaway-BSD
- fedora 44: trousers-devel 0.3.15-17.fc44 Β· LicenseRef-Callaway-BSD
- fedora 44: trousers-devel 0.3.15-17.fc44 Β· LicenseRef-Callaway-BSD
- nixos 26.05: trousers 0.3.15
- nixpkgs unstable: netbsd-source 11.0
- nixpkgs unstable: trousers 0.3.15
- opensuse-leap 16.0: trousers-devel 0.3.15-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: trousers-devel 0.3.15-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: trousers-devel 0.3.15-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: trousers-devel 0.3.15-160000.2.2 Β· BSD-3-Clause
- ubuntu jammy: libtspi-dev 0.3.15-0.2 Β· BSD-3-Clause
- ubuntu noble: libtspi-dev 0.3.15-0.3build2 Β· BSD-3-Clause
- ubuntu questing: libtspi-dev 0.3.15-0.4
- ubuntu resolute: libtspi-dev 0.3.15-1 Β· BSD-3-Clause
- ubuntu stonking: libtspi-dev 0.3.15-1ubuntu2 Β· BSD-3-Clause
- Copyright (C) 2004 International Business Machines Corporation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms