⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ntagimp1.h

📁 windows的加密api源码
💻 H
📖 第 1 页 / 共 2 页
字号:
    BYTE                            *pUser;
    HANDLE                          hWnd;
    DWORD                           dwKeyStorageType;
    PSTORE_INFO                     *pPStore;
    LPWSTR                          pwszPrompt;
    DWORD                           dwOldKeyFlags;
    BOOL                            dwSGCFlags;
    BYTE                            *pbSGCKeyMod;
    DWORD                           cbSGCKeyMod;
    DWORD                           dwSGCKeyExpo;
    HANDLE                          hRNGDriver;
    CHAR                            rgszMachineName[MAX_COMPUTERNAME_LENGTH + 1];
    DWORD                           cbMachineName;
    CRITICAL_SECTION                CritSec;   
    EXPO_OFFLOAD_STRUCT             *pOffloadInfo; // info for offloading modular expo
} NTAGUserList, *PNTAGUserList;


// UserList Rights flags (uses CRYPT_MACHINE_KEYSET and CRYPT_VERIFYCONTEXT)
#define CRYPT_DISABLE_CRYPT             0x1
#define CRYPT_IN_FRANCE                 0x2
#define CRYPT_DES_HASHKEY_BACKWARDS     0x4

#define CRYPT_BLKLEN    8               // Bytes in a crypt block
#define MAX_SALT_LEN    24


// definition of a key list
typedef struct _KeyList
{
    HCRYPTPROV      hUID;                   // must be first
    ALG_ID			Algid;
    DWORD			Rights;
    DWORD			cbKeyLen;
    BYTE			*pKeyValue;             // Actual Key
    DWORD			cbDataLen;
    BYTE			*pData;                 // Inflated Key or Multi-phase
    BYTE			IV[CRYPT_BLKLEN];       // Initialization vector
    BYTE			FeedBack[CRYPT_BLKLEN]; // Feedback register
    DWORD			InProgress;             // Flag to indicate encryption
    DWORD           cbSaltLen;              // Salt length
    BYTE			rgbSalt[MAX_SALT_LEN];  // Salt value
    DWORD			Padding;                // Padding values
    DWORD			Mode;                   // Mode of cipher
    DWORD			ModeBits;               // Number of bits to feedback
    DWORD			Permissions;            // Key permissions
    DWORD           EffectiveKeyLen;        // used by RC2
    BYTE            *pbParams;              // may be used in OAEP
    DWORD           cbParams;               // length of pbParams
#ifdef STT
    DWORD           cbInfo;
    BYTE            rgbInfo[MAXCCNLEN];
#endif
} NTAGKeyList, *PNTAGKeyList;

#define     HMAC_DEFAULT_STRING_LEN     64

// definition of a hash list
typedef struct Hash_List_Defn
{
    HCRYPTPROV      hUID;
    ALG_ID          Algid;
    DWORD           dwDataLen;
    void            *pHashData;
    HCRYPTKEY       hKey;
    DWORD           HashFlags;
    ALG_ID          HMACAlgid;
    DWORD           HMACState;
    BYTE            *pbHMACInner;
    DWORD           cbHMACInner;
    BYTE            *pbHMACOuter;
    DWORD           cbHMACOuter;
    DWORD           dwHashState;
} NTAGHashList, *PNTAGHashList;

#define     HMAC_STARTED    1
#define     HMAC_FINISHED   2

#define     DATA_IN_HASH    1

// Values of the HashFlags

#define HF_VALUE_SET	1

// Hash algorithm's internal state
// -- Placed into PNTAGHashList->pHashData

// for MD5
#define MD5_object      MD5_CTX

// for MD4
// see md4.h for MD4_object

// Stuff for weird SSL 3.0 signature format
#define SSL3_SHAMD5_LEN   (A_SHA_DIGEST_LEN + MD5DIGESTLEN)

// prototypes
void memnuke(volatile BYTE *data, DWORD len);

BOOL LocalCreateHash(
                     IN ALG_ID Algid,
                     OUT BYTE **ppbHashData,
                     OUT DWORD *pcbHashData
                     );

