Skip to content

Commit

Permalink
* feat: load cades.dll dynamically (#4)
Browse files Browse the repository at this point in the history
* feat: load cades.dll dynamically
  • Loading branch information
maxirmx authored Nov 25, 2024
1 parent 3b84432 commit f2c714b
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 278 deletions.
251 changes: 0 additions & 251 deletions CadesSigner/Cades.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

interface

{$DEFINE ISOLATION_AWARE_ENABLED 1}

uses
Windows,
SysUtils,
Expand Down Expand Up @@ -173,255 +171,6 @@ CADES_VIEW_SIGNATURE_PARA = record

PPCRYPT_DATA_BLOB = ^PCRYPT_DATA_BLOB;

function CadesMsgOpenToEncode(dwMsgEncodingType: DWORD; dwFlags: DWORD;
pvMsgEncodeInfo: PCADES_ENCODE_INFO; pszInnerContentObjID: LPSTR;
pStreamInfo: PCMSG_STREAM_INFO): HCRYPTMSG; stdcall; external 'cades.dll';

function CadesMsgIsType(hCryptMsg: HCRYPTMSG; dwSignatureIndex: DWORD;
dwCadesType: DWORD; out pbResult: BOOL): BOOL; stdcall; external 'cades.dll';

function CadesMsgIsTypeEncoded(dwEncodingType: DWORD; pbSignerInfo: PBYTE;
cbSignerInfo: DWORD; dwCadesType: DWORD; out pbResult: BOOL): BOOL; stdcall;
external 'cades.dll';

function CadesMsgEnhanceSignature(hCryptMsg: HCRYPTMSG; dwSignatureIndex: DWORD;
pCadesSignPara: PCADES_SIGN_PARA): BOOL; stdcall; external 'cades.dll';

function CadesMsgEnhanceSignatureAll(hCryptMsg: HCRYPTMSG;
pCadesSignPara: PCADES_SIGN_PARA): BOOL; stdcall; external 'cades.dll';

function CadesMsgAddEnhancedSignature(hCryptMsg: HCRYPTMSG;
pCadesCosignPara: PCADES_COSIGN_PARA): BOOL; stdcall; external 'cades.dll';

function CadesMsgVerifySignature(hCryptMsg: HCRYPTMSG; dwSignatureIndex: DWORD;
pVerificationPara: PCADES_VERIFICATION_PARA; out ppVerificationInfo: PCADES_VERIFICATION_INFO): BOOL; stdcall;
external 'cades.dll';

function CadesMsgCountersignEncoded(dwEncodingType: DWORD; pbSignerInfo: PBYTE;
cbSignerInfo: DWORD; cCountersigners: DWORD; rgCountersigners: PCADES_COSIGN_PARA;
out ppCountersignature: PCRYPT_DATA_BLOB): BOOL; stdcall; external 'cades.dll';

function CadesMsgCountersign(hCryptMsg: HCRYPTMSG; dwIndex: DWORD; cCountersigners: DWORD;
rgCountersigners: PCADES_COSIGN_PARA): BOOL; stdcall; external 'cades.dll';

function CadesMsgVerifyCountersignatureEncoded(hCryptProv: HCRYPTPROV; dwEncodingType: DWORD;
pbSignerInfo: PBYTE; cbSignerInfo: DWORD; pbSignerInfoCountersignature: PBYTE;
cbSignerInfoCountersignature: DWORD; pciCountersigner: PCERT_INFO;
pVerificationPara: PCADES_VERIFICATION_PARA; out ppVerificationInfo: PCADES_VERIFICATION_INFO): BOOL; stdcall;
external 'cades.dll';

function CadesMsgVerifyCountersignatureEncodedEx(hCryptProv: HCRYPTPROV; dwEncodingType: DWORD;
pbSignerInfo: PBYTE; cbSignerInfo: DWORD; pbSignerInfoCountersignature: PBYTE;
cbSignerInfoCountersignature: DWORD; dwSignerType: DWORD; pvSigner: Pointer;
dwFlags: DWORD; pvReserved: Pointer; pVerificationPara: PCADES_VERIFICATION_PARA;
out ppVerificationInfo: PCADES_VERIFICATION_INFO): BOOL; stdcall; external 'cades.dll';

function CadesMsgGetSigningCertId(hCryptMsg: HCRYPTMSG; dwSignatureIndex: DWORD;
out ppCertId: PCRYPT_DATA_BLOB): BOOL; stdcall; external 'cades.dll';

function CadesMsgGetSigningCertIdEx(pSignerInfo: PCMSG_SIGNER_INFO;
out ppCertId: PCRYPT_DATA_BLOB): BOOL; stdcall; external 'cades.dll';

function CadesMsgGetSigningCertIdEncoded(dwEncodingType: DWORD; pbSignerInfo: PBYTE;
cbSignerInfo: DWORD; out ppCertId: PCRYPT_DATA_BLOB): BOOL; stdcall; external 'cades.dll';

function CadesMsgGetSigningCertIdHashAlg(hCryptMsg: HCRYPTMSG; dwSignatureIndex: DWORD): ALG_ID; stdcall;
external 'cades.dll';

function CadesMsgGetSignatureTimestamps(hCryptMsg: HCRYPTMSG; dwSignatureIndex: DWORD;
out ppTimestamps: PCADES_BLOB_ARRAY): BOOL; stdcall; external 'cades.dll';

function CadesMsgGetCadesCTimestamps(hCryptMsg: HCRYPTMSG; dwSignatureIndex: DWORD;
out ppTimestamps: PCADES_BLOB_ARRAY): BOOL; stdcall; external 'cades.dll';

function CadesMsgGetArchiveTimestamps(hCryptMsg: HCRYPTMSG; dwSignatureIndex: DWORD;
dwFlags: DWORD; pvReserved: Pointer; out ppTimestamps: PCADES_BLOB_ARRAY): BOOL; stdcall;
external 'cades.dll';

function CadesMsgGetCertificateValues(hCryptMsg: HCRYPTMSG; dwSignatureIndex: DWORD;
out ppCertificates: PCADES_BLOB_ARRAY): BOOL; stdcall; external 'cades.dll';

function CadesMsgGetRevocationValues(hCryptMsg: HCRYPTMSG; dwSignatureIndex: DWORD;
out ppCRLs: PCADES_BLOB_ARRAY; out ppBasicOCSPResponses: PCADES_BLOB_ARRAY): BOOL; stdcall;
external 'cades.dll';

function CadesMsgGetSigningCertIdHashAlgEx(pSignerInfo: PCMSG_SIGNER_INFO): ALG_ID; stdcall;
external 'cades.dll';

function CadesMsgGetSignatureTimestampsEx(pSignerInfo: PCMSG_SIGNER_INFO;
out ppTimestamps: PCADES_BLOB_ARRAY): BOOL; stdcall; external 'cades.dll';

function CadesMsgGetCadesCTimestampsEx(pSignerInfo: PCMSG_SIGNER_INFO;
out ppTimestamps: PCADES_BLOB_ARRAY): BOOL; stdcall; external 'cades.dll';

function CadesMsgGetArchiveTimestampsEx(pSignerInfo: PCMSG_SIGNER_INFO; dwFlags: DWORD;
pvReserved: Pointer; out ppTimestamps: PCADES_BLOB_ARRAY): BOOL; stdcall;
external 'cades.dll';

function CadesMsgGetCertificateValuesEx(pSignerInfo: PCMSG_SIGNER_INFO;
out ppCertificates: PCADES_BLOB_ARRAY): BOOL; stdcall; external 'cades.dll';

function CadesMsgGetRevocationValuesEx(pSignerInfo: PCMSG_SIGNER_INFO;
out ppCRLs: PCADES_BLOB_ARRAY; out ppBasicOCSPResponses: PCADES_BLOB_ARRAY): BOOL; stdcall;
external 'cades.dll';

function CadesMsgGetSignatureTimestampsEncoded(dwEncodingType: DWORD;
pbSignerInfo: PBYTE; cbSignerInfo: DWORD; out ppTimestamps: PCADES_BLOB_ARRAY): BOOL; stdcall;
external 'cades.dll';
function CadesMsgGetCadesCTimestampsEncoded(dwEncodingType: DWORD;
pbSignerInfo: PBYTE; cbSignerInfo: DWORD; out ppTimestamps: PCADES_BLOB_ARRAY): BOOL; stdcall;
external 'cades.dll';

function CadesMsgGetArchiveTimestampsEncoded(dwEncodingType: DWORD;
pbSignerInfo: PBYTE; cbSignerInfo: DWORD; dwFlags: DWORD; pvReserved: Pointer;
out ppTimestamps: PCADES_BLOB_ARRAY): BOOL; stdcall; external 'cades.dll';

function CadesMsgGetCertificateValuesEncoded(dwEncodingType: DWORD;
pbSignerInfo: PBYTE; cbSignerInfo: DWORD; out ppCertificates: PCADES_BLOB_ARRAY): BOOL; stdcall;
external 'cades.dll';

function CadesMsgGetRevocationValuesEncoded(dwEncodingType: DWORD;
pbSignerInfo: PBYTE; cbSignerInfo: DWORD; out ppCRLs: PCADES_BLOB_ARRAY;
out ppBasicOCSPResponses: PCADES_BLOB_ARRAY): BOOL; stdcall;
external 'cades.dll';

function CadesMsgGetSigningCertIdHashAlgEncoded(dwEncodingType: DWORD;
pbSignerInfo: PBYTE; cbSignerInfo: DWORD): ALG_ID; stdcall;
external 'cades.dll';

function CadesMsgUIDisplaySignature(hCryptMsg: HCRYPTMSG; dwSignatureIndex: DWORD;
hwndParent: HWND; title: LPCWSTR): BOOL; stdcall;
external 'cades.dll';

function CadesMsgUIDisplaySignatureByHash(hCryptMsg: HCRYPTMSG; dwSignatureIndex: DWORD;
hwndParent: HWND; title: LPCWSTR; pbHashBlob: PBYTE; cbHashBlob: DWORD;
pHashAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER): BOOL; stdcall;
external 'cades.dll';

function CadesMsgUIDisplaySignatures(hCryptMsg: HCRYPTMSG; hwndParent: HWND;
title: LPCWSTR): BOOL; stdcall;
external 'cades.dll';

function CadesMsgUIDisplaySignaturesByHash(hCryptMsg: HCRYPTMSG; hwndParent: HWND;
title: LPCWSTR; pbHashBlob: PBYTE; cbHashBlob: DWORD;
pHashAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER): BOOL; stdcall; external 'cades.dll';

function CadesMsgViewSignature(hCryptMsg: HCRYPTMSG; dwSignatureIndex: DWORD;
out prgPropPages: Pointer; out pcPropPages: DWORD): BOOL; stdcall;
external 'cades.dll';

function CadesMsgViewSignatures(hCryptMsg: HCRYPTMSG; out prgPropPages: Pointer;
out pcPropPages: DWORD): BOOL; stdcall;
external 'cades.dll';

function CadesViewSignature(pCadesViewSignaturePara: PCADES_VIEW_SIGNATURE_PARA;
dwSignatureIndex: DWORD; pbSignedBlob: PBYTE; cbSignedBlob: DWORD;
out prgPropPages: Pointer; out pcPropPages: DWORD): BOOL; stdcall;
external 'cades.dll';

function CadesViewSignatureDetached(pCadesViewSignaturePara: PCADES_VIEW_SIGNATURE_PARA;
dwSignatureIndex: DWORD; pbDetachedSignBlob: PBYTE; cbDetachedSignBlob: DWORD;
cToBeSigned: DWORD; rgpbToBeSigned: PBYTE; rgcbToBeSigned: DWORD;
out prgPropPages: Pointer; out pcPropPages: DWORD): BOOL; stdcall;
external 'cades.dll';

function CadesViewSignatures(pCadesViewSignaturePara: PCADES_VIEW_SIGNATURE_PARA;
pbSignedBlob: PBYTE; cbSignedBlob: DWORD; out prgPropPages: Pointer;
out pcPropPages: DWORD): BOOL; stdcall;
external 'cades.dll';

function CadesViewSignaturesDetached(pCadesViewSignaturePara: PCADES_VIEW_SIGNATURE_PARA;
pbDetachedSignBlob: PBYTE; cbDetachedSignBlob: DWORD; cToBeSigned: DWORD;
rgpbToBeSigned: PBYTE; rgcbToBeSigned: DWORD; out prgPropPages: Pointer;
out pcPropPages: DWORD): BOOL; stdcall;
external 'cades.dll';

function CadesUIDisplaySignature(pCadesViewSignaturePara: PCADES_VIEW_SIGNATURE_PARA;
dwSignatureIndex: DWORD; pbSignedBlob: PBYTE; cbSignedBlob: DWORD;
hwndParent: HWND; title: LPCWSTR): BOOL; stdcall;
external 'cades.dll';

function CadesUIDisplaySignatures(pCadesViewSignaturePara: PCADES_VIEW_SIGNATURE_PARA;
pbSignedBlob: PBYTE; cbSignedBlob: DWORD; hwndParent: HWND; title: LPCWSTR): BOOL; stdcall;
external 'cades.dll';

function CadesUIDisplaySignatureDetached(pCadesViewSignaturePara: PCADES_VIEW_SIGNATURE_PARA;
dwSignatureIndex: DWORD; pbDetachedSignBlob: PBYTE; cbDetachedSignBlob: DWORD;
cToBeSigned: DWORD; rgpbToBeSigned: PBYTE; rgcbToBeSigned: DWORD;
hwndParent: HWND; title: LPCWSTR): BOOL; stdcall;
external 'cades.dll';

function CadesUIDisplaySignaturesDetached(pCadesViewSignaturePara: PCADES_VIEW_SIGNATURE_PARA;
pbDetachedSignBlob: PBYTE; cbDetachedSignBlob: DWORD; cToBeSigned: DWORD;
rgpbToBeSigned: PBYTE; rgcbToBeSigned: DWORD; hwndParent: HWND; title: LPCWSTR): BOOL; stdcall;
external 'cades.dll';

function CadesFreeSignaturePropPages(prgPropPages: Pointer;
pcPropPages: DWORD): BOOL; stdcall;
external 'cades.dll';

function CadesSignMessage(pSignPara: PCADES_SIGN_MESSAGE_PARA; fDetachedSignature: BOOL;
cToBeSigned: DWORD; rgpbToBeSigned: Pointer; rgcbToBeSigned: PDWORD;
ppSignedBlob: PPCRYPT_DATA_BLOB): BOOL; stdcall; external 'cades.dll';

function CadesSignHash(pSignPara: PCADES_SIGN_MESSAGE_PARA; pbHash: PBYTE;
cbHash: DWORD; pszInnerContentObjID: LPCSTR; out ppSignedBlob: PCRYPT_DATA_BLOB): BOOL; stdcall;
external 'cades.dll';

function CadesVerifyHash(pVerifyPara: PCADES_VERIFY_MESSAGE_PARA; dwSignerIndex: DWORD;
pbDetachedSignBlob: PBYTE; cbDetachedSignBlob: DWORD; pbHash: PBYTE; cbHash: DWORD;
pHashAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER; out ppVerificationInfo: PCADES_VERIFICATION_INFO): BOOL; stdcall;
external 'cades.dll';

function CadesAddHashSignature(pSignPara: PCADES_SIGN_MESSAGE_PARA;
pbDetachedSignBlob: PBYTE; cbDetachedSignBlob: DWORD; pbHash: PBYTE;
cbHash: DWORD; out ppSignedBlob: PCRYPT_DATA_BLOB): BOOL; stdcall;
external 'cades.dll';

function CadesVerifyMessage(pVerifyPara: PCADES_VERIFY_MESSAGE_PARA; dwSignerIndex: DWORD;
pbSignedBlob: PBYTE; cbSignedBlob: DWORD; out ppDecodedBlob: PCRYPT_DATA_BLOB;
out ppVerificationInfo: PCADES_VERIFICATION_INFO): BOOL; stdcall;
external 'cades.dll';

function CadesVerifyDetachedMessage(pVerifyPara: PCADES_VERIFY_MESSAGE_PARA;
dwSignerIndex: DWORD; pbDetachedSignBlob: PBYTE; cbDetachedSignBlob: DWORD;
cToBeSigned: DWORD; rgpbToBeSigned: PBYTE; rgcbToBeSigned: DWORD;
out ppVerificationInfo: PCADES_VERIFICATION_INFO): BOOL; stdcall;
external 'cades.dll';

function CadesEnhanceMessage(pEnhancePara: PCADES_ENHANCE_MESSAGE_PARA; dwSignerIndex: DWORD;
pbSignedBlob: PBYTE; cbSignedBlob: DWORD; out ppEnhancedBlob: PCRYPT_DATA_BLOB): BOOL; stdcall;
external 'cades.dll';

function CadesEnhanceMessageAll(pEnhancePara: PCADES_ENHANCE_MESSAGE_PARA;
pbSignedBlob: PBYTE; cbSignedBlob: DWORD; out ppEnhancedBlob: PCRYPT_DATA_BLOB): BOOL; stdcall;
external 'cades.dll';

function CadesFreeVerificationInfo(pVerificationInfo: PCADES_VERIFICATION_INFO): BOOL; stdcall;
external 'cades.dll';

function CadesFreeBlob(pBlob: PCRYPT_DATA_BLOB): BOOL; stdcall;
external 'cades.dll';

function CadesFreeBlobArray(pBlobArray: PCADES_BLOB_ARRAY): BOOL; stdcall;
external 'cades.dll';

function CadesFormatMessage(dwFlags: DWORD; lpSource: Pointer; dwMessageId: DWORD;
dwLanguageId: DWORD; lpBuffer: PWideChar; nSize: DWORD; Arguments: va_list): DWORD; stdcall;
external 'cades.dll';


function CadesMsgConvertCreateContext(pStreamInfo: PCMSG_STREAM_INFO; pbDetachedMessage: PBYTE;
cbDetachedMessage: DWORD): PCADES_CONVERT_CONTEXT; stdcall;
external 'cades.dll';

function CadesMsgConvertUpdate(pConvertContext: PCADES_CONVERT_CONTEXT; pbData: PBYTE;
cbData: DWORD; fFinal: BOOL): BOOL; stdcall; external 'cades.dll';

function CadesMsgConvertFreeContext(pConvertContext: PCADES_CONVERT_CONTEXT): BOOL; stdcall;
external 'cades.dll';


implementation

end.
Expand Down
Loading

0 comments on commit f2c714b

Please sign in to comment.