- 時間撮記:
- 2014-6-27 下午08:59:43 (10 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r51687 r51752 421 421 #endif 422 422 , mBusMgr(NULL) 423 , mpIfSecKey(NULL) 423 424 , mVMStateChangeCallbackDisabled(false) 424 425 , mfUseHostClipboard(true) … … 457 458 pVmm2UserMethods->pConsole = this; 458 459 mpVmm2UserMethods = pVmm2UserMethods; 460 461 MYPDMISECKEY *pIfSecKey = (MYPDMISECKEY *)RTMemAllocZ(sizeof(*mpIfSecKey) + sizeof(Console *)); 462 if (!pIfSecKey) 463 return E_OUTOFMEMORY; 464 pIfSecKey->pfnKeyRetain = Console::i_pdmIfSecKey_KeyRetain; 465 pIfSecKey->pfnKeyRelease = Console::i_pdmIfSecKey_KeyRelease; 466 pIfSecKey->pConsole = this; 467 mpIfSecKey = pIfSecKey; 459 468 460 469 return BaseFinalConstruct(); … … 687 696 } 688 697 698 if (mpIfSecKey) 699 { 700 RTMemFree((void *)mpIfSecKey); 701 mpIfSecKey = NULL; 702 } 703 689 704 if (mNvram) 690 705 { … … 727 742 mRemoteUSBDevices.clear(); 728 743 mUSBDevices.clear(); 744 745 for (SecretKeyMap::iterator it = m_mapSecretKeys.begin(); 746 it != m_mapSecretKeys.end(); 747 it++) 748 delete it->second; 749 m_mapSecretKeys.clear(); 729 750 730 751 if (mVRDEServerInfo) … … 4361 4382 * @returns COM status code. 4362 4383 * @param pszUuid The UUID of the disk to configure encryption for. 4363 * @param pbKey The key to use4364 * @param cbKey Size of the key in bytes.4365 4384 */ 4366 HRESULT Console::i_configureEncryptionForDisk(const char *pszUuid , const uint8_t *pbKey, size_t cbKey)4385 HRESULT Console::i_configureEncryptionForDisk(const char *pszUuid) 4367 4386 { 4368 4387 HRESULT hrc = S_OK; … … 4467 4486 } 4468 4487 4469 rc = pIMedium->pfnSet Key(pIMedium, pbKey, cbKey);4488 rc = pIMedium->pfnSetSecKeyIf(pIMedium, mpIfSecKey); 4470 4489 if (RT_FAILURE(rc)) 4471 4490 return setError(E_FAIL, tr("Failed to set the encryption key (%Rrc)"), rc); … … 4542 4561 rc = RTBase64Decode(pszKeyEnc, pbKey, cbKey, NULL, NULL); 4543 4562 if (RT_SUCCESS(rc)) 4544 hrc = i_configureEncryptionForDisk(pszUuid, pbKey, cbKey); 4563 { 4564 SecretKey *pKey = new SecretKey(pbKey, cbKey); 4565 /* Add the key to the map */ 4566 m_mapSecretKeys.insert(std::make_pair(Utf8Str(pszUuid), pKey)); 4567 hrc = i_configureEncryptionForDisk(pszUuid); 4568 } 4545 4569 else 4546 4570 hrc = setError(E_FAIL, 4547 4571 tr("Failed to decode the key (%Rrc)"), 4548 4572 rc); 4549 4550 RTMemWipeThoroughly(pbKey, cbKey, 10 /* cMinPasses */);4551 RTMemLockedFree(pbKey);4552 4573 } 4553 4574 else … … 10134 10155 10135 10156 pConsole->mfPowerOffCausedByReset = true; 10157 } 10158 10159 10160 10161 10162 /** 10163 * @interface_method_impl{PDMISECKEY,pfnKeyRetain} 10164 */ 10165 /*static*/ DECLCALLBACK(int) 10166 Console::i_pdmIfSecKey_KeyRetain(PPDMISECKEY pInterface, const char *pszId, const uint8_t **ppbKey, 10167 size_t *pcbKey) 10168 { 10169 Console *pConsole = ((MYPDMISECKEY *)pInterface)->pConsole; 10170 10171 SecretKeyMap::const_iterator it = pConsole->m_mapSecretKeys.find(Utf8Str(pszId)); 10172 if (it != pConsole->m_mapSecretKeys.end()) 10173 { 10174 SecretKey *pKey = (*it).second; 10175 10176 ASMAtomicIncU32(&pKey->m_cRefs); 10177 *ppbKey = pKey->m_pbKey; 10178 *pcbKey = pKey->m_cbKey; 10179 return VINF_SUCCESS; 10180 } 10181 10182 return VERR_NOT_FOUND; 10183 } 10184 10185 /** 10186 * @interface_method_impl{PDMISECKEY,pfnKeyRelease} 10187 */ 10188 /*static*/ DECLCALLBACK(int) 10189 Console::i_pdmIfSecKey_KeyRelease(PPDMISECKEY pInterface, const char *pszId) 10190 { 10191 Console *pConsole = ((MYPDMISECKEY *)pInterface)->pConsole; 10192 SecretKeyMap::const_iterator it = pConsole->m_mapSecretKeys.find(Utf8Str(pszId)); 10193 if (it != pConsole->m_mapSecretKeys.end()) 10194 { 10195 SecretKey *pKey = (*it).second; 10196 ASMAtomicDecU32(&pKey->m_cRefs); 10197 return VINF_SUCCESS; 10198 } 10199 10200 return VERR_NOT_FOUND; 10136 10201 } 10137 10202
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器