Using CSP for encryption protection under Windows platform

Source: Internet
Author: User
Tags asymmetric encryption
CSP is a shorthand for cryptographic Service provider, the underlying cryptographic interface developed by Microsoft for the Windows family of operating systems, for managing hardware or software encryption devices, data encryption, decryption, digital signatures, validation, and data digest (i.e. HASH). Wait   This example implements several aspects of Operation   1. Operations on containers include creating, opening, closing, and destroying containers. Provider can correspond to a hardware ukey or software virtual container, Microsoft offers several default provider, each provider can contain several containers (Container). Microsoft offers provider:prov_rsa_full prov_rsa_sig prov_dss prov_dss_dh Prov_fortezza prov_ms_exchange PROV_RSA_SCHANNEL SSL prov_ec_ecdsa_sig prov_ec_ecnra_sig prov_ec_ecdsa_full prov_ec_ecnra_full prov_spyrus_lynks PROV_RNG SEC 2 generates random numbers 3. Generates a key in the container, including an RSA cryptographic key pair, and an RSA signature key pair. 4.RSA Encrypted asymmetric encryption is used to encrypt small amounts of data that are more secure. 5. Signature, verification, export of RSA public key (can be used to verify the signature). For authentication. 6.hash,hmac. Used to validate data integrity 7. Symmetric plus decryption. Encrypt data, fast. 8. Protect native data: No CSP handle is required, and container-independent, generating data that can only be decrypted on this computer. Prevents native data from being copy.   9 Here's a way to be interesting. There is a requirement that I will call some functions, and then I want to pop the pop-up message after each call to tell me the function name of this call, call result A, and define a function that is responsible for pop-up information, it input parameters for function name and function return result VOID Ccspdlg::P opupmessage (LPCTSTR lpfunction, bool bresult, bool baddlasterrormsg/*= true*/) {     CString Strinfo;     tchar Szerrmsg[max_path] = {0};     if (baddlasterrormsg)         ssosgetcodedesc (:: GetLastError (), Szerrmsg, Ss_dimof (szerrmsg), NULL);     if (bresult)     {         Strinfo.format (_t ("Execute%s success.\r\n%s"), Lpfunction, szerrmsg);     }else     {         Strinfo.format (_t ("Execute%s failed.\r\n%s"), Lpfunction, szerrmsg);    &NBSP}     afxmessagebox (Strinfo); b) Define a macro #define CALL_FUNC_OF_RLT_BY_BOOL (f) popupmessage (TEXT (#F), F)   c) Scenario     call_ Func_of_rlt_by_bool ((M_hcryptprov = Sscspcreatecontainer (null, NULL))!= NULL);     call_func_of_rlt_by_bool (Sscspclosecontainer (M_hcryptprov));   SOURCE code:http://download.csdn.net/detail/patdz/4280531
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.