We followed the steps described in the link given below
https://msdn.microsoft.com/en-us/library/ms953432.aspx
We also carried out the following steps:
Created a DLL (custom CSP) which is exposing the CryptoAPI entry function in DLL.
Custom CSP dll file was signed using Microsoft Code Signing Certificate.
We made the appropriate changes in registry settings to add custom CSP and placed the dll in /windows32/ folder.
We made self-signed digital certificate using MakeCert tool and this certificate is linked to the custom CSP dll by changing the property of certificate using Cryptography functions (CertSetCertificateContextProperty)
Refer Code:
key_prov_info.pwszContainerName = L"xxxx";
key_prov_info.pwszProvName = L"xxxx Provider";
key_prov_info.dwProvType = PROV_RSA_FULL;
key_prov_info.dwFlags = CERT_SET_KEY_PROV_HANDLE_PROP_ID;
key_prov_info.cProvParam = 0;
key_prov_info.rgProvParam = NULL;
key_prov_info.dwKeySpec = AT_SIGNATURE;
printf("Trying to set new property");
if (!CertSetCertificateContextProperty(pCertCon1,
CERT_KEY_PROV_INFO_PROP_ID, 0, &key_prov_info))
{
goto Exit;
}
We also have a hardware token which has the private key stored in it.
Now as a trial run, we made a trial CSP dll to ascertain the function calls being made by MS Word by writing into a log file. On trying to create a Digital Signature it is only calling the following functions:
o CPAcquireContext
o CPGetUserKey and
o CPDestroyKey
We are unable to access the other functions as given below:
o CPEncrypt
o CPCreateHash and
o CPSignHash
I don't know why the other functions are not calling. If anyone knows please help me.