Cryptlib Spy

While testing my Delphi programs, I sometimes had the problem to find bugs :-))

I wrote a logging program in Delphi, that traces all cryptlib calls to a text file. When the program did not what I thought it should do, I looked into the logfile to decide whether it was my problem or if I should ask Peter Gutman what's wrong. The final version of this tracer is now available for download.

The Cryptlib Spy program has the form of a DLL and the name is CL32.DLL, the same name as the cryptlib DLL. This is a feature, not a bug! If you want to use the tracer, all you have to do is copying the file cl32.dll into the directory where your program is located. The original cryptlib cl32.dll should be copied to the directory C:\Windows\SysWOW64 (for a 64-Bit Windows) or C:\Windows\System32 (for a 32-Bit Windows) or any directory mentioned in your PATH). Cryptlib Spy calls the original library and traces the calling parameters and the result (if necessary) into the logfile.

That's all. No changes in your source, not even a recompilation. The "intermediate" cl32.dll creates a logfile named cryptlib.log in the calling program's directory.

If you want to switch off the trace again, rename cl32.dll or delete the file from your directory.

But remember: 

You have now 2 different libraries named cl32.dll on your system, don't mix them up or delete the wrong one!

Here is an example of the trace output :

cryptAddRandom(randomData, -11);
cryptCreateContext(&cryptContext, CRYPT_UNUSED, CRYPT_ALGO_RSA);
  cryptContext = 995
cryptSetAttributeString(995, CRYPT_CTXINFO_LABEL, "MyKey", 5);
cryptSetAttribute(995, CRYPT_CTXINFO_KEYSIZE, 341);
  certificate = 975
cryptSetAttribute(975, CRYPT_CERTINFO_XYZZY, 1);
cryptSetAttributeString(975, CRYPT_CERTINFO_COMMONNAME, "Max Mustermann", 14);
cryptSetAttributeString(975, CRYPT_CERTINFO_RFC822NAME, "", 14);
cryptSignCert(975, 995);
cryptKeysetOpen(&keyset, CRYPT_UNUSED, CRYPT_KEYSET_FILE, "TestKey.p15", CRYPT_KEYOPT_CREATE);
  keyset = 807
cryptAddPrivateKey(807, 995, "MyPassword");
cryptAddPublicKey(807, 975);
cryptExportCert(NULL, &certObjectLength, CRYPT_CERTFORMAT_TEXT_CERTIFICATE, 975);
  certObjectLength = 1450
cryptExportCert(certObject, &certObjectLength, CRYPT_CERTFORMAT_TEXT_CERTIFICATE, 975);
  certObjectLength = 1450
cryptGetAttributeString(975, CRYPT_CERTINFO_FINGERPRINT, value, &valueLength);
  value = hex(AE284A5F371F97200F5121B53FDFA47E)
  valueLength = 16


And you know, if you download the source, you do it on your own risk. I can't give you any support and any warranties are explicitly disclaimed.

Usable on any 32-bit MS-Windows version (XP, Vista, Windows7). Sorry, no DOS, Linux or Unix versions available.

You need Borlands Memory Manager "BORLNDMM.DLL" on your system! This is part of the Delphi release.

Cryptlib v3.4.3 Files Comment



Be careful ! Do not overwrite your cryptlib dll (put this CL32.DLL in your test directory and the original CL32.DLL in \Windows\system32 or \Windows\SysWOW64

If you find this useful (and if you use it) please leave a message!