MessageProtectionOrder 列挙型

定義

メッセージを保護する操作の順序を指定します。

public enum class MessageProtectionOrder
public enum MessageProtectionOrder
type MessageProtectionOrder = 
Public Enum MessageProtectionOrder
継承
MessageProtectionOrder

フィールド

EncryptBeforeSign 2

SOAP メッセージのデジタル署名を生成する前に SOAP メッセージを暗号化するように指定します。

SignBeforeEncrypt 0

SOAP メッセージの一部を暗号化する前に SOAP メッセージのデジタル署名を生成し、デジタル署名を暗号化しないように指定します。

SignBeforeEncryptAndEncryptSignature 1

SOAP メッセージの一部を暗号化する前に SOAP メッセージのデジタル署名を生成し、デジタル署名を暗号化するように指定します。

次の例では、 要素を SymmetricSecurityBindingElement 作成し、その MessageProtectionOrder プロパティを SignBeforeEncrypt に設定します。

public static Binding CreateCustomBinding()
{
    // Create an empty BindingElementCollection to populate,
    // then create a custom binding from it.
    BindingElementCollection outputBec = new BindingElementCollection();

    // Create a SymmetricSecurityBindingElement.
    SymmetricSecurityBindingElement ssbe =
        new SymmetricSecurityBindingElement();

    // Set the algorithm suite to one that uses 128-bit keys.
    ssbe.DefaultAlgorithmSuite = SecurityAlgorithmSuite.Basic128;

       // Set MessageProtectionOrder to SignBeforeEncrypt.
    ssbe.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt;

    // Use a Kerberos token as the protection token.
    ssbe.ProtectionTokenParameters = new KerberosSecurityTokenParameters();

    // Add the SymmetricSecurityBindingElement to the BindingElementCollection.
    outputBec.Add ( ssbe );
    outputBec.Add(new TextMessageEncodingBindingElement());
    outputBec.Add(new HttpTransportBindingElement());

    // Create a CustomBinding and return it; otherwise, return null.
    return new CustomBinding(outputBec);
}
Public Shared Function CreateCustomBinding() As Binding 
    ' Create an empty BindingElementCollection to populate, 
    ' then create a custom binding from it.
    Dim outputBec As New BindingElementCollection()
    
    ' Create a SymmetricSecurityBindingElement.
    Dim ssbe As New SymmetricSecurityBindingElement()
    
    ' Set the algorithm suite to one that uses 128-bit keys.
    ssbe.DefaultAlgorithmSuite = SecurityAlgorithmSuite.Basic128
    
    ' Set MessageProtectionOrder to SignBeforeEncrypt.
    ssbe.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt
    
    ' Use a Kerberos token as the protection token.
    ssbe.ProtectionTokenParameters = New KerberosSecurityTokenParameters()
    
    ' Add the SymmetricSecurityBindingElement to the BindingElementCollection.
    outputBec.Add(ssbe)
    outputBec.Add(New TextMessageEncodingBindingElement())
    outputBec.Add(New HttpTransportBindingElement())
    
    ' Create a CustomBinding and return it; otherwise, return null.
    Return New CustomBinding(outputBec)

End Function

注釈

この列挙体は、AsymmetricSecurityBindingElement.MessageProtectionOrder クラスの AsymmetricSecurityBindingElement プロパティと SymmetricSecurityBindingElement.MessageProtectionOrder クラスの SymmetricSecurityBindingElement プロパティで使用します。

メッセージがダイジェスト攻撃に対して脆弱な場合 (たとえば、メッセージが短い場合やエントロピが低い場合)、SignBeforeEncryptAndEncryptSignature または EncryptBeforeSign オプションを使用する必要があります。 (エントロピ は、サーバー、クライアント、またはその両方によって提供されるランダム なデータであり、データを暗号化および復号化するための共有キーを作成するために使用されます)。

順序付けの対象

WCF には、SOAP メッセージ セキュリティを使用してメッセージをセキュリティで保護する方法を決定する 3 つの異なる保護レベルが用意されています。 既定値は SignBeforeEncryptAndEncryptSignature です。 この設定では、最初にメッセージに署名し、メッセージ本文を暗号化してから、XML 署名を暗号化します。 これにより、署名に対する暗号解読攻撃が成功する可能性を低くすることができます。

ただし、既定値を使用すると、パフォーマンスへの影響があります。 実際、セキュリティを向上させるために、パフォーマンスのトレードオフが発生します。 署名の暗号化により、パフォーマンスが 10% ~ 40% 低下する可能性があります。 メッセージのデータ コンテンツの値が小さく、パフォーマンスのスループットが大きい場合は、SignBeforeEncrypt を使用します。 この設定では、署名ダイジェストがクリア テキストで送信されるため、エントロピが低い場合はメッセージが推測と検証による攻撃を受けやすくなります。

カスタム バインドのみに使用

MessageProtectionOrder プロパティを変更するには、カスタム セキュリティ バインディングを作成する必要があります。 カスタム バインドを作成する方法の詳細については、「ユーザー定義バインディングの作成」を参照してください。 特定の認証モード用のカスタム バインドを作成する方法の詳細については、「方法: 指定した認証モード用の SecurityBindingElement を作成する」を参照してください。

適用対象

こちらもご覧ください