Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 9e64647

Browse files
committed
Update Crypto.Xml to match ref
Reference assembly for S.S.C.Xml didn't match and had a duplicated version of an API in the implementation which we needed to eliminate.
1 parent f48d483 commit 9e64647

File tree

6 files changed

+28
-68
lines changed

6 files changed

+28
-68
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Compat issues with assembly System.Security.Cryptography.Pkcs:
2+
#These members don't belong in netstandard reference because of type unification with netfx (the members are new in net472).
23
MembersMustExist : Member 'System.Security.Cryptography.Pkcs.SignerInfo.GetSignature()' does not exist in the implementation but it does exist in the contract.
34
MembersMustExist : Member 'System.Security.Cryptography.Pkcs.SignerInfo.SignatureAlgorithm.get()' does not exist in the implementation but it does exist in the contract.
45
Total Issues: 2
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
Compat issues with assembly System.Security.Cryptography.Xml:
2+
#Type must be public in implementation for serialization to work but we don't want to expose it publicly in the contract as it isn't public on .NET Framework
23
TypesMustExist : Type 'System.Security.Cryptography.Xml.CryptoSignedXmlRecursionException' does not exist in the implementation but it does exist in the contract.
3-
TypesMustExist : Type 'System.Security.Cryptography.Xml.X509IssuerSerial' does not exist in the implementation but it does exist in the contract.
4-
Total Issues: 2

src/System.Security.Cryptography.Xml/src/System.Security.Cryptography.Xml.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
<Compile Include="System\Security\Cryptography\Xml\TransformChain.cs" />
7474
<Compile Include="System\Security\Cryptography\Xml\TransformInputType.cs" />
7575
<Compile Include="System\Security\Cryptography\Xml\Utils.cs" />
76-
<Compile Include="System\Security\Cryptography\Xml\X509IssuerSerial.cs" />
7776
<Compile Include="System\Security\Cryptography\Xml\XmlDecryptionTransform.cs" />
7877
<Compile Include="System\Security\Cryptography\Xml\XmlDsigBase64Transform.cs" />
7978
<Compile Include="System\Security\Cryptography\Xml\XmlDsigC14NTransform.cs" />
@@ -106,6 +105,7 @@
106105
<Reference Include="System.Security.Cryptography.Csp" />
107106
<Reference Include="System.Security.Cryptography.Encoding" />
108107
<Reference Include="System.Security.Cryptography.Primitives" />
108+
<Reference Include="System.Security.Cryptography.Pkcs" />
109109
<Reference Include="System.Security.Cryptography.X509Certificates" />
110110
<Reference Include="System.Security.Permissions" />
111111
<Reference Include="System.Text.Encoding.Extensions" />

