Skip to content

Add MbedTLS setup and teardown #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions getting-started/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <mbed.h>
#include <platform.h>
#include "psa/crypto.h"
#include "mbedtls/version.h"
#include <string.h>
Expand Down Expand Up @@ -764,6 +766,13 @@ static void generate_and_export_a_public_key()
int main(void)
{
printf("-- Begin Mbed Crypto Getting Started --\n\n");

int ret = 0;

if((ret = mbedtls_platform_setup(NULL)) != 0) {
mbedtls_printf("Platform initialization failed with error %d\r\n", ret);
return 1;
}

import_a_key(AES_KEY, sizeof(AES_KEY));
sign_a_message_using_rsa(RSA_KEY, sizeof(RSA_KEY));
Expand All @@ -777,6 +786,7 @@ int main(void)
authenticate_and_decrypt_a_message();
generate_and_export_a_public_key();

mbedtls_platform_teardown(NULL);
printf("\n-- End Mbed Crypto Getting Started --\n");

return 0;
Expand Down