Simulated product dispenser

Dependencies:   HTS221

Fork of mbed-cloud-workshop-connect-HTS221 by Jim Carver

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pal_plat_rot_insecure.cpp Source File

pal_plat_rot_insecure.cpp

00001 // ----------------------------------------------------------------------------
00002 // Copyright 2016-2018 ARM Ltd.
00003 //
00004 // SPDX-License-Identifier: Apache-2.0
00005 //
00006 // Licensed under the Apache License, Version 2.0 (the "License");
00007 // you may not use this file except in compliance with the License.
00008 // You may obtain a copy of the License at
00009 //
00010 //     http://www.apache.org/licenses/LICENSE-2.0
00011 //
00012 // Unless required by applicable law or agreed to in writing, software
00013 // distributed under the License is distributed on an "AS IS" BASIS,
00014 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 // See the License for the specific language governing permissions and
00016 // limitations under the License.
00017 // ----------------------------------------------------------------------------
00018 
00019 #include "pal_plat_rtos.h"
00020 
00021 #define PAL_DEVICE_KEY_SIZE_IN_BYTES 16
00022 
00023 //THIS CODE IS FOR TESTING PURPOSES ONLY. DO NOT USE IN PRODUCTION ENVIRONMENTS. REPLACE WITH A PROPER IMPLEMENTATION BEFORE USE
00024 palStatus_t  __attribute__((weak)) pal_plat_osGetRoT128Bit(uint8_t *keyBuf, size_t keyLenBytes)
00025 {
00026 #if defined (__CC_ARM)          /* ARM compiler. */
00027     #warning("PAL_INSECURE- You are using insecure Root Of Trust implementation, DO NOT USE IN PRODUCTION ENVIRONMENTS. REPLACE WITH A PROPER IMPLEMENTATION BEFORE USE")
00028 #else
00029     #pragma message ("You are using insecure Root Of Trust implementation, DO NOT USE IN PRODUCTION ENVIRONMENTS. REPLACE WITH A PROPER IMPLEMENTATION BEFORE USE")
00030 #endif
00031     static bool runOnce = true;
00032     if (runOnce) {
00033 
00034         PAL_LOG(WARN, "You are using insecure Root Of Trust implementation");
00035         runOnce = false;
00036     }
00037 
00038     if (keyLenBytes < PAL_DEVICE_KEY_SIZE_IN_BYTES) {
00039         return PAL_ERR_BUFFER_TOO_SMALL ;
00040     }
00041 
00042     if (NULL == keyBuf) {
00043         return PAL_ERR_NULL_POINTER ;
00044     }
00045 
00046     for (int i=0; i < PAL_DEVICE_KEY_SIZE_IN_BYTES; i++) {
00047         keyBuf[i] = i;
00048     }
00049 
00050     return PAL_SUCCESS;
00051 }
00052