Skip to content

Commit

Permalink
RC2 update
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushev committed Apr 26, 2019
1 parent 9d3f575 commit fd2d67f
Show file tree
Hide file tree
Showing 22 changed files with 396 additions and 208 deletions.
Binary file added certificates/Infineon OPTIGA(TM) Trust M CA 101.crt
Binary file not shown.
16 changes: 16 additions & 0 deletions certificates/Infineon OPTIGA(TM) Trust M CA 101.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-----BEGIN CERTIFICATE-----
MIICeDCCAf6gAwIBAgIEFNFvOzAKBggqhkjOPQQDAzB3MQswCQYDVQQGEwJERTEh
MB8GA1UECgwYSW5maW5lb24gVGVjaG5vbG9naWVzIEFHMRswGQYDVQQLDBJPUFRJ
R0EoVE0pIERldmljZXMxKDAmBgNVBAMMH0luZmluZW9uIE9QVElHQShUTSkgRUND
IFJvb3QgQ0EwHhcNMTgwOTAxMTQ0NjQwWhcNNDMwNzI1MjM1OTU5WjByMQswCQYD
VQQGEwJERTEhMB8GA1UECgwYSW5maW5lb24gVGVjaG5vbG9naWVzIEFHMRMwEQYD
VQQLDApPUFRJR0EoVE0pMSswKQYDVQQDDCJJbmZpbmVvbiBPUFRJR0EoVE0pIFRy
dXN0IE0gQ0EgMTAxMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAElzN3NK10I6FL
9A/U7h0nr47QWuh5cMdN/imIm0ma0tAeokmueRDwUsWdhVFKghXi1j5HMM37XMFT
u8wAp+ZAi6N9MHswHQYDVR0OBBYEFDwwjFzViuijXTKA5FSDsv/Nhk0jMA4GA1Ud
DwEB/wQEAwIABDASBgNVHRMBAf8ECDAGAQH/AgEAMBUGA1UdIAQOMAwwCgYIKoIU
AEQBFAEwHwYDVR0jBBgwFoAUtBiFyEpKxRJ68kA53sT1ix5+StEwCgYIKoZIzj0E
AwMDaAAwZQIxAJ582emCY3u8UWVmqcW6MOylCgw7mB3HJEo9/l3TAEiY7pI4A661
WvolTXNMikx7gwIwc1jw/vO6jjN4TDP/N+pvNXKzVpAytc4+atGsR3lCAbGsN63i
U9h2spNYuRpTEXbN
-----END CERTIFICATE-----
Binary file removed documents/OPTIGA_Trust_M1_Datasheet_v1.60.pdf
Binary file not shown.
Binary file added documents/OPTIGA_Trust_M1_Datasheet_v1.61.pdf
Binary file not shown.
Binary file modified documents/OPTIGA_Trust_M1_Host_Library_Documentation.chm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed documents/OPTIGA_Trust_M1_Release_Notes_v1.01.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
210 changes: 210 additions & 0 deletions examples/optiga/example_optiga_hibernate_restore.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
/**
* \copyright
* MIT License
*
* Copyright (c) 2019 Infineon Technologies AG
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE
*
* \endcopyright
*
* \author Infineon Technologies AG
*
* \file example_optiga_util_write_data.c
*
* \brief This file provides the example for writing data/metadata to OPTIGA using
* #optiga_util_write_data and #optiga_util_write_metadata.
*
* \ingroup grOptigaExamples
*
* @{
*/

#include "optiga/optiga_util.h"
#include "optiga/pal/pal_os_timer.h"

extern void example_log_execution_status(const char_t* function, uint8_t status);
extern void example_log_function_name(const char_t* function);

/**
* Callback when optiga_util_xxxx operation is completed asynchronously
*/
static volatile optiga_lib_status_t optiga_lib_status;
//lint --e{818} suppress "argument "context" is not used in the sample provided"
static void optiga_util_callback(void * context, optiga_lib_status_t return_status)
{
optiga_lib_status = return_status;
if (NULL != context)
{
// callback to upper layer here
}
}

