driverinterfacetwo.h

来自「文件驱动加密,功能强大,可产生加密分区,支持AES,MD2,MD4,MD5MD2」· C头文件 代码 · 共 250 行

H
250
字号
// Description: 
// By Sarah Dean
// Email: sdean12@sdean12.org
// WWW:   http://www.FreeOTFE.org/
//
// -----------------------------------------------------------------------------
//


#ifndef _DriverInterfaceTwo_H
#define _DriverInterfaceTwo_H   1

#include "FreeOTFE4PDAAPI.h"  // Required for main DLL function definitions
#include "FreeOTFEHashAPICommon.h"
#include "FreeOTFECypherAPICommon.h"

#include <WinNT.h>  // Required for WCHAR


// =========================================================================
// Constants...

// Relativly arbitary value; must be large enough to store a prettyprinted
// hash/cypher title
#define MAX_PRETTYPRINTED_TITLE  1024


// =========================================================================
// Variables used in dumping...
static BOOL _driver_DumpFlag = FALSE;
static int _driver_DumpCriticalDataKeyBits;
static FREEOTFEBYTE* _driver_DumpCriticalDataKey = NULL;
static int _driver_DumpCheckMACBits;
static FREEOTFEBYTE* _driver_DumpCheckMAC = NULL;
static int _driver_DumpPlaintextEncryptedBlockBits;
static FREEOTFEBYTE* _driver_DumpPlaintextEncryptedBlock = NULL;
static int _driver_DumpVolumeDetailsBlockBits;
static FREEOTFEBYTE* _driver_DumpVolumeDetailsBlock = NULL;


// =========================================================================
// Structures...

typedef struct _MODULE_DETAILS_MAIN {
    WCHAR* Filename;
    HINSTANCE Lib;

	PMainDLLFnDeriveKey FnDeriveKey;
    PMainDLLFnMACData FnMACData;
} MODULE_DETAILS_MAIN, *PMODULE_DETAILS_MAIN;


typedef struct _CDB_DETAILS {
	int CDBFormatID;

    LARGE_INTEGER PartitionSize;
    unsigned int VolumeFlags;
    SECTOR_IV_GEN_METHOD SectorIVGenMethod;

    char DefaultDrive;  // Not used in PDA version, but included to allow 
                        // password changing on volumes used by the PC version

    ULONG MasterKeyLength;  // In bits
    ULONG VolumeIVLength;  // In bits
    FREEOTFEBYTE* MasterKey;    
    FREEOTFEBYTE* VolumeIV;    
} CDB_DETAILS, *PCDB_DETAILS;

typedef struct _CDB_METADATA {
    WCHAR HashDeviceName[FREEOTFE_MAX_FILENAME_LENGTH];    
    GUID HashGUID;
    WCHAR CypherDeviceName[FREEOTFE_MAX_FILENAME_LENGTH];    
    GUID CypherGUID;
	KDF_ALGORITHM KDFAlgorithm;
	MAC_ALGORITHM MACAlgorithm;
} CDB_METADATA, *PCDB_METADATA;

typedef struct _DRIVER_AND_ALG {
    WCHAR PrettyName[MAX_PRETTYPRINTED_TITLE];
    WCHAR DriverFilename[FREEOTFE_MAX_FILENAME_LENGTH];
    GUID DriverImplAlgGUID;

    // Only used for hashes...
    int HashLength;  // In *bits*
    int HashBlockSize;  // In *bits*

    // Only used for cyphers...
    int CypherKeySize;  // In *bits*
    int CypherBlockSize;  // In *bits*
} DRIVER_AND_ALG, *PDRIVER_AND_ALG;


// =========================================================================
// Functions...

// Key derivation function
BOOL driver_DeriveKey(
    MODULE_DETAILS_MAIN* mainDriver,

    KDF_ALGORITHM kdfAlgorithm,
    WCHAR* hashKernelModeDeviceName,
    GUID hashGUID,
    WCHAR* cypherKernelModeDeviceName,
    GUID cypherGUID,
    char* Password,
    FREEOTFEBYTE* Salt,
    unsigned int SaltLength, // In *bits*
    unsigned int Iterations,
    unsigned int dkLenBits,  // In *bits*
    FREEOTFEBYTE* DK
);


