VirtualBox

Changeset 54855 in vbox


Ignore:
Timestamp:
Mar 19, 2015 8:12:00 PM (10 years ago)
Author:
vboxsync
Message:

Main/Medium: Logic change for IMedium::ChangeEncryption, an empty password and password ID will result in the current password being used for encryption if the cipher is not empty. Useful for changing the encryption cipher of an image while still using the same password

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r54854 r54855  
    1476814768      <param name="newPassword" type="wstring" dir="in">
    1476914769        <desc>
    14770           The new password the medium should be protected with. Use an empty string
    14771           to indicate that the result should not be encrypted.
     14770          The new password the medium should be protected with. An empty password and password ID
     14771          will result in the medium being encrypted with the current password.
    1477214772        </desc>
    1477314773      </param>
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r54854 r54855  
    89378937        char *pszKeyStoreEncNew = NULL;
    89388938        void *pvBuf = NULL;
     8939        const char *pszPasswordNew = NULL;
    89398940        try
    89408941        {
     
    89728973            if (task.mstrCipher.isNotEmpty())
    89738974            {
    8974                 if (task.mstrNewPassword.isEmpty())
     8975                if (   task.mstrNewPassword.isEmpty()
     8976                    && task.mstrNewPasswordId.isEmpty()
     8977                    && task.mstrCurrentPassword.isNotEmpty())
     8978                {
     8979                    /* An empty password and password ID will default to the current password. */
     8980                    pszPasswordNew = task.mstrCurrentPassword.c_str();
     8981                }
     8982                else if (task.mstrNewPassword.isEmpty())
    89758983                    throw setError(VBOX_E_OBJECT_NOT_FOUND,
    89768984                                   tr("A password must be given for the image encryption"));
    8977 
    8978                 if (task.mstrNewPasswordId.isEmpty())
     8985                else if (task.mstrNewPasswordId.isEmpty())
    89798986                    throw setError(VBOX_E_INVALID_OBJECT_STATE,
    89808987                                   tr("A valid identifier for the password must be given"));
     8988                else
     8989                    pszPasswordNew = task.mstrNewPassword.c_str();
    89818990
    89828991                i_taskEncryptSettingsSetup(&CryptoSettingsWrite, task.mstrCipher.c_str(), NULL,
    8983                                            task.mstrNewPassword.c_str(), true /* fCreateKeyStore */);
     8992                                           pszPasswordNew, true /* fCreateKeyStore */);
    89848993                vrc = VDFilterAdd(pDisk, "CRYPT", VD_FILTER_FLAGS_WRITE, CryptoSettingsWrite.vdFilterIfaces);
    89858994                if (RT_FAILURE(vrc))
     
    89908999            else if (task.mstrNewPasswordId.isNotEmpty() || task.mstrNewPassword.isNotEmpty())
    89919000                throw setError(VBOX_E_INVALID_OBJECT_STATE,
    8992                                tr("The password and password identifier must be empty if there is the output shuld be unencrypted"));
     9001                               tr("The password and password identifier must be empty if the output should be unencrypted"));
    89939002
    89949003            /* Open all media in the chain. */
     
    90449053                pBase->m->mapProperties.erase(it);
    90459054
    9046             it = pBase->m->mapProperties.find("CRYPT/KeyId");
    9047             if (it != pBase->m->mapProperties.end())
    9048                 pBase->m->mapProperties.erase(it);
     9055            if (task.mstrNewPasswordId.isNotEmpty())
     9056            {
     9057                it = pBase->m->mapProperties.find("CRYPT/KeyId");
     9058                if (it != pBase->m->mapProperties.end())
     9059                    pBase->m->mapProperties.erase(it);
     9060            }
    90499061
    90509062            if (CryptoSettingsWrite.pszKeyStore)
    90519063            {
    90529064                pBase->m->mapProperties["CRYPT/KeyStore"] = Utf8Str(CryptoSettingsWrite.pszKeyStore);
    9053                 pBase->m->mapProperties["CRYPT/KeyId"] = task.mstrNewPasswordId;
     9065                if (task.mstrNewPasswordId.isNotEmpty())
     9066                    pBase->m->mapProperties["CRYPT/KeyId"] = task.mstrNewPasswordId;
    90549067            }
    90559068
     
    90749087                       tr("Encryption is not supported because extension pack support is not built in"));
    90759088# endif
    9076 
    9077 
    90789089    }
    90799090    catch (HRESULT aRC) { rc = aRC; }
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