Persits Software, Inc. Web Site
Main Menu:  Home |  Tasks |  Object Reference |  Crypto 101 |  FAQ |  Download & Buy |  Clients |  Live Demo |  Contact
 Navigator:  Home |  Object Reference |  CryptoMessage Object
CryptoCert CryptoHash
  CryptoMessage Object
The CryptoMessage object provides PKCS#7-based message signature and encryption functionality. This object is used by the AspEmail component to send secure mail in the S/MIME format. Starting with Version 2.0, it can also be used to generate detached PKCS#7 signatures and envelopes.

Properties Methods
This object has no properties AddRecipientCert
SetSignerCert
EncryptText
DecryptText
SignText
SignFile
VerifySignature

  CryptoMessage Properties
This object has no properties.

  CryptoMessage Methods


Sub AddRecipientCert ( Cert As CryptoCert )
Adds a recipient certificate to the message when this CryptoMessage object is to be used for sending encrypted mail or generating PKCS#7 envelopes. This method can be called as many times as there are message recipients.

Usage:

Msg.AddRecipientCert Cert

Related Task: Send Secure Mail.


Sub SetSignerCert ( Cert As CryptoCert )
Sets the signer certificate for the message when this CryptoMessage object is to be used for sending signed mail or generating detached PKCS#7 signatures.

Usage:

Msg.SetSignerCert Cert

Related Task: Send Secure Mail.


Function EncryptText ( Text As String ) As String
Encrypts a specified text string with one or more certificates specified by AddRecipientCert. Returns a Base64-encoded PKCS#7 envelope (encrypted message).

Usage:

EncrText = Msg.EncryptText("secret")

Related Task: Generate PKCS#7 Signatures and Envelopes.


Function DecryptText ( Envelope As String, Context As String ) As String
Decrypts a specified PKCS#7 envelope using the specified private key context name. The latter can be obtained via Cert.PrivateKeyContext.ContainerName. If Context is an empty string, all certificate contexts in the MY store will be tried until a match is found. If there is no match, an error will be thrown.

Returns the decrypted text string.

Usage:

EncrText = Msg.DecryptText(EncrText, "")

Related Task: Generate PKCS#7 Signatures and Envelopes.


Function SignText ( Text As String ) As String
Computes a detached PKCS#7 signature of the specified text string using a certificate specified by SetSignerCert. Signatures are based on the SHA hash function.

Returns a Base64-encoded PKCS#7 signature blob.

Usage:

Signature = Msg.SignText("some text")

Related Task: Generate PKCS#7 Signatures and Envelopes.


Function SignFile ( Path As String ) As String
Computes a detached PKCS#7 signature of the specified file using a certificate specified by SetSignerCert. Signatures are based on the SHA hash function.

Returns a Base64-encoded PKCS#7 signature blob.

Usage:

Signature = Msg.SignFile("d:\path\myfile.ext")

Related Task: Generate PKCS#7 Signatures and Envelopes.


Function VerifySignature ( Signature As String, Hash As CryptoHash, Cert As CryptoCert ) As Boolean
Verifies a detached PKCS#7 signature specified by Signature against a hash value contained in Hash and a public key contained in Cert.

Returns True if the signature is verified, or False otherwise.

Usage:

Set Cert = CM.ImportCertFromFile("c:\mycert.cer")
Set Hash = Context.CreateHash ' SHA by default
Hash.AddText "secret"
SignatureValid = Msg.VerifySignature(Signature, Hash, Cert)

Related Task: Generate PKCS#7 Signatures and Envelopes.


CryptoHash CryptoCert

Search this Site
  This site is owned and maintained by Persits Software, Inc. Copyright © 2000 - 2009. All Rights Reserved.