Export (0) Print
Expand All

CryptoProvider Class

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

System.Object
  System.Security.RightsManagement.CryptoProvider

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

public class CryptoProvider : IDisposable

The CryptoProvider type exposes the following members.

  NameDescription
Public propertyBlockSizeGets the cipher block size, in bytes.
Public propertyBoundGrantsGets a collection listing the rights that passed verification and that are granted to the user.
Public propertyCanDecryptGets a value that indicates whether the user has rights to decrypt.
Public propertyCanEncryptGets a value that indicates whether the user has rights to encrypt.
Public propertyCanMergeBlocksGets a value that indicates whether Encrypt and Decrypt can accept buffers that are different block sizes in length.
Top

  NameDescription
Public methodDecryptDecrypts cipher text to clear text.
Public methodDispose()Releases all resources used by the CryptoProvider.
Protected methodDispose(Boolean)Releases the unmanaged resources used by the CryptoProvider and optionally releases the managed resources.
Public methodEncryptEncrypts clear text to cipher text.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeFrees resources and performs internal cleanup before the instance is reclaimed by garbage collection. (Overrides Object.Finalize().)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

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

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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