Skip to content

Commit 2316f5c

Browse files
committed
Merge branch 'develop'
* develop: Sync-up with iot-core 1.6.2 Add necessary makefile user configs for rtl apps. fixed code to use mbedtls_pk_parse_public_key api (#569) gettig_started: add device identity entiries details Sync-up with iot-core 1.6.1 rtl: add CONFIG_STDK_CORE_EASYSETUP_DISCOVER_SSID to example Sync-up with iot-core 1.6.0 apps:esp8266: update sdkconfig according to iot-core kconfig changes apps:esp32: update sdkconfig according to iot-core kconfig changes | Conflicts: | iot-core : sync with latest
2 parents 2908ff5 + d230f35 commit 2316f5c

File tree

20 files changed

+79
-39
lines changed

20 files changed

+79
-39
lines changed

apps/esp32/light_example/sdkconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ CONFIG_HEAP_TRACING_OFF=y
339339
# CONFIG_HEAP_TRACING_TOHOST is not set
340340
# CONFIG_HEAP_TRACING is not set
341341
CONFIG_STDK_IOT_CORE=y
342+
CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID=y
342343
CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP=y
344+
CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API=y
343345
# CONFIG_STDK_IOT_CORE_EASYSETUP_X509 is not set
344346
# CONFIG_STDK_IOT_CORE_EASYSETUP_LOG_SUPPORT_NO_USE_LOGFILE is not set
345347
CONFIG_STDK_IOT_CORE_LOG_LEVEL_ERROR=y

apps/esp32/ota_demo/main/ota_util.c

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "mbedtls/rsa.h"
3535
#include "mbedtls/pk.h"
3636
#include "mbedtls/ssl.h"
37+
#include "mbedtls/error.h"
3738

3839
#include <stdio.h>
3940
#include <stdlib.h>
@@ -279,44 +280,64 @@ static int _crypto_sha256(const unsigned char *src, size_t src_len, unsigned cha
279280

280281
static int _pk_verify(const unsigned char *sig, const unsigned char *hash)
281282
{
282-
int ret;
283+
int ret;
283284

284-
mbedtls_pk_context pk;
285+
mbedtls_pk_context pk;
285286

286-
unsigned char *public_key = (unsigned char *) public_key_start;
287-
unsigned int public_key_len = public_key_end - public_key_start;
287+
unsigned char *public_key = (unsigned char *) public_key_start;
288+
unsigned int public_key_len = public_key_end - public_key_start;
289+
unsigned char *public_key_buffer = NULL;
288290

289-
mbedtls_pk_init( &pk );
291+
public_key_buffer = (unsigned char *)malloc(public_key_len + 1);
292+
if (!public_key_buffer) {
293+
printf("Couldn't allocate memory \n");
294+
return -1;
295+
}
290296

291-
ret = mbedtls_pk_parse_public_key( &pk, (const unsigned char *)public_key, public_key_len );
292-
if (ret != 0) {
293-
printf("Parse error: 0x%04X\n", ret);
294-
goto clean_up;
295-
}
297+
memcpy(public_key_buffer, public_key, public_key_len);
298+
public_key_buffer[public_key_len] = '\0';
296299

297-
if (!mbedtls_pk_can_do( &pk, MBEDTLS_PK_RSA))
298-
{
299-
printf("Failed! Key is not an RSA key\n");
300-
ret = MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH;
301-
goto clean_up;
302-
}
300+
mbedtls_pk_init( &pk );
303301

304-
ret = mbedtls_rsa_check_pubkey(mbedtls_pk_rsa(pk));
305-
if (ret != 0) {
306-
printf("Check pubkey failed: 0x%04X\n", ret);
307-
goto clean_up;
308-
}
302+
ret = mbedtls_pk_parse_public_key( &pk, (const unsigned char *)public_key_buffer, public_key_len + 1 );
303+
if (ret != 0) {
304+
char error_buf[100];
305+
mbedtls_strerror( ret, error_buf, 100);
306+
printf( "parse error -0x%04x - %s \n", -ret, error_buf );
307+
goto clean_up;
308+
}
309309

310-
if ((ret = mbedtls_pk_verify(&pk, MBEDTLS_MD_SHA256, hash, OTA_CRYPTO_SHA256_LEN, sig, OTA_SIGNATURE_SIZE)) != 0 ) {
311-
printf("Invalid firmware : 0x%04X\n", ret);
312-
goto clean_up;
313-
}
310+
if (!mbedtls_pk_can_do( &pk, MBEDTLS_PK_RSA))
311+
{
312+
printf("Failed! Key is not an RSA key\n");
313+
ret = MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH;
314+
goto clean_up;
315+
}
316+
317+
ret = mbedtls_rsa_check_pubkey(mbedtls_pk_rsa(pk));
318+
if (ret != 0) {
319+
char error_buf[100];
320+
mbedtls_strerror( ret, error_buf, 100);
321+
printf( "parse error -0x%04x - %s \n", -ret, error_buf );
322+
goto clean_up;
323+
}
324+
325+
if ((ret = mbedtls_pk_verify(&pk, MBEDTLS_MD_SHA256, hash, OTA_CRYPTO_SHA256_LEN, sig, OTA_SIGNATURE_SIZE)) != 0 ) {
326+
char error_buf[100];
327+
mbedtls_strerror( ret, error_buf, 100);
328+
printf( "parse error -0x%04x - %s \n", -ret, error_buf );
329+
goto clean_up;
330+
}
314331

315332
clean_up:
316333

317-
mbedtls_pk_free( &pk );
334+
if (public_key_buffer) {
335+
free(public_key_buffer);
336+
}
318337

319-
return ret;
338+
mbedtls_pk_free( &pk );
339+
340+
return ret;
320341
}
321342

322343
static bool _check_firmware_validation(const unsigned char *sha256, unsigned char *sig_data, unsigned int sig_len)

apps/esp32/ota_demo/sdkconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ CONFIG_HEAP_TRACING_OFF=y
339339
# CONFIG_HEAP_TRACING_TOHOST is not set
340340
# CONFIG_HEAP_TRACING is not set
341341
CONFIG_STDK_IOT_CORE=y
342+
CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID=y
342343
CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP=y
343344
CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API=y
344345
# CONFIG_STDK_IOT_CORE_EASYSETUP_X509 is not set

apps/esp32/switch_example/sdkconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ CONFIG_HEAP_TRACING_OFF=y
339339
# CONFIG_HEAP_TRACING_TOHOST is not set
340340
# CONFIG_HEAP_TRACING is not set
341341
CONFIG_STDK_IOT_CORE=y
342+
CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID=y
342343
CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP=y
344+
CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API=y
343345
# CONFIG_STDK_IOT_CORE_EASYSETUP_X509 is not set
344346
# CONFIG_STDK_IOT_CORE_EASYSETUP_LOG_SUPPORT_NO_USE_LOGFILE is not set
345347
CONFIG_STDK_IOT_CORE_LOG_LEVEL_ERROR=y

apps/esp8266/light_example/sdkconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ CONFIG_OPENSSL_ASSERT_DO_NOTHING=y
354354
# CONFIG_ENABLE_PTHREAD is not set
355355
# CONFIG_USING_SPIFFS is not set
356356
CONFIG_STDK_IOT_CORE=y
357+
CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID=y
357358
CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP=y
358359
CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API=y
359360
# CONFIG_STDK_IOT_CORE_EASYSETUP_X509 is not set

apps/esp8266/switch_example/sdkconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ CONFIG_OPENSSL_ASSERT_DO_NOTHING=y
354354
# CONFIG_ENABLE_PTHREAD is not set
355355
# CONFIG_USING_SPIFFS is not set
356356
CONFIG_STDK_IOT_CORE=y
357+
CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID=y
357358
CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP=y
358359
CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API=y
359360
# CONFIG_STDK_IOT_CORE_EASYSETUP_X509 is not set

apps/rtl8195/light_example/sdkconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define _SDKCONFIG_H_
44

55
#define CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API
6+
#define CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID
67
#define CONFIG_MBEDTLS_XTEA_C 1
78
#define CONFIG_MBEDTLS_KEY_EXCHANGE_RSA 1
89
#define CONFIG_MBEDTLS_AES_C 1

apps/rtl8195/light_example/usr_config.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44

55
CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_SOFTWARE=y
66
CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_HARDWARE=
7-
7+
CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API=y
8+
CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID=y
89

apps/rtl8195/switch_example/sdkconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define _SDKCONFIG_H_
44

55
#define CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API
6+
#define CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID
67
#define CONFIG_MBEDTLS_XTEA_C 1
78
#define CONFIG_MBEDTLS_KEY_EXCHANGE_RSA 1
89
#define CONFIG_MBEDTLS_AES_C 1

apps/rtl8195/switch_example/usr_config.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44

55
CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_SOFTWARE=y
66
CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_HARDWARE=
7-
7+
CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API=y
8+
CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID=y
89

apps/rtl8720c/light_example/sdkconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define _SDKCONFIG_H_
44

55
#define CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API
6+
#define CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID
67
#define CONFIG_MBEDTLS_XTEA_C 1
78
#define CONFIG_MBEDTLS_KEY_EXCHANGE_RSA 1
89
#define CONFIG_MBEDTLS_AES_C 1

apps/rtl8720c/light_example/usr_config.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44

55
CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_SOFTWARE=y
66
CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_HARDWARE=
7-
7+
CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API=y
8+
CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID=y
89

apps/rtl8720c/switch_example/sdkconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define _SDKCONFIG_H_
44

55
#define CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API
6+
#define CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID
67
#define CONFIG_MBEDTLS_XTEA_C 1
78
#define CONFIG_MBEDTLS_KEY_EXCHANGE_RSA 1
89
#define CONFIG_MBEDTLS_AES_C 1

apps/rtl8720c/switch_example/usr_config.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44

55
CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_SOFTWARE=y
66
CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_HARDWARE=
7-
7+
CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API=y
8+
CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID=y
89

apps/rtl8721c/light_example/sdkconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define _SDKCONFIG_H_
44

55
#define CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API
6+
#define CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID
67
#define CONFIG_MBEDTLS_XTEA_C 1
78
#define CONFIG_MBEDTLS_KEY_EXCHANGE_RSA 1
89
#define CONFIG_MBEDTLS_AES_C 1

apps/rtl8721c/light_example/usr_config.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44

55
CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_SOFTWARE=y
66
CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_HARDWARE=
7-
7+
CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API=y
8+
CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID=y
89

apps/rtl8721c/switch_example/sdkconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define _SDKCONFIG_H_
44

55
#define CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API
6+
#define CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID
67
#define CONFIG_MBEDTLS_XTEA_C 1
78
#define CONFIG_MBEDTLS_KEY_EXCHANGE_RSA 1
89
#define CONFIG_MBEDTLS_AES_C 1

apps/rtl8721c/switch_example/usr_config.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44

55
CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_SOFTWARE=y
66
CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_HARDWARE=
7-
7+
CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API=y
8+
CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID=y
89

doc/getting_started.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,11 @@ Your IoT device needs two pieces of information when connecting to the SmartThin
340340
The mapping between `iot_nvd_t` and real storage path name can be found at `iot_bsp_nv_data_XXX.c` for [each bsp's porting layer](https://github.com/SmartThingsCommunity/st-device-sdk-c/tree/master/src/port/bsp).
341341
[stdk-keygen.py](https://github.com/SmartThingsCommunity/st-device-sdk-c/tree/master/tools/keygen#commercial) also supports batch creation by reading csv formatted series of device serial number.
342342
343-
| Data Path | Description | Examples |
344-
| :------------ | :---------------------------- | :----------------------- |
345-
| PublicKey | Client (= Device) Public key | device.pubkey.b64 |
346-
| PrivateKey | Client (= Device) Private key | device.seckey.b64 |
347-
| SerialNum | Device Serial Number | SN12345678F |
343+
| Data Path | Description | Detail | Examples |
344+
| :------------ | :---------------------------- | :---------------------------------- | :----------------------- |
345+
| PublicKey | Client (= Device) Public key | base64 encoded ED25519 Public Key | device.pubkey.b64 |
346+
| PrivateKey | Client (= Device) Private key | base64 encoded ED25519 Privated Key | device.seckey.b64 |
347+
| SerialNum | Device Serial Number | alphanumberic string (8~30) | SN12345678F |
348348
349349
> **Note :**
350350
>

0 commit comments

Comments
 (0)