Parcourir la source

Session: Check that encryption algorithm id matches policy

Tested in the CTT conformance unit "Security User Name Password"
Julius Pfrommer il y a 5 ans
Parent
commit
b313e69881
1 fichiers modifiés avec 8 ajouts et 0 suppressions
  1. 8 0
      src/server/ua_services_session.c

+ 8 - 0
src/server/ua_services_session.c

@@ -426,6 +426,14 @@ Service_ActivateSession(UA_Server *server, UA_SecureChannel *channel,
 
        /* Encrypted password? */
        if(!UA_String_equal(&securityPolicy->policyUri, &UA_SECURITY_POLICY_NONE_URI)) {
+           /* Test if the encryption algorithm is correctly specified */
+           if(!UA_String_equal(&userToken->encryptionAlgorithm,
+                               &securityPolicy->asymmetricModule.cryptoModule.
+                               encryptionAlgorithm.uri)) {
+               response->responseHeader.serviceResult = UA_STATUSCODE_BADIDENTITYTOKENINVALID;
+               return;
+           }
+
            /* Create a temporary channel context if a different SecurityPolicy is
             * used for the password from the SecureChannel */
            void *tempChannelContext = channel->channelContext;