Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update qualification test #110

Merged
merged 6 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,81 +149,42 @@
*/


#define PKCS11_TEST_RSA_KEY_SUPPORT ( 1 )
#define PKCS11_TEST_EC_KEY_SUPPORT ( 0 )
#define PKCS11_TEST_IMPORT_PRIVATE_KEY_SUPPORT ( 1 )
#define PKCS11_TEST_GENERATE_KEYPAIR_SUPPORT ( 0 )
#define PKCS11_TEST_PREPROVISIONED_SUPPORT ( 0 )
#define PKCS11_TEST_LABEL_DEVICE_PRIVATE_KEY_FOR_TLS pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS
#define PKCS11_TEST_LABEL_DEVICE_PUBLIC_KEY_FOR_TLS pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS
#define PKCS11_TEST_LABEL_DEVICE_CERTIFICATE_FOR_TLS pkcs11configLABEL_DEVICE_CERTIFICATE_FOR_TLS


#define OTA_RSA_SHA1 1
#define OTA_RSA_SHA256 2
#define OTA_ECDSA_SHA256 3

/**
* @brief Certificate type for OTA PAL test.
* Valid options are: OTA_RSA_SHA1, OTA_RSA_SHA256, OTA_ECDSA_SHA256.
*
* #define OTA_PAL_TEST_CERT_TYPE OTA_ECDSA_SHA256
*/
#define OTA_PAL_TEST_CERT_TYPE OTA_ECDSA_SHA256

/**
* @brief Path to cert for OTA test PAL. Used to verify signature.
* If applicable, the device must be pre-provisioned with this certificate. Please see
* test/common/ota/test_files for the set of certificates.
*/
#define OTA_PAL_CERTIFICATE_FILE CONFIG_GRI_QUALIFICATION_OTA_PAL_CERTIFICATE_FILE

/**
* @brief Some devices have a hard-coded name for the firmware image to boot.
*/
#define OTA_PAL_FIRMWARE_FILE CONFIG_GRI_QUALIFICATION_OTA_PAL_FIRMWARE_FILE

/**
* @brief Some boards OTA PAL layers will use the file names passed into it for the
* image and the certificates because their non-volatile memory is abstracted by a
* file system. Set this to 1 if that is the case for your device.
*/
#define OTA_PAL_USE_FILE_SYSTEM QUALIFICATION_OTA_PAL_USE_FILE_SYSTEM_SETTING
#define PKCS11_TEST_RSA_KEY_SUPPORT ( 1 )
#define PKCS11_TEST_EC_KEY_SUPPORT ( 0 )
#define PKCS11_TEST_IMPORT_PRIVATE_KEY_SUPPORT ( 1 )
#define PKCS11_TEST_GENERATE_KEYPAIR_SUPPORT ( 0 )
#define PKCS11_TEST_PREPROVISIONED_SUPPORT ( 0 )
#define PKCS11_TEST_LABEL_DEVICE_PRIVATE_KEY_FOR_TLS pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS
#define PKCS11_TEST_LABEL_DEVICE_PUBLIC_KEY_FOR_TLS pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS
#define PKCS11_TEST_LABEL_DEVICE_CERTIFICATE_FOR_TLS pkcs11configLABEL_DEVICE_CERTIFICATE_FOR_TLS

/**
* @brief The IoT Thing name for the device for OTA test.
*
* #define IOT_THING_NAME "PLACE_HOLDER"
*/
#define IOT_THING_NAME CONFIG_GRI_QUALIFICATION_THING_NAME
#define IOT_THING_NAME CONFIG_GRI_QUALIFICATION_THING_NAME

/**
* @brief 1 if using PKCS #11 to access the code sign certificate from NVM.
* @brief Log macro for MQTT test.
*/
#define OTA_PAL_READ_CERTIFICATE_FROM_NVM_WITH_PKCS11 0
#ifndef LogDebug
#define LogDebug( x )
#endif

/**
* @brief Major version for OTA E2E test.
*
* #define OTA_APP_VERSION_MAJOR 0
*/
#define OTA_APP_VERSION_MAJOR CONFIG_GRI_QUALIFICATION_OTA_APP_VERSION_MAJOR
#ifndef LogInfo
#define LogInfo( x )
#endif

