This file implements the platform abstraction layer APIs for cryptographic functions using mbedTLS SW Crypto. More...
#include "optiga_trustm/optiga_lib_common.h"
#include "optiga_trustm/pal_crypt.h"
#include "optiga_trustm/pal_os_memory.h"
#include "mbedtls/ccm.h"
#include "mbedtls/md.h"
#include "mbedtls/ssl.h"
#include "mbedtls/version.h"
Macros | |
#define | PAL_CRYPT_DIGEST_MAX_SIZE (32U) |
#define | AES128_KEY_BITS_SIZE (16U) |
#define | MAC_TAG_BUFFER_SIZE (16U) |
#define | AES128_KEY_BITS_SIZE (16U) |
#define | PAL_CRYPT_MAX_LABEL_SEED_LENGTH (96U) |
pal_status_t | pal_crypt_tls_prf_sha256 (pal_crypt_t *p_pal_crypt, const uint8_t *p_secret, uint16_t secret_length, const uint8_t *p_label, uint16_t label_length, const uint8_t *p_seed, uint16_t seed_length, uint8_t *p_derived_key, uint16_t derived_key_length) |
Derives the key using the TLS PRF SHA256 for a given secret. More... | |
pal_status_t | pal_crypt_encrypt_aes128_ccm (pal_crypt_t *p_pal_crypt, const uint8_t *p_plain_text, uint16_t plain_text_length, const uint8_t *p_encrypt_key, const uint8_t *p_nonce, uint16_t nonce_length, const uint8_t *p_associated_data, uint16_t associated_data_length, uint8_t mac_size, uint8_t *p_cipher_text) |
Encrypts the input plain text using AES CCM algorithm and provides the cipher text as well as MAC into output buffer. More... | |
pal_status_t | pal_crypt_decrypt_aes128_ccm (pal_crypt_t *p_pal_crypt, const uint8_t *p_cipher_text, uint16_t cipher_text_length, const uint8_t *p_decrypt_key, const uint8_t *p_nonce, uint16_t nonce_length, const uint8_t *p_associated_data, uint16_t associated_data_length, uint8_t mac_size, uint8_t *p_plain_text) |
Decrypts the cipher text using AES CCM algorithm and provides the plain text. More... | |
pal_status_t | pal_crypt_version (uint8_t *p_crypt_lib_version_info, uint16_t *length) |
Gets the external crypto library version number. More... | |
This file implements the platform abstraction layer APIs for cryptographic functions using mbedTLS SW Crypto.
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
#define AES128_KEY_BITS_SIZE (16U) |
#define AES128_KEY_BITS_SIZE (16U) |
#define MAC_TAG_BUFFER_SIZE (16U) |
#define PAL_CRYPT_DIGEST_MAX_SIZE (32U) |
#define PAL_CRYPT_MAX_LABEL_SEED_LENGTH (96U) |
pal_status_t pal_crypt_decrypt_aes128_ccm | ( | pal_crypt_t * | p_pal_crypt, |
const uint8_t * | p_cipher_text, | ||
uint16_t | cipher_text_length, | ||
const uint8_t * | p_decrypt_key, | ||
const uint8_t * | p_nonce, | ||
uint16_t | nonce_length, | ||
const uint8_t * | p_associated_data, | ||
uint16_t | associated_data_length, | ||
uint8_t | mac_size, | ||
uint8_t * | p_plain_text | ||
) |
Decrypts the cipher text using AES CCM algorithm and provides the plain text.
Decrypts the cipher text using AES CCM algorithm and provides the plain text.
[in] | p_pal_crypt | Crypt context |
[in] | p_cipher_text | Valid pointer to the Cipher text + MAC data. |
[in] | cipher_text_length | Cipher text data size. |
[in] | p_decrypt_key | Valid pointer to decrypt key. |
[in] | p_nonce | Valid pointer to Nonce data. |
[in] | nonce_length | Nonce size. |
[in] | p_associated_data | Valid pointer to Associated data. |
[in] | associated_data_length | Associated data size. |
[in] | mac_size | Length of MAC data. |
[in,out] | p_plain_text | Valid pointer to store plain text. Buffer length must be at-least Cipher_text_length - mac_size. |
PAL_STATUS_SUCCESS | In case of success |
PAL_STATUS_FAILURE | In case of failure |
pal_status_t pal_crypt_encrypt_aes128_ccm | ( | pal_crypt_t * | p_pal_crypt, |
const uint8_t * | p_plain_text, | ||
uint16_t | plain_text_length, | ||
const uint8_t * | p_encrypt_key, | ||
const uint8_t * | p_nonce, | ||
uint16_t | nonce_length, | ||
const uint8_t * | p_associated_data, | ||
uint16_t | associated_data_length, | ||
uint8_t | mac_size, | ||
uint8_t * | p_cipher_text | ||
) |
Encrypts the input plain text using AES CCM algorithm and provides the cipher text as well as MAC into output buffer.
Encrypts the input plain text using AES CCM algorithm and provides the cipher text as well as MAC into output buffer.
[in] | p_pal_crypt | Crypt context |
[in] | p_plain_text | Valid pointer to plain text data. |
[in] | plain_text_length | Plain text data size. |
[in] | p_encrypt_key | Valid pointer to Encrypt key . |
[in] | p_nonce | Valid pointer to Nonce data. |
[in] | nonce_length | Nonce data size. |
[in] | p_associated_data | Valid pointer to Associated data. |
[in] | associated_data_length | Associated data size. |
[in] | mac_size | Length of expected MAC data. |
[in,out] | p_cipher_text | Valid pointer to store cipher text and MAC output. Buffer length must be at-least plain_text_length + MAC mac_size. |
PAL_STATUS_SUCCESS | In case of success |
PAL_STATUS_FAILURE | In case of failure |
pal_status_t pal_crypt_tls_prf_sha256 | ( | pal_crypt_t * | p_pal_crypt, |
const uint8_t * | p_secret, | ||
uint16_t | secret_length, | ||
const uint8_t * | p_label, | ||
uint16_t | label_length, | ||
const uint8_t * | p_seed, | ||
uint16_t | seed_length, | ||
uint8_t * | p_derived_key, | ||
uint16_t | derived_key_length | ||
) |
Derives the key using the TLS PRF SHA256 for a given secret.
Derives the key using the TLS PRF SHA256 for a given secret.
[in] | p_pal_crypt | Crypt context |
[in] | p_secret | Valid pointer to input shared secret. |
[in] | secret_length | Length of the shared secret. |
[in] | p_label | Valid pointer to Label for PRF calculation. |
[in] | label_length | Label length. |
[in] | p_seed | Valid pointer to the buffer which contains seed. |
[in] | seed_length | seed length. |
[in,out] | p_derived_key | Valid pointer to the buffer where PRF output to be saved. |
[in] | derived_key_length | Length of the key to be derived from secret. |
PAL_STATUS_SUCCESS | In case of success |
PAL_STATUS_FAILURE | In case of failure |
pal_status_t pal_crypt_version | ( | uint8_t * | p_crypt_lib_version_info, |
uint16_t * | length | ||
) |
Gets the external crypto library version number.
Gets the external crypto library version number.
[in,out] | p_crypt_lib_version_info | Valid pointer to store the version number. |
[in,out] | length | version number size. |
PAL_STATUS_SUCCESS | In case of success |
PAL_STATUS_FAILURE | In case of failure |