Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
pal_tls_utils.h
00001 /******************************************************************************* 00002 * Copyright 2016, 2017 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 #ifndef TEST_TLS_PAL_TEST_UTILS_H_ 00018 #define TEST_TLS_PAL_TEST_UTILS_H_ 00019 00020 #include "pal_network.h" 00021 #include "pal_TLS.h" 00022 00023 typedef struct palTLSSocketTest{ 00024 palSocket_t socket; 00025 palSocketAddress_t* socketAddress; 00026 palSocketLength_t addressLength; 00027 palTLSTransportMode_t transportationMode; 00028 }palTLSSocketTest_t; 00029 00030 #define PAL_TLS_RESPONSE_WAIT_MS 5000 00031 #define DTLS_SERVER_PORT_TIMEOUT 9 //Discard protocol 00032 00033 // This is a workaround for Linux PAL test compilation as credentials 00034 // from mbed_cloud_dev_credentials.c are not included in the build. 00035 #define PAL_TLS_TEST_SERVER_ADDRESS "127.0.0.1" 00036 #ifndef PAL_TLS_TEST_SERVER_ADDRESS 00037 // Use bootstrap server as test server by default 00038 // Expect mbed_cloud_dev_credentials.c to be compiled 00039 extern const char MBED_CLOUD_DEV_BOOTSTRAP_SERVER_URI[]; 00040 extern const uint8_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY[]; 00041 extern const uint8_t MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE[]; 00042 extern const uint8_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE[]; 00043 00044 #define PAL_TLS_TEST_SERVER_ADDRESS_UDP MBED_CLOUD_DEV_BOOTSTRAP_SERVER_URI 00045 #define PAL_TLS_TEST_SERVER_ADDRESS_TCP MBED_CLOUD_DEV_BOOTSTRAP_SERVER_URI 00046 #define PAL_TLS_TEST_DEVICE_PRIVATE_KEY MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY 00047 #define PAL_TLS_TEST_SERVER_CA MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE 00048 #define PAL_TLS_TEST_DEVICE_CERTIFICATE MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE 00049 00050 // Bootstrap server responds to 'coap ping' 00051 00052 // confirmable empty message with id 0 00053 const unsigned char coap_ping_message[] = { 00054 0x40, 0x00, 0x00, 0x00 00055 }; 00056 00057 // reset empty with message id 0 00058 const unsigned char coap_ping_response[] = { 00059 0x70, 0x00, 0x00, 0x00 00060 }; 00061 00062 #define PAL_TLS_REQUEST_MESSAGE coap_ping_message 00063 #define PAL_TLS_UDP_REQUEST_MESSAGE coap_ping_message 00064 #define PAL_TLS_RESPONSE_MESSAGE coap_ping_response 00065 #define PAL_TLS_RESPONSE_SIZE sizeof(coap_ping_response) 00066 00067 #else // #ifndef PAL_TLS_TEST_SERVER_ADDRESS 00068 00069 // Expect that pal test servers are in use 00070 //ECC Key 00071 const unsigned char g_pubKey[] = 00072 { 00073 0x30, 0x82, 0x01, 0x99, 0x30, 0x82, 0x01, 0x3d, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 00074 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x05, 0x00, 0x30, 0x29, 00075 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x03, 0x50, 0x41, 0x4c, 0x31, 0x0c, 00076 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x03, 0x61, 0x72, 0x6d, 0x31, 0x0b, 0x30, 0x09, 00077 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x49, 0x4c, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x33, 0x30, 00078 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x17, 0x0d, 0x32, 0x30, 0x31, 0x32, 00079 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x30, 0x31, 0x13, 0x30, 0x11, 0x06, 00080 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x50, 0x41, 0x4c, 0x5f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 00081 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x03, 0x61, 0x72, 0x6d, 0x31, 0x0b, 00082 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x49, 0x4c, 0x30, 0x59, 0x30, 0x13, 0x06, 00083 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 00084 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x18, 0x8f, 0xc6, 0x40, 0xf3, 0xf4, 0xbc, 0xd9, 0xed, 0x72, 00085 0x7e, 0x96, 0x8f, 0xcc, 0x56, 0x31, 0x6d, 0x72, 0x1d, 0x4e, 0xd8, 0xb2, 0xc1, 0x5b, 0xcb, 0xcf, 00086 0xd6, 0xc5, 0xdb, 0x1f, 0xdf, 0x99, 0x21, 0x01, 0xbc, 0x0c, 0x03, 0xb8, 0xa9, 0xbd, 0xd7, 0xb7, 00087 0x4f, 0x06, 0x8c, 0x5f, 0x6e, 0xe8, 0x64, 0xc9, 0x69, 0x46, 0x96, 0xf8, 0xfd, 0x14, 0xe5, 0xe3, 00088 0x5b, 0x8c, 0x92, 0x99, 0x04, 0xe6, 0xa3, 0x4d, 0x30, 0x4b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x1d, 00089 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 00090 0xb8, 0x4f, 0xcc, 0xad, 0x6b, 0xad, 0xa1, 0x31, 0x75, 0x74, 0x57, 0xe3, 0x76, 0x9f, 0x5d, 0xc3, 00091 0x4f, 0xcf, 0x20, 0x53, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 00092 0x14, 0xfe, 0x53, 0x4c, 0xfa, 0x9a, 0xc7, 0x2f, 0x0c, 0x72, 0xbf, 0xaa, 0x47, 0xc5, 0x16, 0x92, 00093 0x67, 0x7f, 0x0e, 0x02, 0xef, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 00094 0x02, 0x05, 0x00, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, 0x21, 0x00, 0x97, 0x90, 0xa3, 0x5d, 0xab, 00095 0xee, 0x4f, 0x56, 0x12, 0x15, 0x0f, 0xbe, 0x3a, 0x39, 0x21, 0x54, 0x44, 0x67, 0x48, 0xf8, 0xb4, 00096 0x83, 0xbe, 0xda, 0x66, 0x62, 0xa0, 0xa5, 0x67, 0x1c, 0xf4, 0xba, 0x02, 0x20, 0x22, 0x41, 0x3f, 00097 0x52, 0x3a, 0xaa, 0x9d, 0x3c, 0xf1, 0x99, 0x7d, 0x2c, 0x04, 0x89, 0xff, 0xce, 0x80, 0x56, 0xd1, 00098 0x9c, 0xd9, 0x19, 0x06, 0xd3, 0xee, 0x41, 0x2b, 0x49, 0x76, 0x27, 0xfe, 0x4e 00099 }; 00100 00101 const uint8_t g_prvKey[] = 00102 { 00103 0x30, 0x78, 0x02, 0x01, 0x01, 0x04, 0x21, 0x00, 0xac, 0xfb, 0x43, 0x6f, 0xa1, 0x3c, 0x2d, 0x1a, 00104 0x91, 0xd7, 0x58, 0xf8, 0x1f, 0x0f, 0xc5, 0x00, 0x11, 0xe1, 0x56, 0xe6, 0xed, 0x89, 0x96, 0x8b, 00105 0x12, 0xe6, 0x32, 0x70, 0x82, 0x06, 0x01, 0xed, 0xa0, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 00106 0x3d, 0x03, 0x01, 0x07, 0xa1, 0x44, 0x03, 0x42, 0x00, 0x04, 0x18, 0x8f, 0xc6, 0x40, 0xf3, 0xf4, 00107 0xbc, 0xd9, 0xed, 0x72, 0x7e, 0x96, 0x8f, 0xcc, 0x56, 0x31, 0x6d, 0x72, 0x1d, 0x4e, 0xd8, 0xb2, 00108 0xc1, 0x5b, 0xcb, 0xcf, 0xd6, 0xc5, 0xdb, 0x1f, 0xdf, 0x99, 0x21, 0x01, 0xbc, 0x0c, 0x03, 0xb8, 00109 0xa9, 0xbd, 0xd7, 0xb7, 0x4f, 0x06, 0x8c, 0x5f, 0x6e, 0xe8, 0x64, 0xc9, 0x69, 0x46, 0x96, 0xf8, 00110 0xfd, 0x14, 0xe5, 0xe3, 0x5b, 0x8c, 0x92, 0x99, 0x04, 0xe6 00111 }; 00112 00113 00114 const char pal_test_cas[] = 00115 { 00116 0x30, 0x82, 0x01, 0x98, 0x30, 0x82, 0x01, 0x3c, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 00117 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x05, 0x00, 0x30, 0x29, 00118 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x03, 0x50, 0x41, 0x4c, 0x31, 0x0c, 00119 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x03, 0x61, 0x72, 0x6d, 0x31, 0x0b, 0x30, 0x09, 00120 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x49, 0x4c, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x33, 0x30, 00121 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x17, 0x0d, 0x32, 0x30, 0x31, 0x32, 00122 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x29, 0x31, 0x0c, 0x30, 0x0a, 0x06, 00123 0x03, 0x55, 0x04, 0x03, 0x13, 0x03, 0x50, 0x41, 0x4c, 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 00124 0x04, 0x0a, 0x13, 0x03, 0x61, 0x72, 0x6d, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 00125 0x13, 0x02, 0x49, 0x4c, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 00126 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xa4, 00127 0x26, 0x26, 0x29, 0x98, 0x43, 0x6c, 0xc2, 0x2c, 0xbe, 0x0a, 0x90, 0xe3, 0x78, 0x44, 0xa9, 0x15, 00128 0x0b, 0x02, 0x26, 0xf6, 0x14, 0xda, 0x36, 0x5b, 0x0f, 0x1d, 0x15, 0xb1, 0x56, 0x76, 0xec, 0x7f, 00129 0x59, 0x6b, 0x9d, 0x69, 0xd9, 0xd8, 0x16, 0x22, 0xf1, 0x90, 0x63, 0xa1, 0xd3, 0xb7, 0xd7, 0x32, 00130 0x31, 0x8d, 0xc7, 0xbe, 0x8f, 0xc8, 0x20, 0x5a, 0x9d, 0xfa, 0x03, 0x79, 0x7a, 0xcb, 0x7e, 0xa3, 00131 0x53, 0x30, 0x51, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 00132 0xff, 0x02, 0x01, 0x00, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xfe, 00133 0x53, 0x4c, 0xfa, 0x9a, 0xc7, 0x2f, 0x0c, 0x72, 0xbf, 0xaa, 0x47, 0xc5, 0x16, 0x92, 0x67, 0x7f, 00134 0x0e, 0x02, 0xef, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 00135 0xfe, 0x53, 0x4c, 0xfa, 0x9a, 0xc7, 0x2f, 0x0c, 0x72, 0xbf, 0xaa, 0x47, 0xc5, 0x16, 0x92, 0x67, 00136 0x7f, 0x0e, 0x02, 0xef, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 00137 0x05, 0x00, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, 0x21, 0x00, 0x97, 0xce, 0xc5, 0x3c, 0x94, 0xb5, 00138 0xd4, 0x3b, 0xec, 0x92, 0xed, 0x2b, 0x96, 0x3f, 0xdc, 0xae, 0x16, 0xd2, 0x02, 0x6a, 0xa6, 0x8d, 00139 0xf5, 0xb1, 0x5b, 0x61, 0x95, 0xfc, 0x4d, 0x17, 0x0e, 0xab, 0x02, 0x20, 0x40, 0x7b, 0x27, 0x11, 00140 0x83, 0x87, 0xfe, 0x62, 0xa2, 0x67, 0x7c, 0xa8, 0x8e, 0xd5, 0xf3, 0xdc, 0x62, 0xf9, 0x35, 0x91, 00141 0x0b, 0x43, 0x80, 0xc9, 0x12, 0x30, 0x2e, 0x66, 0x64, 0xbf, 0xf2, 0xcb 00142 }; 00143 00144 #define PAL_TLS_TEST_DEVICE_PRIVATE_KEY g_prvKey 00145 #define PAL_TLS_TEST_SERVER_CA pal_test_cas 00146 #define PAL_TLS_TEST_DEVICE_CERTIFICATE g_pubKey 00147 00148 // Local test server is http server in tcp cases 00149 const unsigned char http_get_message[] = "GET / HTTP/1.0\r\n\r\n"; 00150 00151 // Non-confirmable GET with payload '/helloWorld', used in udp cases 00152 const unsigned char coap_helloworld_request[] = { 00153 0x50, 0x01, 0x57, 0x3e, 0xff, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x57, 0x6f, 0x72, 0x6c, 0x64 00154 }; 00155 00156 #define PAL_TLS_REQUEST_MESSAGE http_get_message 00157 #define PAL_TLS_UDP_REQUEST_MESSAGE coap_helloworld_request 00158 #undef PAL_TLS_RESPONSE_MESSAGE 00159 #define PAL_TLS_RESPONSE_SIZE 256 00160 00161 #define PAL_TLS_TEST_SERVER_ADDRESS_UDP PAL_TLS_TEST_SERVER_ADDRESS":4422" 00162 #define PAL_TLS_TEST_SERVER_ADDRESS_TCP PAL_TLS_TEST_SERVER_ADDRESS":5544" 00163 00164 #endif // #ifndef PAL_TLS_TEST_SERVER_ADDRESS 00165 00166 const uint16_t MAX_CERTIFICATE_SIZE = 1024; 00167 00168 const unsigned char g_psk[] = { 00169 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 00170 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f 00171 }; 00172 const unsigned char g_psk_id[] = "Client_identity"; 00173 00174 #endif /* TEST_TLS_PAL_TEST_UTILS_H_ */
Generated on Mon Aug 29 2022 19:53:41 by
