Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,10 @@ internal static string GetIdFromLocalUri(string uri, out bool discardComments)

internal static string ExtractIdFromLocalUri(string? uri)
{
string idref = uri!.Substring(1);
if (string.IsNullOrEmpty(uri))
throw new CryptographicException(SR.Cryptography_Xml_UriRequired);

string idref = uri.Substring(1);

Comment thread
vcsjones marked this conversation as resolved.
// Deal with XPointer of type #xpointer(id("ID")). Other XPointer support isn't handled here and is anyway optional
if (idref.StartsWith("xpointer(id(", StringComparison.Ordinal))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,25 @@ public static void EncryptedKey_LoadXml_WithAllElements()
Assert.Equal(1, encKey.ReferenceList.Count);
}

[Fact]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Throws NullReferenceException on .NET Framework")]
public static void DecryptDocument_RetrievalMethodWithoutUri_ThrowsCryptographicException()
Comment thread
vcsjones marked this conversation as resolved.
{
const string xml =
"<root>" +
"<EncryptedData xmlns=\"http://www.w3.org/2001/04/xmlenc#\">" +
"<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\">" +
"<RetrievalMethod/>" +
"</KeyInfo>" +
"<CipherData><CipherValue>AA==</CipherValue></CipherData>" +
"</EncryptedData>" +
"</root>";

var doc = new XmlDocument { XmlResolver = null };
doc.LoadXml(xml);
Assert.Throws<CryptographicException>(() => new EncryptedXml(doc).DecryptDocument());
Comment thread
vcsjones marked this conversation as resolved.
}

#if NET
[Fact]
public static void EncryptedXml_RecursiveKey_Default()
Expand Down
Loading