Changeset 51342 in vbox for trunk/src/VBox/Devices/Storage
- Timestamp:
- May 22, 2014 10:24:53 AM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 93828
- Location:
- trunk/src/VBox/Devices/Storage
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevAHCI.cpp
r51340 r51342 5740 5740 return true; 5741 5741 } 5742 if (rc == VERR_VD_DEK_MISSING) 5743 { 5744 /* Error message already set. */ 5745 ASMAtomicCmpXchgBool(&pAhciPort->fRedo, true, false); 5746 return true; 5747 } 5748 5742 5749 return false; 5743 5750 } -
trunk/src/VBox/Devices/Storage/DevATA.cpp
r50283 r51342 1541 1541 return true; 1542 1542 } 1543 if (rc == VERR_VD_DEK_MISSING) 1544 { 1545 /* Error message already set. */ 1546 pCtl->fRedoIdle = true; 1547 return true; 1548 } 1549 1543 1550 return false; 1544 1551 } -
trunk/src/VBox/Devices/Storage/DrvSCSI.cpp
r50089 r51342 123 123 || rc == VERR_FILE_TOO_BIG 124 124 || rc == VERR_BROKEN_PIPE 125 || rc == VERR_NET_CONNECTION_REFUSED) 125 || rc == VERR_NET_CONNECTION_REFUSED 126 || rc == VERR_VD_DEK_MISSING) 126 127 return true; 127 128 -
trunk/src/VBox/Devices/Storage/DrvVD.cpp
r51103 r51342 186 186 /** The block cache handle if configured. */ 187 187 PPDMBLKCACHE pBlkCache; 188 189 /** Cryptographic support 190 * @{ */ 191 /** Used algorithm, NULL means no encryption. */ 192 char *pszEncryptionAlgorithm; 193 /** Config interface for the encryption filter. */ 194 VDINTERFACECONFIG VDIfCfg; 195 /** Flag whether the DEK was provided. */ 196 bool fDekProvided; 197 /** Pointer to the key material - temporary. */ 198 const uint8_t *pbKey; 199 /** Size of the key material in bytes. */ 200 size_t cbKey; 201 /** @} */ 188 202 } VBOXDISK, *PVBOXDISK; 189 203 … … 621 635 } 622 636 637 638 /******************************************************************************* 639 * VD Configuration interface implementation for the encryption support * 640 *******************************************************************************/ 641 642 static bool drvvdCfgEncAreKeysValid(void *pvUser, const char *pszValid) 643 { 644 return true; 645 } 646 647 static int drvvdCfgEncQuerySize(void *pvUser, const char *pszName, size_t *pcb) 648 { 649 PVBOXDISK pThis = (PVBOXDISK)pvUser; 650 int rc = VINF_SUCCESS; 651 652 if (!strcmp(pszName, "Algorithm")) 653 *pcb = strlen(pThis->pszEncryptionAlgorithm) + 1; 654 else if (!strcmp(pszName, "Key")) 655 *pcb = pThis->cbKey; 656 else 657 rc = VERR_NOT_SUPPORTED; 658 659 return rc; 660 } 661 662 static int drvvdCfgEncQuery(void *pvUser, const char *pszName, char *pszString, size_t cchString) 663 { 664 PVBOXDISK pThis = (PVBOXDISK)pvUser; 665 int rc = VINF_SUCCESS; 666 667 if (!strcmp(pszName, "Algorithm")) 668 rc = RTStrCopy(pszString, cchString, pThis->pszEncryptionAlgorithm); 669 else 670 rc = VERR_NOT_SUPPORTED; 671 672 return rc; 673 } 674 675 static int drvvdCfgEncQueryBytes(void *pvUser, const char *pszName, void *pvData, size_t cbData) 676 { 677 PVBOXDISK pThis = (PVBOXDISK)pvUser; 678 int rc = VINF_SUCCESS; 679 680 if (!strcmp(pszName, "Key")) 681 if (pThis->cbKey > cbData) 682 rc = VERR_BUFFER_OVERFLOW; 683 else 684 memcpy(pvData, pThis->pbKey, pThis->cbKey); 685 else 686 rc = VERR_NOT_SUPPORTED; 687 688 return rc; 689 690 } 623 691 624 692 #ifdef VBOX_WITH_INIP … … 1505 1573 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 1506 1574 1575 if ( pThis->pszEncryptionAlgorithm 1576 && !pThis->fDekProvided) 1577 { 1578 rc = PDMDrvHlpVMSetRuntimeError(pThis->pDrvIns, VMSETRTERR_FLAGS_SUSPEND | VMSETRTERR_FLAGS_NO_WAIT, "DrvVD_DEKMISSING", 1579 N_("VD: The DEK for this disk is missing")); 1580 AssertRC(rc); 1581 return VERR_VD_DEK_MISSING; 1582 } 1583 1507 1584 if (!pThis->fBootAccelActive) 1508 1585 rc = VDRead(pThis->pDisk, off, pvBuf, cbRead); … … 1555 1632 Log2(("%s: off=%#llx pvBuf=%p cbWrite=%d\n%.*Rhxd\n", __FUNCTION__, 1556 1633 off, pvBuf, cbWrite, cbWrite, pvBuf)); 1634 1635 if ( pThis->pszEncryptionAlgorithm 1636 && !pThis->fDekProvided) 1637 { 1638 int rc = PDMDrvHlpVMSetRuntimeError(pThis->pDrvIns, VMSETRTERR_FLAGS_SUSPEND | VMSETRTERR_FLAGS_NO_WAIT, "DrvVD_DEKMISSING", 1639 N_("VD: The DEK for this disk is missing")); 1640 AssertRC(rc); 1641 return VERR_VD_DEK_MISSING; 1642 } 1557 1643 1558 1644 /* Invalidate any buffer if boot acceleration is enabled. */ … … 1613 1699 } 1614 1700 1701 /** @copydoc PDMIMEDIA::pfnSetKey */ 1702 static DECLCALLBACK(int) drvvdSetKey(PPDMIMEDIA pInterface, const uint8_t *pbKey, 1703 size_t cbKey) 1704 { 1705 LogFlowFunc(("\n")); 1706 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 1707 int rc = VINF_SUCCESS; 1708 1709 if (pThis->pszEncryptionAlgorithm) 1710 { 1711 PVDINTERFACE pVDIfFilter = NULL; 1712 1713 pThis->pbKey = pbKey; 1714 pThis->cbKey = cbKey; 1715 1716 rc = VDInterfaceAdd(&pThis->VDIfCfg.Core, "DrvVD_Config", VDINTERFACETYPE_CONFIG, 1717 pThis, sizeof(VDINTERFACECONFIG), &pVDIfFilter); 1718 AssertRC(rc); 1719 1720 /* Load the crypt filter plugin. */ 1721 rc = VDFilterAdd(pThis->pDisk, "CRYPT", pVDIfFilter); 1722 if (RT_SUCCESS(rc)) 1723 pThis->fDekProvided = true; 1724 1725 pThis->pbKey = NULL; 1726 pThis->cbKey = 0; 1727 } 1728 else 1729 rc = VERR_NOT_SUPPORTED; 1730 1731 LogFlowFunc(("returns %Rrc\n", rc)); 1732 return rc; 1733 } 1734 1615 1735 /** @copydoc PDMIMEDIA::pfnGetSize */ 1616 1736 static DECLCALLBACK(uint64_t) drvvdGetSize(PPDMIMEDIA pInterface) … … 1774 1894 PVBOXDISK pThis = PDMIMEDIAASYNC_2_VBOXDISK(pInterface); 1775 1895 1896 if ( pThis->pszEncryptionAlgorithm 1897 && !pThis->fDekProvided) 1898 { 1899 rc = PDMDrvHlpVMSetRuntimeError(pThis->pDrvIns, VMSETRTERR_FLAGS_SUSPEND | VMSETRTERR_FLAGS_NO_WAIT, "DrvVD_DEKMISSING", 1900 N_("VD: The DEK for this disk is missing")); 1901 AssertRC(rc); 1902 return VERR_VD_DEK_MISSING; 1903 } 1904 1776 1905 pThis->fBootAccelActive = false; 1777 1906 … … 1803 1932 PVBOXDISK pThis = PDMIMEDIAASYNC_2_VBOXDISK(pInterface); 1804 1933 1934 if ( pThis->pszEncryptionAlgorithm 1935 && !pThis->fDekProvided) 1936 { 1937 rc = PDMDrvHlpVMSetRuntimeError(pThis->pDrvIns, VMSETRTERR_FLAGS_SUSPEND | VMSETRTERR_FLAGS_NO_WAIT, "DrvVD_DEKMISSING", 1938 N_("VD: The DEK for this disk is missing")); 1939 AssertRC(rc); 1940 return VERR_VD_DEK_MISSING; 1941 } 1942 1805 1943 pThis->fBootAccelActive = false; 1806 1944 … … 1886 2024 int rc = VINF_SUCCESS; 1887 2025 PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK); 2026 2027 Assert (!pThis->pszEncryptionAlgorithm); 1888 2028 1889 2029 switch (enmXferDir) … … 2173 2313 pThis->pszBwGroup = NULL; 2174 2314 } 2315 if (pThis->pszEncryptionAlgorithm) 2316 { 2317 MMR3HeapFree(pThis->pszEncryptionAlgorithm); 2318 pThis->pszBwGroup = NULL; 2319 } 2175 2320 } 2176 2321 … … 2208 2353 pThis->uMergeSource = VD_LAST_IMAGE; 2209 2354 pThis->uMergeTarget = VD_LAST_IMAGE; 2355 pThis->pszEncryptionAlgorithm = NULL; 2356 pThis->fDekProvided = false; 2210 2357 2211 2358 /* IMedia */ … … 2214 2361 pThis->IMedia.pfnFlush = drvvdFlush; 2215 2362 pThis->IMedia.pfnMerge = drvvdMerge; 2363 pThis->IMedia.pfnSetKey = drvvdSetKey; 2216 2364 pThis->IMedia.pfnGetSize = drvvdGetSize; 2217 2365 pThis->IMedia.pfnGetSectorSize = drvvdGetSectorSize; … … 2612 2760 pCfgVDConfig, sizeof(VDINTERFACECONFIG), &pImage->pVDIfsImage); 2613 2761 AssertRC(rc); 2762 2763 /* Check VDConfig for encryption config. */ 2764 if (pCfgVDConfig) 2765 { 2766 rc = CFGMR3QueryStringAlloc(pCfgVDConfig, "EncryptionAlgorithm", &pThis->pszEncryptionAlgorithm); 2767 if (RT_FAILURE(rc) && rc != VERR_CFGM_VALUE_NOT_FOUND) 2768 { 2769 rc = PDMDRV_SET_ERROR(pDrvIns, rc, 2770 N_("DrvVD: Configuration error: Querying \"EncryptionAlgorithm\" as string failed")); 2771 break; 2772 } 2773 else 2774 rc = VINF_SUCCESS; 2775 } 2776 2777 if (pThis->pszEncryptionAlgorithm) 2778 { 2779 /* Setup VDConfig interface for disk encryption support. */ 2780 pThis->VDIfCfg.pfnAreKeysValid = drvvdCfgEncAreKeysValid; 2781 pThis->VDIfCfg.pfnQuerySize = drvvdCfgEncQuerySize; 2782 pThis->VDIfCfg.pfnQuery = drvvdCfgEncQuery; 2783 pThis->VDIfCfg.pfnQueryBytes = drvvdCfgEncQueryBytes; 2784 } 2614 2785 2615 2786 /* Unconditionally insert the TCPNET interface, don't bother to check … … 2850 3021 && !pThis->fShareable 2851 3022 && !fDiscard 3023 && !pThis->pszEncryptionAlgorithm /* Disk encryption disables the block cache for security reasons */ 2852 3024 && RT_SUCCESS(rc)) 2853 3025 {
Note:
See TracChangeset
for help on using the changeset viewer.