Skip to content

Commit f9d17b3

Browse files
Andrzej KurekPatater
authored andcommitted
Add platform setup and teardown support
Add platform setup and teardown for authcrypt, benchmark, hashing and tls-client examples.
1 parent 61219a3 commit f9d17b3

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

authcrypt/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
#include "mbedtls/platform.h"
2525

2626
int main() {
27+
mbedtls_platform_context platform_ctx;
28+
if(mbedtls_platform_setup(&platform_ctx)) {
29+
return -1;
30+
}
31+
2732
int exit_code = MBEDTLS_EXIT_SUCCESS;
2833
Authcrypt *authcrypt = new Authcrypt();
2934

@@ -34,5 +39,6 @@ int main() {
3439

3540
delete authcrypt;
3641

42+
mbedtls_platform_teardown(&platform_ctx);
3743
return exit_code;
3844
}

benchmark/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,8 +961,14 @@ static int benchmark( int argc, char *argv[] )
961961
}
962962

963963
int main(void) {
964+
mbedtls_platform_context platform_ctx;
965+
if(mbedtls_platform_setup(&platform_ctx)) {
966+
return -1;
967+
}
968+
964969
int ret = benchmark(0, NULL);
965970
if (ret != 0) {
966971
mbedtls_printf("Benchmark failed with error %d\r\n", ret);
967972
}
973+
mbedtls_platform_teardown(&platform_ctx);
968974
}

hashing/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,14 @@ static int example(void)
152152
}
153153

154154
int main() {
155+
mbedtls_platform_context platform_ctx;
156+
if( mbedtls_platform_setup(&platform_ctx)) {
157+
return -1;
158+
}
159+
155160
int ret = example();
156161
if (ret != 0) {
157162
mbedtls_printf("Example failed with error %d\r\n", ret);
158163
}
164+
mbedtls_platform_teardown(&platform_ctx);
159165
}

tls-client/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ const int SERVER_PORT = 443;
4949
*/
5050
int main()
5151
{
52+
mbedtls_platform_context platform_ctx;
53+
if( mbedtls_platform_setup(&platform_ctx)) {
54+
return -1;
55+
}
5256
/*
5357
* The default 9600 bps is too slow to print full TLS debug info and could
5458
* cause the other party to time out.
@@ -71,6 +75,7 @@ int main()
7175
if (client == NULL) {
7276
mbedtls_printf("Failed to allocate HelloHttpsClient object\n"
7377
"\nFAIL\n");
78+
mbedtls_platform_teardown(&platform_ctx);
7479
return exit_code;
7580
}
7681

@@ -84,5 +89,6 @@ int main()
8489

8590
delete client;
8691

92+
mbedtls_platform_teardown(&platform_ctx);
8793
return exit_code;
8894
}

0 commit comments

Comments
 (0)