Show / Hide Table of Contents

Class EncryptedAttribute

Represents an encrypted attribute.

Inheritance
System.Object
EncryptedElementType
EncryptedAttribute
Inherited Members
EncryptedElementType.GetKeyInfo(XmlElement)
EncryptedElementType.GetCertificate(XmlElement)
EncryptedElementType.EncryptedData
EncryptedElementType.EncryptedKeys
EncryptedElementType.ToXml(XmlElement)
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: ComponentSpace.SAML2.Assertions
Assembly: ComponentSpace.Saml2.dll
Syntax
public class EncryptedAttribute : EncryptedElementType
Remarks

Refer to the Assertions and Protocol for the OASIS Security Assertion Markup Language (SAML) V2.0 specification for further details.

Constructors

EncryptedAttribute()

Initializes a new instance of the EncryptedAttribute class.

Declaration
public EncryptedAttribute()

EncryptedAttribute(SAMLAttribute, AsymmetricAlgorithm, EncryptionMethod, EncryptionMethod, KeyInfo)

Initializes a new instance of the EncryptedAttribute class from a SAML attribute.

Declaration
public EncryptedAttribute(SAMLAttribute samlAttribute, AsymmetricAlgorithm keyEncryptingKey, EncryptionMethod keyEncryptionMethod, EncryptionMethod dataEncryptionMethod, KeyInfo keyInfo)
Parameters
Type Name Description
SAMLAttribute samlAttribute

The SAML attribute.

System.Security.Cryptography.AsymmetricAlgorithm keyEncryptingKey

The asymmetric key encrypting key.

System.Security.Cryptography.Xml.EncryptionMethod keyEncryptionMethod

The method for encrypting the symmetric key.

System.Security.Cryptography.Xml.EncryptionMethod dataEncryptionMethod

The method for encrypting the data.

System.Security.Cryptography.Xml.KeyInfo keyInfo

The key info to include with the encrypted data.

Remarks

A random symmetric session key is generated from the public asymmetric key. The symmetric key is used to encrypt the data.

The specified key encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.

The specified data encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#aes256-cbc.

Exceptions
Type Condition
SAMLSerializationException

Thrown when the XML deserialization fails.

SAMLEncryptionException

Thrown when the encryption fails.

See Also
Decrypt(AsymmetricAlgorithm, EncryptionMethod, EncryptionMethod)
Decrypt(X509Certificate2, EncryptionMethod, EncryptionMethod)

EncryptedAttribute(SAMLAttribute, AsymmetricAlgorithm, EncryptionMethod, EncryptionMethod, String, String, KeyInfo)

Initializes a new instance of the EncryptedAttribute class from a SAML attribute.

Declaration
public EncryptedAttribute(SAMLAttribute samlAttribute, AsymmetricAlgorithm keyEncryptingKey, EncryptionMethod keyEncryptionMethod, EncryptionMethod dataEncryptionMethod, string digestMethod, string maskGenerationFunction, KeyInfo keyInfo)
Parameters
Type Name Description
SAMLAttribute samlAttribute

The SAML attribute.

System.Security.Cryptography.AsymmetricAlgorithm keyEncryptingKey

The asymmetric key encrypting key.

System.Security.Cryptography.Xml.EncryptionMethod keyEncryptionMethod

The method for encrypting the symmetric key.

System.Security.Cryptography.Xml.EncryptionMethod dataEncryptionMethod

The method for encrypting the data.

System.String digestMethod

The key encryption digest method or null.

System.String maskGenerationFunction

The key encryption mask generation function or null.

System.Security.Cryptography.Xml.KeyInfo keyInfo

The key info to include with the encrypted data.

Remarks

A random symmetric session key is generated from the public asymmetric key. The symmetric key is used to encrypt the data.

The specified key encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.

The specified data encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#aes256-cbc.

Exceptions
Type Condition
SAMLSerializationException

Thrown when the XML deserialization fails.

SAMLEncryptionException

Thrown when the encryption fails.

See Also
Decrypt(AsymmetricAlgorithm, EncryptionMethod, EncryptionMethod)
Decrypt(X509Certificate2, EncryptionMethod, EncryptionMethod)

EncryptedAttribute(SAMLAttribute, AsymmetricAlgorithm, EncryptionMethod, KeyInfo)

Initializes a new instance of the EncryptedAttribute class from a SAML attribute.

