Browse Source

Removed unused variable that was previously part of the solution

Jonas Green 5 years ago
parent
commit
4c5fa4a33f
1 changed files with 23 additions and 26 deletions
  1. 23 26
      src/ua_securechannel.c

+ 23 - 26
src/ua_securechannel.c

@@ -584,33 +584,30 @@ setBufPos(UA_MessageContext *mc) {
      * if the chunk is encrypted. */
     if(channel->securityMode == UA_MESSAGESECURITYMODE_SIGN ||
        channel->securityMode == UA_MESSAGESECURITYMODE_SIGNANDENCRYPT)
-    {
-        size_t signatureSize = securityPolicy->symmetricModule.cryptoModule.signatureAlgorithm.
+        mc->buf_end -= securityPolicy->symmetricModule.cryptoModule.signatureAlgorithm.
             getLocalSignatureSize(securityPolicy, channel->channelContext);
-        mc->buf_end -= signatureSize;
-
-        /* The size of the padding depends on the amount of data that shall be sent
-         * and is unknown at this point. Reserve space for the PaddingSize byte,
-         * the maximum amount of Padding which equals the block size of the
-         * symmetric encryption algorithm and last 1 byte for the ExtraPaddingSize
-         * field that is present if the encryption key is larger than 2048 bits.
-         * The actual padding size is later calculated by the function
-         * calculatePaddingSym(). */
-        if(channel->securityMode == UA_MESSAGESECURITYMODE_SIGNANDENCRYPT)
-        {
-            /* PaddingSize and ExtraPaddingSize fields */
-            size_t encryptionBlockSize = securityPolicy->symmetricModule.cryptoModule.encryptionAlgorithm.
-                getLocalBlockSize(securityPolicy, channel->channelContext );
-            mc->buf_end -= 1 + (encryptionBlockSize>>8)?1:0;
-
-            /* Reduce the message body size with the remainder of the operation
-             * maxEncryptedDataSize modulo EncryptionBlockSize to get a whole
-             * number of blocks to encrypt later. Also reserve one byte for
-             * padding (1 <= paddingSize <= encryptionBlockSize).
-             */
-            size_t maxEncryptDataSize = mc->messageBuffer.length-UA_SECURE_CONVERSATION_MESSAGE_HEADER_LENGTH-UA_SYMMETRIC_ALG_SECURITY_HEADER_LENGTH;
-            mc->buf_end -= (maxEncryptDataSize % encryptionBlockSize) + 1;
-        }
+
+    /* The size of the padding depends on the amount of data that shall be sent
+     * and is unknown at this point. Reserve space for the PaddingSize byte,
+     * the maximum amount of Padding which equals the block size of the
+     * symmetric encryption algorithm and last 1 byte for the ExtraPaddingSize
+     * field that is present if the encryption key is larger than 2048 bits.
+     * The actual padding size is later calculated by the function
+     * calculatePaddingSym(). */
+    if(channel->securityMode == UA_MESSAGESECURITYMODE_SIGNANDENCRYPT)
+    {
+        /* PaddingSize and ExtraPaddingSize fields */
+        size_t encryptionBlockSize = securityPolicy->symmetricModule.cryptoModule.encryptionAlgorithm.
+            getLocalBlockSize(securityPolicy, channel->channelContext );
+        mc->buf_end -= 1 + (encryptionBlockSize >> 8) ? 1 : 0;
+
+        /* Reduce the message body size with the remainder of the operation
+         * maxEncryptedDataSize modulo EncryptionBlockSize to get a whole
+         * number of blocks to encrypt later. Also reserve one byte for
+         * padding (1 <= paddingSize <= encryptionBlockSize).
+         */
+        size_t maxEncryptDataSize = mc->messageBuffer.length-UA_SECURE_CONVERSATION_MESSAGE_HEADER_LENGTH-UA_SYMMETRIC_ALG_SECURITY_HEADER_LENGTH;
+        mc->buf_end -= (maxEncryptDataSize % encryptionBlockSize) + 1;
     }
 }