/**
* @brief Major version for OTA E2E test.
*
* #define OTA_APP_VERSION_MINOR 9
*/
#define OTA_APP_VERSION_MINOR CONFIG_GRI_QUALIFICATION_OTA_APP_VERSION_MINOR
#ifndef LogWarn
#define LogWarn( x )
#endif

/**
* @brief Major version for OTA E2E test.
*
* #define OTA_APP_VERSION_BUILD 1
*/
#define OTA_APP_VERSION_BUILD CONFIG_GRI_QUALIFICATION_OTA_APP_VERSION_BUILD
#ifndef LogError
#define LogError( x )
#endif

#define OUTGOING_PUBLISH_RECORD_COUNT ( 10 )
#define INCOMING_PUBLISH_RECORD_COUNT ( 10 )
#define OUTGOING_PUBLISH_RECORD_COUNT ( 10 )
#define INCOMING_PUBLISH_RECORD_COUNT ( 10 )

#endif /* TEST_PARAM_CONFIG_H */
1 change: 0 additions & 1 deletion main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ endif()
if( CONFIG_GRI_RUN_QUALIFICATION_TEST )
list(APPEND MAIN_SRCS
"qualification_app_main.c"
"demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo.c"
"demo_tasks/sub_pub_unsub_demo/sub_pub_unsub_demo.c")
endif()

Expand Down
23 changes: 0 additions & 23 deletions main/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -87,33 +87,10 @@ menu "Featured FreeRTOS IoT Integration"
int "Port for Echo Server to use"
default 9000

config GRI_QUALIFICATION_OTA_PAL_CERTIFICATE_FILE
string "Path to cert for OTA PAL Test."
default ""

config GRI_QUALIFICATION_OTA_PAL_FIRMWARE_FILE
string "Path to store firmware for OTA PAL Test."
default "/"

config GRI_QUALIFICATION_OTA_PAL_USE_FILE_SYSTEM
bool "Use File System for OTA PAL Test."
default n

config GRI_QUALIFICATION_THING_NAME
string "Thing Name for Device Advisor Test/OTA end-to-end Test"
default "PLACE_HOLDER"

config GRI_QUALIFICATION_OTA_APP_VERSION_MAJOR
int "Application version major for OTA end-to-end Test."
default 0

config GRI_QUALIFICATION_OTA_APP_VERSION_MINOR
int "Application version minor for OTA end-to-end Test."
default 9

config GRI_QUALIFICATION_OTA_APP_VERSION_BUILD
int "Application version build for OTA end-to-end Test."
default 0
endmenu # "Qualification Parameter Configurations"

menu "Sub pub unsub demo configurations"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
#include "app_driver.h"
#include "esp_idf_version.h"

static const char * TAG = "app_driver";
#ifdef APP_SOC_TEMP_SENSOR_SUPPORTED
static const char * TAG = "app_driver";
#endif

#define GRI_LED_GPIO CONFIG_GRI_TEMPERATURE_PUB_SUB_AND_LED_CONTROL_DEMO_LED_GPIO_NUMBER

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#endif
/* *INDENT-ON* */

#include "driver/temp_sensor.h"
#include "driver/temperature_sensor.h"
#include "driver/gpio.h"
#include "led_strip.h"

Expand Down
105 changes: 11 additions & 94 deletions main/qualification_app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@
/* SubscribePublishUnsubscribeDemo demo includes. */
#include "sub_pub_unsub_demo.h"

/* OTACodeSigningDemo demo includes. */
#include "ota_pal.h"
#include "ota_over_mqtt_demo.h"

/* ESP Secure Certificate Manager include. */
#include "esp_secure_cert_read.h"

Expand All @@ -60,46 +56,29 @@
#include "test_execution_config.h"
#include "qualification_test.h"
#include "transport_interface_test.h"
#include "ota_pal_test.h"
#include "mqtt_test.h"

#define keyCLIENT_CERTIFICATE_PEM NULL
#define keyCLIENT_PRIVATE_KEY_PEM NULL

/* Use ROOT CA in binary. */
#ifndef ECHO_SERVER_ROOT_CA
#define ECHO_SERVER_ROOT_CA NULL
#endif

/* Global variables ***********************************************************/

