Simple interface for Mbed Cloud Client
Embed:
(wiki syntax)
Show/hide line numbers
pal_plat_rot_insecure.cpp
00001 // ---------------------------------------------------------------------------- 00002 // Copyright 2016-2017 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 00020 #include "pal_plat_rtos.h" 00021 00022 #define PAL_DEVICE_KEY_SIZE_IN_BYTES 16 00023 00024 //THIS CODE IS FOR TESTING PURPOSES ONLY. DO NOT USE IN PRODUCTION ENVIRONMENTS. REPLACE WITH A PROPER IMPLEMENTATION BEFORE USE 00025 palStatus_t __attribute__((weak)) pal_plat_osGetRoT128Bit(uint8_t *keyBuf, size_t keyLenBytes) 00026 { 00027 #if defined (__CC_ARM) /* ARM compiler. */ 00028 #warning("PAL_INSECURE- You are using insecure Root Of Trust implementation, DO NOT USE IN PRODUCTION ENVIRONMENTS. REPLACE WITH A PROPER IMPLEMENTATION BEFORE USE") 00029 #else 00030 #pragma message ("You are using insecure Root Of Trust implementation, DO NOT USE IN PRODUCTION ENVIRONMENTS. REPLACE WITH A PROPER IMPLEMENTATION BEFORE USE") 00031 #endif 00032 static bool runOnce = true; 00033 if (runOnce) { 00034 00035 PAL_LOG(WARN, "You are using insecure Root Of Trust implementation"); 00036 runOnce = false; 00037 } 00038 00039 if (keyLenBytes < PAL_DEVICE_KEY_SIZE_IN_BYTES) { 00040 return PAL_ERR_BUFFER_TOO_SMALL ; 00041 } 00042 00043 if (NULL == keyBuf) { 00044 return PAL_ERR_NULL_POINTER ; 00045 } 00046 00047 for (int i=0; i < PAL_DEVICE_KEY_SIZE_IN_BYTES; i++) { 00048 keyBuf[i] = i; 00049 } 00050 00051 return PAL_SUCCESS; 00052 } 00053
Generated on Tue Jul 12 2022 19:01:36 by 1.7.2