BOOL driver_MACData(
    MODULE_DETAILS_MAIN* mainDriver,

    MAC_ALGORITHM macAlgorithm,
    const WCHAR* hashKernelModeDeviceName,
    GUID hashGUID,
    const WCHAR* cypherKernelModeDeviceName,
    GUID cypherGUID,
    unsigned int KeyLength,
    FREEOTFEBYTE* Key,
    unsigned int DataLength,
    FREEOTFEBYTE* Data,
    FREEOTFEBYTE** MACOut,
    int* tBits
);


BOOL driver_Mount(
    WCHAR* Mountpoint,
    WCHAR* Filename,
    WCHAR* Keyfile,
    LARGE_INTEGER OffsetWithinFile,
    BOOL CDBAtOffset,
    unsigned char* UserPassword,
    unsigned int SaltLength,  // In *bits*
    unsigned int KeyIterations,
    BOOL ReadOnly
);


BOOL driver_GetAllAlgorithmDriverDetails(
    int* countDriversHash,
    WCHAR*** driverFilenamesHash,
    HASH_DRIVER_INFO*** driverInfoHash,

    int* countDriversCypher,
    WCHAR*** driverFilenamesCypher,
    CYPHER_DRIVER_INFO*** driverInfoCypher
);

BOOL driver_GetAllAlgorithmDriverOptions(
    int* CountImplHash,
    DRIVER_AND_ALG** HashImpl,

    int* CountImplCypher,
    DRIVER_AND_ALG** CypherImpl
);

void driver_FreeAllAlgorithmDriverOptions(
    int* CountImplHash,
    DRIVER_AND_ALG** HashImpl,

    int* CountImplCypher,
    DRIVER_AND_ALG** CypherImpl
);

BOOL
driver_CreateVolumeFile(
    WCHAR* Filename,
    WCHAR* KeyFilename,
    LARGE_INTEGER Offset,
    char* UserPassword,
    int SaltLength,  // In *bits*
    int KeyIterations,
    FREEOTFEBYTE* RandomPool,
    CDB_DETAILS* CDBDetails,
    CDB_METADATA* CDBMetaData
);

// Create a new keyfile, given a volume with CDB or existing keyfile
BOOL
driver_CreateKeyfile(
    WCHAR* ExistingFilename,
    LARGE_INTEGER Offset,
    char* ExistingUserPassword,
    unsigned int ExistingSaltLength,  // In *bits*
    unsigned int ExistingKeyIterations,

    WCHAR* KeyfileFilename,
    char* KeyfileUserPassword,
    unsigned int KeyfileSaltLength,  // In *bits*
    unsigned int KeyfileKeyIterations,

    FREEOTFEBYTE* RandomPool
);

// Change a volume/keyfile's details (e.g. password)
BOOL
driver_ChangeDetails(
    WCHAR* Filename,
    LARGE_INTEGER Offset,

    char* CurrentUserPassword,
    unsigned int CurrentSaltLength,  // In *bits*
    unsigned int CurrentKeyIterations,

    char* NewUserPassword,
    unsigned int NewSaltLength,  // In *bits*
    unsigned int NewKeyIterations,

    FREEOTFEBYTE* RandomPool
);

void driver_FreeCriticalDump();

BOOL
driver_DumpCDB(
    WCHAR* SrcFilename,
    LARGE_INTEGER SrcOffset,
    char* SrcUserPassword,
    unsigned int SrcSaltLength,  // In *bits*
    unsigned int SrcKeyIterations,

    WCHAR* DestFilename
);

BOOL
driver_BackupCDB(
    WCHAR* SrcFilename,
    LARGE_INTEGER SrcOffset,
    WCHAR* DestFilename
);

BOOL
driver_RestoreCDB(
    WCHAR* SrcFilename,
    WCHAR* DestFilename,
    LARGE_INTEGER DestOffset
);


// =========================================================================
// =========================================================================

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?