/**
* @brief Logging tag for ESP-IDF logging functions.
*/
static const char * TAG = "qual_main";

/**
* @brief The AWS code signing certificate passed in from ./certs/aws_codesign.crt
*/
extern const char pcAwsCodeSigningCertPem[] asm ( "_binary_aws_codesign_crt_start" );

/**
* @brief The AWS RootCA1 passed in from ./certs/root_cert_auth.pem
*/
extern const uint8_t root_cert_auth_crt_start[] asm ( "_binary_root_cert_auth_crt_start" );
extern const uint8_t root_cert_auth_crt_end[] asm ( "_binary_root_cert_auth_crt_end" );

/**
* @brief The code signing certificate from
* components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests/src/ota/test_files/ecdsa-sha256-signer.crt.pem.test
*/
const char pcOtaPalTestCodeSigningCertPem[] = \
"-----BEGIN CERTIFICATE-----\n" \
"MIIBXDCCAQOgAwIBAgIJAPMhJT8l0C6AMAoGCCqGSM49BAMCMCExHzAdBgNVBAMM\n" \
"FnRlc3Rfc2lnbmVyQGFtYXpvbi5jb20wHhcNMTgwNjI3MjAwNDQyWhcNMTkwNjI3\n" \
"MjAwNDQyWjAhMR8wHQYDVQQDDBZ0ZXN0X3NpZ25lckBhbWF6b24uY29tMFkwEwYH\n" \
"KoZIzj0CAQYIKoZIzj0DAQcDQgAEyza/tGLVbVxhL41iYtC8D6tGEvAHu498gNtq\n" \
"DtPsKaoR3t5xQx+6zdWiCi32fgFT2vkeVAmX3pf/Gl8nIP48ZqMkMCIwCwYDVR0P\n" \
"BAQDAgeAMBMGA1UdJQQMMAoGCCsGAQUFBwMDMAoGCCqGSM49BAMCA0cAMEQCIDkf\n" \
"83Oq8sOXhSyJCWAN63gc4vp9//RFCXh/hUXPYcTWAiBgmQ5JV2MZH01Upi2lMflN\n" \
"YLbC+lYscwcSlB2tECUbJA==\n" \
"-----END CERTIFICATE-----\n";

/**
* @brief Socket send and receive timeouts to use. Specified in milliseconds.
*/
Expand Down Expand Up @@ -155,7 +134,7 @@ static BaseType_t prvInitializeNetworkContext( char * pcServerName,
/*-----------------------------------------------------------*/

#if ( MQTT_TEST_ENABLED == 1 ) || ( TRANSPORT_INTERFACE_TEST_ENABLED == 1 ) || \
( DEVICE_ADVISOR_TEST_ENABLED == 1 ) || ( OTA_E2E_TEST_ENABLED == 1 )
( DEVICE_ADVISOR_TEST_ENABLED == 1 )
static NetworkContext_t xNetworkContext = { 0 };

static BaseType_t prvInitializeNetworkContext( char * pcServerName,
Expand Down Expand Up @@ -384,7 +363,7 @@ static BaseType_t prvInitializeNetworkContext( char * pcServerName,
return xRet;
}
#endif /* ( MQTT_TEST_ENABLED == 1 ) || ( TRANSPORT_INTERFACE_TEST_ENABLED == 1 ) ||
* ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) || ( OTA_E2E_TEST_ENABLED == 1 ) */
* ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) */
/*-----------------------------------------------------------*/

uint32_t MqttTestGetTimeMs( void )
Expand Down Expand Up @@ -445,12 +424,6 @@ uint32_t MqttTestGetTimeMs( void )
}
#endif /* if ( TRANSPORT_INTERFACE_TEST_ENABLED == 1 ) */

#if ( OTA_PAL_TEST_ENABLED == 1 )
void SetupOtaPalTestParam( OtaPalTestParam_t * pTestParam )
{
pTestParam->pageSize = 1 << otaconfigLOG2_FILE_BLOCK_SIZE;
}
#endif /* if ( OTA_PAL_TEST_ENABLED == 1 ) */
/*-----------------------------------------------------------*/

void runQualification( void * pvArgs )
Expand Down Expand Up @@ -478,9 +451,9 @@ BaseType_t xQualificationStart( void )

ESP_LOGE( TAG, "Run xQualificationStart" );

