Skip to content

Commit

Permalink
Sync version
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushev committed Sep 21, 2020
1 parent c0dd21e commit 71b5c5f
Show file tree
Hide file tree
Showing 40 changed files with 1,494 additions and 131 deletions.
Binary file modified documents/OPTIGA_Trust_M_Datasheet_v3.00.pdf
Binary file not shown.
Binary file modified documents/OPTIGA_Trust_M_Getting_Started_Guide_v3.00.pdf
Binary file not shown.
Binary file modified documents/OPTIGA_Trust_M_Host_Library_Documentation.chm
Binary file not shown.
Binary file modified documents/OPTIGA_Trust_M_Keys_And_Certificates_v3.00.pdf
Binary file not shown.
Binary file modified documents/OPTIGA_Trust_M_Release_Notes_v3.00.pdf
Binary file not shown.
Binary file modified documents/OPTIGA_Trust_M_Solution_Reference_Manual_v3.00.pdf
Binary file not shown.
33 changes: 31 additions & 2 deletions examples/optiga/example_optiga_crypt_clear_auto_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
#include "mbedtls/md.h"
#include "mbedtls/ssl.h"
#if defined (OPTIGA_CRYPT_GENERATE_AUTH_CODE_ENABLED) && defined (OPTIGA_CRYPT_HMAC_VERIFY_ENABLED) && defined (OPTIGA_CRYPT_CLEAR_AUTO_STATE_ENABLED)

#ifndef OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
extern void example_optiga_init(void);
extern void example_optiga_deinit(void);
#endif

//lint --e{526} suppress "CalcHMAC" it's define in other file"
extern pal_status_t CalcHMAC(const uint8_t * secret_key,
uint16_t secret_key_len,
Expand Down Expand Up @@ -124,11 +130,20 @@ void example_optiga_crypt_clear_auto_state(void)
pal_status_t pal_return_status;
optiga_util_t * me_util = NULL;
optiga_crypt_t * me_crypt = NULL;

OPTIGA_EXAMPLE_LOG_MESSAGE(__FUNCTION__);
uint32_t time_taken = 0;

do
{

#ifndef OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
/**
* Open the application on OPTIGA which is a precondition to perform any other operations
* using optiga_util_open_application
*/
example_optiga_init();
#endif //OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY

OPTIGA_EXAMPLE_LOG_MESSAGE(__FUNCTION__);
/**
* 1. Create OPTIGA crypt and util Instances
*/
Expand Down Expand Up @@ -224,10 +239,15 @@ void example_optiga_crypt_clear_auto_state(void)
* 8. Perform clear auto state using OPTIGA
*/
optiga_lib_status = OPTIGA_LIB_BUSY;

START_PERFORMANCE_MEASUREMENT(time_taken);

return_status = optiga_crypt_clear_auto_state(me_crypt,
0xF1D0);
WAIT_AND_CHECK_STATUS(return_status, optiga_lib_status);

READ_PERFORMANCE_MEASUREMENT(time_taken);

return_status = OPTIGA_LIB_SUCCESS;

} while(FALSE);
Expand All @@ -254,6 +274,15 @@ void example_optiga_crypt_clear_auto_state(void)
}
}

