public XmlSerializedDescriptorInfo ExportToXml() { // <descriptor> // <!-- Windows CNG-CBC --> // <encryption algorithm="..." keyLength="..." [provider="..."] /> // <hash algorithm="..." [provider="..."] /> // <masterKey>...</masterKey> // </descriptor> var encryptionElement = new XElement("encryption", new XAttribute("algorithm", Configuration.EncryptionAlgorithm), new XAttribute("keyLength", Configuration.EncryptionAlgorithmKeySize)); if (Configuration.EncryptionAlgorithmProvider != null) { encryptionElement.SetAttributeValue("provider", Configuration.EncryptionAlgorithmProvider); } var hashElement = new XElement("hash", new XAttribute("algorithm", Configuration.HashAlgorithm)); if (Configuration.HashAlgorithmProvider != null) { hashElement.SetAttributeValue("provider", Configuration.HashAlgorithmProvider); } var rootElement = new XElement("descriptor", new XComment(" Algorithms provided by Windows CNG, using CBC-mode encryption with HMAC validation "), encryptionElement, hashElement, MasterKey.ToMasterKeyElement()); return(new XmlSerializedDescriptorInfo(rootElement, typeof(CngCbcAuthenticatedEncryptorDescriptorDeserializer))); }
/// <inheritdoc/> public XmlSerializedDescriptorInfo ExportToXml() { // <descriptor> // <encryption algorithm="..." /> // <validation algorithm="..." /> <!-- only if not GCM --> // <masterKey requiresEncryption="true">...</masterKey> // </descriptor> var encryptionElement = new XElement("encryption", new XAttribute("algorithm", Configuration.EncryptionAlgorithm)); var validationElement = (AuthenticatedEncryptorFactory.IsGcmAlgorithm(Configuration.EncryptionAlgorithm)) ? (object)new XComment(" AES-GCM includes a 128-bit authentication tag, no extra validation algorithm required. ") : (object)new XElement("validation", new XAttribute("algorithm", Configuration.ValidationAlgorithm)); var outerElement = new XElement("descriptor", encryptionElement, validationElement, MasterKey.ToMasterKeyElement()); return(new XmlSerializedDescriptorInfo(outerElement, typeof(AuthenticatedEncryptorDescriptorDeserializer))); }
public XmlSerializedDescriptorInfo ExportToXml() { // <descriptor> // <!-- managed implementations --> // <encryption algorithm="..." keyLength="..." /> // <validation algorithm="..." /> // <masterKey>...</masterKey> // </descriptor> var encryptionElement = new XElement("encryption", new XAttribute("algorithm", TypeToFriendlyName(Configuration.EncryptionAlgorithmType)), new XAttribute("keyLength", Configuration.EncryptionAlgorithmKeySize)); var validationElement = new XElement("validation", new XAttribute("algorithm", TypeToFriendlyName(Configuration.ValidationAlgorithmType))); var rootElement = new XElement("descriptor", new XComment(" Algorithms provided by specified SymmetricAlgorithm and KeyedHashAlgorithm "), encryptionElement, validationElement, MasterKey.ToMasterKeyElement()); return(new XmlSerializedDescriptorInfo(rootElement, typeof(ManagedAuthenticatedEncryptorDescriptorDeserializer))); }
public XmlSerializedDescriptorInfo ExportToXml() { // <descriptor> // <!-- Windows CNG-GCM --> // <encryption algorithm="..." keyLength="..." [provider="..."] /> // <masterKey>...</masterKey> // </descriptor> var encryptionElement = new XElement("encryption", new XAttribute("algorithm", Settings.EncryptionAlgorithm), new XAttribute("keyLength", Settings.EncryptionAlgorithmKeySize)); if (Settings.EncryptionAlgorithmProvider != null) { encryptionElement.SetAttributeValue("provider", Settings.EncryptionAlgorithmProvider); } var rootElement = new XElement("descriptor", new XComment(" Algorithms provided by Windows CNG, using Galois/Counter Mode encryption and validation "), encryptionElement, MasterKey.ToMasterKeyElement()); return(new XmlSerializedDescriptorInfo(rootElement, typeof(CngGcmAuthenticatedEncryptorDescriptorDeserializer))); }