Ver código fonte

feat(mbedtls): Use mbedtls_hardware_poll fallback if MBEDTLS_NO_PLATFORM_ENTROPY defined

Stefan Profanter 5 anos atrás
pai
commit
a6db9c0a91

+ 7 - 0
plugins/include/open62541/plugin/securitypolicy_mbedtls_common.h

@@ -15,6 +15,13 @@
 #include <mbedtls/x509_crt.h>
 #include <mbedtls/ctr_drbg.h>
 
+#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
+#define MBEDTLS_ENTROPY_POLL_METHOD mbedtls_platform_entropy_poll
+#else
+// MBEDTLS_ENTROPY_HARDWARE_ALT should be defined if your hardware does not supportd platform entropy
+#define MBEDTLS_ENTROPY_POLL_METHOD mbedtls_hardware_poll
+#endif
+
 #define UA_SHA1_LENGTH 20
 
 _UA_BEGIN_DECLS

+ 1 - 1
plugins/securityPolicies/ua_securitypolicy_basic128rsa15.c

@@ -691,7 +691,7 @@ policyContext_newContext_sp_basic128rsa15(UA_SecurityPolicy *securityPolicy,
 
     /* Add the system entropy source */
     mbedErr = mbedtls_entropy_add_source(&pc->entropyContext,
-                                         mbedtls_platform_entropy_poll, NULL, 0,
+                                         MBEDTLS_ENTROPY_POLL_METHOD, NULL, 0,
                                          MBEDTLS_ENTROPY_SOURCE_STRONG);
     if(mbedErr) {
         retval = UA_STATUSCODE_BADSECURITYCHECKSFAILED;

+ 1 - 1
plugins/securityPolicies/ua_securitypolicy_basic256.c

@@ -641,7 +641,7 @@ policyContext_newContext_sp_basic256(UA_SecurityPolicy *securityPolicy,
 
     /* Add the system entropy source */
     mbedErr = mbedtls_entropy_add_source(&pc->entropyContext,
-                                         mbedtls_platform_entropy_poll, NULL, 0,
+                                         MBEDTLS_ENTROPY_POLL_METHOD, NULL, 0,
                                          MBEDTLS_ENTROPY_SOURCE_STRONG);
     if(mbedErr) {
         retval = UA_STATUSCODE_BADSECURITYCHECKSFAILED;

+ 1 - 1
plugins/securityPolicies/ua_securitypolicy_basic256sha256.c

@@ -682,7 +682,7 @@ policyContext_newContext_sp_basic256sha256(UA_SecurityPolicy *securityPolicy,
 
     /* Add the system entropy source */
     mbedErr = mbedtls_entropy_add_source(&pc->entropyContext,
-                                         mbedtls_platform_entropy_poll, NULL, 0,
+                                         MBEDTLS_ENTROPY_POLL_METHOD, NULL, 0,
                                          MBEDTLS_ENTROPY_SOURCE_STRONG);
     if(mbedErr) {
         retval = UA_STATUSCODE_BADSECURITYCHECKSFAILED;