Mayank Gupta / Mbed OS pelion-example-frdm

Dependencies:   FXAS21002 FXOS8700Q

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pal_plat_rot.h Source File

pal_plat_rot.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * Copyright 2016-2018 ARM Ltd.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  *******************************************************************************/
00016 
00017 
00018 #ifndef _PAL_PLAT_ROT_H
00019 #define _PAL_PLAT_ROT_H
00020 
00021 #ifdef __cplusplus
00022 extern "C" {
00023 #endif
00024 
00025 #include "pal.h"
00026 
00027 #include <stdint.h>
00028 #include <stddef.h>
00029 
00030 #define PAL_SHA256_DEVICE_KEY_SIZE_IN_BYTES 32
00031 #define PAL_DEVICE_KEY_SIZE_IN_BITS (128)
00032 #define PAL_DEVICE_KEY_SIZE_IN_BYTES (PAL_DEVICE_KEY_SIZE_IN_BITS / 8)
00033 
00034 /*! \file pal_plat_rot.h
00035 *  \brief PAL RoT - platform.
00036 *   This file contains the RoT (Root of Trust) API.
00037 */
00038 
00039 /*! \brief Retrieves a platform Root of Trust certificate.
00040  *
00041  * @param[in,out] *keyBuf A pointer to the buffer that holds the RoT. The buffer needs to be able to hold 16 bytes of data.
00042  * @param[in] keyLenBytes The size of the buffer must be 16 bytes.
00043  *
00044  * \return PAL_SUCCESS(0) in case of success. A negative value indicating a specific error code in case of failure.
00045  */
00046 palStatus_t pal_plat_osGetRoT(uint8_t *keyBuf, size_t keyLenBytes);
00047 
00048 #if PAL_USE_HW_ROT
00049 /*! \brief Retrieves a hardware platform Root of Trust certificate.
00050  *
00051  * This function must be implemented for hardware RoT configuration.
00052  *
00053  * @param[in,out] *keyBuf A pointer to the buffer that holds the RoT. The buffer needs to be able to hold 16 bytes of data.
00054  * @param[in] keyLenBytes The size of the buffer must be 16 bytes.
00055  *
00056  * \return PAL_SUCCESS(0) in case of success. A negative value indicating a specific error code in case of failure.
00057  */
00058 palStatus_t pal_plat_osGetRoTFromHW(uint8_t *keyBuf, size_t keyLenBytes);
00059 #endif
00060 
00061 #if defined (PAL_USE_HW_ROT) && (PAL_USE_HW_ROT==0)
00062 /*! \brief Sets a Root of Trust certificate.
00063  *
00064  * The size of the Root of Trust must be 16 bytes.
00065  * This function is not implemented for hardware RoT configuration.
00066  *
00067  * @param[in] keyBuf A 16-byte buffer with a Root of Trust key to set.
00068  * @param[in] keyLenBytes The size of the buffer must be 16 bytes.
00069  *
00070  * \return PAL_SUCCESS in case of success and one of the following error codes in case of failure:
00071  * \return PAL_ERR_ITEM_EXIST - RoT key already exists.
00072  * \return PAL_ERR_INVALID_ARGUMENT - invalid parameter.
00073  * \return PAL_ERR_GENERIC_FAILURE - set operation failed.
00074  */
00075 palStatus_t pal_plat_osSetRoT(uint8_t *keyBuf, size_t keyLenBytes);
00076 #endif
00077 
00078 #ifdef __cplusplus
00079 }
00080 #endif
00081 #endif //_PAL_PLAT_ROT_H