Declaration
public EncryptedAttribute(SAMLAttribute samlAttribute, AsymmetricAlgorithm keyEncryptingKey, EncryptionMethod dataEncryptionMethod, KeyInfo keyInfo)
Parameters
Type Name Description
SAMLAttribute samlAttribute

The SAML attribute.

System.Security.Cryptography.AsymmetricAlgorithm keyEncryptingKey

The asymmetric key encrypting key.

System.Security.Cryptography.Xml.EncryptionMethod dataEncryptionMethod

The method for encrypting the data.

System.Security.Cryptography.Xml.KeyInfo keyInfo

The key info to include with the encrypted data.

Remarks

A random symmetric session key is generated from the public asymmetric key. The symmetric key is used to encrypt the data.

The encryption method for the encrypted symmetric key is http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.

The specified data encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#aes256-cbc.

Exceptions
Type Condition
SAMLSerializationException

Thrown when the XML deserialization fails.

SAMLEncryptionException

Thrown when the encryption fails.

See Also
Decrypt(AsymmetricAlgorithm, EncryptionMethod, EncryptionMethod)
Decrypt(X509Certificate2, EncryptionMethod, EncryptionMethod)

EncryptedAttribute(SAMLAttribute, X509Certificate2, EncryptionMethod)

Initializes a new instance of the EncryptedAttribute class from a SAML attribute.

Declaration
public EncryptedAttribute(SAMLAttribute samlAttribute, X509Certificate2 x509Certificate, EncryptionMethod dataEncryptionMethod)
Parameters
Type Name Description
SAMLAttribute samlAttribute

The SAML attribute.

System.Security.Cryptography.X509Certificates.X509Certificate2 x509Certificate

The X.509 certificate used when encrypting the data.

System.Security.Cryptography.Xml.EncryptionMethod dataEncryptionMethod

The method for encrypting the data.

Remarks

A random symmetric session key is generated from the public key contained within the X.509 certificate. The symmetric key is used to encrypt the data.

The encryption method for the encrypted symmetric key is http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.

The specified data encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#aes256-cbc.

Exceptions
Type Condition
SAMLSerializationException

Thrown when the XML deserialization fails.

SAMLEncryptionException

Thrown when the encryption fails.

See Also
Decrypt(AsymmetricAlgorithm, EncryptionMethod, EncryptionMethod)
Decrypt(X509Certificate2, EncryptionMethod, EncryptionMethod)

EncryptedAttribute(SAMLAttribute, X509Certificate2, EncryptionMethod, EncryptionMethod)

Initializes a new instance of the EncryptedAttribute class from a SAML attribute.

Declaration
public EncryptedAttribute(SAMLAttribute samlAttribute, X509Certificate2 x509Certificate, EncryptionMethod keyEncryptionMethod, EncryptionMethod dataEncryptionMethod)
Parameters
Type Name Description
SAMLAttribute samlAttribute

The SAML attribute.

System.Security.Cryptography.X509Certificates.X509Certificate2 x509Certificate

The X.509 certificate used when encrypting the data.

System.Security.Cryptography.Xml.EncryptionMethod keyEncryptionMethod

The method for encrypting the symmetric key.

System.Security.Cryptography.Xml.EncryptionMethod dataEncryptionMethod

The method for encrypting the data.

Remarks

A random symmetric session key is generated from the public key contained within the X.509 certificate. The symmetric key is used to encrypt the data.

The specified key encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.

The specified data encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#aes256-cbc.

Exceptions
Type Condition
SAMLSerializationException

Thrown when the XML deserialization fails.

SAMLEncryptionException

Thrown when the encryption fails.

See Also
Decrypt(AsymmetricAlgorithm, EncryptionMethod, EncryptionMethod)
Decrypt(X509Certificate2, EncryptionMethod, EncryptionMethod)

EncryptedAttribute(SAMLAttribute, X509Certificate2, EncryptionMethod, EncryptionMethod, String, String)

Initializes a new instance of the EncryptedAttribute class from a SAML attribute.

Declaration
public EncryptedAttribute(SAMLAttribute samlAttribute, X509Certificate2 x509Certificate, EncryptionMethod keyEncryptionMethod, EncryptionMethod dataEncryptionMethod, string digestMethod, string maskGenerationFunction)
Parameters
Type Name Description
SAMLAttribute samlAttribute

The SAML attribute.

System.Security.Cryptography.X509Certificates.X509Certificate2 x509Certificate

