Call now: (800) 766-1884  


 SQL Server Tips
 SQL Server Training

 SQL Server Consulting
 SQL Server Support
 SQL Server Remote DBA

 SQL Server Scripts
 Scripts Menu




  SQL Server Tips by Gama and Naughter

MS CryptoAPI based Hash Algorithm Implementations

To initialize MS CryptoAPI we first must acquire a so-called ‘Cryptography Service Provider (CSP)’. A CSP is a software module, which integrates with the CryptoAPI to provide cryptography functionality to client applications. This concept is similar to the approach taken by printer manufacturers in Windows. The manufacturer of a printer or Microsoft themselves develop a driver which talks directly to the printer hardware and then presents a standard interface to Windows and client applications. This allows developers to develop to the standard printer API’s. This allows Windows applications to support any printer installed on Windows without the need for additional application code. Unlike Printer Drivers however, CSP’s are normally implemented as standard user mode DLLs. Application code calls the Crypto API functions, which in turn call the CSP functions. The code used in XP_CRYPTOAPI to initialize a CSP is as follows:


Upon successful return of the ‘CryptAcquireContext’ function, we get a handle to the CSP in the hProv variable. We use the flag ‘CRYPT_VERIFYCONTEXT’ to specify that we do not need access to any public/private key pairs because we are only interested in hashing support. This helps speed up this call. We use the ‘CRYPT_SILENT’ to ensure that the CSP does not display any user interface. This is especially important in the context of an XP since it will be running as a service with no one available to respond to any UI, which might appear.

The above book excerpt is from:

Super SQL Server Systems
Turbocharge Database Performance with C++ External Procedures

ISBN: 0-9761573-2-2
Joseph Gama, P. J. Naughter  


Burleson Consulting Remote DB Administration







Burleson is the America's Team

Note: The pages on this site were created as a support and training reference for use by our staff of DBA consultants.  If you find it confusing, please exit this page.

Errata?  SQL Server technology is changing and we strive to update our SQL Server support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:and include the URL for the page.

Burleson Consulting
SQL Server database support


Copyright © 1996 -  2013 by Vaaltech Web Services. All rights reserved.

Hit Counter