Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Use CrpytAPI to encode and decode PKCS#7 messages

Shulou Source: shulou.com Published: 2022-06-01 04:46:07 10月05日 Update

In order to encrypt messages interactively between networks and computers of different architectures, encrypted communication parties need to encode the transmitted messages in a standard way. CryptAPI supports PKCS # 7 standard encrypted message syntax format messages. The PKCS # 7 standard adopts the ASN.1 BER encoding rules defined by CCITT X.208 and defines the types and encoding methods associated with encrypted messages. The basic steps for encrypted message encoding using CryptAPI are as follows: initialize the data structures related to the message type. Call CryptMsgOpenToEncode to get the message handle. Call CryptMsgUpdate to fill in the data, and this function can be called multiple times until all the data in this message is filled in. The last call should set the fFinal parameter to TRUE. Call CryptMsgGetParam to get the required encoding result. Call CryptMsgClose to close the message. The basic steps for decoding are as follows: use CryptMsgCalculateEncodedLength to determine the buffer length needed to decode the message. Call CryptMsgOpenToDecode to get the message handle. Call CryptMsgUpdate to fill in the data, and this function can be called multiple times until all the data in this message is filled in. Call CryptMsgControl for additional processing such as decrypting or verifying signatures. Call CryptMsgGetParam to get the decoding result you need. Call CryptMsgClose to close the message.

Tags: Messages coding data encryption standards functions handles methods steps types structures results differences between architectures parameters data structures formats buffers Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Apple Xiaomi Linux Docker