浏览代码

fold an identical if-condition during asym encryption

Julius Pfrommer 7 年之前
父节点
当前提交
c7466d5539
共有 1 个文件被更改,包括 4 次插入5 次删除
  1. 4 5
      src/ua_securechannel.c

+ 4 - 5
src/ua_securechannel.c

@@ -361,9 +361,9 @@ UA_SecureChannel_sendAsymmetricOPNMessage(UA_SecureChannel *channel, UA_UInt32 r
         return retval;
     }
 
-    /* Sign message */
     if(channel->securityMode == UA_MESSAGESECURITYMODE_SIGN ||
        channel->securityMode == UA_MESSAGESECURITYMODE_SIGNANDENCRYPT) {
+        /* Sign message */
         const UA_ByteString dataToSign = {pre_sig_length, buf.data};
         size_t sigsize = securityPolicy->asymmetricModule.cryptoModule.
             getLocalSignatureSize(securityPolicy, channel->channelContext);
@@ -374,11 +374,10 @@ UA_SecureChannel_sendAsymmetricOPNMessage(UA_SecureChannel *channel, UA_UInt32 r
             connection->releaseSendBuffer(connection, &buf);
             return retval;
         }
-    }
 
-    /* Encrypt message if mode not none */
-    if(channel->securityMode == UA_MESSAGESECURITYMODE_SIGN ||
-       channel->securityMode == UA_MESSAGESECURITYMODE_SIGNANDENCRYPT) {
+        /* Specification part 6, §6.7.4: The OpenSecureChannel Messages are
+         * signed and encrypted if the SecurityMode is not None (even if the
+         * SecurityMode is SignOnly). */
         size_t unencrypted_length =
             UA_SECURE_CONVERSATION_MESSAGE_HEADER_LENGTH + securityHeaderLength;
         UA_ByteString dataToEncrypt = {total_length - unencrypted_length,