#ifndef OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
/**
* Close the application on OPTIGA after all the operations are executed
* using optiga_util_close_application
*/
example_optiga_deinit();
#endif //OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
OPTIGA_EXAMPLE_LOG_PERFORMANCE_VALUE(time_taken, return_status);

}
#endif //(OPTIGA_CRYPT_GENERATE_AUTH_CODE_ENABLED) && (OPTIGA_CRYPT_HMAC_VERIFY_ENABLED) && (OPTIGA_CRYPT_CLEAR_AUTO_STATE_ENABLED)
/**
Expand Down
34 changes: 31 additions & 3 deletions examples/optiga/example_optiga_crypt_ecc_generate_keypair.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@

#ifdef OPTIGA_CRYPT_ECC_GENERATE_KEYPAIR_ENABLED

#ifndef OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
extern void example_optiga_init(void);
extern void example_optiga_deinit(void);
#endif

/**
* Callback when optiga_crypt_xxxx operation is completed asynchronously
*/
Expand Down Expand Up @@ -77,18 +82,27 @@ void example_optiga_crypt_ecc_generate_keypair(void)
{
optiga_lib_status_t return_status = !OPTIGA_LIB_SUCCESS;
optiga_key_id_t optiga_key_id;

uint32_t time_taken = 0;
//To store the generated public key as part of Generate key pair
uint8_t public_key [100];
uint16_t public_key_length = sizeof(public_key);
uint16_t optiga_oid;

optiga_crypt_t * crypt_me = NULL;
optiga_util_t * util_me = NULL;
OPTIGA_EXAMPLE_LOG_MESSAGE(__FUNCTION__);

do
{

#ifndef OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
/**
* Open the application on OPTIGA which is a precondition to perform any other operations
* using optiga_util_open_application
*/
example_optiga_init();
#endif //OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY

OPTIGA_EXAMPLE_LOG_MESSAGE(__FUNCTION__);
/**
* 1. Create OPTIGA Crypt Instance
*/
Expand All @@ -113,6 +127,8 @@ void example_optiga_crypt_ecc_generate_keypair(void)

WAIT_AND_CHECK_STATUS(return_status, optiga_lib_status);

START_PERFORMANCE_MEASUREMENT(time_taken);

/**
* 2. Generate ECC Key pair
* - Use ECC NIST P 256 Curve
Expand All @@ -132,6 +148,9 @@ void example_optiga_crypt_ecc_generate_keypair(void)
public_key,
&public_key_length);
WAIT_AND_CHECK_STATUS(return_status, optiga_lib_status);

READ_PERFORMANCE_MEASUREMENT(time_taken);

return_status = OPTIGA_LIB_SUCCESS;
} while (FALSE);
OPTIGA_EXAMPLE_LOG_STATUS(return_status);
Expand All @@ -155,7 +174,16 @@ void example_optiga_crypt_ecc_generate_keypair(void)
//lint --e{774} suppress This is a generic macro
OPTIGA_EXAMPLE_LOG_STATUS(return_status);
}
}
}

#ifndef OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
/**
* Close the application on OPTIGA after all the operations are executed
* using optiga_util_close_application
*/
example_optiga_deinit();
#endif //OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
OPTIGA_EXAMPLE_LOG_PERFORMANCE_VALUE(time_taken, return_status);
}

#endif //OPTIGA_CRYPT_ECC_GENERATE_KEYPAIR_ENABLED
Expand Down
32 changes: 30 additions & 2 deletions examples/optiga/example_optiga_crypt_ecdh.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@

#ifdef OPTIGA_CRYPT_ECDH_ENABLED

#ifndef OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
extern void example_optiga_init(void);
extern void example_optiga_deinit(void);
#endif

/**
* Callback when optiga_crypt_xxxx operation is completed asynchronously
*/
Expand Down Expand Up @@ -87,7 +92,7 @@ void example_optiga_crypt_ecdh(void)
{
optiga_lib_status_t return_status = !OPTIGA_LIB_SUCCESS;
optiga_key_id_t optiga_key_id;

uint32_t time_taken = 0;
//To store the generated public key as part of Generate key pair
uint8_t public_key [100];
uint16_t public_key_length = sizeof(public_key);
Expand All @@ -96,10 +101,19 @@ void example_optiga_crypt_ecdh(void)
uint8_t shared_secret [32];

optiga_crypt_t * me = NULL;
OPTIGA_EXAMPLE_LOG_MESSAGE(__FUNCTION__);

do
{

#ifndef OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
/**
* Open the application on OPTIGA which is a precondition to perform any other operations
* using optiga_util_open_application
*/
example_optiga_init();
#endif //OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY

OPTIGA_EXAMPLE_LOG_MESSAGE(__FUNCTION__);
/**
* 1. Create OPTIGA Crypt Instance
*/
Expand Down Expand Up @@ -130,6 +144,8 @@ void example_optiga_crypt_ecdh(void)
&public_key_length);
WAIT_AND_CHECK_STATUS(return_status, optiga_lib_status);

START_PERFORMANCE_MEASUREMENT(time_taken);

/**
* 3. Perform ECDH using the Peer Public key
* - Use ECC NIST P 256 Curve
Expand All @@ -145,6 +161,9 @@ void example_optiga_crypt_ecdh(void)
TRUE,
shared_secret);
WAIT_AND_CHECK_STATUS(return_status, optiga_lib_status);

READ_PERFORMANCE_MEASUREMENT(time_taken);

return_status = OPTIGA_LIB_SUCCESS;
} while (FALSE);
OPTIGA_EXAMPLE_LOG_STATUS(return_status);
Expand All @@ -159,6 +178,15 @@ void example_optiga_crypt_ecdh(void)
OPTIGA_EXAMPLE_LOG_STATUS(return_status);
}
}

#ifndef OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
/**
* Close the application on OPTIGA after all the operations are executed
* using optiga_util_close_application
*/
example_optiga_deinit();
#endif //OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
OPTIGA_EXAMPLE_LOG_PERFORMANCE_VALUE(time_taken, return_status);
}

#endif //OPTIGA_CRYPT_ECDH_ENABLED
Expand Down
34 changes: 32 additions & 2 deletions examples/optiga/example_optiga_crypt_ecdsa_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@

#ifdef OPTIGA_CRYPT_ECDSA_SIGN_ENABLED

#ifndef OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
extern void example_optiga_init(void);
extern void example_optiga_deinit(void);
#endif

/**
* Callback when optiga_crypt_xxxx operation is completed asynchronously
*/
Expand Down Expand Up @@ -73,13 +78,24 @@ void example_optiga_crypt_ecdsa_sign(void)
//To store the signture generated
uint8_t signature [80];
uint16_t signature_length = sizeof(signature);

uint32_t time_taken = 0;
optiga_crypt_t * me = NULL;
optiga_lib_status_t return_status = !OPTIGA_LIB_SUCCESS;
OPTIGA_EXAMPLE_LOG_MESSAGE(__FUNCTION__);

do
{

#ifndef OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
/**
* Open the application on OPTIGA which is a precondition to perform any other operations
* using optiga_util_open_application
*/
example_optiga_init();
#endif //OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY


OPTIGA_EXAMPLE_LOG_MESSAGE(__FUNCTION__);

/**
* 1. Create OPTIGA Crypt Instance
*/
Expand All @@ -89,6 +105,8 @@ void example_optiga_crypt_ecdsa_sign(void)
break;
}

START_PERFORMANCE_MEASUREMENT(time_taken);

/**
* 2. Sign the digest using Private key from Key Store ID E0F0
*/
Expand All @@ -101,6 +119,9 @@ void example_optiga_crypt_ecdsa_sign(void)
&signature_length);

