VirtualBox

Changeset 74314 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 17, 2018 3:54:12 PM (6 years ago)
Author:
vboxsync
Message:

IPRT/crypto: Simple symmetric cipher abstraction with just was we need right now. Untested. bugref:9246 [build fix]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/crypto/cipher-openssl.cpp

    r74313 r74314  
    228228             * Do the encryption.
    229229             */
    230             int cbEncrypted = 0;
    231             rcOssl = EVP_EncryptUpdate(pCipherCtx, (unsigned char *)pvEncrypted, &cbEncrypted,
     230            int cbEncrypted1 = 0;
     231            rcOssl = EVP_EncryptUpdate(pCipherCtx, (unsigned char *)pvEncrypted, &cbEncrypted1,
    232232                                       (unsigned char const *)pvPlainText, (int)cbPlainText);
    233233            if (rcOssl > 0)
    234234            {
    235                 Assert(cbEncrypted <= (ssize_t)cbNeeded);
    236                 int cbEncryptedFinal = 0;
    237                 rcOssl = EVP_DecryptFinal(pCipherCtx, (unsigned char *)pvEncrypted + cbEncrypted, &cbEncryptedFinal);
     235                Assert(cbEncrypted1 <= (ssize_t)cbNeeded);
     236                int cbEncrypted2 = 0;
     237                rcOssl = EVP_DecryptFinal(pCipherCtx, (unsigned char *)pvEncrypted + cbEncrypted1, &cbEncrypted1);
    238238                if (rcOssl > 0)
    239239                {
    240                     Assert(cbEncryptedFinal + cbEncrypted == (ssize_t)cbNeeded);
     240                    Assert(cbEncrypted1 + cbEncrypted2 == (ssize_t)cbNeeded);
    241241                    if (pcbEncrypted)
    242                         *pcbEncrypted = cbEncryptedFinal + cbEncrypted;
     242                        *pcbEncrypted = cbEncrypted1 + cbEncrypted2;
    243243                    rc = VINF_SUCCESS;
    244244                }
     
    312312             * Do the decryption.
    313313             */
    314             int cbDecrypted = 0;
    315             rcOssl = EVP_DecryptUpdate(pCipherCtx, (unsigned char *)pvPlainText, &cbDecrypted,
     314            int cbDecrypted1 = 0;
     315            rcOssl = EVP_DecryptUpdate(pCipherCtx, (unsigned char *)pvPlainText, &cbDecrypted1,
    316316                                       (unsigned char const *)pvEncrypted, (int)cbEncrypted);
    317317            if (rcOssl > 0)
    318318            {
    319                 Assert(cbDecrypted <= (ssize_t)cbNeeded);
    320                 int cbDecryptedFinal = 0;
    321                 rcOssl = EVP_DecryptFinal(pCipherCtx, (unsigned char *)pvPlainText + cbDecrypted, &cbDecryptedFinal);
     319                Assert(cbDecrypted1 <= (ssize_t)cbNeeded);
     320                int cbDecrypted2 = 0;
     321                rcOssl = EVP_DecryptFinal(pCipherCtx, (unsigned char *)pvPlainText + cbDecrypted1, &cbDecrypted2);
    322322                if (rcOssl > 0)
    323323                {
    324                     Assert(cbDecryptedFinal + cbDecrypted == (ssize_t)cbNeeded);
     324                    Assert(cbDecrypted1 + cbDecrypted2 == (ssize_t)cbNeeded);
    325325                    if (pcbPlainText)
    326                         *pcbPlainText = cbDecryptedFinal + cbDecrypted;
     326                        *pcbPlainText = cbDecrypted1 + cbDecrypted2;
    327327                    rc = VINF_SUCCESS;
    328328                }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette