I am trying to write TPM agnostic code that could potentially run on other platforms but with other engines.
Look at the following code:
const char *key_uri = "sss://key/ID=0x00000001";
const char *engine_id = "e4sss";
if (!OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL)) {
}
ENGINE_load_builtin_engines();
e = ENGINE_by_id(engine_id);
if (!e) {
}
if (!ENGINE_init(e)) {
return 1;
}
ENGINE_set_default(e, ENGINE_METHOD_ALL);
// Step 5: Load the private key from the specified key URI
pkey = ENGINE_load_private_key(e, key_uri, NULL, NULL);
if (!pkey) {
fprintf(stderr, "Failed to load private key from URI: %s\n", key_uri);
ENGINE_free(e);
return 1;
}
Here the program breaks, the key can not be loaded.
What am I doing wrong?