Changeset 51899 in vbox for trunk/src/VBox/Devices/Storage
- Timestamp:
- Jul 7, 2014 10:34:49 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DrvVD.cpp
r51754 r51899 189 189 /** Cryptographic support 190 190 * @{ */ 191 /** Used algorithm, NULL means no encryption. */ 192 char *pszEncryptionAlgorithm; 193 /** Stored key id, queried from the crypto filter. */ 194 char *pszKeyId; 191 /** Pointer to the CFGM node containing the config of the crypto filter 192 * if enable. */ 193 PCFGMNODE pCfgCrypto; 195 194 /** Config interface for the encryption filter. */ 196 195 VDINTERFACECONFIG VDIfCfg; … … 633 632 { 634 633 return CFGMR3QueryBytes((PCFGMNODE)pvUser, pszName, ppvData, cbData); 635 }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, "KeyId"))655 *pcb = strlen(pThis->pszKeyId) + 1;656 else657 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 if (!strcmp(pszName, "KeyId"))670 rc = RTStrCopy(pszString, cchString, pThis->pszKeyId);671 else672 rc = VERR_NOT_SUPPORTED;673 674 return rc;675 634 } 676 635 … … 1591 1550 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 1592 1551 1593 if ( pThis->p szEncryptionAlgorithm1552 if ( pThis->pCfgCrypto 1594 1553 && !pThis->pIfSecKey) 1595 1554 { … … 1651 1610 off, pvBuf, cbWrite, cbWrite, pvBuf)); 1652 1611 1653 if ( pThis->p szEncryptionAlgorithm1612 if ( pThis->pCfgCrypto 1654 1613 && !pThis->pIfSecKey) 1655 1614 { … … 1724 1683 int rc = VINF_SUCCESS; 1725 1684 1726 if (pThis->p szEncryptionAlgorithm)1685 if (pThis->pCfgCrypto) 1727 1686 { 1728 1687 PVDINTERFACE pVDIfFilter = NULL; … … 1742 1701 1743 1702 rc = VDInterfaceAdd(&pThis->VDIfCfg.Core, "DrvVD_Config", VDINTERFACETYPE_CONFIG, 1744 pThis , sizeof(VDINTERFACECONFIG), &pVDIfFilter);1703 pThis->pCfgCrypto, sizeof(VDINTERFACECONFIG), &pVDIfFilter); 1745 1704 AssertRC(rc); 1746 1705 … … 1923 1882 PVBOXDISK pThis = PDMIMEDIAASYNC_2_VBOXDISK(pInterface); 1924 1883 1925 if ( pThis->p szEncryptionAlgorithm1884 if ( pThis->pCfgCrypto 1926 1885 && !pThis->pIfSecKey) 1927 1886 { … … 1961 1920 PVBOXDISK pThis = PDMIMEDIAASYNC_2_VBOXDISK(pInterface); 1962 1921 1963 if ( pThis->p szEncryptionAlgorithm1922 if ( pThis->pCfgCrypto 1964 1923 && !pThis->pIfSecKey) 1965 1924 { … … 2054 2013 PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK); 2055 2014 2056 Assert (!pThis->p szEncryptionAlgorithm);2015 Assert (!pThis->pCfgCrypto); 2057 2016 2058 2017 switch (enmXferDir) … … 2373 2332 pThis->pszBwGroup = NULL; 2374 2333 } 2375 if (pThis->pszEncryptionAlgorithm)2376 {2377 MMR3HeapFree(pThis->pszEncryptionAlgorithm);2378 pThis->pszEncryptionAlgorithm = NULL;2379 }2380 if (pThis->pszKeyId)2381 {2382 MMR3HeapFree(pThis->pszKeyId);2383 pThis->pszKeyId = NULL;2384 }2385 2334 } 2386 2335 … … 2418 2367 pThis->uMergeSource = VD_LAST_IMAGE; 2419 2368 pThis->uMergeTarget = VD_LAST_IMAGE; 2420 pThis->p szEncryptionAlgorithm= NULL;2369 pThis->pCfgCrypto = NULL; 2421 2370 pThis->pIfSecKey = NULL; 2422 2371 … … 2833 2782 /* Check VDConfig for encryption config. */ 2834 2783 if (pCfgVDConfig) 2835 { 2836 rc = CFGMR3QueryStringAlloc(pCfgVDConfig, "EncryptionAlgorithm", &pThis->pszEncryptionAlgorithm); 2837 if (RT_FAILURE(rc) && rc != VERR_CFGM_VALUE_NOT_FOUND) 2838 { 2839 rc = PDMDRV_SET_ERROR(pDrvIns, rc, 2840 N_("DrvVD: Configuration error: Querying \"EncryptionAlgorithm\" as string failed")); 2841 break; 2842 } 2843 else 2844 rc = VINF_SUCCESS; 2845 } 2846 2847 if (pThis->pszEncryptionAlgorithm) 2848 { 2849 rc = CFGMR3QueryStringAlloc(pCfgVDConfig, "KeyId", &pThis->pszKeyId); 2850 if (RT_FAILURE(rc)) 2851 { 2852 rc = PDMDRV_SET_ERROR(pDrvIns, rc, 2853 N_("DrvVD: Configuration error: Querying \"KeyId\" as string failed")); 2854 break; 2855 } 2856 2784 pThis->pCfgCrypto = CFGMR3GetChild(pCfgVDConfig, "CRYPT"); 2785 2786 if (pThis->pCfgCrypto) 2787 { 2857 2788 /* Setup VDConfig interface for disk encryption support. */ 2858 pThis->VDIfCfg.pfnAreKeysValid = drvvdCfg EncAreKeysValid;2859 pThis->VDIfCfg.pfnQuerySize = drvvdCfg EncQuerySize;2860 pThis->VDIfCfg.pfnQuery = drvvdCfg EncQuery;2789 pThis->VDIfCfg.pfnAreKeysValid = drvvdCfgAreKeysValid; 2790 pThis->VDIfCfg.pfnQuerySize = drvvdCfgQuerySize; 2791 pThis->VDIfCfg.pfnQuery = drvvdCfgQuery; 2861 2792 pThis->VDIfCfg.pfnQueryBytes = NULL; 2862 2793 … … 3102 3033 && !pThis->fShareable 3103 3034 && !fDiscard 3104 && !pThis->p szEncryptionAlgorithm/* Disk encryption disables the block cache for security reasons */3035 && !pThis->pCfgCrypto /* Disk encryption disables the block cache for security reasons */ 3105 3036 && RT_SUCCESS(rc)) 3106 3037 {
Note:
See TracChangeset
for help on using the changeset viewer.