Skip to content

Commit

Permalink
Merge pull request #74 from Infineon/topic/v3.0.2558
Browse files Browse the repository at this point in the history
version 3.0.2558
  • Loading branch information
ayushev authored Oct 18, 2021
2 parents 650f7ab + 84139d3 commit ec0c3d6
Show file tree
Hide file tree
Showing 112 changed files with 502 additions and 381 deletions.
2 changes: 1 addition & 1 deletion examples/optiga/example_optiga_crypt_clear_auto_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/example_optiga_crypt_ecdh.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/example_optiga_crypt_ecdsa_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/example_optiga_crypt_ecdsa_verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/example_optiga_crypt_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/example_optiga_crypt_hkdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/example_optiga_crypt_hmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/example_optiga_crypt_random.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/example_optiga_crypt_rsa_decrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/example_optiga_crypt_rsa_encrypt_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/example_optiga_crypt_rsa_encrypt_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/example_optiga_crypt_rsa_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/example_optiga_crypt_rsa_verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
18 changes: 12 additions & 6 deletions examples/optiga/example_optiga_crypt_symmetric_generate_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down Expand Up @@ -49,8 +49,10 @@ extern void example_optiga_deinit(void);
uint32_t time_taken_to_generate_key = 0;

#define METADATA_TAG_KEY_ALGO_ID (0xE0)
extern optiga_lib_status_t example_check_tag_in_metadata(const uint8_t * buffer,
const uint8_t tag);
extern optiga_lib_status_t example_check_tag_in_metadata(const uint8_t * buffer,
const uint8_t buffer_length,
const uint8_t tag,
bool_t * tag_available);

/**
* Callback when optiga_crypt_xxxx operation is completed asynchronously
Expand Down Expand Up @@ -91,6 +93,7 @@ optiga_lib_status_t generate_symmetric_key(void)
optiga_key_id_t symmetric_key;
uint16_t optiga_oid, bytes_to_read;
uint8_t read_data_buffer[100];
bool_t tag_available = FALSE;

optiga_crypt_t * crypt_me = NULL;
optiga_util_t * util_me = NULL;
Expand Down Expand Up @@ -127,10 +130,13 @@ optiga_lib_status_t generate_symmetric_key(void)
WAIT_AND_CHECK_STATUS(return_status, optiga_lib_status);

return_status = example_check_tag_in_metadata(read_data_buffer,
METADATA_TAG_KEY_ALGO_ID);
if (OPTIGA_LIB_SUCCESS != return_status)
(uint8_t)bytes_to_read,
METADATA_TAG_KEY_ALGO_ID,
&tag_available);
// Check if tag is already available or other errors occurred
if (((TRUE == tag_available) && (OPTIGA_LIB_SUCCESS == return_status)) ||
(OPTIGA_LIB_SUCCESS != return_status))
{
return_status = OPTIGA_LIB_SUCCESS;
break;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/example_optiga_crypt_tls_prf_sha256.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/example_optiga_init_deinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/example_optiga_util_protected_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/example_optiga_util_read_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/example_optiga_util_update_count.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/example_optiga_util_write_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
41 changes: 26 additions & 15 deletions examples/optiga/example_utilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down Expand Up @@ -59,11 +59,11 @@ char performance_buffer_string[30];

//lint --e{838} suppress "first time use of modulus_signed_bit_len and length_field_in_bytes"
void example_util_encode_rsa_public_key_in_bit_string_format(const uint8_t * n_buffer,
uint16_t n_length,
const uint8_t * e_buffer,
uint16_t e_length,
uint8_t * pub_key_buffer,
uint16_t * pub_key_length)
uint16_t n_length,
const uint8_t * e_buffer,
uint16_t e_length,
uint8_t * pub_key_buffer,
uint16_t * pub_key_length)
{
#define OPTIGA_EXAMPLE_UTIL_RSA_DER_MIN_LEN_FIELD (0x80)
#define OPTIGA_EXAMPLE_UTIL_RSA_DER_SEQUENCE_TAG (0x30)
Expand Down Expand Up @@ -120,9 +120,9 @@ void example_util_encode_rsa_public_key_in_bit_string_format(const uint8_t * n_b
}

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,
uint16_t * pub_key_length)
uint8_t q_length,
uint8_t * pub_key_buffer,
uint16_t * pub_key_length)
{
#define OPTIGA_EXAMPLE_UTIL_ECC_DER_ADDITIONAL_LENGTH (0x02)

Expand All @@ -141,20 +141,31 @@ void example_util_encode_ecc_public_key_in_bit_string_format(const uint8_t * q_b

#undef OPTIGA_EXAMPLE_UTIL_ECC_DER_ADDITIONAL_LENGTH
}
optiga_lib_status_t example_check_tag_in_metadata(const uint8_t * buffer, const uint8_t tag)
optiga_lib_status_t example_check_tag_in_metadata(const uint8_t * buffer,
const uint8_t buffer_length,
const uint8_t tag,
bool_t * tag_available)
{
optiga_lib_status_t return_status = OPTIGA_LIB_SUCCESS;
optiga_lib_status_t return_status = !OPTIGA_LIB_SUCCESS;
uint8_t offset = 1;
uint8_t buffer_length = 0;
uint8_t expected_buffer_length = buffer[offset++] + 0x02; // 0x02 is length for tag and length
uint8_t tag_length = 0;
do
{
buffer_length = buffer[offset++];
while(offset < buffer_length)
*tag_available = FALSE;
// Check if expected buffer length matches input buffer length
if (buffer_length != expected_buffer_length)
{
break;
}

return_status = OPTIGA_LIB_SUCCESS;
// Check for tag in the input buffer
while(offset < (buffer_length - 0x02))
{
if (tag == buffer[offset++])
{
return_status = !OPTIGA_LIB_SUCCESS;
*tag_available = TRUE;
break;
}
tag_length = buffer[offset];
Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/include/optiga_example.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
2 changes: 1 addition & 1 deletion examples/optiga/protected_update_data_set/data_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \copyright
* MIT License
*
* Copyright (c) 2020 Infineon Technologies AG
* Copyright (c) 2021 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
Expand Down
Loading

0 comments on commit ec0c3d6

Please sign in to comment.