Add authentication support to coreSNTP demo (#625)

Update the coreSNTP demo to showcase use of symmetric key algorithm of authentication scheme for securing SNTP communication between client and server.
The demo uses the AES-128-CMAC algorithm for the generating Message Authentication Code for the client on sending the SNTP time request to server as well as validating the server response received by verifying if the payload present authentication code can be generated. Use of an authentication mechanism in SNTP communication protects against server spoofing attacks as well as man-in-the-middle attacks of server response modification.

The demo uses corePKCS11 library for the AES-CMAC operations. Also, the demo adds functionality of generating random number, using corePKCS11, for sending as a parameter to the Sntp_SendTimeRequest API.

Note: For symmetric key based security mechanism to be protective against malicious, it is IMPORTANT to securely pre-share the symmetric key between client and server.
This commit is contained in:
Archit Aggarwal
2021-06-16 10:22:06 -07:00
committed by GitHub
parent f771faef4a
commit 5a41846f05
8 changed files with 1765 additions and 57 deletions
File diff suppressed because it is too large Load Diff
+194 -5
View File
@@ -58,8 +58,8 @@
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\..\FreeRTOS-Plus\Source\Utilities\logging;..\Common\WinPCap;..\..\..\FreeRTOS\Source\include;..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\Source\Application-Protocols\coreSNTP\source\include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\Source\Utilities\mbedtls_freertos;..\..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\..\FreeRTOS-Plus\Source\Utilities\logging;..\Common\WinPCap;..\..\..\FreeRTOS\Source\include;..\..\..\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\portable\MSVC-MingW;..\..\Source\Application-Protocols\coreSNTP\source\include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;MBEDTLS_CONFIG_FILE="mbedtls_config.h";CONFIG_MEDTLS_USE_AFR_MEMORY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -88,7 +88,7 @@
<ProgramDatabaseFile>.\Debug/WIN32.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
<AdditionalDependencies>wpcap.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>wpcap.lib;Bcrypt.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\Common\WinPCap</AdditionalLibraryDirectories>
<Profile>false</Profile>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
@@ -130,7 +130,7 @@
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
<AdditionalLibraryDirectories>..\Common\ethernet\lwip-1.4.0\ports\win32\WinPCap</AdditionalLibraryDirectories>
<AdditionalDependencies>wpcap.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>wpcap.lib;Bcrypt.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
@@ -146,6 +146,97 @@
<ClCompile Include="..\..\..\FreeRTOS\Source\stream_buffer.c" />
<ClCompile Include="..\..\..\FreeRTOS\Source\tasks.c" />
<ClCompile Include="..\..\..\FreeRTOS\Source\timers.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\aes.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\aesni.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\arc4.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\aria.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\asn1parse.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\asn1write.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\base64.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\bignum.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\blowfish.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\camellia.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\ccm.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\certs.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\chacha20.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\chachapoly.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\cipher.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\cipher_wrap.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\cmac.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\ctr_drbg.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\debug.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\des.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\dhm.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\ecdh.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\ecdsa.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\ecjpake.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\ecp.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\ecp_curves.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\entropy.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\entropy_poll.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\error.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\gcm.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\havege.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\hkdf.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\hmac_drbg.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\md.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\md2.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\md4.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\md5.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\memory_buffer_alloc.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\net_sockets.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\nist_kw.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\oid.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\padlock.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\pem.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\pk.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\pkcs11.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\pkcs12.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\pkcs5.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\pkparse.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\pkwrite.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\pk_wrap.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\platform.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\platform_util.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\poly1305.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\psa_crypto.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\psa_crypto_se.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\psa_crypto_slot_management.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\psa_crypto_storage.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\psa_its_file.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\ripemd160.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\rsa.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\rsa_internal.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\sha1.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\sha256.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\sha512.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\ssl_cache.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\ssl_ciphersuites.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\ssl_cli.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\ssl_cookie.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\ssl_msg.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\ssl_srv.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\ssl_ticket.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\ssl_tls.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\threading.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\timing.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\version.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\version_features.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\x509.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\x509write_crt.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\x509write_csr.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\x509_create.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\x509_crl.c" />
<ClCompile Include="..\..\thirdparty\mbedtls\library\x509_crt.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\x509_csr.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\xtea.c" />
<ClCompile Include="..\..\Source\corePKCS11\source\dependency\3rdparty\mbedtls_utils\mbedtls_error.c" />
<ClCompile Include="..\..\Source\corePKCS11\source\dependency\3rdparty\mbedtls_utils\mbedtls_utils.c" />
<ClCompile Include="..\..\Source\corePKCS11\source\core_pkcs11.c" />
<ClCompile Include="..\..\Source\corePKCS11\source\core_pki_utils.c" />
<ClCompile Include="..\..\Source\corePKCS11\source\portable\mbedtls\core_pkcs11_mbedtls.c" />
<ClCompile Include="..\..\Source\corePKCS11\source\portable\windows\core_pkcs11_pal.c" />
<ClCompile Include="..\..\Source\Utilities\mbedtls_freertos\mbedtls_freertos_port.c" />
<ClCompile Include="..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\FreeRTOS_ARP.c" />
<ClCompile Include="..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\FreeRTOS_DHCP.c" />
<ClCompile Include="..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\FreeRTOS_DNS.c" />
@@ -188,11 +279,106 @@
<ClInclude Include="..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include\IPTraceMacroDefaults.h" />
<ClInclude Include="..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include\NetworkBufferManagement.h" />
<ClInclude Include="..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include\NetworkInterface.h" />
<ClInclude Include="..\..\Source\FreeRTOS-Plus-TCP\include\FreeRTOS_errno_TCP.h" />
<ClInclude Include="..\..\..\FreeRTOS-Plus\Source\Utilities\logging\logging.h" />
<ClInclude Include="..\..\..\FreeRTOS-Plus\Source\Utilities\logging\logging_levels.h" />
<ClInclude Include="..\..\..\FreeRTOS-Plus\Source\Utilities\logging\logging_stack.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\aes.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\aesni.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\arc4.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\aria.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\asn1.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\asn1write.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\base64.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\bignum.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\blowfish.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\bn_mul.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\camellia.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\ccm.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\certs.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\chacha20.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\chachapoly.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\check_config.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\cipher.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\cipher_internal.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\cmac.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\compat-1.3.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\config.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\ctr_drbg.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\debug.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\des.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\dhm.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\ecdh.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\ecdsa.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\ecjpake.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\ecp.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\ecp_internal.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\entropy.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\entropy_poll.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\error.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\gcm.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\havege.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\hkdf.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\hmac_drbg.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\md.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\md2.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\md4.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\md5.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\md_internal.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\memory_buffer_alloc.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\net.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\net_sockets.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\nist_kw.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\oid.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\padlock.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\pem.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\pk.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\pkcs11.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\pkcs12.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\pkcs5.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\pk_internal.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\platform.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\platform_time.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\platform_util.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\poly1305.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\psa_util.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\ripemd160.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\rsa.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\rsa_internal.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\sha1.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\sha256.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\sha512.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\ssl.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\ssl_cache.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\ssl_ciphersuites.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\ssl_cookie.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\ssl_internal.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\ssl_ticket.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\threading.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\timing.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\version.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\x509.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\x509_crl.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\x509_crt.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\x509_csr.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\xtea.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\library\common.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\library\psa_crypto_core.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\library\psa_crypto_invasive.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\library\psa_crypto_its.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\library\psa_crypto_se.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\library\psa_crypto_service_integration.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\library\psa_crypto_slot_management.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\library\psa_crypto_storage.h" />
<ClInclude Include="..\..\ThirdParty\mbedtls\library\ssl_invasive.h" />
<ClInclude Include="..\..\Source\corePKCS11\source\dependency\3rdparty\mbedtls_utils\mbedtls_error.h" />
<ClInclude Include="..\..\Source\corePKCS11\source\dependency\3rdparty\pkcs11\pkcs11.h" />
<ClInclude Include="..\..\Source\corePKCS11\source\dependency\3rdparty\pkcs11\pkcs11f.h" />
<ClInclude Include="..\..\Source\corePKCS11\source\dependency\3rdparty\pkcs11\pkcs11t.h" />
<ClInclude Include="..\..\Source\corePKCS11\source\include\core_pkcs11.h" />
<ClInclude Include="..\..\Source\corePKCS11\source\include\core_pkcs11_pal.h" />
<ClInclude Include="..\..\Source\corePKCS11\source\include\core_pki_utils.h" />
<ClInclude Include="..\..\Source\Application-Protocols\coreSNTP\source\include\core_sntp_config_defaults.h" />
<ClInclude Include="..\..\Source\FreeRTOS-Plus-TCP\include\FreeRTOS_errno_TCP.h" />
<ClInclude Include="..\..\Source\Application-Protocols\coreSNTP\source\include\core_sntp_serializer.h" />
<ClInclude Include="..\..\Source\Application-Protocols\coreSNTP\source\include\core_sntp_client.h" />
<ClInclude Include="demo_config.h" />
@@ -200,6 +386,9 @@
<ClInclude Include="FreeRTOSConfig.h" />
<ClInclude Include="FreeRTOSIPConfig.h" />
<ClInclude Include="core_sntp_config.h" />
<ClInclude Include="aws_mbedtls_config.h" />
<ClInclude Include="threading_alt.h" />
<ClInclude Include="core_pkcs11_config.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,192 @@
/*
* FreeRTOS V202104.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
*
*/
/**
* @file core_pkcs11_config.h
* @brief PCKS#11 config options.
*/
#ifndef _CORE_PKCS11_CONFIG_H_
#define _CORE_PKCS11_CONFIG_H_
#include "FreeRTOS.h"
/**************************************************/
/******* DO NOT CHANGE the following order ********/
/**************************************************/
/* Include logging header files and define logging macros in the following order:
* 1. Include the header file "logging_levels.h".
* 2. Define the LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL macros depending on
* the logging configuration for PKCS #11.
* 3. Include the header file "logging_stack.h", if logging is enabled for PKCS #11.
*/
#include "logging_levels.h"
/* Logging configuration for the PKCS #11 library. */
#ifndef LIBRARY_LOG_NAME
#define LIBRARY_LOG_NAME "PKCS11"
#endif
#ifndef LIBRARY_LOG_LEVEL
#define LIBRARY_LOG_LEVEL LOG_ERROR
#endif
/* Prototype for the function used to print to console on Windows simulator
* of FreeRTOS.
* The function prints to the console before the network is connected;
* then a UDP port after the network has connected. */
extern void vLoggingPrintf( const char * pcFormatString,
... );
/* Map the SdkLog macro to the logging function to enable logging
* on Windows simulator. */
#ifndef SdkLog
#define SdkLog( message ) vLoggingPrintf message
#endif
#include "logging_stack.h"
/**
* @brief Malloc API used by core_pkcs11.h
*/
#define PKCS11_MALLOC pvPortMalloc
/**
* @brief Free API used by core_pkcs11.h
*/
#define PKCS11_FREE vPortFree
/**
* @brief PKCS #11 default user PIN.
*
* The PKCS #11 standard specifies the presence of a user PIN. That feature is
* sensible for applications that have an interactive user interface and memory
* protections. However, since typical microcontroller applications lack one or
* both of those, the user PIN is assumed to be used herein for interoperability
* purposes only, and not as a security feature.
*
* Note: Do not cast this to a pointer! The library calls sizeof to get the length
* of this string.
*/
#define configPKCS11_DEFAULT_USER_PIN "0000"
/**
* @brief Maximum length (in characters) for a PKCS #11 CKA_LABEL
* attribute.
*/
#define pkcs11configMAX_LABEL_LENGTH 32
/**
* @brief Maximum number of token objects that can be stored
* by the PKCS #11 module.
*/
#define pkcs11configMAX_NUM_OBJECTS 6
/**
* @brief Maximum number of sessions that can be stored
* by the PKCS #11 module.
*/
#define pkcs11configMAX_SESSIONS 10
/**
* @brief Set to 1 if a PAL destroy object is implemented.
*
* If set to 0, no PAL destroy object is implemented, and this functionality
* is implemented in the common PKCS #11 layer.
*/
#define pkcs11configPAL_DESTROY_SUPPORTED 0
/**
* @brief Set to 1 if OTA image verification via PKCS #11 module is supported.
*
* If set to 0, OTA code signing certificate is built in via
* aws_ota_codesigner_certificate.h.
*/
#define pkcs11configOTA_SUPPORTED 0
/**
* @brief Set to 1 if PAL supports storage for JITP certificate,
* code verify certificate, and trusted server root certificate.
*
* If set to 0, PAL does not support storage mechanism for these, and
* they are accessed via headers compiled into the code.
*/
#define pkcs11configJITP_CODEVERIFY_ROOT_CERT_SUPPORTED 0
/**
* @brief The PKCS #11 label for device private key.
*
* Private key for connection to AWS IoT endpoint. The corresponding
* public key should be registered with the AWS IoT endpoint.
*/
#define pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS "Device Priv TLS Key"
/**
* @brief The PKCS #11 label for device public key.
*
* The public key corresponding to pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS.
*/
#define pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS "Device Pub TLS Key"
/**
* @brief The PKCS #11 label for the device certificate.
*
* Device certificate corresponding to pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS.
*/
#define pkcs11configLABEL_DEVICE_CERTIFICATE_FOR_TLS "Device Cert"
/**
* @brief The PKCS #11 label for the object to be used for CMAC operations.
*/
#define pkcs11configLABEL_CMAC_KEY "CMAC Key"
/**
* @brief The PKCS #11 label for the object to be used for code verification.
*
* Used by over-the-air update code to verify an incoming signed image.
*/
#define pkcs11configLABEL_CODE_VERIFICATION_KEY "Code Verify Key"
/**
* @brief The PKCS #11 label for Just-In-Time-Provisioning.
*
* The certificate corresponding to the issuer of the device certificate
* (pkcs11configLABEL_DEVICE_CERTIFICATE_FOR_TLS) when using the JITR or
* JITP flow.
*/
#define pkcs11configLABEL_JITP_CERTIFICATE "JITP Cert"
/**
* @brief The PKCS #11 label for the AWS Trusted Root Certificate.
*
* @see aws_default_root_certificates.h
*/
#define pkcs11configLABEL_ROOT_CERTIFICATE "Root Cert"
#endif /* _CORE_PKCS11_CONFIG_H_ */
@@ -90,8 +90,49 @@ extern void vLoggingPrintf( const char * pcFormatString,
* @brief The set of time servers, in decreasing order of priority, for configuring the SNTP client.
* The servers SHOULD be listed as comma-separated list of strings. For example, the following
* can be a configuration used:
*
* #define democonfigLIST_OF_TIME_SERVERS "<custom-timeserver-1>", "<custom-timeserver-2>", "pool.ntp.org"
*/
/**
* @brief The list of 128-bit (or 16 bytes) symmetric keys for authenticating communication with the NTP/SNTP time servers
* corresponding to the list in democonfigLIST_OF_TIME_SERVERS. A symmetric key is used for generating authentication code
* in client request to related NTP/SNTP server as well as validating server from the time response received.
*
* This demo shows use of AES-128-CMAC algorithm for a mutual authentication mechanism in the SNTP communication
* between the NTP/SNTP server and client. The demo generates a Message Authentication Code (MAC) using
* the algorithm and appends it to the client request packet before the coreSNTP library sends it over
* the network to the server. The server validates the client from the request from the authentication code
* present in the request packet. Similarly, this demo validates the server from the response received on
* the network by verifying the authentication code present in the response packet.
*
* It is RECOMMENDED to use an authentication mechanism for protecting devices against server spoofing
* attacks.
*
* @note Please provide the 128-bit keys as comma separated list of hexadecimal strings in the order matching
* the list of time servers configured in democonfigLIST_OF_TIME_SERVERS configuration. If a time server does
* not support authentication, then NULL should be used to indicate use of no authentication mechanism for the
* time server.
*
* @note Use of the AES-128-CMAC based authentication scheme in the demo requires that the symmetric key
* is shared safely between the time server and the client device.
*
* #define democonfigAES_CMAC_AUTHENTICATION_SYMMETRIC_KEY "<hexstring-key-1>", "<hexstring-key-2>", NULL
*/
/**
* @brief The list of key IDs of the shared @ref democonfigLIST_OF_AUTHENTICATION_SYMMETRIC_KEYS keys between
* the client and the corresponding NTP/SNTP servers, in democonfigLIST_OF_TIME_SERVERS, for authenticating
* the SNTP communication between the client and server.
*
* The ID for a key usually represents the ID used to reference the symmetric key in the NTP/SNTP server system.
*
* @note This Key IDs should be configured as a comma-separated list of integer Key IDs that match the order of
* keys in democonfigdemoconfigLIST_OF_AUTHENTICATION_SYMMETRIC_KEYS. If there is a NULL (or no key) in the list
* of keys, then -1 can be used as the corresponding key ID.
*
* #define democonfigLIST_OF_AUTHENTICATION_KEY_IDS <key-ID-1>, <key-ID-2>, -1
*/
#define democonfigLIST_OF_TIME_SERVERS "time.cloudflare.com", "pool.ntp.org"
/**
* @brief The year to bake in the demo application for initializing the system clock with.
@@ -47,6 +47,11 @@
/* Demo logging includes. */
#include "logging.h"
/* mbedTLS include for configuring
* threading functions. */
#include "mbedtls/threading.h"
#include "threading_alt.h"
/* Demo Specific configs. */
#include "demo_config.h"
#include "common_demo_include.h"
@@ -150,6 +155,12 @@ void vStartSntpDemo( void )
{
initializeSystemClock();
/* Configure mbedTLS to use FreeRTOS specific threading function. */
mbedtls_threading_set_alt( mbedtls_platform_mutex_init,
mbedtls_platform_mutex_free,
mbedtls_platform_mutex_lock,
mbedtls_platform_mutex_unlock );
/* Create the SNTP client task that is responsible for synchronizing system time with the time servers
* periodically. This is created as a high priority task to keep the SNTP client operation unhindered. */
xTaskCreate( sntpTask, /* Function that implements the task. */
@@ -0,0 +1,137 @@
/*
* FreeRTOS V202104.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
*
*/
/* This file configures mbed TLS for FreeRTOS. */
#ifndef MBEDTLS_CONFIG_H_
#define MBEDTLS_CONFIG_H_
/* FreeRTOS include. */
#include "FreeRTOS.h"
/* Generate errors if deprecated functions are used. */
#define MBEDTLS_DEPRECATED_REMOVED
/* Place AES tables in ROM. */
#define MBEDTLS_AES_ROM_TABLES
/* Enable the following cipher modes. */
#define MBEDTLS_CIPHER_MODE_CBC
#define MBEDTLS_CIPHER_MODE_CFB
#define MBEDTLS_CIPHER_MODE_CTR
/* Enable CMAC mode for authentication code generation. */
#define MBEDTLS_CMAC_C
/* Enable the following cipher padding modes. */
#define MBEDTLS_CIPHER_PADDING_PKCS7
#define MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS
#define MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN
#define MBEDTLS_CIPHER_PADDING_ZEROS
/* Cipher suite configuration. */
#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES
#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
#define MBEDTLS_ECP_NIST_OPTIM
#define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
/* Enable all SSL alert messages. */
#define MBEDTLS_SSL_ALL_ALERT_MESSAGES
/* Enable the following SSL features. */
#define MBEDTLS_SSL_ENCRYPT_THEN_MAC
#define MBEDTLS_SSL_EXTENDED_MASTER_SECRET
#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
#define MBEDTLS_SSL_PROTO_TLS1_2
#define MBEDTLS_SSL_ALPN
#define MBEDTLS_SSL_SERVER_NAME_INDICATION
/* Check certificate key usage. */
#define MBEDTLS_X509_CHECK_KEY_USAGE
#define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE
/* Disable platform entropy functions. */
#define MBEDTLS_NO_PLATFORM_ENTROPY
/* Enable the following mbed TLS features. */
#define MBEDTLS_AES_C
#define MBEDTLS_ASN1_PARSE_C
#define MBEDTLS_ASN1_WRITE_C
#define MBEDTLS_BASE64_C
#define MBEDTLS_BIGNUM_C
#define MBEDTLS_CIPHER_C
#define MBEDTLS_CTR_DRBG_C
#define MBEDTLS_ECDH_C
#define MBEDTLS_ECDSA_C
#define MBEDTLS_ECP_C
#define MBEDTLS_ENTROPY_C
#define MBEDTLS_ENTROPY_HARDWARE_ALT
#define MBEDTLS_GCM_C
#define MBEDTLS_MD_C
#define MBEDTLS_OID_C
#define MBEDTLS_PEM_PARSE_C
#define MBEDTLS_PK_C
#define MBEDTLS_PK_PARSE_C
#define MBEDTLS_PK_WRITE_C
#define MBEDTLS_PKCS1_V15
#define MBEDTLS_PLATFORM_C
#define MBEDTLS_RSA_C
#define MBEDTLS_SHA1_C
#define MBEDTLS_SHA256_C
#define MBEDTLS_SSL_CLI_C
#define MBEDTLS_SSL_TLS_C
#define MBEDTLS_THREADING_ALT
#define MBEDTLS_THREADING_C
#define MBEDTLS_X509_USE_C
#define MBEDTLS_X509_CRT_PARSE_C
/* Set the memory allocation functions on FreeRTOS. */
void * mbedtls_platform_calloc( size_t nmemb,
size_t size );
void mbedtls_platform_free( void * ptr );
#define MBEDTLS_PLATFORM_MEMORY
#define MBEDTLS_PLATFORM_CALLOC_MACRO mbedtls_platform_calloc
#define MBEDTLS_PLATFORM_FREE_MACRO mbedtls_platform_free
/* The network send and receive functions on FreeRTOS. */
int mbedtls_platform_send( void * ctx,
const unsigned char * buf,
size_t len );
int mbedtls_platform_recv( void * ctx,
unsigned char * buf,
size_t len );
/* The entropy poll function. */
int mbedtls_platform_entropy_poll( void * data,
unsigned char * output,
size_t len,
size_t * olen );
#include "mbedtls/check_config.h"
#endif /* ifndef MBEDTLS_CONFIG_H_ */
+16
View File
@@ -7,6 +7,7 @@ aclk
acm
adc
adcclk
addclientauthcode
adden
addfaketaskwaitingtoreceivefromqueue
addfaketaskwaitingtosendtoqueue
@@ -151,6 +152,7 @@ bss
btimer
btn
buf
buffersize
bufsize
burtc
burtcclkdiv
@@ -441,6 +443,7 @@ dap
dat
datashee
datasheet
datatracker
dbe
dcdc
dclr
@@ -811,6 +814,7 @@ het
hetbase
hetport
hetreg
hexstring
hfclk
hfrco
hfxo
@@ -1396,6 +1400,8 @@ passsed
passwordsize
pasv
pathlen
pauthcodesize
pauthcontext
payloadlength
pb
pbasetime
@@ -1445,6 +1451,7 @@ pclientcert
pclk
pclkb
pclwipappsblockinggettxbuffer
pcmackey
pcmethod
pcmyreply
pcname
@@ -1511,6 +1518,7 @@ pfm
pfr
pfs
pfswe
pfunctionlist
phostname
php
phy
@@ -1609,11 +1617,13 @@ preceivedcommand
predivide
prefen
premain
prequestbuffer
prescale
prescaled
prescaler
presense
presigned
presponsedata
prev
printc
printf
@@ -1812,6 +1822,7 @@ ps
psc
pscheckvariable
psel
pserver
pserverinfo
psignature
psl
@@ -2048,6 +2059,7 @@ resetart
resetprg
resoltion
resp
responsesize
resubscribe
resubscribes
resync
@@ -2214,6 +2226,9 @@ sni
snprintf
sntp
sntpclienttask
sntperrorauthfailure
sntpservernotauthenticated
sntpsuccess
sntptask
soc
sockaddr
@@ -2370,6 +2385,7 @@ tim
timeguard
timertest
timertimer
timeserver
tls
tmr
tmrdemoone