BOOL LocalHashData(
                   IN ALG_ID Algid,
                   IN OUT BYTE *pbHashData,
                   IN BYTE *pbData,
                   IN DWORD cbData
                   );

BOOL LocalEncrypt(IN HCRYPTPROV hUID,
                  IN HCRYPTKEY hKey,
                  IN HCRYPTHASH hHash,
                  IN BOOL Final,
                  IN DWORD dwFlags,
                  IN OUT BYTE *pbData,
                  IN OUT DWORD *pdwDataLen,
                  IN DWORD dwBufSize,
                  IN BOOL fIsExternal);

BOOL LocalDecrypt(IN HCRYPTPROV hUID,
                  IN HCRYPTKEY hKey,
                  IN HCRYPTHASH hHash,
                  IN BOOL Final,
                  IN DWORD dwFlags,
                  IN OUT BYTE *pbData,
                  IN OUT DWORD *pdwDataLen,
                  IN BOOL fIsExternal);

BOOL FIPS186GenRandom(
                      IN HANDLE *phRNGDriver,
                      IN BYTE **ppbContextSeed,
                      IN DWORD *pcbContextSeed,
                      IN OUT BYTE *pb,
                      IN DWORD cb
                      );
//
// Function : TestEncDec
//
// Description : This function expands the passed in key buffer for the appropriate
//               algorithm, and then either encryption or decryption is performed.
//               A comparison is then made to see if the ciphertext or plaintext
//               matches the expected value.
//               The function only uses ECB mode for block ciphers and the plaintext
//               buffer must be the same length as the ciphertext buffer.  The length
//               of the plaintext must be either the block length of the cipher if it
//               is a block cipher or less than MAX_BLOCKLEN if a stream cipher is
//               being used.
//
BOOL TestEncDec(
                IN ALG_ID Algid,
                IN BYTE *pbKey,
                IN DWORD cbKey,
                IN BYTE *pbPlaintext,
                IN DWORD cbPlaintext,
                IN BYTE *pbCiphertext,
                IN BYTE *pbIV,
                IN int iOperation
                );

//
// Function : TestSymmetricAlgorithm
//
// Description : This function expands the passed in key buffer for the appropriate algorithm,
//               encrypts the plaintext buffer with the same algorithm and key, and the
//               compares the passed in expected ciphertext with the calculated ciphertext
//               to make sure they are the same.  The opposite is then done with decryption.
//               The function only uses ECB mode for block ciphers and the plaintext
//               buffer must be the same length as the ciphertext buffer.  The length
//               of the plaintext must be either the block length of the cipher if it
//               is a block cipher or less than MAX_BLOCKLEN if a stream cipher is
//               being used.
//
BOOL TestSymmetricAlgorithm(
                            IN ALG_ID Algid,
                            IN BYTE *pbKey,
                            IN DWORD cbKey,
                            IN BYTE *pbPlaintext,
                            IN DWORD cbPlaintext,
                            IN BYTE *pbCiphertext,
                            IN BYTE *pbIV
                            );

#ifdef CSP_USE_MD5
//
// Function : TestMD5
//
// Description : This function hashes the passed in message with the MD5 hash
//               algorithm and returns the resulting hash value.
//
BOOL TestMD5(
             BYTE *pbMsg,
             DWORD cbMsg,
             BYTE *pbHash
             );
#endif // CSP_USE_MD5

#ifdef CSP_USE_SHA1
//
// Function : TestSHA1
//
// Description : This function hashes the passed in message with the SHA1 hash
//               algorithm and returns the resulting hash value.
//
BOOL TestSHA1(
              BYTE *pbMsg,
              DWORD cbMsg,
              BYTE *pbHash
              );
#endif // CSP_USE_SHA1

// These may later be changed to set/use NT's [GS]etLastErrorEx
// so make it easy to switch over..
#ifdef MTS
__declspec(thread)
#endif

#ifdef __cplusplus
}
#endif

#endif // __NTAGIMP1_H__

⌨️ 快捷键说明

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