Self-Defending KMS provides multiple interfaces to application developers. For C/C++ programmers, Self-Defending KMS provides a PKCS#11 interface through a library. For Java programmers, Self-Defending KMS can be accessed through the JCE interface and through Java SDK. Self-Defending KMS can also be accessed through its RESTful interface, documented at https://www.fortanix.com/api/
We provide examples for using Self-Defending KMS in 7 languages – a C++ program using the PKCS#11 interface, a Java program using the JCE interface, and other programs using the REST interface through Java, Python, Go, C#, PHP and Javascript SDKs
The example programs can be downloaded in full at the Downloads page.
C++
CK_RV delete_key(CK_FUNCTION_LIST_PTR p11, CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hKey) {
return p11->C_DestroyObject(hSession, hKey);
}
C#
public void deleteKey() {
SecurityObjectsApi securityObjectsApi = new SecurityObjectsApi();
securityObjectsApi.DeleteSecurityObject(key.Kid);
}
Go
err = client.DeleteSobject(ctx, *sobject.Kid)
if err != nil {
log.Fatalf("Failed to delete security object: %v", err)
}
fmt.Printf("Deleted security object %v\n", *sobject.Kid)
Java
private static boolean delete_key() {
try {
SecurityObjectsApi securityObjectsApi = new SecurityObjectsApi(apiClient);
securityObjectsApi.deleteSecurityObject(kid);
return true;
} catch (Exception e) {
System.out.println("Can't delete key: " + e);
return false;
}
}
Python
def delete_key():
api_instance = sdkms.v1.SecurityObjectsApi(api_client=client)
try:
api_instance.delete_security_object(kid)
except ApiException as e:
print("Exception when calling SecurityObjectsApi->delete_security_object: %s\n" % e)
Javascript
var deleteKeyCallback = function(error, data, response) {
if (error) {
console.error("Error: " + JSON.stringify(response));
} else {
console.log('security object deleted successfully.');
}
};
var securityObjectApi = new FortanixSdkmsRestApi.SecurityObjectsApi()
securityObjectApi.deleteSecurityObject(kid, deleteKeyCallback);