src/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/KeyInfoX509Data.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace System.Security.Cryptography.Xml
1616
{
1717
public class KeyInfoX509Data : KeyInfoClause
1818
{
19-
// An array of certificates representing the certificate chain
19+
// An array of certificates representing the certificate chain
2020
private ArrayList _certificates = null;
2121
// An array of issuer serial structs
2222
private ArrayList _issuerSerials = null;
@@ -167,15 +167,15 @@ public void AddIssuerSerial(string issuerName, string serialNumber)
167167

168168
if (_issuerSerials == null)
169169
_issuerSerials = new ArrayList();
170-
_issuerSerials.Add(new X509IssuerSerial(issuerName, h.ToString()));
170+
_issuerSerials.Add(Utils.CreateX509IssuerSerial(issuerName, h.ToString()));
171171
}
172172

173173
// When we load an X509Data from Xml, we know the serial number is in decimal representation.
174174
internal void InternalAddIssuerSerial(string issuerName, string serialNumber)
175175
{
176176
if (_issuerSerials == null)
177177
_issuerSerials = new ArrayList();
178-
_issuerSerials.Add(new X509IssuerSerial(issuerName, serialNumber));
178+
_issuerSerials.Add(Utils.CreateX509IssuerSerial(issuerName, serialNumber));
179179
}
180180

181181
public byte[] CRL

src/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Utils.cs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ internal static string GetIdFromLocalUri(string uri, out bool discardComments)
309309
// initialize the return value
310310
discardComments = true;
311311

312-
// Deal with XPointer of type #xpointer(id("ID")). Other XPointer support isn't handled here and is anyway optional
312+
// Deal with XPointer of type #xpointer(id("ID")). Other XPointer support isn't handled here and is anyway optional
313313
if (idref.StartsWith("xpointer(id(", StringComparison.Ordinal))
314314
{
315315
int startId = idref.IndexOf("id(", StringComparison.Ordinal);
@@ -328,7 +328,7 @@ internal static string ExtractIdFromLocalUri(string uri)
328328
{
329329
string idref = uri.Substring(1);
330330

331-
// Deal with XPointer of type #xpointer(id("ID")). Other XPointer support isn't handled here and is anyway optional
331+
// Deal with XPointer of type #xpointer(id("ID")). Other XPointer support isn't handled here and is anyway optional
332332
if (idref.StartsWith("xpointer(id(", StringComparison.Ordinal))
333333
{
334334
int startId = idref.IndexOf("id(", StringComparison.Ordinal);
@@ -356,9 +356,9 @@ internal static void RemoveAllChildren(XmlElement inputElement)
356356
}
357357
}
358358

359-
// Writes one stream (starting from the current position) into
360-
// an output stream, connecting them up and reading until
361-
// hitting the end of the input stream.
359+
// Writes one stream (starting from the current position) into
360+
// an output stream, connecting them up and reading until
361+
// hitting the end of the input stream.
362362
// returns the number of bytes copied
363363
internal static long Pump(Stream input, Stream output)
364364
{
@@ -482,7 +482,7 @@ internal static void AddNamespaces(XmlElement elem, Hashtable namespaces)
482482
}
483483
}
484484

485-
// This method gets the attributes that should be propagated
485+
// This method gets the attributes that should be propagated
486486
internal static CanonicalXmlNodeList GetPropagatedAttributes(XmlElement elem)
487487
{
488488
if (elem == null)
@@ -606,6 +606,21 @@ internal static int GetHexArraySize(byte[] hex)
606606
return index + 1;
607607
}
608608

609+
// Mimic the behavior of the X509IssuerSerial constructor with null and empty checks
610+
internal static X509IssuerSerial CreateX509IssuerSerial(string issuerName, string serialNumber)
611+
{
612+
if (issuerName == null || issuerName.Length == 0)
613+
throw new ArgumentException(SR.Arg_EmptyOrNullString, nameof(issuerName));
614+
if (serialNumber == null || serialNumber.Length == 0)
615+
throw new ArgumentException(SR.Arg_EmptyOrNullString, nameof(serialNumber));
616+
617+
return new X509IssuerSerial()
618+
{
619+
IssuerName = issuerName,
620+
SerialNumber = serialNumber
621+
};
622+
}
623+
609624
internal static X509Certificate2Collection BuildBagOfCerts(KeyInfoX509Data keyInfoX509Data, CertUsageType certUsageType)
610625
{
611626
X509Certificate2Collection collection = new X509Certificate2Collection();
@@ -620,7 +635,7 @@ internal static X509Certificate2Collection BuildBagOfCerts(KeyInfoX509Data keyIn
620635
collection.Add(certificate);
621636
break;
622637
case CertUsageType.Decryption:
623-
decryptionIssuerSerials.Add(new X509IssuerSerial(certificate.IssuerName.Name, certificate.SerialNumber));
638+
decryptionIssuerSerials.Add(CreateX509IssuerSerial(certificate.IssuerName.Name, certificate.SerialNumber));
624639
break;
625640
}
626641
}

src/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/X509IssuerSerial.cs

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)