The X.509 certificate used when encrypting the data.

System.Security.Cryptography.Xml.EncryptionMethod keyEncryptionMethod

The method for encrypting the symmetric key.

System.Security.Cryptography.Xml.EncryptionMethod dataEncryptionMethod

The method for encrypting the data.

System.String digestMethod

The key encryption digest method or null.

System.String maskGenerationFunction

The key encryption mask generation function or null.

Remarks

A random symmetric session key is generated from the public key contained within the X.509 certificate. The symmetric key is used to encrypt the data.

The specified key encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.

The specified data encryption method is used. For example, http://www.w3.org/2001/04/xmlenc#aes256-cbc.

Exceptions
Type Condition
SAMLSerializationException

Thrown when the XML deserialization fails.

SAMLEncryptionException

Thrown when the encryption fails.

See Also
Decrypt(AsymmetricAlgorithm, EncryptionMethod, EncryptionMethod)
Decrypt(X509Certificate2, EncryptionMethod, EncryptionMethod)

EncryptedAttribute(XmlElement)

Initializes a new instance of the EncryptedAttribute class from XML.

Declaration
public EncryptedAttribute(XmlElement xmlElement)
Parameters
Type Name Description
System.Xml.XmlElement xmlElement

The encrypted attribute XML.

Exceptions
Type Condition
SAMLSerializationException

Thrown when the XML deserialization fails.

EncryptedAttribute(XmlElement, XmlNodeList)

Initializes a new instance of the EncryptedAttribute class.

Declaration
public EncryptedAttribute(XmlElement encryptedData, XmlNodeList encryptedKeys)
Parameters
Type Name Description
System.Xml.XmlElement encryptedData

The encrypted data.

System.Xml.XmlNodeList encryptedKeys

The encrypted keys.

Methods

Decrypt(AsymmetricAlgorithm, EncryptionMethod)

Decrypts an encrypted attribute.

Declaration
public SAMLAttribute Decrypt(AsymmetricAlgorithm keyDecryptingKey, EncryptionMethod dataEncryptionMethod)
Parameters
Type Name Description
System.Security.Cryptography.AsymmetricAlgorithm keyDecryptingKey

The asymmetric key decrypting key.

System.Security.Cryptography.Xml.EncryptionMethod dataEncryptionMethod

The method for decrypting the data or null if specified in the encrypted data.

Returns
Type Description
SAMLAttribute

The SAML attribute.

Remarks

The asymmetric key is used to decrypt the symmetric key contained within the encrypted data. The symmetric key is used to decrypt the data.

The encryption method for the encrypted symmetric key is expected to be http://www.w3.org/2001/04/xmlenc#rsa-1_5 or http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.

The encryption method for the data is specified in the encrypted data or may be explicitly specified.

Exceptions
Type Condition
SAMLSerializationException

Thrown when the XML deserialization fails.

SAMLEncryptionException

Thrown when the decryption fails.

See Also
EncryptedAttribute(SAMLAttribute, AsymmetricAlgorithm, EncryptionMethod, EncryptionMethod, KeyInfo)
EncryptedAttribute(SAMLAttribute, X509Certificate2, EncryptionMethod, EncryptionMethod)

Decrypt(AsymmetricAlgorithm, EncryptionMethod, EncryptionMethod)

Decrypts an encrypted attribute.

Declaration
public SAMLAttribute Decrypt(AsymmetricAlgorithm keyDecryptingKey, EncryptionMethod keyEncryptionMethod, EncryptionMethod dataEncryptionMethod)
Parameters
Type Name Description
System.Security.Cryptography.AsymmetricAlgorithm keyDecryptingKey

The asymmetric key decrypting key.

System.Security.Cryptography.Xml.EncryptionMethod keyEncryptionMethod

The method for decrypting the symmetric key or null if specified in the encrypted key.

System.Security.Cryptography.Xml.EncryptionMethod dataEncryptionMethod

The method for decrypting the data or null if specified in the encrypted data.

Returns
Type Description
SAMLAttribute

The SAML attribute.

Remarks

The asymmetric key is used to decrypt the symmetric key contained within the encrypted data. The symmetric key is used to decrypt the data.

The encryption method for the encrypted symmetric key is expected to be http://www.w3.org/2001/04/xmlenc#rsa-1_5 or http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.

The encryption method for the key is specified in the encrypted data or may be explicitly specified.

