Skip to content

Commit c793455

Browse files
committed
Add MbedTLS setup and teardown
1 parent a3362c9 commit c793455

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

getting-started/main.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
#include <mbed.h>
18+
#include <platform.h>
1719
#include "psa/crypto.h"
1820
#include "mbedtls/version.h"
1921
#include <string.h>
@@ -764,6 +766,13 @@ static void generate_and_export_a_public_key()
764766
int main(void)
765767
{
766768
printf("-- Begin Mbed Crypto Getting Started --\n\n");
769+
770+
int ret = 0;
771+
772+
if((ret = mbedtls_platform_setup(NULL)) != 0) {
773+
mbedtls_printf("Platform initialization failed with error %d\r\n", ret);
774+
return 1;
775+
}
767776

768777
import_a_key(AES_KEY, sizeof(AES_KEY));
769778
sign_a_message_using_rsa(RSA_KEY, sizeof(RSA_KEY));
@@ -777,6 +786,7 @@ int main(void)
777786
authenticate_and_decrypt_a_message();
778787
generate_and_export_a_public_key();
779788

789+
mbedtls_platform_teardown(NULL);
780790
printf("\n-- End Mbed Crypto Getting Started --\n");
781791

782792
return 0;

0 commit comments

Comments
 (0)