CryptoProvider Class

 

Provides digital rights management services for encrypting and decrypting protected content.

Namespace:   System.Security.RightsManagement
Assembly:  WindowsBase (in WindowsBase.dll)

System.Object
  System.Security.RightsManagement.CryptoProvider

[SecurityCriticalAttribute(SecurityCriticalScope.Everything)]
public class CryptoProvider : IDisposable

NameDescription
System_CAPS_pubpropertyBlockSize

Gets the cipher block size, in bytes.

System_CAPS_pubpropertyBoundGrants

Gets a collection listing the rights that passed verification and that are granted to the user.

System_CAPS_pubpropertyCanDecrypt

Gets a value that indicates whether the user has rights to decrypt.

System_CAPS_pubpropertyCanEncrypt

Gets a value that indicates whether the user has rights to encrypt.

System_CAPS_pubpropertyCanMergeBlocks

Gets a value that indicates whether Encrypt and Decrypt can accept buffers that are different block sizes in length.

NameDescription
System_CAPS_pubmethodDecrypt(Byte[])

Decrypts cipher text to clear text.

System_CAPS_pubmethodDispose()

Releases all resources used by the CryptoProvider.

System_CAPS_protmethodDispose(Boolean)

Releases the unmanaged resources used by the CryptoProvider and optionally releases the managed resources.

System_CAPS_pubmethodEncrypt(Byte[])

Encrypts clear text to cipher text.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Frees resources and performs internal cleanup before the instance is reclaimed by garbage collection.(Overrides Object.Finalize().)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

CryptoProvider is created as a result of the Bind method when binding a rights managed UseLicense to a SecureEnvironment.

As with other System.Security.RightsManagement types, CryptoProvider is only usable in full trust applications.

The following example shows how to use the CryptoProvider class to create an EncryptedPackageEnvelope.

WriteStatus("   Signing the UnsignedPublishLicense\n" +
            "       to build the PublishLicense.");
UseLicense authorsUseLicense;
PublishLicense publishLicense =
    unsignedLicense.Sign(_secureEnv, out authorsUseLicense);

WriteStatus("   Binding the author's UseLicense and");
WriteStatus("       obtaining the CryptoProvider.");
CryptoProvider cryptoProvider = authorsUseLicense.Bind(_secureEnv);

WriteStatus("   Creating the EncryptedPackage.");
Stream packageStream = File.OpenRead(packageFile);
EncryptedPackageEnvelope ePackage =
    EncryptedPackageEnvelope.CreateFromPackage(encryptedFile,
        packageStream, publishLicense, cryptoProvider);

WriteStatus("   Adding an author's UseLicense.");
RightsManagementInformation rmi =
    ePackage.RightsManagementInformation;
rmi.SaveUseLicense(author, authorsUseLicense);

ePackage.Close();
WriteStatus("   Done - Package encryption complete.");

WriteStatus("Verifying package encryption.");
if (EncryptedPackageEnvelope.IsEncryptedPackageEnvelope(encryptedFile))
{
    WriteStatus("   Confirmed - '" + encryptedFilename +
                "' is encrypted.");
}
else
{
    MessageBox.Show("ERROR: '" + encryptedFilename +
        "' is NOT ENCRYPTED.", "Encryption Error",
        MessageBoxButton.OK, MessageBoxImage.Error);
    WriteStatus("ERROR: '" + encryptedFilename +
                "' is NOT ENCRYPTED.\n");
    return false;
}

.NET Framework
Available since 3.0

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: