freeotfecypherapicommon.h

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

H
154
字号
// Description: FreeOTFE Cypher Device Driver API
// By Sarah Dean
// Email: sdean12@sdean12.org
// WWW:   http://www.FreeOTFE.org/
//
// -----------------------------------------------------------------------------
//


#ifndef _FreeOTFECypherAPITypes_H
#define _FreeOTFECypherAPITypes_H   1

#ifdef WINCE
#include <WinDef.h>  // Required for ULONG
#else
#include <ntdef.h>  // Required for ULONG
#endif


// =========================================================================
// Const definitions

#define MAX_CYPHER_TITLE 256

// Maximum cypher blocksize
// This should be set to the MAXIMUM cypher blocksize possible.
// This is used for allocating storage for IVs; i.e.:
//   1) In the FreeOTFE driver when generating sector IVs
//   2) So that the length of the DIOC passed to the cypher driver is more deterministic, which
//      makes creating and populating this struct easier
// If a cypher uses a blocksize greater than this value (e.g. a cypher driver which 
// uses an arbitary blocksize), then attempts to encrypt/decrypt may fail if the IVs passed to
// the encryption/decryption routines may not be large enough.
// Note: This value is in *bits*
#define FREEOTFE_MAX_CYPHER_BLOCKSIZE    512


// =========================================================================
// Type definitions

typedef enum _CYPHER_MODE {
    CYPHER_MODE_NONE    =    0,
    CYPHER_MODE_ECB     =    1,
    CYPHER_MODE_CBC     =    2,
    CYPHER_MODE_UNKNOWN = 9999
} CYPHER_MODE, *PCYPHER_MODE;

typedef struct _CYPHER {
    GUID CypherGUID;
    char Title[MAX_CYPHER_TITLE];
    CYPHER_MODE Mode;
    // KeySize = -1 for *any* KeySize
    int KeySize;  // In bits
    // BlockSize = -1 for *any* BlockSize
    int BlockSize;  // In bits
    ULONG VersionID;
} CYPHER, *PCYPHER;

typedef struct _CYPHER_DRIVER_INFO {
    // Driver identification...
    GUID DriverGUID;
    char DriverTitle[MAX_CYPHER_TITLE];
    ULONG DriverVersionID;

    // Cyphers supported...
    unsigned int CypherCount;
    CYPHER* CypherDetails;  // This is a *pointer* to an *array* of "CypherCount"
                            // CYPHER structures
} CYPHER_DRIVER_INFO, *PCYPHER_DRIVER_INFO;


typedef struct _DIOC_CYPHER_IDENTIFYDRIVER {    
    GUID DriverGUID;
    char Title[MAX_CYPHER_TITLE];
    ULONG VersionID;
    unsigned int CountCyphers;
} DIOC_CYPHER_IDENTIFYDRIVER, *PDIOC_CYPHER_IDENTIFYDRIVER;


typedef struct _DIOC_CYPHER_IDENTIFYSUPPORTED {    
    unsigned int BufCount;  // The number of *elements* in the "Cyphers" array
    CYPHER Cyphers[1];  // Variable length
} DIOC_CYPHER_IDENTIFYSUPPORTED, *PDIOC_CYPHER_IDENTIFYSUPPORTED;


typedef struct _DIOC_CYPHER_DATA_IN {
    GUID CypherGUID;
    int KeyLength;  // In *bits*
    int IVLength;  // In *bits*
                   // Note: Not all cyphers use an IV (e.g. in EBC mode)
                   //       If specified though, IVLength, and IV, should 
                   //       be equal to the blocksize of the cypher being used
    int DataLength;  // In *bytes*
    char Key[1];  // Variable length
    char IV[1];  // Variable length
    char Data[1];  // Variable length
} DIOC_CYPHER_DATA_IN, *PDIOC_CYPHER_DATA_IN;


// When used, this buffer must be the same size as the "Data" member
// of DIOC_CYPHER_DATA_IN
typedef struct _DIOC_CYPHER_DATA_OUT {
    char Data[1];  // Variable length
} DIOC_CYPHER_DATA_OUT, *PDIOC_CYPHER_DATA_OUT;



// This definition must be kept in sync with "ImpCypherEncryptData"
typedef NTSTATUS (* PDataEncryptFn)(
                                    GUID*,
                                    int, 
                                    char*, 
                                    char*, 
                                    int, 
                                    char*, 
                                    int, 
                                    char*, 
                                    char*
                                   );


// This definition must be kept in sync with "ImpCypherDecryptData"
typedef NTSTATUS (* PDataDecryptFn)(
                                    GUID*,
                                    int, 
                                    char*, 
                                    char*, 
                                    int, 
                                    char*, 
                                    int, 
                                    char*, 
                                    char*
                                   );

// This definition must be kept in sync with "GetCypherDetails"
typedef NTSTATUS (* PCypherDetailsFn)(
                                    GUID*,
                                    CYPHER*
                                   );

// Internal details
typedef struct _DIOC_CYPHER_INTL_DETAILS {
    PCypherDetailsFn FnCypherDetails;
    PDataEncryptFn   FnEncrypt;
    PDataDecryptFn   FnDecrypt;
} DIOC_CYPHER_INTL_DETAILS, *PDIOC_CYPHER_INTL_DETAILS;


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

#endif

⌨️ 快捷键说明

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