-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Declaring MBEDTLS_ALLOW_PRIVATE_ACCESS allows access to mbedtls "private" fields. * Migration guide: https://github.com/Mbed-TLS/mbedtls/blob/development/docs/3.0-migration-guide.md Signed-off-by: Dávid Házi <[email protected]>
- Loading branch information
1 parent
465e9e9
commit d7beac7
Showing
15 changed files
with
217 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
components/connectivity/freertos_plus_tcp/integration/src/transport_mbedtls.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
/* | ||
* FreeRTOS V202212.00 | ||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* Copyright 2024 Arm Limited and/or its affiliates | ||
* <[email protected]> | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
* this software and associated documentation files (the "Software"), to deal in | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
.../security/freertos_pkcs11_psa/integration/patches/0001-build-Update-mbedtls-version.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
From a0345f268535e2150a4a347f6723081a6630ed0b Mon Sep 17 00:00:00 2001 | ||
From: Dávid Házi <[email protected]> | ||
Date: Thu, 18 Jan 2024 16:24:20 +0100 | ||
Subject: [PATCH] build: Update mbedtls to v3.5.2 | ||
|
||
* Add #define MBEDTLS_ALLOW_PRIVATE_ACCESS to every file that | ||
access private struct members. | ||
* Remove mbedtls/pk_internal.h header file inclusion, | ||
because it no longer exists in the latest mbedtls version. | ||
* Direct access to pk_info structs has been removed, | ||
mbedtls_pk_info_from_type function should be used. | ||
* mbedtls_rsa_init function prototype has been changed, | ||
newer prototype should be used. | ||
|
||
Signed-off-by: Dávid Házi <[email protected]> | ||
--- | ||
iot_pkcs11_psa.c | 11 ++++++----- | ||
iot_pkcs11_psa_input_format.h | 1 - | ||
iot_pkcs11_psa_object_management.c | 3 +++ | ||
3 files changed, 9 insertions(+), 6 deletions(-) | ||
|
||
diff --git a/iot_pkcs11_psa.c b/iot_pkcs11_psa.c | ||
index 54a0669..abe2e75 100644 | ||
--- a/iot_pkcs11_psa.c | ||
+++ b/iot_pkcs11_psa.c | ||
@@ -38,6 +38,8 @@ | ||
/* FreeRTOS includes. */ | ||
#include "FreeRTOS.h" | ||
|
||
+#define MBEDTLS_ALLOW_PRIVATE_ACCESS | ||
+ | ||
/* PKCS#11 includes. */ | ||
#include "core_pkcs11_config.h" | ||
#include "core_pkcs11.h" | ||
@@ -46,7 +48,6 @@ | ||
|
||
/* mbedTLS includes. */ | ||
#include "mbedtls/pk.h" | ||
-#include "mbedtls/pk_internal.h" | ||
|
||
#define PKCS11_PRINT( X ) vLoggingPrintf X | ||
#define PKCS11_WARNING_PRINT( X ) /* vLoggingPrintf X */ | ||
@@ -646,7 +647,7 @@ CK_RV prvCreateRsaPrivateKey( mbedtls_pk_context * pxMbedContext, | ||
*ppxLabel = NULL; | ||
*ppxClass = NULL; | ||
pxRsaContext = pxMbedContext->pk_ctx; | ||
- mbedtls_rsa_init( pxRsaContext, MBEDTLS_RSA_PKCS_V15, 0 /*ignored.*/ ); | ||
+ mbedtls_rsa_init( pxRsaContext ); | ||
|
||
/* Parse template and collect the relevant parts. */ | ||
for( ulIndex = 0; ulIndex < ulCount; ulIndex++ ) | ||
@@ -819,7 +820,7 @@ CK_RV prvCreatePrivateKey( CK_ATTRIBUTE_PTR pxTemplate, | ||
if( pxRsaCtx != NULL ) | ||
{ | ||
xMbedContext.pk_ctx = pxRsaCtx; | ||
- xMbedContext.pk_info = &mbedtls_rsa_info; | ||
+ xMbedContext.pk_info = mbedtls_pk_info_from_type(MBEDTLS_PK_RSA); | ||
xResult = prvCreateRsaPrivateKey( &xMbedContext, | ||
&pxLabel, | ||
&pxClass, | ||
@@ -851,7 +852,7 @@ CK_RV prvCreatePrivateKey( CK_ATTRIBUTE_PTR pxTemplate, | ||
if( pxKeyPair != NULL ) | ||
{ | ||
/* Initialize the info. */ | ||
- xMbedContext.pk_info = &mbedtls_eckey_info; | ||
+ xMbedContext.pk_info = mbedtls_pk_info_from_type(MBEDTLS_PK_ECKEY); | ||
|
||
/* Initialize the context. */ | ||
xMbedContext.pk_ctx = pxKeyPair; | ||
@@ -1082,7 +1083,7 @@ CK_RV prvCreatePublicKey( CK_ATTRIBUTE_PTR pxTemplate, | ||
if( pxKeyPair != NULL ) | ||
{ | ||
/* Initialize the info. */ | ||
- xMbedContext.pk_info = &mbedtls_eckey_info; | ||
+ xMbedContext.pk_info = mbedtls_pk_info_from_type(MBEDTLS_PK_ECKEY);; | ||
|
||
/* Initialize the context. */ | ||
xMbedContext.pk_ctx = pxKeyPair; | ||
diff --git a/iot_pkcs11_psa_input_format.h b/iot_pkcs11_psa_input_format.h | ||
index 3bf18b3..b8cdfda 100644 | ||
--- a/iot_pkcs11_psa_input_format.h | ||
+++ b/iot_pkcs11_psa_input_format.h | ||
@@ -27,7 +27,6 @@ | ||
/* mbedTLS includes. */ | ||
#include "mbedtls/pk.h" | ||
#include "mbedtls/asn1.h" | ||
-#include "mbedtls/pk_internal.h" | ||
#include "mbedtls/oid.h" | ||
|
||
#define pkcs11DER_ENCODED_OID_P256_LEGNTH 19 | ||
diff --git a/iot_pkcs11_psa_object_management.c b/iot_pkcs11_psa_object_management.c | ||
index 6e6a969..ace6dc6 100644 | ||
--- a/iot_pkcs11_psa_object_management.c | ||
+++ b/iot_pkcs11_psa_object_management.c | ||
@@ -32,6 +32,9 @@ | ||
*/ | ||
|
||
#include <string.h> | ||
+ | ||
+#define MBEDTLS_ALLOW_PRIVATE_ACCESS | ||
+ | ||
#include "iot_pkcs11_psa_object_management.h" | ||
#include "iot_pkcs11_psa_input_format.h" | ||
|
||
-- | ||
2.40.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
/* | ||
* FreeRTOS TLS V1.3.1 | ||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* Copyright 2024 Arm Limited and/or its affiliates | ||
* <[email protected]> | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
* this software and associated documentation files (the "Software"), to deal in | ||
|
@@ -26,11 +28,22 @@ | |
#ifndef IOT_TLS_H | ||
#define IOT_TLS_H | ||
|
||
/** | ||
* @brief Declaring MBEDTLS_ALLOW_PRIVATE_ACCESS allows access to mbedtls "private" fields. | ||
*/ | ||
#define MBEDTLS_ALLOW_PRIVATE_ACCESS | ||
|
||
#include "mbedtls/ctr_drbg.h" | ||
#include "mbedtls/entropy.h" | ||
#include "mbedtls/sha256.h" | ||
#include "mbedtls/pk.h" | ||
#include "mbedtls/pk_internal.h" | ||
|
||
/** | ||
* @brief Custom pk_info struct is not supported by mbedtls v3, | ||
* but the current solution should define one. With this | ||
* private include we can access to mbedtls_pk_info_t. | ||
*/ | ||
#include "../library/pk_wrap.h" | ||
#include "mbedtls/debug.h" | ||
#include "core_pkcs11.h" | ||
|
||
|
Oops, something went wrong.