Skip to content

Commit 701f1a5

Browse files
components: Add patches for Jobs-for-AWS-IoT-embedded-sdk library
Two patches are added for the Jobs-for-AWS-IoT-embedded-sdk library: - The Jobs library assumes the OTA job is signed using ECDSA. However, we currently use RSA. Therefore, add a patch to change the check for an ECDSA signature to a check for an RSA signature. - The Jobs library contains calls to the `strnlen` function. However, this function is not supported by the Arm Compiler for Embedded (v6.21). Therefore, add a patch which replaces these calls with calls to our custom implementation `app_strnlen`. Signed-off-by: Chuyue Luo <[email protected]>
1 parent 802def9 commit 701f1a5

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed

components/aws_iot/jobs_for_aws_iot_embedded_sdk/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,14 @@ else()
1111
"Path to AWS IoT Jobs source code"
1212
)
1313

14+
include(ApplyPatches)
15+
16+
set(PATCH_FILES_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/integration/patches")
17+
set(PATCH_FILES
18+
"${PATCH_FILES_DIRECTORY}/0001-Check-for-RSA-signature-instead-of-ECDSA.patch"
19+
"${PATCH_FILES_DIRECTORY}/0002-Use-custom-strnlen-implementation.patch"
20+
)
21+
iot_reference_arm_corstone3xx_apply_patches("${jobs-for-aws-iot-embedded-sdk_SOURCE_DIR}" "${PATCH_FILES}")
22+
1423
add_subdirectory(integration)
1524
endif()
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
From 6ea98c733a2ea3c9d8cfdf4d3b689598ffdf8d54 Mon Sep 17 00:00:00 2001
2+
From: Chuyue Luo <[email protected]>
3+
Date: Wed, 4 Dec 2024 15:20:34 +0000
4+
Subject: [PATCH 1/2] Check for RSA signature instead of ECDSA
5+
6+
The Jobs-for-AWS-IoT-embedded-sdk library assumes the OTA job is signed
7+
using ECDSA, but we currently use RSA. Thus, change the check for an
8+
ECDSA signature to a check for an RSA signature.
9+
10+
Signed-off-by: Chuyue Luo <[email protected]>
11+
---
12+
source/otaJobParser/job_parser.c | 7 +++++--
13+
1 file changed, 5 insertions(+), 2 deletions(-)
14+
15+
diff --git a/source/otaJobParser/job_parser.c b/source/otaJobParser/job_parser.c
16+
index 4a1da8a..8638dc0 100644
17+
--- a/source/otaJobParser/job_parser.c
18+
+++ b/source/otaJobParser/job_parser.c
19+
@@ -1,6 +1,9 @@
20+
/*
21+
* AWS IoT Jobs v1.5.1
22+
* Copyright (C) 2023 Amazon.com, Inc. and its affiliates. All Rights Reserved.
23+
+ * Copyright 2024 Arm Limited and/or its affiliates
24+
25+
+ *
26+
* SPDX-License-Identifier: MIT
27+
*
28+
* Licensed under the MIT License. See the LICENSE accompanying this file
29+
@@ -263,8 +266,8 @@ static JSONStatus_t populateCommonFields( const char * jobDoc,
30+
if( jsonResult == JSONSuccess )
31+
{
32+
buildIndexedFileQueryString( fileIndex,
33+
- "sig-sha256-ecdsa",
34+
- 16U,
35+
+ "sig-sha256-rsa",
36+
+ 14U,
37+
queryString,
38+
&queryStringLength );
39+
jsonResult = JSON_SearchConst( jobDoc,
40+
--
41+
2.47.0
42+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
From 02b777ed41b393163c3f793d8ff3b608ac0b9634 Mon Sep 17 00:00:00 2001
2+
From: Chuyue Luo <[email protected]>
3+
Date: Wed, 4 Dec 2024 15:24:44 +0000
4+
Subject: [PATCH 2/2] Use custom `strnlen` implementation
5+
6+
The Arm Compiler for Embedded (v6.21) does not support the `strnlen`
7+
function. Therefore, use our own implementation (`app_strnlen`) instead.
8+
9+
Signed-off-by: Chuyue Luo <[email protected]>
10+
---
11+
source/jobs.c | 8 ++++++--
12+
1 file changed, 6 insertions(+), 2 deletions(-)
13+
14+
diff --git a/source/jobs.c b/source/jobs.c
15+
index 9614d90..0f83c27 100644
16+
--- a/source/jobs.c
17+
+++ b/source/jobs.c
18+
@@ -1,6 +1,8 @@
19+
/*
20+
* AWS IoT Jobs v1.5.1
21+
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22+
+ * Copyright 2024 Arm Limited and/or its affiliates
23+
24+
*
25+
* SPDX-License-Identifier: MIT
26+
*
27+
@@ -36,6 +38,8 @@
28+
/* External Dependencies */
29+
#include "core_json.h"
30+
31+
+#include "app_strnlen.h"
32+
+
33+
/** @cond DO_NOT_DOCUMENT */
34+
35+
/**
36+
@@ -575,7 +579,7 @@ static bool isThingnameTopicMatch( const char * topic,
37+
writePreamble( expectedTopicBuffer, &start, TOPIC_BUFFER_SIZE, thingName, ( uint16_t ) thingNameLength );
38+
( void ) strnAppend( expectedTopicBuffer, &start, TOPIC_BUFFER_SIZE, topicSuffix, topicSuffixLength );
39+
40+
- isMatch = ( size_t ) strnlen( expectedTopicBuffer, TOPIC_BUFFER_SIZE ) ==
41+
+ isMatch = ( size_t ) app_strnlen( expectedTopicBuffer, TOPIC_BUFFER_SIZE ) ==
42+
topicLength;
43+
isMatch = isMatch && ( strncmp( expectedTopicBuffer, topic, topicLength ) == 0 );
44+
}
45+
@@ -894,7 +898,7 @@ bool Jobs_IsJobUpdateStatus( const char * topic,
46+
( void ) strnAppend( suffixBuffer, &start, suffixBufferLength, "/update/", ( CONST_STRLEN( "/update/" ) ) );
47+
( void ) strnAppend( suffixBuffer, &start, suffixBufferLength, jobUpdateStatusString[ expectedStatus ], jobUpdateStatusStringLengths[ expectedStatus ] );
48+
49+
- return isThingnameTopicMatch( topic, topicLength, suffixBuffer, strnlen( suffixBuffer, suffixBufferLength ), thingName, thingNameLength );
50+
+ return isThingnameTopicMatch( topic, topicLength, suffixBuffer, app_strnlen( suffixBuffer, suffixBufferLength ), thingName, thingNameLength );
51+
}
52+
53+
size_t Jobs_GetJobId( const char * message,
54+
--
55+
2.47.0
56+

0 commit comments

Comments
 (0)