CryptoProvider クラス

定義

保護されたコンテンツを暗号化および復号化するためのデジタル著作権管理サービスを提供します。

public ref class CryptoProvider : IDisposable
[System.Security.SecurityCritical(System.Security.SecurityCriticalScope.Everything)]
public class CryptoProvider : IDisposable
public class CryptoProvider : IDisposable
[<System.Security.SecurityCritical(System.Security.SecurityCriticalScope.Everything)>]
type CryptoProvider = class
    interface IDisposable
type CryptoProvider = class
    interface IDisposable
Public Class CryptoProvider
Implements IDisposable
継承
CryptoProvider
属性
実装

次の例は、 CryptoProvider クラスを使用して 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;
}
WriteStatus("   Signing the UnsignedPublishLicense" & vbLf & "       to build the PublishLicense.")
Dim authorsUseLicense As UseLicense = Nothing
Dim publishLicense As PublishLicense = unsignedLicense.Sign(_secureEnv, authorsUseLicense)

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

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

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

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

WriteStatus("Verifying package encryption.")
If EncryptedPackageEnvelope.IsEncryptedPackageEnvelope(encryptedFile) Then
    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." & vbLf)
    Return False
End If

注釈

CryptoProviderは、管理されている権限BindUseLicenseにバインドするときに、SecureEnvironment メソッドの結果として作成されます。

他の System.Security.RightsManagement の種類と同様に、 CryptoProvider は完全信頼アプリケーションでのみ使用できます。

プロパティ

名前 説明
BlockSize

暗号ブロック サイズをバイト単位で取得します。

BoundGrants

検証に合格し、ユーザーに付与される権限を一覧表示するコレクションを取得します。

CanDecrypt

ユーザーが復号化する権限を持っているかどうかを示す値を取得します。

CanEncrypt

ユーザーが暗号化する権限を持っているかどうかを示す値を取得します。

CanMergeBlocks

Encrypt(Byte[])Decrypt(Byte[])が、長さが異なるブロック サイズのバッファーを受け入れることができるかどうかを示す値を取得します。

メソッド

名前 説明
Decrypt(Byte[])

暗号テキストを復号化してテキストをクリアします。

Dispose()

CryptoProviderで使用されているすべてのリソースを解放します。

Dispose(Boolean)

CryptoProviderによって使用されるアンマネージ リソースを解放し、必要に応じてマネージド リソースを解放します。

Encrypt(Byte[])

クリア テキストを暗号化してテキストを暗号化します。

Equals(Object)

指定したオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
Finalize()

ガベージ コレクションによってインスタンスが再利用される前に、リソースを解放し、内部クリーンアップを実行します。

GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Objectの簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象

こちらもご覧ください