Skip to content

Commit 5729c6d

Browse files
authored
sdk 2.2.0 fixes (#1587)
* sdk 2.2.0 fixes Update mbedtls functions and defines from v2 to v3 for pico sdk 2.2.0 support * update github workflow * update cmakelists version * bump cmake version incompatible cmake version - https://forums.raspberrypi.com/viewtopic.php?t=391251#p2334074
1 parent a5196fe commit 5729c6d

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

.github/workflows/cmake.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ jobs:
8888
- name: Setup cmake
8989
uses: jwlawson/actions-setup-cmake@v2
9090
with:
91-
cmake-version: "3.17.x"
91+
cmake-version: "3.31.x"
9292
- name: Verify cmake
9393
run: cmake --version
9494

@@ -102,11 +102,11 @@ jobs:
102102
- name: arm-none-eabi-gcc GNU Arm Embedded Toolchain
103103
uses: carlosperate/arm-none-eabi-gcc-action@v1.11.1
104104

105-
- name: Checkout pico-sdk/2.1.1
105+
- name: Checkout pico-sdk/2.2.0
106106
uses: actions/checkout@v6.0.1
107107
with:
108108
repository: raspberrypi/pico-sdk
109-
ref: 2.1.1
109+
ref: 2.2.0
110110
path: pico-sdk
111111

112112
- name: Checkout pico-sdk submodules

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ if(WIN32)
44
else()
55
set(USERHOME $ENV{HOME})
66
endif()
7-
set(sdkVersion 2.1.1)
7+
set(sdkVersion 2.2.0)
88
set(toolchainVersion 14_2_Rel1)
9-
set(picotoolVersion 2.1.1)
9+
set(picotoolVersion 2.2.0-a4)
1010
set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake)
1111
if (EXISTS ${picoVscode})
1212
include(${picoVscode})
@@ -59,8 +59,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
5959
# note: this must happen before project()
6060
include(pico_sdk_import.cmake)
6161

62-
if (PICO_SDK_VERSION_STRING VERSION_LESS "2.1.1")
63-
message(FATAL_ERROR "Raspberry Pi Pico SDK version 2.1.1 (or later) required. Your version is ${PICO_SDK_VERSION_STRING}")
62+
if (PICO_SDK_VERSION_STRING VERSION_LESS "2.2.0")
63+
message(FATAL_ERROR "Raspberry Pi Pico SDK version 2.2.0 (or later) required. Your version is ${PICO_SDK_VERSION_STRING}")
6464
endif()
6565

6666
# set the version for webconfig, etc. based on git

headers/mbedtls_config.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* This can be enabled lated when we use SNTP */
22
#undef MBEDTLS_HAVE_TIME_DATE
33

4-
#define MBEDTLS_CHECK_PARAMS
54
#define MBEDTLS_CHECK_PARAMS_ASSERT
65
#define MBEDTLS_ENTROPY_HARDWARE_ALT
76
#define MBEDTLS_AES_ROM_TABLES
@@ -21,6 +20,14 @@
2120
#define MBEDTLS_SSL_ASYNC_PRIVATE
2221
#define MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2322
#define MBEDTLS_USE_PSA_CRYPTO
23+
#define MBEDTLS_OID_C
24+
#define MBEDTLS_X509_CRT_PARSE_C
25+
#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
26+
#define MBEDTLS_X509_USE_C
27+
#define MBEDTLS_ASN1_PARSE_C
28+
#define MBEDTLS_PK_PARSE_C
29+
#define MBEDTLS_PK_C
30+
#define MBEDTLS_PRIVATE
2431
#undef MBEDTLS_NET_C
2532
#undef MBEDTLS_PSA_CRYPTO_STORAGE_C
2633
#undef MBEDTLS_PSA_ITS_FILE_C

src/drivers/ps4/PS4Auth.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#define NEW_CONFIG_MPI(name, buf, size) \
1818
mbedtls_mpi_uint *bytes ## name = new mbedtls_mpi_uint[size / sizeof(mbedtls_mpi_uint)]; \
19-
mbedtls_mpi name = { .s=1, .n=size / sizeof(mbedtls_mpi_uint), .p=bytes ## name }; \
19+
mbedtls_mpi name = { .p=bytes ## name, .s=1, .n=size / sizeof(mbedtls_mpi_uint) }; \
2020
memcpy(bytes ## name, buf, size);
2121

2222
#define DELETE_CONFIG_MPI(name) delete bytes ## name;
@@ -78,7 +78,8 @@ void PS4Auth::keyModeInitialize() {
7878
NEW_CONFIG_MPI(E, options.rsaE.bytes, options.rsaE.size)
7979
NEW_CONFIG_MPI(P, options.rsaP.bytes, options.rsaP.size)
8080
NEW_CONFIG_MPI(Q, options.rsaQ.bytes, options.rsaQ.size)
81-
mbedtls_rsa_init(&ps4AuthData.rsa_context, MBEDTLS_RSA_PKCS_V21, MBEDTLS_MD_SHA256);
81+
mbedtls_rsa_init(&ps4AuthData.rsa_context);
82+
mbedtls_rsa_set_padding(&ps4AuthData.rsa_context, MBEDTLS_RSA_PKCS_V21, MBEDTLS_MD_SHA256);
8283
if (mbedtls_rsa_import(&ps4AuthData.rsa_context, &N, &P, &Q, nullptr, &E) == 0 &&
8384
mbedtls_rsa_complete(&ps4AuthData.rsa_context) == 0) {
8485
ps4AuthData.valid_rsa = true;
@@ -105,11 +106,11 @@ void PS4Auth::keyModeProcess() {
105106
int rss_error = 0;
106107
uint8_t hashed_nonce[32];
107108
// Sign our nonce into hashed_nonce
108-
if ( mbedtls_sha256_ret(ps4AuthData.ps4_auth_buffer, 256, hashed_nonce, 0) < 0 ) {
109+
if ( mbedtls_sha256(ps4AuthData.ps4_auth_buffer, 256, hashed_nonce, 0) < 0 ) {
109110
return;
110111
}
111112
rss_error = mbedtls_rsa_rsassa_pss_sign(&ps4AuthData.rsa_context, rng, nullptr,
112-
MBEDTLS_RSA_PRIVATE, MBEDTLS_MD_SHA256,
113+
MBEDTLS_MD_SHA256,
113114
32, hashed_nonce,
114115
ps4AuthData.ps4_auth_buffer);
115116
if ( rss_error < 0 ) {

0 commit comments

Comments
 (0)