diff --git a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/core_pkcs11_config.h b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/core_pkcs11_config.h index 5d2a7b122a..6e8f79f7aa 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/core_pkcs11_config.h +++ b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/core_pkcs11_config.h @@ -1,5 +1,5 @@ /* - * FreeRTOS V1.4.8 + * FreeRTOS V202011.00 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -19,11 +19,11 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ - /** * @file core_pkcs11_config.h * @brief PCKS#11 config options. diff --git a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj index 5dc9ce7069..9095323cca 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj +++ b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj @@ -58,7 +58,7 @@ Disabled - ..\..\..\FreeRTOS-Plus\Source\Utilities\logging;..\..\..\FreeRTOS-Plus\Source\corePKCS11\source\include;..\..\..\FreeRTOS-Plus\Source\corePKCS11\source\portable\mbedtls\include;..\..\..\FreeRTOS-Plus\Source\corePKCS11\source\dependency\3rdparty\pkcs11;..\..\ThirdParty\mbedtls\include;..\..\..\FreeRTOS-Plus\Source\corePKCS11\source\dependency\3rdparty\mbedtls_utils;..\..\..\FreeRTOS\Source\include;..\..\..\FreeRTOS\Source\portable\MSVC-MingW;examples;.;%(AdditionalIncludeDirectories) + ..\..\..\FreeRTOS-Plus\Source\Utilities\logging;..\..\..\FreeRTOS-Plus\Source\corePKCS11\source\include;..\..\..\FreeRTOS-Plus\Source\corePKCS11\source\dependency\3rdparty\pkcs11;..\..\ThirdParty\mbedtls\include;..\..\..\FreeRTOS-Plus\Source\corePKCS11\source\dependency\3rdparty\mbedtls_utils;..\..\..\FreeRTOS\Source\include;..\..\..\FreeRTOS\Source\portable\MSVC-MingW;examples;.;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;MBEDTLS_CONFIG_FILE="aws_mbedtls_config.h";CONFIG_MEDTLS_USE_AFR_MEMORY;%(PreprocessorDefinitions) false EnableFastChecks @@ -358,7 +358,7 @@ - + diff --git a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj.filters b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj.filters index fa2c37177c..979a110fe6 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj.filters +++ b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj.filters @@ -412,8 +412,8 @@ corePKCS11\include - - corePKCS11\include + + examples 3rdparty\mbedtls\include @@ -707,4 +707,4 @@ 3rdparty\mbedtls - \ No newline at end of file + diff --git a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/core_pkcs11_config.h b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/core_pkcs11_config.h index bd27b61f3d..cea12ed7b0 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/core_pkcs11_config.h +++ b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/core_pkcs11_config.h @@ -1,5 +1,5 @@ /* - * FreeRTOS V1.4.8 + * FreeRTOS V202011.00 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -19,8 +19,9 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ /** diff --git a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/demo_helpers.c b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/demo_helpers.c index 21937f12ca..1d8d3259a0 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/demo_helpers.c +++ b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/demo_helpers.c @@ -1,5 +1,5 @@ /* - * FreeRTOS PKCS #11 V1.0.3 + * FreeRTOS V202011.00 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -19,8 +19,9 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ /* FreeRTOS includes. */ diff --git a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/demo_helpers.h b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/demo_helpers.h index 7c758325a6..232f30fdd5 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/demo_helpers.h +++ b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/demo_helpers.h @@ -1,5 +1,5 @@ /* - * FreeRTOS PKCS #11 V1.0.3 + * FreeRTOS V202011.00 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -19,9 +19,11 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ + #ifndef _DEMO_HELPER_FUNCTIONS_ #define _DEMO_HELPER_FUNCTIONS_ diff --git a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/management_and_rng.c b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/management_and_rng.c index 740f8e74e0..3397d1eb2a 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/management_and_rng.c +++ b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/management_and_rng.c @@ -1,5 +1,5 @@ /* - * FreeRTOS PKCS #11 V1.0.3 + * FreeRTOS V202011.00 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -19,9 +19,11 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ + /* FreeRTOS includes. */ #include "FreeRTOS.h" #include "task.h" diff --git a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/mechanisms_and_digests.c b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/mechanisms_and_digests.c index c56fa2cb14..1dd7bc0770 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/mechanisms_and_digests.c +++ b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/mechanisms_and_digests.c @@ -1,5 +1,5 @@ /* - * FreeRTOS PKCS #11 V1.0.3 + * FreeRTOS V202011.00 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -19,9 +19,11 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ + /* FreeRTOS includes. */ #include "FreeRTOS.h" #include "task.h" diff --git a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/objects.c b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/objects.c index 0de32dd85b..8a88cfac6e 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/objects.c +++ b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/objects.c @@ -1,5 +1,5 @@ /* - * FreeRTOS PKCS #11 V1.0.3 + * FreeRTOS V202011.00 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -19,9 +19,11 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ + /* FreeRTOS includes. */ #include "FreeRTOS.h" #include "task.h" @@ -185,17 +187,17 @@ static void prvObjectImporting( void ) /* Specify certificate subject. */ xCertificateTemplate.xSubject.type = CKA_SUBJECT; xCertificateTemplate.xSubject.pValue = xSubject; - xCertificateTemplate.xSubject.ulValueLen = strlen( ( const char * ) xSubject ); + xCertificateTemplate.xSubject.ulValueLen = sizeof( xSubject ) - 1UL; /* Point to contents of certificate. */ xCertificateTemplate.xValue.type = CKA_VALUE; xCertificateTemplate.xValue.pValue = ( CK_VOID_PTR ) pkcs11demo_RSA_CERTIFICATE; - xCertificateTemplate.xValue.ulValueLen = ( CK_ULONG ) sizeof( pkcs11demo_RSA_CERTIFICATE ); + xCertificateTemplate.xValue.ulValueLen = ( CK_ULONG ) sizeof( pkcs11demo_RSA_CERTIFICATE ) - 1UL; /* Specify certificate label. */ xCertificateTemplate.xLabel.type = CKA_LABEL; xCertificateTemplate.xLabel.pValue = ( CK_VOID_PTR ) pucLabel; - xCertificateTemplate.xLabel.ulValueLen = strlen( ( const char * ) pucLabel ); + xCertificateTemplate.xLabel.ulValueLen = sizeof( pucLabel ) - 1UL; /* Specify certificate type as x509. */ xCertificateTemplate.xCertificateType.type = CKA_CERTIFICATE_TYPE; diff --git a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/pkcs11_demos.h b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/pkcs11_demos.h index 935aee40f9..8bfa52d7f2 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/pkcs11_demos.h +++ b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/pkcs11_demos.h @@ -1,5 +1,5 @@ /* - * FreeRTOS PKCS #11 V1.0.3 + * FreeRTOS V202011.00 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -19,9 +19,11 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ + #ifndef _PKCS11_DEMOS_h_ #define _PKCS11_DEMOS_h_ diff --git a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/sign_and_verify.c b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/sign_and_verify.c index 65c99a84b8..1d3db5f5a2 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/sign_and_verify.c +++ b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/sign_and_verify.c @@ -1,5 +1,5 @@ /* - * FreeRTOS PKCS #11 V1.0.3 + * FreeRTOS V202011.00 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -19,9 +19,11 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ + /* FreeRTOS includes. */ #include "FreeRTOS.h" #include "task.h" @@ -151,6 +153,7 @@ void vPKCS11SignVerifyDemo( void ) */ xResult = xFindObjectWithLabelAndClass( hSession, pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS, + sizeof( pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS ) - 1UL, CKO_PRIVATE_KEY, &xPrivateKeyHandle ); configASSERT( xResult == CKR_OK ); @@ -160,6 +163,7 @@ void vPKCS11SignVerifyDemo( void ) * demo. */ xResult = xFindObjectWithLabelAndClass( hSession, pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS, + sizeof( pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS ) - 1UL, CKO_PRIVATE_KEY, &xPublicKeyHandle ); configASSERT( xResult == CKR_OK ); diff --git a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/pkcs11_demo_config.h b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/pkcs11_demo_config.h index 7da59c9e3d..2d306db687 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/pkcs11_demo_config.h +++ b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/pkcs11_demo_config.h @@ -1,5 +1,5 @@ /* - * FreeRTOS PKCS #11 V1.0.3 + * FreeRTOS V202011.00 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -19,8 +19,9 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * http://aws.amazon.com/freertos - * http://www.FreeRTOS.org + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ #ifndef _PKCS11_DEMO_CONFIG_ diff --git a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/threading_alt.h b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/threading_alt.h new file mode 100644 index 0000000000..3292e328fb --- /dev/null +++ b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/threading_alt.h @@ -0,0 +1,50 @@ +/* + * FreeRTOS V202011.00 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * 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 + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +#ifndef __THREADING_ALT_H__ +#define __THREADING_ALT_H__ + + +#include "FreeRTOS.h" +#include "semphr.h" + +/** + * @brief Mutex struct used to synchronize mbed TLS operations. + * + */ +typedef struct +{ + SemaphoreHandle_t mutex; /**< @brief FreeRTOS semaphore. */ + char is_valid; /**< @brief Flag used by mbedTLS to track wether a mutex is valid. */ +} mbedtls_threading_mutex_t; + +extern void mbedtls_threading_set_alt( void ( * mutex_init )( mbedtls_threading_mutex_t * ), + void ( * mutex_free )( mbedtls_threading_mutex_t * ), + int ( * mutex_lock )( mbedtls_threading_mutex_t * ), + int ( * mutex_unlock )( mbedtls_threading_mutex_t * ) ); + + +#endif /* ifndef __THREADING_ALT_H__ */ diff --git a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls_pkcs11/using_mbedtls_pkcs11.c b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls_pkcs11/using_mbedtls_pkcs11.c index 410011e20e..49a61d0a69 100644 --- a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls_pkcs11/using_mbedtls_pkcs11.c +++ b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls_pkcs11/using_mbedtls_pkcs11.c @@ -517,6 +517,7 @@ static CK_RV readCertificateIntoContext( SSLContext_t * pSslContext, /* Get the handle of the certificate. */ xResult = xFindObjectWithLabelAndClass( pSslContext->xP11Session, pcLabelName, + strlen( pcLabelName ), xClass, &xCertObj ); @@ -630,6 +631,7 @@ static CK_RV initializeClientKeys( SSLContext_t * pxCtx ) /* Get the handle of the device private key. */ xResult = xFindObjectWithLabelAndClass( pxCtx->xP11Session, pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS, + sizeof( pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS ) - 1UL, CKO_PRIVATE_KEY, &pxCtx->xP11PrivateKey ); } diff --git a/FreeRTOS-Plus/Source/corePKCS11 b/FreeRTOS-Plus/Source/corePKCS11 index 40bef76639..d35a8f041f 160000 --- a/FreeRTOS-Plus/Source/corePKCS11 +++ b/FreeRTOS-Plus/Source/corePKCS11 @@ -1 +1 @@ -Subproject commit 40bef76639fc5e85a7ec188a31a45cf72d5fb6a0 +Subproject commit d35a8f041fa335a1661ad0a523c44f4c967fa492