WAIT_AND_CHECK_STATUS(return_status, optiga_lib_status);

READ_PERFORMANCE_MEASUREMENT(time_taken);

return_status = OPTIGA_LIB_SUCCESS;

} while (FALSE);
Expand All @@ -116,6 +137,15 @@ void example_optiga_crypt_ecdsa_sign(void)
OPTIGA_EXAMPLE_LOG_STATUS(return_status);
}
}

#ifndef OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
/**
* Close the application on OPTIGA after all the operations are executed
* using optiga_util_close_application
*/
example_optiga_deinit();
#endif //OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
OPTIGA_EXAMPLE_LOG_PERFORMANCE_VALUE(time_taken, return_status);
}
#endif //OPTIGA_CRYPT_ECDSA_SIGN_ENABLED
/**
Expand Down
30 changes: 28 additions & 2 deletions examples/optiga/example_optiga_crypt_ecdsa_verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@

#ifdef OPTIGA_CRYPT_ECDSA_VERIFY_ENABLED

#ifndef OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
extern void example_optiga_init(void);
extern void example_optiga_deinit(void);
#endif

void example_util_encode_ecc_public_key_in_bit_string_format(const uint8_t * q_buffer,
uint8_t q_length,
uint8_t * pub_key_buffer,
Expand Down Expand Up @@ -115,8 +120,7 @@ void example_optiga_crypt_ecdsa_verify(void)
optiga_lib_status_t return_status = !OPTIGA_LIB_SUCCESS;

optiga_crypt_t * me = NULL;
OPTIGA_EXAMPLE_LOG_MESSAGE(__FUNCTION__);

uint32_t time_taken = 0;
example_util_encode_ecc_public_key_in_bit_string_format(ecc_public_key_component,
sizeof(ecc_public_key_component),
ecc_public_key,
Expand All @@ -131,6 +135,16 @@ void example_optiga_crypt_ecdsa_verify(void)

do
{

#ifndef OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
/**
* Open the application on OPTIGA which is a precondition to perform any other operations
* using optiga_util_open_application
*/
example_optiga_init();
#endif //OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY

OPTIGA_EXAMPLE_LOG_MESSAGE(__FUNCTION__);
/**
* 1. Create OPTIGA Crypt Instance
*/
Expand All @@ -140,6 +154,8 @@ void example_optiga_crypt_ecdsa_verify(void)
break;
}

START_PERFORMANCE_MEASUREMENT(time_taken);

/**
* 2. Verify ECDSA signature using public key from host
*/
Expand All @@ -153,6 +169,8 @@ void example_optiga_crypt_ecdsa_verify(void)
&public_key_details);

WAIT_AND_CHECK_STATUS(return_status, optiga_lib_status);
READ_PERFORMANCE_MEASUREMENT(time_taken);

return_status = OPTIGA_LIB_SUCCESS;
} while (FALSE);
OPTIGA_EXAMPLE_LOG_STATUS(return_status);
Expand All @@ -168,6 +186,14 @@ void example_optiga_crypt_ecdsa_verify(void)
}
}

#ifndef OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
/**
* Close the application on OPTIGA after all the operations are executed
* using optiga_util_close_application
*/
example_optiga_deinit();
#endif //OPTIGA_INIT_DEINIT_DONE_EXCLUSIVELY
OPTIGA_EXAMPLE_LOG_PERFORMANCE_VALUE(time_taken, return_status);
}

#endif //OPTIGA_CRYPT_ECDSA_VERIFY_ENABLED
Expand Down
Loading

0 comments on commit 71b5c5f

Please sign in to comment.