Commit 33684470 authored by apapkovskiy's avatar apapkovskiy
Browse files

Initial commit

parents
# Snapcraft
*.snap
parts/
stage/
prime/
/snap/.snapcraft/
.snapcraft/
# IDE
.idea/
# visual studio code
/.vscode/
/.settings/
/.history/
#temporary build
middleware_build/
\ No newline at end of file
This diff is collapsed.
# Copyright 2018 NXP
#
# This software is owned or controlled by NXP and may only be used
# strictly in accordance with the applicable license terms. By expressly
# accepting such terms or by downloading, installing, activating and/or
# otherwise using the software, you are agreeing that you have read, and
# that you agree to comply with and are bound by, such license terms. If
# you do not agree to be bound by the applicable license terms, then you
# may not retain, install, activate or otherwise use the software.
#
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.0)
PROJECT(SecureIoTMW)
INCLUDE(scripts/cmake_options.cmake)
SET(CMAKE_MODULE_PATH "./scripts")
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
CONFIGURE_FILE(sss/inc/fsl_sss_ftr.h.in fsl_sss_ftr.h)
# EXT and DOC should not be dependent on any compile time variables/depednencies
# ESPECIALLY, SSS_USE_FTR_FILE and FLOW_VERBOSE
ADD_DEFINITIONS(-DSSS_USE_FTR_FILE)
ADD_DEFINITIONS(-DmqttconfigENABLE_METRICS=0)
ADD_SUBDIRECTORY(ext)
IF(NXPInternal)
ADD_SUBDIRECTORY(doc)
ENDIF()
IF(WithLog_FlowVerbose)
MESSAGE(STATUS "FLOW_VERBOSE is ON!!!")
ADD_DEFINITIONS(-DFLOW_VERBOSE)
ENDIF()
IF(WithCodeCoverage)
IF(CMAKE_COMPILER_IS_GNUCXX)
INCLUDE(scripts/CodeCoverage.cmake)
APPEND_COVERAGE_COMPILER_FLAGS()
ENDIF()
ENDIF()
ADD_SUBDIRECTORY(hostlib)
ADD_SUBDIRECTORY(sss)
IF(WithHost_PCWindows)
LINK_DIRECTORIES(ext/amazon-freertos/lib/third_party/win_pcap)
ENDIF()
ADD_SUBDIRECTORY(demos)
IF(WithHostCrypto_OPENSSL)
IF(WithApplet_A71CH)
ADD_SUBDIRECTORY(nxp_iot_agent)
ENDIF()
ENDIF()
SE050 Middleware
================================================
Pre-Requistires:
- CMAKE 3.5.0 or above
- Python 2.7 32bit (Required for CLI Tool)
To build native windows software:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> cd <RootSourceDir>
> mkdir ../build
> cd ../build
> cmake ../<RootSourceDir>
Above commands will create Visual Studio projects in the build directory.
To change build configuration:
> cd <RootSourceDir>
> mkdir ../build
> cmake-gui .
You can select different Applets/COM Interface.
To build MCUXPresso projects:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
MCUXpresso project files can be import from projects folder. Prebuilt binaries are provieded in binaires folder.
To run CLI Tool:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Pre-Requsites: VCOM Firmware running on K64F and connected to PC.
For instllation, it is recommneded to use a virtual env:
> cd <RootSourceDir>\pycli
> python.exe virtualenv venv
> call venv\Scripts\activate.bat
> pip install click
> pip install cryptography
>
> cd src
>
> pip install --editable .
Now ``ssscli`` tool can be used to configure devices.
Command options are listed in pycli\cliReadme.txt
IF(NXPInternal)
IF(WithApplet_SE050_EAR_CH OR WithApplet_A71CH)
ADD_SUBDIRECTORY(ksdk)
ENDIF()
ENDIF()
IF(WithApplet_SE05X)
ADD_SUBDIRECTORY(se05x)
ENDIF()
INCLUDE_DIRECTORIES(common)
IF(WithHost_PCWindows)
ADD_SUBDIRECTORY(x86pc)
ENDIF()
IF(WithmbedTLS_ALT_SSS)
IF(RTOS_FreeRTOS)
IF(WithIOT_GCP)
ADD_SUBDIRECTORY(gcp)
ENDIF()
IF(WithIOT_AZURE)
ADD_SUBDIRECTORY(azure)
ENDIF()
IF(WithIOT_AWS)
ADD_SUBDIRECTORY(aws_jitr)
ENDIF()
IF(WithIOT_IBM)
ADD_SUBDIRECTORY(ibm_watson)
ENDIF()
ELSE()
ADD_SUBDIRECTORY(provisioning)
ENDIF()
ENDIF()
/**
* @file aws_cert.c
* @author NXP Semiconductors
* @version 1.0
* @par License
* Copyright 2017,2018 NXP
*
* This software is owned or controlled by NXP and may only be used
* strictly in accordance with the applicable license terms. By expressly
* accepting such terms or by downloading, installing, activating and/or
* otherwise using the software, you are agreeing that you have read, and
* that you agree to comply with and are bound by, such license terms. If
* you do not agree to be bound by the applicable license terms, then you
* may not retain, install, activate or otherwise use the software.
*
* @par Description
* Keys / Key Indexes
*/
#include <stddef.h>
#include "aws_iot_config.h"
/* Root CA certificate */
const unsigned char certRootCA[] =
"-----BEGIN CERTIFICATE-----\r\n"
"MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB\r\n"
"yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL\r\n"
"ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJp\r\n"
"U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxW\r\n"
"ZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0\r\n"
"aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCByjEL\r\n"
"MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW\r\n"
"ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2ln\r\n"
"biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJp\r\n"
"U2lnbiBDbGFzcyAzIFB1YmxpYyBQcmlt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6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vEZV8N\r\n"
"hnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq\r\n"
"-----END CERTIFICATE-----\r\n";
const size_t lenCertRootCA = sizeof(certRootCA);
#if AWS_IOT_USE_KEYS_FROM_SM
/*
Reference steps to load keys to debug sample.
>>> debug reset
>>> set pair -x 0 -k C:\temp\aws_pg.pem
ECCPrivateKey: hidden
ECCPublicKey (LEN=65):
04:61:B7:F8:1C:EE:E5:17:BF:E9:AD:50:D5:3D:DE:25:5B:E3:FF:95:9D:DD:F5:89:4C:B6:CB:5B:F7:9E:4E:4D:
42:E2:06:A6:E3:E2:A1:7B:12:E7:F6:75:58:E4:E0:D4:B9:3C:3C:C2:F8:FF:0F:A2:A5:E6:1D:4F:2E:3A:6A:0D:
6E
>>> set gp -h 0000 -c C:\temp\aws_pg.crt
Filename: C:\temp\aws_pg.crt
Certificate Size (DER format) = 421 byte
*/
/* Device certificate */
const unsigned char certClient[] = {
0x00, 0x00, // Starting address in GP Storage. (Little Endian Format)
};
const size_t lenCertClient = sizeof(certClient);
#else
/* Device certificate */
const unsigned char certClient[] =
"-----BEGIN CERTIFICATE-----\r\n"
"MIIBbDCCAROgAwIBAgIBATAKBggqhkjOPQQDAjAyMTAwLgYDVQQDDCdOWFAgU2Vt"
"aWNvbmR1Y3RvcnMgNzAwMjIwODkwMDI5MzQ5MTY0MjMwHhcNMTgwMTMwMDkxMTUy"
"WhcNMjgwMTI4MDkxMTUyWjAyMTAwLgYDVQQDDCdOWFAgU2VtaWNvbmR1Y3RvcnMg"
"NzAwMjIwODkwMDI5MzQ5MTY0MjMwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASl"
"w1vxaLpTNzT1L9Zqr+8zkRRBQ85RTAyecNIRTIZa06qp1hz8Ty1x5mibQk3pDkHt"
"TG0kt4MVrt+JP97OcYnOoxowGDAJBgNVHRMEAjAAMAsGA1UdDwQEAwIHgDAK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l5m5McuPaqlS7E1a0BogpsVepd"
"HVyB9YpStSVUM/PlXfinr8fNmFMAgeJ3I168Ny1JmgfrrdBvnZmLGNX2bshNeVwG"
"G94c8vR1wSI9UK6xjN3f2SJkh7X/BJP8zq72IyvfDvfFIyzn2D3qD/6fajBsTNlS"
"WaORgsyuBPJtckMgYPLSDyJWv/TyMNmT2vrPMdNx1gyibf2qI5AWPsSdVUB3Sl/r"
"49ZuTV04WZUee8cRC73dzoKvV94NK33dv3ZZzPSEvO6M2+RfvUFXqKj0kkaXdS3J"
"BiXrfwDbzA=="
"-----END CERTIFICATE-----\r\n";
const size_t lenCertClient = sizeof(certClient);
/* Private key */
const unsigned char privKey[] =
"-----BEGIN EC PRIVATE KEY-----\r\n"
"ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ\r\n"
"ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ\r\n"
"-----END EC PRIVATE KEY-----\r\n";
const size_t lenPrivKey = sizeof(privKey);
#endif
/* Copyright 2018 NXP
*
* This software is owned or controlled by NXP and may only be used
* strictly in accordance with the applicable license terms. By expressly
* accepting such terms or by downloading, installing, activating and/or
* otherwise using the software, you are agreeing that you have read, and
* that you agree to comply with and are bound by, such license terms. If
* you do not agree to be bound by the applicable license terms, then you
* may not retain, install, activate or otherwise use the software.
* */
#include "aws_demo.h"
#include "sm_types.h"
#if AX_EMBEDDED
#include "fsl_device_registers.h"
#include "fsl_debug_console.h"
#include "board.h"
#include "app.h"
#include "FreeRTOSConfig.h"
#include "FreeRTOS.h"
#include "task.h"
#include "board.h"
#include "ksdk_mbedtls.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "ax_api.h"
#include "aws_iot_config.h"
#ifdef IMX_RT
#include "pin_mux.h"
#include "fsl_trng.h"
#include "fsl_dcp.h"
#include "sm_printf.h"
#include "fsl_iomuxc.h"
#endif
#ifdef CPU_LPC54018
#include "fsl_power.h"
#endif
#include "nxLog_App.h"
/*******************************************************************
* MACROS
*******************************************************************/
#ifdef CPU_MIMXRT1052DVL6B
#define TRNG0 TRNG
#endif
/*******************************************************************************
* Definitions
******************************************************************************/
#define AWS_TASK_PRIORITY (tskIDLE_PRIORITY)
#define AWS_TASK_STACK_SIZE 9000
/*******************************************************************************
* Prototypes
******************************************************************************/
extern void awsPubSub_task(void *);
/*******************************************************************************
* Code
******************************************************************************/
#if defined(IMX_RT)
void BOARD_InitModuleClock(void)
{
const clock_enet_pll_config_t config = {true, false, 1};
CLOCK_InitEnetPll(&config);
}
void delay(void)
{
volatile uint32_t i = 0;
for (i = 0; i < 1000000; ++i) {
__asm("NOP"); /* delay */
}
}
#endif
/*!
* @brief Main function
*/
int main(void)
{
#if defined(IMX_RT)
dcp_config_t dcpConfig;
trng_config_t trngConfig;
gpio_pin_config_t gpio_config = {kGPIO_DigitalOutput, 0, kGPIO_NoIntmode};
BOARD_ConfigMPU();
BOARD_InitBootPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();
BOARD_InitModuleClock();
IOMUXC_EnableMode(IOMUXC_GPR, kIOMUXC_GPR_ENET1TxClkOutputDir, true);
GPIO_PinInit(GPIO1, 9, &gpio_config);
GPIO_PinInit(GPIO1, 10, &gpio_config);
/* pull up the ENET_INT before RESET. */
GPIO_WritePinOutput(GPIO1, 10, 1);
GPIO_WritePinOutput(GPIO1, 9, 0);
delay();
GPIO_WritePinOutput(GPIO1, 9, 1);
SCB_DisableDCache();
CRYPTO_InitHardware();
/* Initialize DCP */
DCP_GetDefaultConfig(&dcpConfig);
DCP_Init(DCP, &dcpConfig);
/* Initialize TRNG */
TRNG_GetDefaultConfig(&trngConfig);
/* Set sample mode of the TRNG ring oscillator to Von Neumann, for better random data.
* It is optional.*/
trngConfig.sampleMode = kTRNG_SampleModeVonNeumann;
/* Initialize TRNG */
TRNG_Init(TRNG0, &trngConfig);
#elif defined(CPU_LPC54018)
MPU_Type *base = MPU;
CLOCK_EnableClock(kCLOCK_InputMux);
/* attach 12 MHz clock to FLEXCOMM0 (debug console) */
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
/* Enable Clock for RIT */
CLOCK_EnableClock(kCLOCK_Gpio3);
/* attach 12 MHz clock to FLEXCOMM2 (I2C master) */
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM2);
/* reset FLEXCOMM for I2C */
RESET_PeripheralReset(kFC2_RST_SHIFT_RSTn);
#if defined(FSL_FEATURE_SOC_SHA_COUNT) && (FSL_FEATURE_SOC_SHA_COUNT > 0)
CLOCK_EnableClock(kCLOCK_Sha0);
RESET_PeripheralReset(kSHA_RST_SHIFT_RSTn);
#endif
BOARD_InitBootPins();
BOARD_BootClockFROHF96M();
BOARD_InitDebugConsole();
/* Disable MPU. */
base->CTRL &= ~(0x1U);
#else
SYSMPU_Type *base = SYSMPU;
BOARD_InitHardware();
base->CESR &= ~SYSMPU_CESR_VLD_MASK;
#endif
/*Initialize the Tri-color LED */
LED_GREEN_INIT(1);
LED_RED_INIT(1);
LED_BLUE_INIT(1);
CRYPTO_InitHardware();
if (xTaskCreate(&awsPubSub_task, "awsPubSub", AWS_TASK_STACK_SIZE, NULL, AWS_TASK_PRIORITY, NULL) != pdPASS) {
LOG_E("Task creation failed!.\r\n");
while (1)
;
}
/* Run RTOS */
vTaskStartScheduler();
/* Should not reach this statement */
for (;;)
;
}
#endif //#if AX_EMBEDDED
/*
* Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright 2017-2018 NXP Semiconductors. Not a Contribution
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
/**
* @file aws_jitr_task.c
*
* @brief simple MQTT publish and subscribe for A71CH Demo
*
* This example takes the parameters from the aws_iot_config.h file and establishes a connection to the AWS IoT MQTT
* Platform.
*
* It subscribes to topic - "$aws/things/" clientcredentialIOT_THING_NAME "/shadow/update/accepted"
*
* If all the certs are correct, you should be get messages from cloud to this thing.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <ctype.h>
#include <limits.h>
#include <string.h>
#include "aws_iot_config.h"
#include "aws_clientcredential.h"
#include "aws_default_root_certificates.h"
#include "FreeRTOS.h"
#include "task.h"
#include "sm_types.h"
#if AX_EMBEDDED
#include "board.h"
#include "ksdk_mbedtls.h"
#include "fsl_device_registers.h"
#include "pin_mux.h"
#include "clock_config.h"
#endif
#include "jsmn.h"
#include "mbedtls/base64.h"
#include "ax_api.h"
#include "sm_printf.h"
#include "tst_utils_kinetis.h"
#if SSS_HAVE_ALT_A71CH
#include "ax_mbedtls.h"
#include <fsl_sscp_a71ch.h>
#endif
#if SSS_HAVE_ALT_SSS
#include "sss_mbedtls.h"
#include "ex_sss.h"
#endif
#include "HLSEAPI.h"
#include "aws_mqtt_agent.h"
#include "aws_bufferpool.h"
#include "aws_secure_sockets.h"
#include "tst_utils_kinetis.h"
#if SSS_HAVE_SSS
#include <fsl_sss_sscp.h>
#include <fsl_sss_api.h>
#endif
#include "ledHandler.h"
#include "nxLog_App.h"
sss_session_t currentSession;
sss_key_store_t ks;
sss_object_t keyPair;
sss_object_t interCaKeyPair;
sss_object_t clientCert;
sss_object_t interCaCert;
//sss_object_t extPubkey;
sss_asymmetric_t asymm;
sss_a71ch_key_store_t *a71ch_keystore;
sss_sscp_session_t *sscp_session;
sscp_context_t sscp;
sss_asymmetric_t asymVerifyCtx;
/*******************************************************************************
* Definitions
******************************************************************************/
#define SUB_TOPIC "$aws/things/" clientcredentialIOT_THING_NAME "/shadow/update/accepted"
#define PUB_TOPIC "sdkTest/sub"
/* Used to avoid warnings in case of unused parameters in function pointers */
#define IOT_UNUSED(x) (void)(x)
/*******************************************************************************
* types
******************************************************************************/
/*******************************************************************************
* Prototypes
******************************************************************************/
int HandleReceivedMsg(char *sJsonString, uint16_t len);
void awsPubSub(const U8 ax_uid[A71CH_MODULE_UNIQUE_ID_LEN]);
static MQTTBool_t prvMQTTCallback(void *pvUserData, const MQTTPublishData_t *const pxCallbackParams);
/*******************************************************************************
* Variables
******************************************************************************/
/**
* @brief Default MQTT port is pulled from the aws_iot_config.h
*/
uint32_t port = clientcredentialMQTT_BROKER_PORT;
/**
* @brief This parameter will avoid infinite loop of publish and exit the program after certain number of publishes
*/
uint32_t publishCount = 4;
/*******************************************************************************
* AFR
******************************************************************************/
static MQTTAgentHandle_t xMQTTHandle = NULL;
#define echoCLIENT_ID ((const uint8_t *)AWS_IOT_MQTT_CLIENT_ID)
/*******************************************************************************
* Code
******************************************************************************/
#if !AX_EMBEDDED
int8_t jsoneq(const char *json, jsmntok_t *tok, const char *s)
{
if (tok->type == JSMN_STRING) {
if ((int)strlen(s) == tok->end - tok->start) {
if (strncmp(json + tok->