From 986518e2ad9ac431d08ff7effb21fbe1f3aeb3ed Mon Sep 17 00:00:00 2001 From: Kevin Jones Date: Mon, 6 Apr 2020 13:31:58 -0400 Subject: [PATCH] Enable more nullable reference types in asn.xslt. string and Oid types on Choice can be null. Reference types that are @optional can be null. Also, remove #nullable enable, because all projects that include the ASN.1 generate files should already have nullable enable project-wide. --- .../Cryptography/Asn1/DirectoryStringAsn.xml.cs | 9 ++++----- .../Cryptography/Asn1/ECDomainParameters.xml.cs | 3 +-- .../Cryptography/Asn1/GeneralNameAsn.xml.cs | 9 ++++----- .../Cryptography/Asn1/Pbkdf2SaltChoice.xml.cs | 1 - .../Cryptography/Asn1/Pkcs12/SafeBagAsn.xml.cs | 2 +- .../Asn1/Pkcs7/EncryptedDataAsn.xml.cs | 2 +- .../Cryptography/Asn1/PrivateKeyInfoAsn.xml.cs | 2 +- .../Cryptography/Asn1/SpecifiedECDomain.xml.cs | 2 +- .../src/System/Security/Cryptography/Asn1/asn.xslt | 9 ++++----- .../Pkcs/Asn1/CertificateChoiceAsn.xml.cs | 1 - .../Cryptography/Pkcs/Asn1/EnvelopedDataAsn.xml.cs | 2 +- .../Asn1/KeyAgreeRecipientIdentifierAsn.xml.cs | 1 - .../Pkcs/Asn1/OriginatorIdentifierOrKeyAsn.xml.cs | 1 - .../Pkcs/Asn1/OriginatorInfoAsn.xml.cs | 4 ++-- .../Pkcs/Asn1/PolicyInformation.xml.cs | 2 +- .../Pkcs/Asn1/RecipientIdentifierAsn.xml.cs | 1 - .../Cryptography/Pkcs/Asn1/RecipientInfoAsn.xml.cs | 1 - .../Pkcs/Asn1/Rfc3161TimeStampReq.xml.cs | 2 +- .../Cryptography/Pkcs/Asn1/Rfc3161TstInfo.xml.cs | 2 +- .../Pkcs/Asn1/SignedAttributesSet.xml.cs | 3 +-- .../Cryptography/Pkcs/Asn1/SignedDataAsn.xml.cs | 4 ++-- .../Pkcs/Asn1/SignerIdentifierAsn.xml.cs | 1 - .../Pkcs/Asn1/SigningCertificateAsn.xml.cs | 2 +- .../Pkcs/Asn1/SigningCertificateV2Asn.xml.cs | 2 +- .../Cryptography/Pkcs/Rfc3161TimestampRequest.cs | 2 +- .../Cryptography/Pkcs/Rfc3161TimestampTokenInfo.cs | 2 +- .../System/Security/Cryptography/Pkcs/SignedCms.cs | 2 +- .../Cryptography/Pal.Unix/UnixExportProvider.cs | 22 ++++++++++------------ .../Cryptography/Pal.Unix/UnixPkcs12Reader.cs | 12 ++++++------ .../Asn1/DistributionPointAsn.xml.cs | 2 +- .../Asn1/DistributionPointNameAsn.xml.cs | 3 +-- .../X509Certificates/Asn1/TbsCertificateAsn.xml.cs | 2 +- .../X509Certificates/Asn1/TimeAsn.xml.cs | 1 - 33 files changed, 50 insertions(+), 66 deletions(-) diff --git a/src/libraries/Common/src/System/Security/Cryptography/Asn1/DirectoryStringAsn.xml.cs b/src/libraries/Common/src/System/Security/Cryptography/Asn1/DirectoryStringAsn.xml.cs index 2f420f8..eda1cfd 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/Asn1/DirectoryStringAsn.xml.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/Asn1/DirectoryStringAsn.xml.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable enable #pragma warning disable SA1028 // ignore whitespace warnings for generated code using System; using System.Runtime.InteropServices; @@ -14,11 +13,11 @@ namespace System.Security.Cryptography.Asn1 [StructLayout(LayoutKind.Sequential)] internal partial struct DirectoryStringAsn { - internal string TeletexString; - internal string PrintableString; + internal string? TeletexString; + internal string? PrintableString; internal ReadOnlyMemory? UniversalString; - internal string Utf8String; - internal string BmpString; + internal string? Utf8String; + internal string? BmpString; #if DEBUG static DirectoryStringAsn() diff --git a/src/libraries/Common/src/System/Security/Cryptography/Asn1/ECDomainParameters.xml.cs b/src/libraries/Common/src/System/Security/Cryptography/Asn1/ECDomainParameters.xml.cs index 4c89970..727797d 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/Asn1/ECDomainParameters.xml.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/Asn1/ECDomainParameters.xml.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable enable #pragma warning disable SA1028 // ignore whitespace warnings for generated code using System; using System.Runtime.InteropServices; @@ -15,7 +14,7 @@ namespace System.Security.Cryptography.Asn1 internal partial struct ECDomainParameters { internal System.Security.Cryptography.Asn1.SpecifiedECDomain? Specified; - internal Oid Named; + internal Oid? Named; #if DEBUG static ECDomainParameters() diff --git a/src/libraries/Common/src/System/Security/Cryptography/Asn1/GeneralNameAsn.xml.cs b/src/libraries/Common/src/System/Security/Cryptography/Asn1/GeneralNameAsn.xml.cs index 79316b1..5525fc3 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/Asn1/GeneralNameAsn.xml.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/Asn1/GeneralNameAsn.xml.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable enable #pragma warning disable SA1028 // ignore whitespace warnings for generated code using System; using System.Runtime.InteropServices; @@ -15,14 +14,14 @@ namespace System.Security.Cryptography.Asn1 internal partial struct GeneralNameAsn { internal System.Security.Cryptography.Asn1.OtherNameAsn? OtherName; - internal string Rfc822Name; - internal string DnsName; + internal string? Rfc822Name; + internal string? DnsName; internal ReadOnlyMemory? X400Address; internal ReadOnlyMemory? DirectoryName; internal System.Security.Cryptography.Asn1.EdiPartyNameAsn? EdiPartyName; - internal string Uri; + internal string? Uri; internal ReadOnlyMemory? IPAddress; - internal string RegisteredId; + internal string? RegisteredId; #if DEBUG static GeneralNameAsn() diff --git a/src/libraries/Common/src/System/Security/Cryptography/Asn1/Pbkdf2SaltChoice.xml.cs b/src/libraries/Common/src/System/Security/Cryptography/Asn1/Pbkdf2SaltChoice.xml.cs index 0ff367a..9a1c275 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/Asn1/Pbkdf2SaltChoice.xml.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/Asn1/Pbkdf2SaltChoice.xml.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable enable #pragma warning disable SA1028 // ignore whitespace warnings for generated code using System; using System.Runtime.InteropServices; diff --git a/src/libraries/Common/src/System/Security/Cryptography/Asn1/Pkcs12/SafeBagAsn.xml.cs b/src/libraries/Common/src/System/Security/Cryptography/Asn1/Pkcs12/SafeBagAsn.xml.cs index e961640..c34015f 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/Asn1/Pkcs12/SafeBagAsn.xml.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/Asn1/Pkcs12/SafeBagAsn.xml.cs @@ -16,7 +16,7 @@ namespace System.Security.Cryptography.Asn1.Pkcs12 { internal string BagId; internal ReadOnlyMemory BagValue; - internal System.Security.Cryptography.Asn1.AttributeAsn[] BagAttributes; + internal System.Security.Cryptography.Asn1.AttributeAsn[]? BagAttributes; internal void Encode(AsnWriter writer) { diff --git a/src/libraries/Common/src/System/Security/Cryptography/Asn1/Pkcs7/EncryptedDataAsn.xml.cs b/src/libraries/Common/src/System/Security/Cryptography/Asn1/Pkcs7/EncryptedDataAsn.xml.cs index 8938c54..fffd2c0 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/Asn1/Pkcs7/EncryptedDataAsn.xml.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/Asn1/Pkcs7/EncryptedDataAsn.xml.cs @@ -16,7 +16,7 @@ namespace System.Security.Cryptography.Asn1.Pkcs7 { internal int Version; internal System.Security.Cryptography.Asn1.Pkcs7.EncryptedContentInfoAsn EncryptedContentInfo; - internal System.Security.Cryptography.Asn1.AttributeAsn[] UnprotectedAttributes; + internal System.Security.Cryptography.Asn1.AttributeAsn[]? UnprotectedAttributes; internal void Encode(AsnWriter writer) { diff --git a/src/libraries/Common/src/System/Security/Cryptography/Asn1/PrivateKeyInfoAsn.xml.cs b/src/libraries/Common/src/System/Security/Cryptography/Asn1/PrivateKeyInfoAsn.xml.cs index 12ba027..648489e 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/Asn1/PrivateKeyInfoAsn.xml.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/Asn1/PrivateKeyInfoAsn.xml.cs @@ -17,7 +17,7 @@ namespace System.Security.Cryptography.Asn1 internal byte Version; internal System.Security.Cryptography.Asn1.AlgorithmIdentifierAsn PrivateKeyAlgorithm; internal ReadOnlyMemory PrivateKey; - internal System.Security.Cryptography.Asn1.AttributeAsn[] Attributes; + internal System.Security.Cryptography.Asn1.AttributeAsn[]? Attributes; internal void Encode(AsnWriter writer) { diff --git a/src/libraries/Common/src/System/Security/Cryptography/Asn1/SpecifiedECDomain.xml.cs b/src/libraries/Common/src/System/Security/Cryptography/Asn1/SpecifiedECDomain.xml.cs index f1f44d8..dbe070a 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/Asn1/SpecifiedECDomain.xml.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/Asn1/SpecifiedECDomain.xml.cs @@ -19,7 +19,7 @@ namespace System.Security.Cryptography.Asn1 internal ReadOnlyMemory Base; internal ReadOnlyMemory Order; internal ReadOnlyMemory? Cofactor; - internal Oid Hash; + internal Oid? Hash; internal void Encode(AsnWriter writer) { diff --git a/src/libraries/Common/src/System/Security/Cryptography/Asn1/asn.xslt b/src/libraries/Common/src/System/Security/Cryptography/Asn1/asn.xslt index b686608..3433cd1 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/Asn1/asn.xslt +++ b/src/libraries/Common/src/System/Security/Cryptography/Asn1/asn.xslt @@ -127,7 +127,6 @@ namespace // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable enable #pragma warning disable SA1028 // ignore whitespace warnings for generated code using System; using System.Collections.Generic; @@ -690,9 +689,9 @@ namespace Asn1Tag.PrimitiveOctetString - internal Oid ; + internal Oid? ; - internal string ; + internal string? ; Oid string @@ -761,7 +760,7 @@ namespace - internal string ; + internal string? ; string @@ -784,7 +783,7 @@ namespace new Asn1Tag(UniversalTagNumber.) - internal [] ; + internal []? ; diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/CertificateChoiceAsn.xml.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/CertificateChoiceAsn.xml.cs index f0efb33..073aac1 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/CertificateChoiceAsn.xml.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/CertificateChoiceAsn.xml.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable enable #pragma warning disable SA1028 // ignore whitespace warnings for generated code using System; using System.Runtime.InteropServices; diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/EnvelopedDataAsn.xml.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/EnvelopedDataAsn.xml.cs index 005d78a..dfcaffa 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/EnvelopedDataAsn.xml.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/EnvelopedDataAsn.xml.cs @@ -18,7 +18,7 @@ namespace System.Security.Cryptography.Pkcs.Asn1 internal System.Security.Cryptography.Pkcs.Asn1.OriginatorInfoAsn? OriginatorInfo; internal System.Security.Cryptography.Pkcs.Asn1.RecipientInfoAsn[] RecipientInfos; internal System.Security.Cryptography.Asn1.Pkcs7.EncryptedContentInfoAsn EncryptedContentInfo; - internal System.Security.Cryptography.Asn1.AttributeAsn[] UnprotectedAttributes; + internal System.Security.Cryptography.Asn1.AttributeAsn[]? UnprotectedAttributes; internal void Encode(AsnWriter writer) { diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/KeyAgreeRecipientIdentifierAsn.xml.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/KeyAgreeRecipientIdentifierAsn.xml.cs index 8ccaea7..cc5df62 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/KeyAgreeRecipientIdentifierAsn.xml.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/KeyAgreeRecipientIdentifierAsn.xml.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable enable #pragma warning disable SA1028 // ignore whitespace warnings for generated code using System; using System.Runtime.InteropServices; diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/OriginatorIdentifierOrKeyAsn.xml.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/OriginatorIdentifierOrKeyAsn.xml.cs index 82acb18..b9a72cc 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/OriginatorIdentifierOrKeyAsn.xml.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/OriginatorIdentifierOrKeyAsn.xml.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable enable #pragma warning disable SA1028 // ignore whitespace warnings for generated code using System; using System.Runtime.InteropServices; diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/OriginatorInfoAsn.xml.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/OriginatorInfoAsn.xml.cs index 76af43c..009aef4 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/OriginatorInfoAsn.xml.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/OriginatorInfoAsn.xml.cs @@ -14,8 +14,8 @@ namespace System.Security.Cryptography.Pkcs.Asn1 [StructLayout(LayoutKind.Sequential)] internal partial struct OriginatorInfoAsn { - internal System.Security.Cryptography.Pkcs.Asn1.CertificateChoiceAsn[] CertificateSet; - internal ReadOnlyMemory[] RevocationInfoChoices; + internal System.Security.Cryptography.Pkcs.Asn1.CertificateChoiceAsn[]? CertificateSet; + internal ReadOnlyMemory[]? RevocationInfoChoices; internal void Encode(AsnWriter writer) { diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/PolicyInformation.xml.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/PolicyInformation.xml.cs index b70e9ae..2836c2a 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/PolicyInformation.xml.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/PolicyInformation.xml.cs @@ -15,7 +15,7 @@ namespace System.Security.Cryptography.Pkcs.Asn1 internal partial struct PolicyInformation { internal string PolicyIdentifier; - internal System.Security.Cryptography.Pkcs.Asn1.PolicyQualifierInfo[] PolicyQualifiers; + internal System.Security.Cryptography.Pkcs.Asn1.PolicyQualifierInfo[]? PolicyQualifiers; internal void Encode(AsnWriter writer) { diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/RecipientIdentifierAsn.xml.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/RecipientIdentifierAsn.xml.cs index b8e3f7c..2523671 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/RecipientIdentifierAsn.xml.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/RecipientIdentifierAsn.xml.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable enable #pragma warning disable SA1028 // ignore whitespace warnings for generated code using System; using System.Runtime.InteropServices; diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/RecipientInfoAsn.xml.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/RecipientInfoAsn.xml.cs index 8f4a41a..4290612 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/RecipientInfoAsn.xml.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/RecipientInfoAsn.xml.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable enable #pragma warning disable SA1028 // ignore whitespace warnings for generated code using System; using System.Runtime.InteropServices; diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/Rfc3161TimeStampReq.xml.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/Rfc3161TimeStampReq.xml.cs index f99b08c..704fcc6 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/Rfc3161TimeStampReq.xml.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/Rfc3161TimeStampReq.xml.cs @@ -21,7 +21,7 @@ namespace System.Security.Cryptography.Pkcs.Asn1 internal Oid? ReqPolicy; internal ReadOnlyMemory? Nonce; internal bool CertReq; - internal System.Security.Cryptography.Asn1.X509ExtensionAsn[] Extensions; + internal System.Security.Cryptography.Asn1.X509ExtensionAsn[]? Extensions; #if DEBUG static Rfc3161TimeStampReq() diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/Rfc3161TstInfo.xml.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/Rfc3161TstInfo.xml.cs index 8bf7ca2..49a96ec 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/Rfc3161TstInfo.xml.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/Rfc3161TstInfo.xml.cs @@ -25,7 +25,7 @@ namespace System.Security.Cryptography.Pkcs.Asn1 internal bool Ordering; internal ReadOnlyMemory? Nonce; internal System.Security.Cryptography.Asn1.GeneralNameAsn? Tsa; - internal System.Security.Cryptography.Asn1.X509ExtensionAsn[] Extensions; + internal System.Security.Cryptography.Asn1.X509ExtensionAsn[]? Extensions; #if DEBUG static Rfc3161TstInfo() diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SignedAttributesSet.xml.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SignedAttributesSet.xml.cs index 8b2e7a1..7c81d8c 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SignedAttributesSet.xml.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SignedAttributesSet.xml.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable enable #pragma warning disable SA1028 // ignore whitespace warnings for generated code using System; using System.Collections.Generic; @@ -15,7 +14,7 @@ namespace System.Security.Cryptography.Pkcs [StructLayout(LayoutKind.Sequential)] internal partial struct SignedAttributesSet { - internal System.Security.Cryptography.Asn1.AttributeAsn[] SignedAttributes; + internal System.Security.Cryptography.Asn1.AttributeAsn[]? SignedAttributes; #if DEBUG static SignedAttributesSet() diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SignedDataAsn.xml.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SignedDataAsn.xml.cs index 75fa98e..1af67b0 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SignedDataAsn.xml.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SignedDataAsn.xml.cs @@ -17,8 +17,8 @@ namespace System.Security.Cryptography.Pkcs.Asn1 internal int Version; internal System.Security.Cryptography.Asn1.AlgorithmIdentifierAsn[] DigestAlgorithms; internal System.Security.Cryptography.Pkcs.Asn1.EncapsulatedContentInfoAsn EncapContentInfo; - internal System.Security.Cryptography.Pkcs.Asn1.CertificateChoiceAsn[] CertificateSet; - internal ReadOnlyMemory[] Crls; + internal System.Security.Cryptography.Pkcs.Asn1.CertificateChoiceAsn[]? CertificateSet; + internal ReadOnlyMemory[]? Crls; internal System.Security.Cryptography.Pkcs.Asn1.SignerInfoAsn[] SignerInfos; internal void Encode(AsnWriter writer) diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SignerIdentifierAsn.xml.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SignerIdentifierAsn.xml.cs index 2a0a97b..5cb956e 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SignerIdentifierAsn.xml.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SignerIdentifierAsn.xml.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable enable #pragma warning disable SA1028 // ignore whitespace warnings for generated code using System; using System.Runtime.InteropServices; diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SigningCertificateAsn.xml.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SigningCertificateAsn.xml.cs index ae7922f..52a06d9 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SigningCertificateAsn.xml.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SigningCertificateAsn.xml.cs @@ -15,7 +15,7 @@ namespace System.Security.Cryptography.Pkcs.Asn1 internal partial struct SigningCertificateAsn { internal System.Security.Cryptography.Pkcs.Asn1.EssCertId[] Certs; - internal System.Security.Cryptography.Pkcs.Asn1.PolicyInformation[] Policies; + internal System.Security.Cryptography.Pkcs.Asn1.PolicyInformation[]? Policies; internal void Encode(AsnWriter writer) { diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SigningCertificateV2Asn.xml.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SigningCertificateV2Asn.xml.cs index 01c8929..6556faf 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SigningCertificateV2Asn.xml.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Asn1/SigningCertificateV2Asn.xml.cs @@ -15,7 +15,7 @@ namespace System.Security.Cryptography.Pkcs.Asn1 internal partial struct SigningCertificateV2Asn { internal System.Security.Cryptography.Pkcs.Asn1.EssCertIdV2[] Certs; - internal System.Security.Cryptography.Pkcs.Asn1.PolicyInformation[] Policies; + internal System.Security.Cryptography.Pkcs.Asn1.PolicyInformation[]? Policies; internal void Encode(AsnWriter writer) { diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Rfc3161TimestampRequest.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Rfc3161TimestampRequest.cs index 15e9076..b126b1a 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Rfc3161TimestampRequest.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Rfc3161TimestampRequest.cs @@ -38,7 +38,7 @@ namespace System.Security.Cryptography.Pkcs return coll; } - X509ExtensionAsn[] rawExtensions = _parsedData.Extensions; + X509ExtensionAsn[] rawExtensions = _parsedData.Extensions!; foreach (X509ExtensionAsn rawExtension in rawExtensions) { diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Rfc3161TimestampTokenInfo.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Rfc3161TimestampTokenInfo.cs index c2e1d89..a9ff1fe 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Rfc3161TimestampTokenInfo.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Rfc3161TimestampTokenInfo.cs @@ -97,7 +97,7 @@ namespace System.Security.Cryptography.Pkcs return coll; } - X509ExtensionAsn[] rawExtensions = _parsedData.Extensions; + X509ExtensionAsn[] rawExtensions = _parsedData.Extensions!; foreach (X509ExtensionAsn rawExtension in rawExtensions) { diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/SignedCms.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/SignedCms.cs index d7a5e8a..d45d274 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/SignedCms.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/SignedCms.cs @@ -80,7 +80,7 @@ namespace System.Security.Cryptography.Pkcs return coll; } - CertificateChoiceAsn[] certChoices = _signedData.CertificateSet; + CertificateChoiceAsn[]? certChoices = _signedData.CertificateSet; if (certChoices == null) { diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/UnixExportProvider.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/UnixExportProvider.cs index b2bc76f..89c5e0c 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/UnixExportProvider.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/UnixExportProvider.cs @@ -197,25 +197,23 @@ namespace Internal.Cryptography.Pal attrBytes[1] = sizeof(int); MemoryMarshal.Write(attrBytes.AsSpan(2), ref keyIdx); + AttributeAsn attribute = new AttributeAsn + { + AttrType = new Oid(Oids.LocalKeyId, null), + AttrValues = new ReadOnlyMemory[] + { + attrBytes, + } + }; keyBags[keyIdx] = new SafeBagAsn { BagId = Oids.Pkcs12ShroudedKeyBag, BagValue = ExportPkcs8(certPal, passwordSpan), - BagAttributes = new[] - { - new AttributeAsn - { - AttrType = new Oid(Oids.LocalKeyId, null), - AttrValues = new ReadOnlyMemory[] - { - attrBytes, - } - } - } + BagAttributes = new[] { attribute } }; // Reuse the attribute between the cert and the key. - certAttrs[certIdx] = keyBags[keyIdx].BagAttributes[0]; + certAttrs[certIdx] = attribute; keyIdx++; } diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/UnixPkcs12Reader.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/UnixPkcs12Reader.cs index 808ff35..d1d4532 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/UnixPkcs12Reader.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/UnixPkcs12Reader.cs @@ -248,7 +248,7 @@ namespace Internal.Cryptography.Pal // Nothing requires that there be fewer keys than certs, // but it's sort of nonsensical when loading this way. CertBagAsn[] certBags = ArrayPool.Shared.Rent(10); - AttributeAsn[][] certBagAttrs = ArrayPool.Shared.Rent(10); + AttributeAsn[]?[] certBagAttrs = ArrayPool.Shared.Rent(10); SafeBagAsn[] keyBags = ArrayPool.Shared.Rent(10); RentedSubjectPublicKeyInfo[]? publicKeyInfos = null; AsymmetricAlgorithm[]? keys = null; @@ -326,7 +326,7 @@ namespace Internal.Cryptography.Pal } ArrayPool.Shared.Return(certBags, clearArray: true); - ArrayPool.Shared.Return(certBagAttrs, clearArray: true); + ArrayPool.Shared.Return(certBagAttrs, clearArray: true); ArrayPool.Shared.Return(keyBags, clearArray: true); } } @@ -356,7 +356,7 @@ namespace Internal.Cryptography.Pal private void DecryptAndProcessSafeContents( ReadOnlySpan password, ref CertBagAsn[] certBags, - ref AttributeAsn[][] certBagAttrs, + ref AttributeAsn[]?[] certBagAttrs, ref int certBagIdx, ref SafeBagAsn[] keyBags, ref int keyBagIdx) @@ -455,7 +455,7 @@ namespace Internal.Cryptography.Pal private void BuildCertsWithKeys( CertBagAsn[] certBags, - AttributeAsn[][] certBagAttrs, + AttributeAsn[]?[] certBagAttrs, CertAndKey[] certs, int certBagIdx, SafeBagAsn[] keyBags, @@ -581,7 +581,7 @@ namespace Internal.Cryptography.Pal { for (int i = 0; i < keyBagCount; i++) { - foreach (AttributeAsn attr in keyBags[i].BagAttributes) + foreach (AttributeAsn attr in keyBags[i].BagAttributes ?? Array.Empty()) { if (attr.AttrType.Value == Oids.LocalKeyId && attr.AttrValues.Length > 0) { @@ -656,7 +656,7 @@ namespace Internal.Cryptography.Pal private static void ProcessSafeContents( in ContentInfoAsn safeContentsAsn, ref CertBagAsn[] certBags, - ref AttributeAsn[][] certBagAttrs, + ref AttributeAsn[]?[] certBagAttrs, ref int certBagIdx, ref SafeBagAsn[] keyBags, ref int keyBagIdx) diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/Asn1/DistributionPointAsn.xml.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/Asn1/DistributionPointAsn.xml.cs index 94adda8..23af630 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/Asn1/DistributionPointAsn.xml.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/Asn1/DistributionPointAsn.xml.cs @@ -16,7 +16,7 @@ namespace System.Security.Cryptography.X509Certificates.Asn1 { internal System.Security.Cryptography.X509Certificates.Asn1.DistributionPointNameAsn? DistributionPoint; internal System.Security.Cryptography.X509Certificates.Asn1.ReasonFlagsAsn? Reasons; - internal System.Security.Cryptography.Asn1.GeneralNameAsn[] CRLIssuer; + internal System.Security.Cryptography.Asn1.GeneralNameAsn[]? CRLIssuer; internal void Encode(AsnWriter writer) { diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/Asn1/DistributionPointNameAsn.xml.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/Asn1/DistributionPointNameAsn.xml.cs index 2a4d6d5..03164cd 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/Asn1/DistributionPointNameAsn.xml.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/Asn1/DistributionPointNameAsn.xml.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable enable #pragma warning disable SA1028 // ignore whitespace warnings for generated code using System; using System.Collections.Generic; @@ -15,7 +14,7 @@ namespace System.Security.Cryptography.X509Certificates.Asn1 [StructLayout(LayoutKind.Sequential)] internal partial struct DistributionPointNameAsn { - internal System.Security.Cryptography.Asn1.GeneralNameAsn[] FullName; + internal System.Security.Cryptography.Asn1.GeneralNameAsn[]? FullName; internal ReadOnlyMemory? NameRelativeToCRLIssuer; #if DEBUG diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/Asn1/TbsCertificateAsn.xml.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/Asn1/TbsCertificateAsn.xml.cs index cdebe2a..c9ea25a 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/Asn1/TbsCertificateAsn.xml.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/Asn1/TbsCertificateAsn.xml.cs @@ -25,7 +25,7 @@ namespace System.Security.Cryptography.X509Certificates.Asn1 internal System.Security.Cryptography.Asn1.SubjectPublicKeyInfoAsn SubjectPublicKeyInfo; internal ReadOnlyMemory? IssuerUniqueId; internal ReadOnlyMemory? SubjectUniqueId; - internal System.Security.Cryptography.Asn1.X509ExtensionAsn[] Extensions; + internal System.Security.Cryptography.Asn1.X509ExtensionAsn[]? Extensions; #if DEBUG static TbsCertificateAsn() diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/Asn1/TimeAsn.xml.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/Asn1/TimeAsn.xml.cs index e382786..4b2f3ac 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/Asn1/TimeAsn.xml.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/Asn1/TimeAsn.xml.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable enable #pragma warning disable SA1028 // ignore whitespace warnings for generated code using System; using System.Runtime.InteropServices; -- 2.7.4