mbed-os-examples / Mbed OS mbed-os-example-tls-authcrypt
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002  *  Hello world example of using the authenticated encryption with Mbed TLS
00003  *
00004  *  Copyright (C) 2016-2017, Arm Limited, All Rights Reserved
00005  *  SPDX-License-Identifier: Apache-2.0
00006  *
00007  *  Licensed under the Apache License, Version 2.0 (the "License"); you may
00008  *  not use this file except in compliance with the License.
00009  *  You may obtain a copy of the License at
00010  *
00011  *  http://www.apache.org/licenses/LICENSE-2.0
00012  *
00013  *  Unless required by applicable law or agreed to in writing, software
00014  *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00015  *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016  *  See the License for the specific language governing permissions and
00017  *  limitations under the License.
00018  */
00019 
00020 #include "mbed.h"
00021 
00022 #include "authcrypt.h"
00023 
00024 #include "mbedtls/platform.h"
00025 
00026 int main() {
00027     int exit_code = MBEDTLS_EXIT_SUCCESS;
00028     int ret;
00029 
00030     if ((ret = mbedtls_platform_setup(NULL)) != 0) {
00031         printf("Platform initialization failed with error %d\n", ret);
00032         return MBEDTLS_EXIT_FAILURE;
00033     }
00034 
00035     Authcrypt *authcrypt = new Authcrypt();
00036 
00037     if ((ret = authcrypt->run()) != 0) {
00038         mbedtls_printf("Example failed with error %d\n", ret);
00039         exit_code = MBEDTLS_EXIT_FAILURE;
00040     }
00041 
00042     delete authcrypt;
00043 
00044     mbedtls_platform_teardown(NULL);
00045     return exit_code;
00046 }