/**
* The below example demonstrates hibernate and restore functionalities
*
* Example for #optiga_util_open_application and #optiga_util_close_application
*
*/
void example_optiga_util_hibernate_restore(void)
{
optiga_lib_status_t return_status;
optiga_util_t * me = NULL;
uint8_t logging_status = 0;
uint8_t security_event_counter = 0;
uint16_t bytes_to_read = 1;
example_log_function_name(__FUNCTION__);

do
{
//Create an instance of optiga_util to open the application on OPTIGA.
me = optiga_util_create(0, optiga_util_callback, NULL);

/**
* Open the application on OPTIGA which is a precondition to perform any other operations
* using optiga_util_open_application
*/
optiga_lib_status = OPTIGA_LIB_BUSY;
return_status = optiga_util_open_application(me, 0);

if (OPTIGA_LIB_SUCCESS != return_status)
{
break;
}
while (optiga_lib_status == OPTIGA_LIB_BUSY)
{
//Wait until the optiga_util_open_application is completed
}
if (OPTIGA_LIB_SUCCESS != optiga_lib_status)
{
//optiga_util_open_application failed
break;
}

/**
* To perform the hibernate, Security Event Counter(SEC) must be 0.
* Read SEC data object (0xE0C5) and wait until SEC = 0
*/
do
{
optiga_lib_status = OPTIGA_LIB_BUSY;
return_status = optiga_util_read_data(me,
0xE0C5,
0x00,
&security_event_counter,
&bytes_to_read);

if (OPTIGA_LIB_SUCCESS != return_status)
{
break;
}

while (OPTIGA_LIB_BUSY == optiga_lib_status)
{
//Wait until the optiga_util_read_data operation is completed
}

if (OPTIGA_LIB_SUCCESS != optiga_lib_status)
{
//Reading the data object failed.
break;
}
pal_os_timer_delay_in_milliseconds(1000);
} while (0 != security_event_counter);

/**
* Hibernate the application on OPTIGA
* using optiga_util_close_application with perform_hibernate parameter as true
*/
optiga_lib_status = OPTIGA_LIB_BUSY;
return_status = optiga_util_close_application(me, 1);

if (OPTIGA_LIB_SUCCESS != return_status)
{
break;
}

while (optiga_lib_status == OPTIGA_LIB_BUSY)
{
//Wait until the optiga_util_close_application is completed
}

if (OPTIGA_LIB_SUCCESS != optiga_lib_status)
{
//optiga_util_close_application failed
break;
}

/**
* Restore the application on OPTIGA
* using optiga_util_open_application with perform_restore parameter as true
*/
optiga_lib_status = OPTIGA_LIB_BUSY;
return_status = optiga_util_open_application(me, 1);

if (OPTIGA_LIB_SUCCESS != return_status)
{
break;
}
while (OPTIGA_LIB_BUSY == optiga_lib_status)
{
//Wait until the optiga_util_open_application is completed
}
if (OPTIGA_LIB_SUCCESS != optiga_lib_status)
{
//optiga_util_open_application failed
break;
}

/**
* Close the application on OPTIGA without hibernating
* using optiga_util_close_application
*/
optiga_lib_status = OPTIGA_LIB_BUSY;
return_status = optiga_util_close_application(me, 0);
if (OPTIGA_LIB_SUCCESS != return_status)
{
break;
}

while (optiga_lib_status == OPTIGA_LIB_BUSY)
{
//Wait until the optiga_util_close_application is completed
}

if (OPTIGA_LIB_SUCCESS != optiga_lib_status)
{
//optiga_util_close_application failed
break;
}
logging_status = 1;

} while (FALSE);

if (me)
{
//Destroy the instance after the completion of usecase if not required.
return_status = optiga_util_destroy(me);
}
example_log_execution_status(__FUNCTION__,logging_status);
}

/**
* @}
*/
Loading

0 comments on commit fd2d67f

Please sign in to comment.