[tools/sgx] Improve public API of Secret Prov lib
Description of the changes
This is a breaking change that modifies the API of the Secret Prov lib as follows:
-
secret_provision_start()allocates a context that should be supplied to all other Secret Prov APIs and must be closed afterwards. -
secret_provision_get()requires a context as the first argument, and extracts the secret that is associated with this context. Thus, it allows for several secrets being delivered in parallel from different remote parties (previously, the secret was a global variable). -
secret_provision_destroy()is removed. Instead, users should callsecret_provision_close()that will both close the session and destroy the secret.
With these changes, the context ceases to be global, and the library becomes thread-safe. Also, leaks of mbedTLS resources are prevented.
As a small side fix, the library always returns normal POSIX error codes (previously, the library could return mbedTLS error codes).
Fixes #646. Supersedes #647.
How to test this PR?
CI should be enough. But also see manual way in #647 to test resource/memory leaks.
after changing API, cross-language-framework solution can work well on this PR. https://github.com/intel/confidential-computing-zoo/tree/main/cczoo/cross_lang_framework