VirtualBox

Changeset 54403 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Feb 23, 2015 10:17:04 PM (10 years ago)
Author:
vboxsync
Message:

Storage/VDFilterrypt,Main: Move key store implementation to the crypto filter plugin and make it accessible to Main from there by extending the interfaces to save key stores and query passwords for unlocking key stores

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vd-ifs.h

    r53539 r54403  
    7070    /** Interface for the metadata traverse callback. Per-operation. */
    7171    VDINTERFACETYPE_TRAVERSEMETADATA,
    72     /** Interface for crypto opertions. Per-disk. */
     72    /** Interface for crypto operations. Per-filter. */
    7373    VDINTERFACETYPE_CRYPTO,
    7474    /** invalid interface. */
     
    822822
    823823/**
     824 * Query configuration, unsigned 64-bit integer value.
     825 *
     826 * @return  VBox status code.
     827 * @param   pCfgIf      Pointer to configuration callback table.
     828 * @param   pszName     Name of an integer value
     829 * @param   pu64        Where to store the value.
     830 */
     831DECLINLINE(int) VDCFGQueryU64(PVDINTERFACECONFIG pCfgIf, const char *pszName,
     832                              uint64_t *pu64)
     833{
     834    char aszBuf[32];
     835    int rc = pCfgIf->pfnQuery(pCfgIf->Core.pvUser, pszName, aszBuf, sizeof(aszBuf));
     836    if (RT_SUCCESS(rc))
     837    {
     838        rc = RTStrToUInt64Full(aszBuf, 0, pu64);
     839    }
     840
     841    return rc;
     842}
     843
     844/**
    824845 * Query configuration, unsigned 32-bit integer value with default.
    825846 *
     
    861882    uint64_t u64;
    862883    int rc = VDCFGQueryU64Def(pCfgIf, pszName, &u64, fDef);
     884    if (RT_SUCCESS(rc))
     885        *pf = u64 ? true : false;
     886    return rc;
     887}
     888
     889/**
     890 * Query configuration, bool value.
     891 *
     892 * @return  VBox status code.
     893 * @param   pCfgIf      Pointer to configuration callback table.
     894 * @param   pszName     Name of an integer value
     895 * @param   pf          Where to store the value.
     896 */
     897DECLINLINE(int) VDCFGQueryBool(PVDINTERFACECONFIG pCfgIf, const char *pszName,
     898                               bool *pf)
     899{
     900    uint64_t u64;
     901    int rc = VDCFGQueryU64(pCfgIf, pszName, &u64);
    863902    if (RT_SUCCESS(rc))
    864903        *pf = u64 ? true : false;
     
    13911430    DECLR3CALLBACKMEMBER(int, pfnKeyRelease, (void *pvUser, const char *pszId));
    13921431
     1432    /**
     1433     * Gets the password to open a key store supplied through the onfig interface.
     1434     *
     1435     * @returns VBox status code.
     1436     * @param   pvUser          The opaque user data associated with this interface.
     1437     * @param   ppszPassword    Where to store the password to unlock the key store on success.
     1438     */
     1439    DECLR3CALLBACKMEMBER(int, pfnKeyStoreGetPassword, (void *pvUser, const char **ppszPassword));
     1440
     1441    /**
     1442     * Saves a key store.
     1443     *
     1444     * @returns VBox status code.
     1445     * @param   pvUser          The opaque user data associated with this interface.
     1446     * @param   pvKeyStore      The key store to save.
     1447     * @param   cbKeyStore      Size of the key store in bytes.
     1448     *
     1449     * @note The format is filter specific and should be treated as binary data.
     1450     */
     1451    DECLR3CALLBACKMEMBER(int, pfnKeyStoreSave, (void *pvUser, const void *pvKeyStore, size_t cbKeyStore));
     1452
     1453    /**
     1454     * Returns the parameters after the key store was loaded successfully.
     1455     *
     1456     * @returns VBox status code.
     1457     * @param   pvUser          The opaque user data associated with this interface.
     1458     * @param   pszCipher       The cipher identifier the DEK is used for.
     1459     * @param   pbDek           The raw DEK which was contained in the key store loaded by
     1460     *                          VDINTERFACECRYPTO::pfnKeyStoreLoad().
     1461     * @param   cbDek           The size of the DEK.
     1462     *
     1463     * @note The provided pointer to the DEK is only valid until this call returns.
     1464     *       The content might change afterwards with out notice (when scrambling the key
     1465     *       for further protection for example) or might be even freed.
     1466     *
     1467     * @note This method is optional and can be NULL if the caller does not require the
     1468     *       parameters.
     1469     */
     1470    DECLR3CALLBACKMEMBER(int, pfnKeyStoreReturnParameters, (void *pvUser, const char *pszCipher,
     1471                                                            const uint8_t *pbDek, size_t cbDek));
     1472
    13931473} VDINTERFACECRYPTO, *PVDINTERFACECRYPTO;
    13941474
     
    14141494
    14151495/**
    1416  * @copydoc VDINTERFACECRYPTOKEYS::pfnKeyRetain
     1496 * @copydoc VDINTERFACECRYPTO::pfnKeyRetain
    14171497 */
    14181498DECLINLINE(int) vdIfCryptoKeyRetain(PVDINTERFACECRYPTO pIfCrypto, const char *pszId, const uint8_t **ppbKey, size_t *pcbKey)
     
    14221502
    14231503/**
    1424  * @copydoc VDINTERFACECRYPTOKEYS::pfnKeyRelease
     1504 * @copydoc VDINTERFACECRYPTO::pfnKeyRelease
    14251505 */
    14261506DECLINLINE(int) vdIfCryptoKeyRelease(PVDINTERFACECRYPTO pIfCrypto, const char *pszId)
     
    14291509}
    14301510
     1511/**
     1512 * @copydoc VDINTERFACECRYPTO::pfnKeyStoreGetPassword
     1513 */
     1514DECLINLINE(int) vdIfCryptoKeyStoreGetPassword(PVDINTERFACECRYPTO pIfCrypto, const char **ppszPassword)
     1515{
     1516    return pIfCrypto->pfnKeyStoreGetPassword(pIfCrypto->Core.pvUser, ppszPassword);
     1517}
     1518
     1519/**
     1520 * @copydoc VDINTERFACECRYPTO::pfnKeyStoreSave
     1521 */
     1522DECLINLINE(int) vdIfCryptoKeyStoreSave(PVDINTERFACECRYPTO pIfCrypto, const void *pvKeyStore, size_t cbKeyStore)
     1523{
     1524    return pIfCrypto->pfnKeyStoreSave(pIfCrypto->Core.pvUser, pvKeyStore, cbKeyStore);
     1525}
     1526
     1527/**
     1528 * @copydoc VDINTERFACECRYPTO::pfnKeyStoreReturnParameters
     1529 */
     1530DECLINLINE(int) vdIfCryptoKeyStoreReturnParameters(PVDINTERFACECRYPTO pIfCrypto, const char *pszCipher,
     1531                                                   const uint8_t *pbDek, size_t cbDek)
     1532{
     1533    if (pIfCrypto->pfnKeyStoreReturnParameters)
     1534        return pIfCrypto->pfnKeyStoreReturnParameters(pIfCrypto->Core.pvUser, pszCipher, pbDek, cbDek);
     1535
     1536    return VINF_SUCCESS;
     1537}
     1538
     1539
    14311540RT_C_DECLS_END
    14321541
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