The encryption method for the data is specified in the encrypted data or may be explicitly specified.

Exceptions
Type Condition
SAMLSerializationException

Thrown when the XML deserialization fails.

SAMLEncryptionException

Thrown when the decryption fails.

See Also
EncryptedAttribute(SAMLAttribute, AsymmetricAlgorithm, EncryptionMethod, EncryptionMethod, KeyInfo)
EncryptedAttribute(SAMLAttribute, X509Certificate2, EncryptionMethod, EncryptionMethod)

Decrypt(X509Certificate2, EncryptionMethod)

Decrypts an encrypted attribute.

Declaration
public SAMLAttribute Decrypt(X509Certificate2 x509Certificate, EncryptionMethod dataEncryptionMethod)
Parameters
Type Name Description
System.Security.Cryptography.X509Certificates.X509Certificate2 x509Certificate

The X.509 certificate containing a private key.

System.Security.Cryptography.Xml.EncryptionMethod dataEncryptionMethod

The method for decrypting the data or null if specified in the encrypted data.

Returns
Type Description
SAMLAttribute

The SAML attribute.

Remarks

The X.509 certificate's private key is used to decrypt the symmetric key contained within the encrypted data. The symmetric key is used to decrypt the data.

The encryption method for the encrypted symmetric key is expected to be http://www.w3.org/2001/04/xmlenc#rsa-1_5 or http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.

The encryption method for the data is specified in the encrypted data or may be explicitly specified.

Exceptions
Type Condition
SAMLSerializationException

Thrown when the XML deserialization fails.

SAMLEncryptionException

Thrown when the decryption fails.

See Also
EncryptedAttribute(SAMLAttribute, AsymmetricAlgorithm, EncryptionMethod, EncryptionMethod, KeyInfo)
EncryptedAttribute(SAMLAttribute, X509Certificate2, EncryptionMethod, EncryptionMethod)

Decrypt(X509Certificate2, EncryptionMethod, EncryptionMethod)

Decrypts an encrypted attribute.

Declaration
public SAMLAttribute Decrypt(X509Certificate2 x509Certificate, EncryptionMethod keyEncryptionMethod, EncryptionMethod dataEncryptionMethod)
Parameters
Type Name Description
System.Security.Cryptography.X509Certificates.X509Certificate2 x509Certificate

The X.509 certificate containing a private key.

System.Security.Cryptography.Xml.EncryptionMethod keyEncryptionMethod

The method for decrypting the symmetric key or null if specified in the encrypted key.

System.Security.Cryptography.Xml.EncryptionMethod dataEncryptionMethod

The method for decrypting the data or null if specified in the encrypted data.

Returns
Type Description
SAMLAttribute

The SAML attribute.

Remarks

The X.509 certificate's private key is used to decrypt the symmetric key contained within the encrypted data. The symmetric key is used to decrypt the data.

The encryption method for the encrypted symmetric key is expected to be http://www.w3.org/2001/04/xmlenc#rsa-1_5 or http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.

The encryption method for the key is specified in the encrypted data or may be explicitly specified.

The encryption method for the data is specified in the encrypted data or may be explicitly specified.

Exceptions
Type Condition
SAMLSerializationException

Thrown when the XML deserialization fails.

SAMLEncryptionException

Thrown when the decryption fails.

See Also
EncryptedAttribute(SAMLAttribute, AsymmetricAlgorithm, EncryptionMethod, EncryptionMethod, KeyInfo)
EncryptedAttribute(SAMLAttribute, X509Certificate2, EncryptionMethod, EncryptionMethod)

IsValid(XmlElement)

Indicates whether the XML is an encrypted attribute.

Declaration
public static bool IsValid(XmlElement xmlElement)
Parameters
Type Name Description
System.Xml.XmlElement xmlElement

The XML to test.

Returns
Type Description
System.Boolean

true if the XML is an encrypted attribute; otherwise false.

ToXml(XmlDocument)

Serializes the encrypted attribute to XML.

Declaration
public XmlElement ToXml(XmlDocument xmlDocument)
Parameters
Type Name Description
System.Xml.XmlDocument xmlDocument

The owning XML document.

Returns
Type Description
System.Xml.XmlElement

The encrypted attribute as XML.

Exceptions
Type Condition
SAMLSerializationException

Thrown when the XML serialization fails.

In This Article
Back to top Copyright © ComponentSpace Pty Ltd 2004-2022. All rights reserved.