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

📄 pkcsdll.h

📁 windows的加密api源码
💻 H
📖 第 1 页 / 共 2 页
字号:
/*++

Copyright (c) 1995  Microsoft Corporation

Module Name:

    PKCSlib

Abstract:

    This header file describes the services and definitions necessary to use the
    Crypto Certificate API.

Author:

    Doug Barlow (dbarlow) 8/17/1995

Environment:

    Win32, Crypto API

Notes:

    Current X.509 Support Level : V3
    Current PKCS Support Level  : V1

--*/

#ifndef _PKCSLIB_H_
#define _PKCSLIB_H_

#include <wincrypt.h>

#ifdef _cplusplus
extern "C" {
#endif

#ifndef PKCSDLLAPI
#define PKCSDLLAPI
#endif

typedef const void *
    PKCSHANDLE;


//
//==============================================================================
//
//  Attribute List services.
//
//  Also see the list of standard Attribute types, below.
//

typedef PKCSHANDLE
    ATTRIBLISTHANDLE;               // Reference handle type.
typedef ATTRIBLISTHANDLE
    *PATTRIBLISTHANDLE,             // Pointers to reference handles.
    *LPATTRIBLISTHANDLE;

extern PKCSDLLAPI BOOL WINAPI
PkcsAttributeListCreate(
    OUT LPATTRIBLISTHANDLE hAtrList); // Handle for future reference.

extern PKCSDLLAPI BOOL WINAPI
PkcsAttributeListClose(
    IN ATTRIBLISTHANDLE hAtrList);  // The handle to the attrList to discard

extern PKCSDLLAPI BOOL WINAPI
PkcsAttributeListAdd(
    IN ATTRIBLISTHANDLE hAtrList,   // The reference handle to the List.
    IN LPCTSTR szAtrType,           // The Object Identifier of the attribute
    IN const BYTE * pbAtrValue);    // The Value of the ASN.1 encoded attribute

extern PKCSDLLAPI BOOL WINAPI
PkcsAttributeListLookup(
    IN ATTRIBLISTHANDLE hAtrList,   // The reference handle to the List.
    IN LPCTSTR szAtrType,           // The Object Identifier of the attribute
    OUT LPBYTE pbAtrValue,          // The value of the attribute
    IN OUT LPDWORD pcbAtrValLen);   // The length of the pbAtrValue buffer

extern PKCSDLLAPI BOOL WINAPI
PkcsAttributeListContents(
    IN ATTRIBLISTHANDLE hAtrList,   // The reference handle to the List.
    OUT LPTSTR mszAtrTypes,         // The Object Identifier list
    IN OUT LPDWORD pcbAtrTypesLen); // The length of the mszAtrTypes buffer

    //
    // ?Q? - Is there any need for a remove service?
    //


//
//==============================================================================
//
//  X.509 v3 Certificate Extension List services.
//
// ?TODO?
//

typedef PKCSHANDLE
    EXTENSIONLISTHANDLE;            // Reference handle type.
typedef EXTENSIONLISTHANDLE
    *PEXTENSIONLISTHANDLE,          // Pointers to reference handles.
    *LPEXTENSIONLISTHANDLE;


//
//==============================================================================
//
//  Subject services.  To use these services, you must have created a
//      key, either directly via the CryptoAPI, or via the
//      convenience service PkcsCreateSubject.
//

typedef PKCSHANDLE
    SUBJECTHANDLE;                  // Reference handle type.
typedef SUBJECTHANDLE
    *PSUBJECTHANDLE,                // Pointers to reference handles.
    *LPSUBJECTHANDLE;

extern PKCSDLLAPI BOOL WINAPI
PkcsSetDNamePrefix(
    IN DWORD dwStore,               // The Certificate Store.
    IN LPCTSTR szPrefix);           // The Prefix to set.

extern PKCSDLLAPI BOOL WINAPI
PkcsSubjectCreate(
    OUT LPSUBJECTHANDLE phSubject,  // Handle for future reference
    IN LPCTSTR szKeySet,            // What to name the new Subject keyset
    IN LPCTSTR szProvider,          // The specific name of the CSP, or Blank
    IN DWORD dwKeyType,             // Specifies the type of key
    IN DWORD dwProvType,            // Should be PROV_RSA_FULL
    IN ALG_ID algPref,              // Suggest optional algorithm preferences
    IN DWORD dwStore);              // Store Id or zero.

extern PKCSDLLAPI BOOL WINAPI
PkcsSubjectOpen(
    OUT LPSUBJECTHANDLE phSubject,  // Handle for future reference
    IN LPCTSTR szKeySet,            // The name of the Subject keyset
    IN LPCTSTR szProvider,          // The specific name of the CSP, or Blank
    IN DWORD dwKeyType,             // Specifies the type of key
    IN DWORD dwProvType,            // Should be PROV_RSA_FULL
    IN ALG_ID algPref,              // Suggest optional algorithm preferences
    IN DWORD dwStore);              // Store Id or zero.

extern PKCSDLLAPI BOOL WINAPI
PkcsSubjectSign(
    IN SUBJECTHANDLE hSubject,      // The reference handle to the Subject
    IN const BYTE *pbData,          // The data to be signed
    IN DWORD cbDataLen,             // The length of the data to be signed
    IN LPCTSTR szComment,           // Comment string associated with signature
    OUT LPBYTE pbSignature,         // Buffer to receive the signature
    IN OUT LPDWORD pcbSigLen);      // Length of the pbSignature buffer.

extern PKCSDLLAPI BOOL WINAPI
PkcsSubjectClose(
    IN SUBJECTHANDLE hSubject);     // The reference handle to the Subject

extern PKCSDLLAPI BOOL WINAPI
PkcsSubjectDelete(
    IN SUBJECTHANDLE hSubject);     // The handle to the Subject to remove

extern PKCSDLLAPI BOOL WINAPI
PkcsSubjectRequestCertification(
    IN SUBJECTHANDLE hSubject,      // The reference handle to the Subject
    IN ATTRIBLISTHANDLE hAtrList,   // reference to subject attributes, if any
    OUT LPBYTE pbCertReq,           // Buffer to receive certificate request
    IN OUT LPDWORD pcbCertReqLen);  // Length of pbCertReq buffer

extern PKCSDLLAPI BOOL WINAPI
PkcsSubjectDistinguishedName(
    IN SUBJECTHANDLE hSubject,      // The reference handle to the Subject
    OUT LPTSTR szDname,             // Buffer to receive the distinguished name
    IN OUT LPDWORD pcbDnameLen);    // Length of pbCertReq buffer

    //
    // ?TODO? - Need to attach an X.509 v2 UniqueIdentifier to the Subject.
    // ?HOW? -  Can we attach an X.509 v2 UniqueIdentifier to the request?
    //


//
//==============================================================================
//
//  Issuer services.  To use these services, you must have created an
//      AT_SIGNATURE key, either directly via the CryptoAPI, or via the
//      convienience service PkcsCreateIssuer, and you will be certifying
//      other's keys.
//

typedef PKCSHANDLE
    ISSUERHANDLE;                   // Reference handle type.
typedef ISSUERHANDLE
    *PISSUERHANDLE,                 // Pointers to reference handles.
    *LPISSUERHANDLE;

extern PKCSDLLAPI BOOL WINAPI
PkcsIssuerCreate(
    OUT LPISSUERHANDLE phIssuer,    // Handle for future reference
    IN LPCTSTR szKeySet,            // What to name the new Issuer keyset
    IN LPCTSTR szProvider,          // The specific name of the CSP, or Blank
    IN DWORD dwProvType,            // Should be PROV_RSA_FULL
    IN ALG_ID algPref,              // Suggest optional algorithm preferences
    IN DWORD dwStore);              // Store Id or zero.

extern PKCSDLLAPI BOOL WINAPI
PkcsIssuerOpen(
    OUT LPISSUERHANDLE phIssuer,    // Handle for future reference
    IN LPCTSTR szKeySet,            // The name of the Issuer keyset
    IN LPCTSTR szProvider,          // The specific name of the CSP, or Blank
    IN DWORD dwProvType,            // Should be PROV_RSA_FULL
    IN ALG_ID algPref,              // Suggest optional algorithm preferences
    IN DWORD dwStore);              // Store Id or zero.

extern PKCSDLLAPI BOOL WINAPI
PkcsIssuerClose(
    IN ISSUERHANDLE hIssuer);       // The reference handle to the Issuer

extern PKCSDLLAPI BOOL WINAPI
PkcsIssuerDelete(
    IN ISSUERHANDLE hIssuer);       // The handle to the Issuer to remove

extern PKCSDLLAPI BOOL WINAPI
PkcsIssuerRequestCertification(
    IN ISSUERHANDLE hIssuer,        // The reference handle to the Issuer
    IN ATTRIBLISTHANDLE hAtrList,   // reference to issuer attributes, if any
    OUT LPBYTE pbCertReq,           // Buffer to receive the certificate request
    IN OUT LPDWORD pcbCertReqLen);  // Length of the pbCertReq buffer

    //
    // ?TODO? - Need to attach an X.509 v2 UniqueIdentifier to the Issuer.
    //          It would be nice to get at the X.509 name.  Other info?
    // ?HOW? -  How can we attach an X.509 v2 UniqueIdentifier to the request?
    //

extern PKCSDLLAPI BOOL WINAPI
PkcsIssuerIssueLocalCA(
    IN ISSUERHANDLE hIssuer,        // The reference handle to the Issuer
    OUT LPBYTE pbCert,              // Buffer to receive certificate
    IN OUT LPDWORD pcbCertLen);     // Length of the pbCert buffer.

extern PKCSDLLAPI BOOL WINAPI
PkcsIssuerCertify(
    IN ISSUERHANDLE hIssuer,        // The reference handle to the Issuer
    IN const BYTE *pbCertReq,       // Buffer containing the certificate request
    IN const BYTE *pbSerialNo,      // Serial number to assign to certificate
    IN DWORD cbSerialNoLen,         // Length of the serial number
    IN LPFILETIME pftStartDate,     // Effective date of the certificate
    IN LPFILETIME pftEndDate,       // Termination date of the certificate
    OUT LPBYTE pbCert,              // Buffer to receive the certificate
    IN OUT LPDWORD pcbCertLen);     // Length of the pbCert buffer.

extern PKCSDLLAPI BOOL WINAPI
PkcsIssuerRecertify(
    IN ISSUERHANDLE hIssuer,        // The reference handle to the Issuer
    IN const BYTE *pbInCert,        // Buffer containing the old certificate
    IN const BYTE *pbSerialNo,      // Serial number to assign to certificate
    IN DWORD cbSerialNoLen,         // Length of the serial number
    IN LPFILETIME pftStartDate,     // Effective date of the certificate
    IN LPFILETIME pftEndDate,       // Termination date of the certificate
    OUT LPBYTE pbOutCert,           // Buffer to receive the certificate
    IN OUT LPDWORD pcbCertLen);     // Length of the pbCert buffer.

extern PKCSDLLAPI BOOL WINAPI
PkcsIssuerDistinguishedName(
    IN ISSUERHANDLE hIssuer,        // The reference handle to the Issuer
    OUT LPTSTR szDname,             // Buffer to receive the distinguished name
    IN OUT LPDWORD pcbDnameLen);    // Length of pbCertReq buffer

    //
    // ?HOW? -  How do we get the Issuer's UniqueIdentifier?
    //          How do we attach X.509 v3 Extensions to the certificate?
    //


//
//==============================================================================
//
//  CRL services.
//

typedef PKCSHANDLE
    CRLHANDLE;                      // Reference handle type.
typedef CRLHANDLE
    *PCRLHANDLE,                    // Pointers to reference handles.
    *LPCRLHANDLE;

extern PKCSDLLAPI BOOL WINAPI
PkcsCrlCreate(
    OUT LPCRLHANDLE phCrl,          // Handle for future reference
    IN ISSUERHANDLE hIssuer);       // Handle of controlling issuer

extern PKCSDLLAPI BOOL WINAPI
PkcsCrlLoad(

⌨️ 快捷键说明

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