Because overly complex cryptographic algorithms are difficult to implement, in the past, many applications used only very simple encryption techniques, and the result is that encrypted data can easily be deciphered. Using the cryptographic application interface (that is, the cryptography API) provided by Microsoft, or CryptoAPI, makes it easy to add powerful encryption capabilities to your application without having to consider basic algorithms. This paper introduces CryptoAPI and the principle of data encryption, then gives the general steps of writing encryption program with CryptoAPI, and finally demonstrates some functions of CryptoAPI with a file encryption and decryption program.
1. CryptoAPI Introduction
CryptoAPI is a set of functions that must have a cryptographic service provider module (CSP) to complete a mathematical calculation. Microsoft provides a CSP at the operating system level by bundling RSA Base provider, using RSA's public key encryption algorithm, and more CSPs can be added to the application as needed. In fact, a CSP might be able to encrypt data with a special hardware device, such as a smart card. The CryptoAPI interface allows simple function tuning to encrypt data, Exchange public keys, hash out a message to create a digest, and generate a digital signature. It also provides advanced administrative operations, such as using a CSP from a set of possible CSPs. In addition, CryptoAPI provides a foundation for many advanced security services, including the set for E-commerce, the PCT for encrypting client/server messages, and the PFX, code signature, and so on for passing confidential data and keys back and forth between platforms. The architecture of the CryptoAPI is shown below:
Windows OSR2, Windows NT SP3 and later versions, Windows 98, Windows 2000, and so on are currently supported for CryptoAPI. CryptoAPI configuration information is stored in the registry, including the following key:
HKEY_LOCAL_MACHINE\SOFTWARE\
Microsoft \ Cryptography \Defaults
HKEY_CURRENT_USER\ Software \ Microsoft
\ Cryptography \Providers