#if ( MQTT_TEST_ENABLED == 1 ) || ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) || ( OTA_E2E_TEST_ENABLED == 1 )
#if ( MQTT_TEST_ENABLED == 1 ) || ( DEVICE_ADVISOR_TEST_ENABLED == 1 )
prvInitializeNetworkContext( MQTT_SERVER_ENDPOINT, MQTT_SERVER_PORT, NULL, keyCLIENT_CERTIFICATE_PEM, keyCLIENT_PRIVATE_KEY_PEM );
#endif /* ( MQTT_TEST_ENABLED == 1 ) || ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) || ( OTA_E2E_TEST_ENABLED == 1 ) */
#endif /* ( MQTT_TEST_ENABLED == 1 ) || ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) */

#if ( TRANSPORT_INTERFACE_TEST_ENABLED == 1 )
#if defined( TRANSPORT_CLIENT_PRIVATE_KEY )
Expand All @@ -497,7 +470,7 @@ BaseType_t xQualificationStart( void )
}
#endif /* ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) */

#if ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) || ( OTA_E2E_TEST_ENABLED == 1 )
#if ( DEVICE_ADVISOR_TEST_ENABLED == 1 )
if( xRet == pdPASS )
{
xRet = xCoreMqttAgentManagerStart( &xNetworkContext );
Expand All @@ -510,55 +483,7 @@ BaseType_t xQualificationStart( void )
configASSERT( xRet == pdPASS );
}
}
#endif /* ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) || ( OTA_E2E_TEST_ENABLED == 1 ) */

#if ( OTA_E2E_TEST_ENABLED == 1 )
if( xRet == pdPASS )
{
#if CONFIG_GRI_OUTPUT_CERTS_KEYS
ESP_LOGI( TAG, "\nCS Cert: \nLength: %d\n%s",
strlen( pcAwsCodeSigningCertPem ),
pcAwsCodeSigningCertPem );
#endif /* CONFIG_GRI_OUTPUT_CERTS_KEYS */

if( otaPal_SetCodeSigningCertificate( pcAwsCodeSigningCertPem ) )
{
vStartOTACodeSigningDemo();
}
else
{
ESP_LOGE( TAG,
"Failed to set the code signing certificate for the AWS OTA "
"library. OTA demo will not be started." );

configASSERT( 0 );
}
}
#endif /* OTA_E2E_TEST_ENABLED == 1 */

#if ( OTA_PAL_TEST_ENABLED == 1 )
if( xRet == pdPASS )
{
#if CONFIG_GRI_OUTPUT_CERTS_KEYS
ESP_LOGI( TAG, "\nCS Cert: \nLength: %d\n%s",
strlen( pcOtaPalTestCodeSigningCertPem ),
pcOtaPalTestCodeSigningCertPem );
#endif /* CONFIG_GRI_OUTPUT_CERTS_KEYS */

if( otaPal_SetCodeSigningCertificate( pcOtaPalTestCodeSigningCertPem ) )
{
/* No need to enable OTA task for OTA PAL test. */
}
else
{
ESP_LOGE( TAG,
"Failed to set the code signing certificate for the AWS OTA "
"library. OTA demo will not be started." );

configASSERT( 0 );
}
}
#endif /* OTA_E2E_TEST_ENABLED == 1 */
#endif /* ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) */

if( ( xRet = xTaskCreate( runQualification,
"QualTask",
Expand All @@ -583,11 +508,3 @@ BaseType_t xQualificationStart( void )
}
#endif /* DEVICE_ADVISOR_TEST_ENABLED == 1 */
/*-----------------------------------------------------------*/

#if ( OTA_E2E_TEST_ENABLED == 1 )
int RunOtaE2eDemo( void )
{
return 0;
}
#endif /* ( OTA_E2E_TEST_ENABLED == 1) */
/*-----------------------------------------------------------*/
6 changes: 6 additions & 0 deletions sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,9 @@ CONFIG_MBEDTLS_TLS_SERVER=n
CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=n
CONFIG_MBEDTLS_TLS_CLIENT=y
CONFIG_MBEDTLS_TLS_ENABLED=y


#
# Unity unit testing library
#
CONFIG_UNITY_ENABLE_FIXTURE=y
Loading