diff --git a/crypto/src/asn1/Asn1Exception.cs b/crypto/src/asn1/Asn1Exception.cs
index ae89bbcdc8..9a2432aed4 100644
--- a/crypto/src/asn1/Asn1Exception.cs
+++ b/crypto/src/asn1/Asn1Exception.cs
@@ -23,6 +23,12 @@ public Asn1Exception(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected Asn1Exception(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/asn1/Asn1ParsingException.cs b/crypto/src/asn1/Asn1ParsingException.cs
index 2b54ae0a1d..c915b81b20 100644
--- a/crypto/src/asn1/Asn1ParsingException.cs
+++ b/crypto/src/asn1/Asn1ParsingException.cs
@@ -22,6 +22,12 @@ public Asn1ParsingException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected Asn1ParsingException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/bcpg/UnsupportedPacketVersionException.cs b/crypto/src/bcpg/UnsupportedPacketVersionException.cs
index d59404f7a0..94bc0c111d 100644
--- a/crypto/src/bcpg/UnsupportedPacketVersionException.cs
+++ b/crypto/src/bcpg/UnsupportedPacketVersionException.cs
@@ -22,6 +22,12 @@ public UnsupportedPacketVersionException(string message, Exception innerExceptio
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected UnsupportedPacketVersionException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/cmp/CmpException.cs b/crypto/src/cmp/CmpException.cs
index 6d3271a20f..fcea03cd16 100644
--- a/crypto/src/cmp/CmpException.cs
+++ b/crypto/src/cmp/CmpException.cs
@@ -22,7 +22,13 @@ public CmpException(string message, Exception innerException)
{
}
- protected CmpException(SerializationInfo info, StreamingContext context)
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
+ protected CmpException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
diff --git a/crypto/src/cms/CMSAttributeTableGenerationException.cs b/crypto/src/cms/CMSAttributeTableGenerationException.cs
index 977d60e5ce..ee24dba1b2 100644
--- a/crypto/src/cms/CMSAttributeTableGenerationException.cs
+++ b/crypto/src/cms/CMSAttributeTableGenerationException.cs
@@ -22,7 +22,13 @@ public CmsAttributeTableGenerationException(string message, Exception innerExcep
{
}
- protected CmsAttributeTableGenerationException(SerializationInfo info, StreamingContext context)
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
+ protected CmsAttributeTableGenerationException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
diff --git a/crypto/src/cms/CMSException.cs b/crypto/src/cms/CMSException.cs
index eab32f9167..8aae585b42 100644
--- a/crypto/src/cms/CMSException.cs
+++ b/crypto/src/cms/CMSException.cs
@@ -22,6 +22,12 @@ public CmsException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected CmsException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/cms/CMSStreamException.cs b/crypto/src/cms/CMSStreamException.cs
index 42ae409f7b..e5e50f81d0 100644
--- a/crypto/src/cms/CMSStreamException.cs
+++ b/crypto/src/cms/CMSStreamException.cs
@@ -23,6 +23,12 @@ public CmsStreamException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected CmsStreamException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/crmf/CrmfException.cs b/crypto/src/crmf/CrmfException.cs
index 9b15974003..0f3bd539b5 100644
--- a/crypto/src/crmf/CrmfException.cs
+++ b/crypto/src/crmf/CrmfException.cs
@@ -22,6 +22,12 @@ public CrmfException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected CrmfException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/crypto/CryptoException.cs b/crypto/src/crypto/CryptoException.cs
index e40cfbc045..3d521d2f2b 100644
--- a/crypto/src/crypto/CryptoException.cs
+++ b/crypto/src/crypto/CryptoException.cs
@@ -22,6 +22,12 @@ public CryptoException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected CryptoException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/crypto/DataLengthException.cs b/crypto/src/crypto/DataLengthException.cs
index 9096391448..1b53c6a654 100644
--- a/crypto/src/crypto/DataLengthException.cs
+++ b/crypto/src/crypto/DataLengthException.cs
@@ -27,6 +27,12 @@ public DataLengthException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected DataLengthException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/crypto/InvalidCipherTextException.cs b/crypto/src/crypto/InvalidCipherTextException.cs
index 13ac867639..9f3fe2a48d 100644
--- a/crypto/src/crypto/InvalidCipherTextException.cs
+++ b/crypto/src/crypto/InvalidCipherTextException.cs
@@ -23,6 +23,12 @@ public InvalidCipherTextException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected InvalidCipherTextException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/crypto/MaxBytesExceededException.cs b/crypto/src/crypto/MaxBytesExceededException.cs
index b83b16fd42..493f23e240 100644
--- a/crypto/src/crypto/MaxBytesExceededException.cs
+++ b/crypto/src/crypto/MaxBytesExceededException.cs
@@ -25,6 +25,12 @@ public MaxBytesExceededException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected MaxBytesExceededException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/crypto/OutputLengthException.cs b/crypto/src/crypto/OutputLengthException.cs
index c8b2718f28..32d8f41ee0 100644
--- a/crypto/src/crypto/OutputLengthException.cs
+++ b/crypto/src/crypto/OutputLengthException.cs
@@ -22,6 +22,12 @@ public OutputLengthException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected OutputLengthException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/ocsp/OCSPException.cs b/crypto/src/ocsp/OCSPException.cs
index c575660c52..164fa44b97 100644
--- a/crypto/src/ocsp/OCSPException.cs
+++ b/crypto/src/ocsp/OCSPException.cs
@@ -22,6 +22,12 @@ public OcspException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected OcspException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/openpgp/PgpDataValidationException.cs b/crypto/src/openpgp/PgpDataValidationException.cs
index 7718ab26c2..b851d78e63 100644
--- a/crypto/src/openpgp/PgpDataValidationException.cs
+++ b/crypto/src/openpgp/PgpDataValidationException.cs
@@ -23,6 +23,12 @@ public PgpDataValidationException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected PgpDataValidationException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/openpgp/PgpException.cs b/crypto/src/openpgp/PgpException.cs
index cb5ea35697..9efd45fbba 100644
--- a/crypto/src/openpgp/PgpException.cs
+++ b/crypto/src/openpgp/PgpException.cs
@@ -23,6 +23,12 @@ public PgpException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected PgpException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/openpgp/PgpKeyValidationException.cs b/crypto/src/openpgp/PgpKeyValidationException.cs
index 655c0a766b..f525abc21b 100644
--- a/crypto/src/openpgp/PgpKeyValidationException.cs
+++ b/crypto/src/openpgp/PgpKeyValidationException.cs
@@ -23,6 +23,12 @@ public PgpKeyValidationException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected PgpKeyValidationException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/openssl/EncryptionException.cs b/crypto/src/openssl/EncryptionException.cs
index 414f8f68b0..f981e91735 100644
--- a/crypto/src/openssl/EncryptionException.cs
+++ b/crypto/src/openssl/EncryptionException.cs
@@ -23,6 +23,12 @@ public EncryptionException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected EncryptionException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/openssl/PEMException.cs b/crypto/src/openssl/PEMException.cs
index c4314b498e..1150c06db1 100644
--- a/crypto/src/openssl/PEMException.cs
+++ b/crypto/src/openssl/PEMException.cs
@@ -23,6 +23,12 @@ public PemException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected PemException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/openssl/PasswordException.cs b/crypto/src/openssl/PasswordException.cs
index d056bb9b02..d29e77033a 100644
--- a/crypto/src/openssl/PasswordException.cs
+++ b/crypto/src/openssl/PasswordException.cs
@@ -23,6 +23,12 @@ public PasswordException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected PasswordException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/pkcs/PkcsException.cs b/crypto/src/pkcs/PkcsException.cs
index ba296882c6..954cbd9fc3 100644
--- a/crypto/src/pkcs/PkcsException.cs
+++ b/crypto/src/pkcs/PkcsException.cs
@@ -23,6 +23,12 @@ public PkcsException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected PkcsException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/pkcs/PkcsIOException.cs b/crypto/src/pkcs/PkcsIOException.cs
index 4523ac286e..6d774ed4ab 100644
--- a/crypto/src/pkcs/PkcsIOException.cs
+++ b/crypto/src/pkcs/PkcsIOException.cs
@@ -24,6 +24,12 @@ public PkcsIOException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected PkcsIOException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/pkix/PkixCertPathBuilderException.cs b/crypto/src/pkix/PkixCertPathBuilderException.cs
index 81c833459f..3293e831d9 100644
--- a/crypto/src/pkix/PkixCertPathBuilderException.cs
+++ b/crypto/src/pkix/PkixCertPathBuilderException.cs
@@ -24,6 +24,12 @@ public PkixCertPathBuilderException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected PkixCertPathBuilderException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/pkix/PkixCertPathValidatorException.cs b/crypto/src/pkix/PkixCertPathValidatorException.cs
index 6f9812a49e..7835a072f5 100644
--- a/crypto/src/pkix/PkixCertPathValidatorException.cs
+++ b/crypto/src/pkix/PkixCertPathValidatorException.cs
@@ -65,12 +65,21 @@ public PkixCertPathValidatorException(string message, Exception innerException,
m_index = index;
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected PkixCertPathValidatorException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
m_index = info.GetInt32("index");
}
+#if NET8_0_OR_GREATER
+ [Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
+#endif
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
diff --git a/crypto/src/pkix/PkixNameConstraintValidatorException.cs b/crypto/src/pkix/PkixNameConstraintValidatorException.cs
index c67123506c..cf82ce6475 100644
--- a/crypto/src/pkix/PkixNameConstraintValidatorException.cs
+++ b/crypto/src/pkix/PkixNameConstraintValidatorException.cs
@@ -22,6 +22,12 @@ public PkixNameConstraintValidatorException(string message, Exception innerExcep
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected PkixNameConstraintValidatorException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/pqc/crypto/lms/LMSException.cs b/crypto/src/pqc/crypto/lms/LMSException.cs
index c581610d55..4756568a57 100644
--- a/crypto/src/pqc/crypto/lms/LMSException.cs
+++ b/crypto/src/pqc/crypto/lms/LMSException.cs
@@ -23,6 +23,12 @@ public LmsException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected LmsException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/security/DotNetUtilities.cs b/crypto/src/security/DotNetUtilities.cs
index 8ff8e8a1ee..bfdd5f032c 100644
--- a/crypto/src/security/DotNetUtilities.cs
+++ b/crypto/src/security/DotNetUtilities.cs
@@ -16,297 +16,274 @@
using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.X509;
-namespace Org.BouncyCastle.Security
-{
- ///
- /// A class containing methods to interface the BouncyCastle world to the .NET Crypto world.
- ///
- public static class DotNetUtilities
- {
- ///
- /// Create an System.Security.Cryptography.X509Certificate from an X509Certificate Structure.
- ///
- ///
- /// A System.Security.Cryptography.X509Certificate.
- public static SystemX509.X509Certificate ToX509Certificate(X509CertificateStructure x509Struct) =>
- new SystemX509.X509Certificate(x509Struct.GetEncoded(Asn1Encodable.Der));
-
+namespace Org.BouncyCastle.Security {
+ ///
+ /// A class containing methods to interface the BouncyCastle world to the .NET Crypto world.
+ ///
+ public static class DotNetUtilities {
+ ///
+ /// Create an System.Security.Cryptography.X509Certificate from an X509Certificate Structure.
+ ///
+ ///
+ /// A System.Security.Cryptography.X509Certificate.
+
+#if NET9_0_OR_GREATER
+ public static SystemX509.X509Certificate ToX509Certificate( X509CertificateStructure x509Struct ) =>
+ SystemX509.X509CertificateLoader.LoadCertificate( x509Struct.GetEncoded( Asn1Encodable.Der ) );
public static SystemX509.X509Certificate ToX509Certificate(X509Certificate x509Cert) =>
- new SystemX509.X509Certificate(x509Cert.GetEncoded());
+ SystemX509.X509CertificateLoader.LoadCertificate(x509Cert.GetEncoded());
+#else
+ public static SystemX509.X509Certificate ToX509Certificate( X509CertificateStructure x509Struct ) =>
+ new SystemX509.X509Certificate( x509Struct.GetEncoded( Asn1Encodable.Der ) );
+ public static SystemX509.X509Certificate ToX509Certificate( X509Certificate x509Cert ) =>
+ new SystemX509.X509Certificate( x509Cert.GetEncoded() );
+#endif
- public static X509Certificate FromX509Certificate(SystemX509.X509Certificate x509Cert) =>
- new X509Certificate(x509Cert.GetRawCertData());
+ public static X509Certificate FromX509Certificate( SystemX509.X509Certificate x509Cert ) =>
+ new X509Certificate( x509Cert.GetRawCertData() );
- public static AsymmetricCipherKeyPair GetDsaKeyPair(DSA dsa)
- {
- return GetDsaKeyPair(dsa.ExportParameters(true));
- }
+ public static AsymmetricCipherKeyPair GetDsaKeyPair( DSA dsa ) {
+ return GetDsaKeyPair( dsa.ExportParameters( true ) );
+ }
- public static AsymmetricCipherKeyPair GetDsaKeyPair(DSAParameters dp)
- {
- DsaPublicKeyParameters pubKey = GetDsaPublicKey(dp);
+ public static AsymmetricCipherKeyPair GetDsaKeyPair( DSAParameters dp ) {
+ DsaPublicKeyParameters pubKey = GetDsaPublicKey( dp );
- DsaPrivateKeyParameters privKey = new DsaPrivateKeyParameters(
- new BigInteger(1, dp.X),
- pubKey.Parameters);
+ DsaPrivateKeyParameters privKey = new DsaPrivateKeyParameters(
+ new BigInteger( 1, dp.X ),
+ pubKey.Parameters );
- return new AsymmetricCipherKeyPair(pubKey, privKey);
- }
+ return new AsymmetricCipherKeyPair( pubKey, privKey );
+ }
- public static DsaPublicKeyParameters GetDsaPublicKey(DSA dsa)
- {
- return GetDsaPublicKey(dsa.ExportParameters(false));
- }
+ public static DsaPublicKeyParameters GetDsaPublicKey( DSA dsa ) {
+ return GetDsaPublicKey( dsa.ExportParameters( false ) );
+ }
- public static DsaPublicKeyParameters GetDsaPublicKey(DSAParameters dp)
- {
- DsaValidationParameters validationParameters = (dp.Seed != null)
- ? new DsaValidationParameters(dp.Seed, dp.Counter)
- : null;
+ public static DsaPublicKeyParameters GetDsaPublicKey( DSAParameters dp ) {
+ DsaValidationParameters validationParameters = ( dp.Seed != null )
+ ? new DsaValidationParameters( dp.Seed, dp.Counter )
+ : null;
- DsaParameters parameters = new DsaParameters(
- new BigInteger(1, dp.P),
- new BigInteger(1, dp.Q),
- new BigInteger(1, dp.G),
- validationParameters);
+ DsaParameters parameters = new DsaParameters(
+ new BigInteger( 1, dp.P ),
+ new BigInteger( 1, dp.Q ),
+ new BigInteger( 1, dp.G ),
+ validationParameters );
- return new DsaPublicKeyParameters(
- new BigInteger(1, dp.Y),
- parameters);
- }
+ return new DsaPublicKeyParameters(
+ new BigInteger( 1, dp.Y ),
+ parameters );
+ }
#if NETCOREAPP1_0_OR_GREATER || NET47_OR_GREATER || NETSTANDARD1_6_OR_GREATER
- public static AsymmetricCipherKeyPair GetECDsaKeyPair(ECDsa ecDsa)
- {
- return GetECKeyPair("ECDSA", ecDsa.ExportParameters(true));
- }
-
- public static ECPublicKeyParameters GetECDsaPublicKey(ECDsa ecDsa)
- {
- return GetECPublicKey("ECDSA", ecDsa.ExportParameters(false));
- }
-
- public static AsymmetricCipherKeyPair GetECKeyPair(string algorithm, ECParameters ec)
- {
- ECPublicKeyParameters pubKey = GetECPublicKey(algorithm, ec);
-
- ECPrivateKeyParameters privKey = new ECPrivateKeyParameters(
- pubKey.AlgorithmName,
- new BigInteger(1, ec.D),
- pubKey.Parameters);
-
- return new AsymmetricCipherKeyPair(pubKey, privKey);
- }
-
- public static ECPublicKeyParameters GetECPublicKey(string algorithm, ECParameters ec)
- {
- X9ECParameters x9 = GetX9ECParameters(ec.Curve);
- if (x9 == null)
- throw new NotSupportedException("Unrecognized curve");
-
- return new ECPublicKeyParameters(
- algorithm,
- GetECPoint(x9.Curve, ec.Q),
- new ECDomainParameters(x9));
- }
-
- private static Math.EC.ECPoint GetECPoint(Math.EC.ECCurve curve, ECPoint point)
- {
- return curve.CreatePoint(new BigInteger(1, point.X), new BigInteger(1, point.Y));
- }
-
- private static X9ECParameters GetX9ECParameters(ECCurve curve)
- {
- if (!curve.IsNamed)
- throw new NotSupportedException("Only named curves are supported");
-
- Oid oid = curve.Oid;
- if (oid != null)
- {
- string oidValue = oid.Value;
- if (oidValue != null)
- return ECKeyPairGenerator.FindECCurveByOid(new DerObjectIdentifier(oidValue));
- }
- return null;
- }
+ public static AsymmetricCipherKeyPair GetECDsaKeyPair( ECDsa ecDsa ) {
+ return GetECKeyPair( "ECDSA", ecDsa.ExportParameters( true ) );
+ }
+
+ public static ECPublicKeyParameters GetECDsaPublicKey( ECDsa ecDsa ) {
+ return GetECPublicKey( "ECDSA", ecDsa.ExportParameters( false ) );
+ }
+
+ public static AsymmetricCipherKeyPair GetECKeyPair( string algorithm, ECParameters ec ) {
+ ECPublicKeyParameters pubKey = GetECPublicKey( algorithm, ec );
+
+ ECPrivateKeyParameters privKey = new ECPrivateKeyParameters(
+ pubKey.AlgorithmName,
+ new BigInteger( 1, ec.D ),
+ pubKey.Parameters );
+
+ return new AsymmetricCipherKeyPair( pubKey, privKey );
+ }
+
+ public static ECPublicKeyParameters GetECPublicKey( string algorithm, ECParameters ec ) {
+ X9ECParameters x9 = GetX9ECParameters( ec.Curve );
+ if ( x9 == null )
+ throw new NotSupportedException( "Unrecognized curve" );
+
+ return new ECPublicKeyParameters(
+ algorithm,
+ GetECPoint( x9.Curve, ec.Q ),
+ new ECDomainParameters( x9 ) );
+ }
+
+ private static Math.EC.ECPoint GetECPoint( Math.EC.ECCurve curve, ECPoint point ) {
+ return curve.CreatePoint( new BigInteger( 1, point.X ), new BigInteger( 1, point.Y ) );
+ }
+
+ private static X9ECParameters GetX9ECParameters( ECCurve curve ) {
+ if ( !curve.IsNamed )
+ throw new NotSupportedException( "Only named curves are supported" );
+
+ Oid oid = curve.Oid;
+ if ( oid != null ) {
+ string oidValue = oid.Value;
+ if ( oidValue != null )
+ return ECKeyPairGenerator.FindECCurveByOid( new DerObjectIdentifier( oidValue ) );
+ }
+ return null;
+ }
#endif
- public static AsymmetricCipherKeyPair GetRsaKeyPair(RSA rsa)
- {
- return GetRsaKeyPair(rsa.ExportParameters(true));
- }
-
- public static AsymmetricCipherKeyPair GetRsaKeyPair(RSAParameters rp)
- {
- RsaKeyParameters pubKey = GetRsaPublicKey(rp);
-
- RsaPrivateCrtKeyParameters privKey = new RsaPrivateCrtKeyParameters(
- pubKey.Modulus,
- pubKey.Exponent,
- new BigInteger(1, rp.D),
- new BigInteger(1, rp.P),
- new BigInteger(1, rp.Q),
- new BigInteger(1, rp.DP),
- new BigInteger(1, rp.DQ),
- new BigInteger(1, rp.InverseQ));
-
- return new AsymmetricCipherKeyPair(pubKey, privKey);
- }
-
- public static RsaKeyParameters GetRsaPublicKey(RSA rsa)
- {
- return GetRsaPublicKey(rsa.ExportParameters(false));
- }
-
- public static RsaKeyParameters GetRsaPublicKey(
- RSAParameters rp)
- {
- return new RsaKeyParameters(
- false,
- new BigInteger(1, rp.Modulus),
- new BigInteger(1, rp.Exponent));
- }
-
- public static AsymmetricCipherKeyPair GetKeyPair(AsymmetricAlgorithm privateKey)
- {
- if (privateKey is DSA dsa)
- return GetDsaKeyPair(dsa);
+ public static AsymmetricCipherKeyPair GetRsaKeyPair( RSA rsa ) {
+ return GetRsaKeyPair( rsa.ExportParameters( true ) );
+ }
+
+ public static AsymmetricCipherKeyPair GetRsaKeyPair( RSAParameters rp ) {
+ RsaKeyParameters pubKey = GetRsaPublicKey( rp );
+
+ RsaPrivateCrtKeyParameters privKey = new RsaPrivateCrtKeyParameters(
+ pubKey.Modulus,
+ pubKey.Exponent,
+ new BigInteger( 1, rp.D ),
+ new BigInteger( 1, rp.P ),
+ new BigInteger( 1, rp.Q ),
+ new BigInteger( 1, rp.DP ),
+ new BigInteger( 1, rp.DQ ),
+ new BigInteger( 1, rp.InverseQ ) );
+
+ return new AsymmetricCipherKeyPair( pubKey, privKey );
+ }
+
+ public static RsaKeyParameters GetRsaPublicKey( RSA rsa ) {
+ return GetRsaPublicKey( rsa.ExportParameters( false ) );
+ }
+
+ public static RsaKeyParameters GetRsaPublicKey(
+ RSAParameters rp ) {
+ return new RsaKeyParameters(
+ false,
+ new BigInteger( 1, rp.Modulus ),
+ new BigInteger( 1, rp.Exponent ) );
+ }
+
+ public static AsymmetricCipherKeyPair GetKeyPair( AsymmetricAlgorithm privateKey ) {
+ if ( privateKey is DSA dsa )
+ return GetDsaKeyPair( dsa );
#if NETCOREAPP1_0_OR_GREATER || NET47_OR_GREATER || NETSTANDARD1_6_OR_GREATER
- if (privateKey is ECDsa ecDsa)
- return GetECDsaKeyPair(ecDsa);
+ if ( privateKey is ECDsa ecDsa )
+ return GetECDsaKeyPair( ecDsa );
#endif
- if (privateKey is RSA rsa)
- return GetRsaKeyPair(rsa);
+ if ( privateKey is RSA rsa )
+ return GetRsaKeyPair( rsa );
- throw new ArgumentException("Unsupported algorithm specified", nameof(privateKey));
- }
+ throw new ArgumentException( "Unsupported algorithm specified", nameof( privateKey ) );
+ }
#if NET5_0_OR_GREATER
- [SupportedOSPlatform("windows")]
+ [SupportedOSPlatform( "windows" )]
#endif
- public static RSA ToRSA(RsaKeyParameters rsaKey)
- {
- // TODO This appears to not work for private keys (when no CRT info)
- return CreateRSAProvider(ToRSAParameters(rsaKey));
- }
+ public static RSA ToRSA( RsaKeyParameters rsaKey ) {
+ // TODO This appears to not work for private keys (when no CRT info)
+ return CreateRSAProvider( ToRSAParameters( rsaKey ) );
+ }
#if NET5_0_OR_GREATER
- [SupportedOSPlatform("windows")]
+ [SupportedOSPlatform( "windows" )]
#endif
- public static RSA ToRSA(RsaKeyParameters rsaKey, CspParameters csp)
- {
- // TODO This appears to not work for private keys (when no CRT info)
- return CreateRSAProvider(ToRSAParameters(rsaKey), csp);
- }
+ public static RSA ToRSA( RsaKeyParameters rsaKey, CspParameters csp ) {
+ // TODO This appears to not work for private keys (when no CRT info)
+ return CreateRSAProvider( ToRSAParameters( rsaKey ), csp );
+ }
#if NET5_0_OR_GREATER
- [SupportedOSPlatform("windows")]
+ [SupportedOSPlatform( "windows" )]
#endif
- public static RSA ToRSA(RsaPrivateCrtKeyParameters privKey)
- {
- return CreateRSAProvider(ToRSAParameters(privKey));
- }
+ public static RSA ToRSA( RsaPrivateCrtKeyParameters privKey ) {
+ return CreateRSAProvider( ToRSAParameters( privKey ) );
+ }
#if NET5_0_OR_GREATER
- [SupportedOSPlatform("windows")]
+ [SupportedOSPlatform( "windows" )]
#endif
- public static RSA ToRSA(RsaPrivateCrtKeyParameters privKey, CspParameters csp)
- {
- return CreateRSAProvider(ToRSAParameters(privKey), csp);
- }
+ public static RSA ToRSA( RsaPrivateCrtKeyParameters privKey, CspParameters csp ) {
+ return CreateRSAProvider( ToRSAParameters( privKey ), csp );
+ }
#if NET5_0_OR_GREATER
- [SupportedOSPlatform("windows")]
+ [SupportedOSPlatform( "windows" )]
#endif
- public static RSA ToRSA(RsaPrivateKeyStructure privKey)
- {
- return CreateRSAProvider(ToRSAParameters(privKey));
- }
+ public static RSA ToRSA( RsaPrivateKeyStructure privKey ) {
+ return CreateRSAProvider( ToRSAParameters( privKey ) );
+ }
#if NET5_0_OR_GREATER
- [SupportedOSPlatform("windows")]
+ [SupportedOSPlatform( "windows" )]
#endif
- public static RSA ToRSA(RsaPrivateKeyStructure privKey, CspParameters csp)
- {
- return CreateRSAProvider(ToRSAParameters(privKey), csp);
- }
-
- public static RSAParameters ToRSAParameters(RsaKeyParameters rsaKey)
- {
- RSAParameters rp = new RSAParameters();
- rp.Modulus = rsaKey.Modulus.ToByteArrayUnsigned();
- if (rsaKey.IsPrivate)
- rp.D = ConvertRSAParametersField(rsaKey.Exponent, rp.Modulus.Length);
- else
- rp.Exponent = rsaKey.Exponent.ToByteArrayUnsigned();
- return rp;
- }
-
- public static RSAParameters ToRSAParameters(RsaPrivateCrtKeyParameters privKey)
- {
- RSAParameters rp = new RSAParameters();
- rp.Modulus = privKey.Modulus.ToByteArrayUnsigned();
- rp.Exponent = privKey.PublicExponent.ToByteArrayUnsigned();
- rp.P = privKey.P.ToByteArrayUnsigned();
- rp.Q = privKey.Q.ToByteArrayUnsigned();
- rp.D = ConvertRSAParametersField(privKey.Exponent, rp.Modulus.Length);
- rp.DP = ConvertRSAParametersField(privKey.DP, rp.P.Length);
- rp.DQ = ConvertRSAParametersField(privKey.DQ, rp.Q.Length);
- rp.InverseQ = ConvertRSAParametersField(privKey.QInv, rp.Q.Length);
- return rp;
- }
-
- public static RSAParameters ToRSAParameters(RsaPrivateKeyStructure privKey)
- {
- RSAParameters rp = new RSAParameters();
- rp.Modulus = privKey.Modulus.ToByteArrayUnsigned();
- rp.Exponent = privKey.PublicExponent.ToByteArrayUnsigned();
- rp.P = privKey.Prime1.ToByteArrayUnsigned();
- rp.Q = privKey.Prime2.ToByteArrayUnsigned();
- rp.D = ConvertRSAParametersField(privKey.PrivateExponent, rp.Modulus.Length);
- rp.DP = ConvertRSAParametersField(privKey.Exponent1, rp.P.Length);
- rp.DQ = ConvertRSAParametersField(privKey.Exponent2, rp.Q.Length);
- rp.InverseQ = ConvertRSAParametersField(privKey.Coefficient, rp.Q.Length);
- return rp;
- }
-
- private static byte[] ConvertRSAParametersField(BigInteger n, int size)
- {
- return BigIntegers.AsUnsignedByteArray(size, n);
- }
-
- // TODO Why do we use CspParameters instead of just RSA.Create in methods below?
-// private static RSA CreateRSA(RSAParameters rp)
-// {
-//#if NETCOREAPP2_0_OR_GREATER || NET472_OR_GREATER || NETSTANDARD2_1_OR_GREATER
-// return RSA.Create(rp);
-//#else
-// var rsa = RSA.Create();
-// rsa.ImportParameters(rp);
-// return rsa;
-//#endif
-// }
+ public static RSA ToRSA( RsaPrivateKeyStructure privKey, CspParameters csp ) {
+ return CreateRSAProvider( ToRSAParameters( privKey ), csp );
+ }
+
+ public static RSAParameters ToRSAParameters( RsaKeyParameters rsaKey ) {
+ RSAParameters rp = new RSAParameters();
+ rp.Modulus = rsaKey.Modulus.ToByteArrayUnsigned();
+ if ( rsaKey.IsPrivate )
+ rp.D = ConvertRSAParametersField( rsaKey.Exponent, rp.Modulus.Length );
+ else
+ rp.Exponent = rsaKey.Exponent.ToByteArrayUnsigned();
+ return rp;
+ }
+
+ public static RSAParameters ToRSAParameters( RsaPrivateCrtKeyParameters privKey ) {
+ RSAParameters rp = new RSAParameters();
+ rp.Modulus = privKey.Modulus.ToByteArrayUnsigned();
+ rp.Exponent = privKey.PublicExponent.ToByteArrayUnsigned();
+ rp.P = privKey.P.ToByteArrayUnsigned();
+ rp.Q = privKey.Q.ToByteArrayUnsigned();
+ rp.D = ConvertRSAParametersField( privKey.Exponent, rp.Modulus.Length );
+ rp.DP = ConvertRSAParametersField( privKey.DP, rp.P.Length );
+ rp.DQ = ConvertRSAParametersField( privKey.DQ, rp.Q.Length );
+ rp.InverseQ = ConvertRSAParametersField( privKey.QInv, rp.Q.Length );
+ return rp;
+ }
+
+ public static RSAParameters ToRSAParameters( RsaPrivateKeyStructure privKey ) {
+ RSAParameters rp = new RSAParameters();
+ rp.Modulus = privKey.Modulus.ToByteArrayUnsigned();
+ rp.Exponent = privKey.PublicExponent.ToByteArrayUnsigned();
+ rp.P = privKey.Prime1.ToByteArrayUnsigned();
+ rp.Q = privKey.Prime2.ToByteArrayUnsigned();
+ rp.D = ConvertRSAParametersField( privKey.PrivateExponent, rp.Modulus.Length );
+ rp.DP = ConvertRSAParametersField( privKey.Exponent1, rp.P.Length );
+ rp.DQ = ConvertRSAParametersField( privKey.Exponent2, rp.Q.Length );
+ rp.InverseQ = ConvertRSAParametersField( privKey.Coefficient, rp.Q.Length );
+ return rp;
+ }
+
+ private static byte[] ConvertRSAParametersField( BigInteger n, int size ) {
+ return BigIntegers.AsUnsignedByteArray( size, n );
+ }
+
+ // TODO Why do we use CspParameters instead of just RSA.Create in methods below?
+ // private static RSA CreateRSA(RSAParameters rp)
+ // {
+ //#if NETCOREAPP2_0_OR_GREATER || NET472_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+ // return RSA.Create(rp);
+ //#else
+ // var rsa = RSA.Create();
+ // rsa.ImportParameters(rp);
+ // return rsa;
+ //#endif
+ // }
#if NET5_0_OR_GREATER
- [SupportedOSPlatform("windows")]
+ [SupportedOSPlatform( "windows" )]
#endif
- private static RSACryptoServiceProvider CreateRSAProvider(RSAParameters rp)
- {
- CspParameters csp = new CspParameters();
- csp.KeyContainerName = string.Format("BouncyCastle-{0}", Guid.NewGuid());
- return CreateRSAProvider(rp, csp);
- }
+ private static RSACryptoServiceProvider CreateRSAProvider( RSAParameters rp ) {
+ CspParameters csp = new CspParameters();
+ csp.KeyContainerName = string.Format( "BouncyCastle-{0}", Guid.NewGuid() );
+ return CreateRSAProvider( rp, csp );
+ }
#if NET5_0_OR_GREATER
- [SupportedOSPlatform("windows")]
+ [SupportedOSPlatform( "windows" )]
#endif
- private static RSACryptoServiceProvider CreateRSAProvider(RSAParameters rp, CspParameters csp)
- {
- RSACryptoServiceProvider rsaCsp = new RSACryptoServiceProvider(csp);
- rsaCsp.ImportParameters(rp);
- return rsaCsp;
- }
- }
+ private static RSACryptoServiceProvider CreateRSAProvider( RSAParameters rp, CspParameters csp ) {
+ RSACryptoServiceProvider rsaCsp = new RSACryptoServiceProvider( csp );
+ rsaCsp.ImportParameters( rp );
+ return rsaCsp;
+ }
+ }
}
diff --git a/crypto/src/security/GeneralSecurityException.cs b/crypto/src/security/GeneralSecurityException.cs
index 02b1f6c579..402da9e613 100644
--- a/crypto/src/security/GeneralSecurityException.cs
+++ b/crypto/src/security/GeneralSecurityException.cs
@@ -22,6 +22,12 @@ public GeneralSecurityException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected GeneralSecurityException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/security/InvalidKeyException.cs b/crypto/src/security/InvalidKeyException.cs
index 73a59fbb8c..79ff2c68f2 100644
--- a/crypto/src/security/InvalidKeyException.cs
+++ b/crypto/src/security/InvalidKeyException.cs
@@ -22,6 +22,12 @@ public InvalidKeyException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected InvalidKeyException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/security/InvalidParameterException.cs b/crypto/src/security/InvalidParameterException.cs
index fb27a36884..dcb58ae795 100644
--- a/crypto/src/security/InvalidParameterException.cs
+++ b/crypto/src/security/InvalidParameterException.cs
@@ -22,6 +22,12 @@ public InvalidParameterException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected InvalidParameterException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/security/KeyException.cs b/crypto/src/security/KeyException.cs
index 1ad1b0c496..1ea525f040 100644
--- a/crypto/src/security/KeyException.cs
+++ b/crypto/src/security/KeyException.cs
@@ -22,6 +22,12 @@ public KeyException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected KeyException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/security/SecurityUtilityException.cs b/crypto/src/security/SecurityUtilityException.cs
index f10a7fbc5a..cd01d73b91 100644
--- a/crypto/src/security/SecurityUtilityException.cs
+++ b/crypto/src/security/SecurityUtilityException.cs
@@ -22,6 +22,12 @@ public SecurityUtilityException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected SecurityUtilityException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/security/SignatureException.cs b/crypto/src/security/SignatureException.cs
index 4bddc3d51a..05bf4fc9a5 100644
--- a/crypto/src/security/SignatureException.cs
+++ b/crypto/src/security/SignatureException.cs
@@ -22,6 +22,12 @@ public SignatureException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected SignatureException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/security/cert/CertificateEncodingException.cs b/crypto/src/security/cert/CertificateEncodingException.cs
index 5c902dfd11..fb16706256 100644
--- a/crypto/src/security/cert/CertificateEncodingException.cs
+++ b/crypto/src/security/cert/CertificateEncodingException.cs
@@ -22,6 +22,12 @@ public CertificateEncodingException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected CertificateEncodingException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/security/cert/CertificateException.cs b/crypto/src/security/cert/CertificateException.cs
index 5214675ab1..b5eb0e84b7 100644
--- a/crypto/src/security/cert/CertificateException.cs
+++ b/crypto/src/security/cert/CertificateException.cs
@@ -22,6 +22,12 @@ public CertificateException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected CertificateException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/security/cert/CertificateExpiredException.cs b/crypto/src/security/cert/CertificateExpiredException.cs
index 25cb054bf2..cc1172c46d 100644
--- a/crypto/src/security/cert/CertificateExpiredException.cs
+++ b/crypto/src/security/cert/CertificateExpiredException.cs
@@ -22,6 +22,12 @@ public CertificateExpiredException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected CertificateExpiredException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/security/cert/CertificateNotYetValidException.cs b/crypto/src/security/cert/CertificateNotYetValidException.cs
index 1ea3d0b971..d03021c22f 100644
--- a/crypto/src/security/cert/CertificateNotYetValidException.cs
+++ b/crypto/src/security/cert/CertificateNotYetValidException.cs
@@ -22,6 +22,12 @@ public CertificateNotYetValidException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected CertificateNotYetValidException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/security/cert/CertificateParsingException.cs b/crypto/src/security/cert/CertificateParsingException.cs
index 244f3b614f..5af960b627 100644
--- a/crypto/src/security/cert/CertificateParsingException.cs
+++ b/crypto/src/security/cert/CertificateParsingException.cs
@@ -22,6 +22,12 @@ public CertificateParsingException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected CertificateParsingException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/security/cert/CrlException.cs b/crypto/src/security/cert/CrlException.cs
index 9475f74de6..5b69b97ca9 100644
--- a/crypto/src/security/cert/CrlException.cs
+++ b/crypto/src/security/cert/CrlException.cs
@@ -22,6 +22,12 @@ public CrlException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected CrlException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/tls/TlsException.cs b/crypto/src/tls/TlsException.cs
index 9c6d74bf45..eedf4f8696 100644
--- a/crypto/src/tls/TlsException.cs
+++ b/crypto/src/tls/TlsException.cs
@@ -23,6 +23,12 @@ public TlsException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected TlsException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/tls/TlsFatalAlert.cs b/crypto/src/tls/TlsFatalAlert.cs
index feca848204..25858618e1 100644
--- a/crypto/src/tls/TlsFatalAlert.cs
+++ b/crypto/src/tls/TlsFatalAlert.cs
@@ -43,13 +43,22 @@ public TlsFatalAlert(short alertDescription, string detailMessage, Exception ale
m_alertDescription = (byte)alertDescription;
}
- protected TlsFatalAlert(SerializationInfo info, StreamingContext context)
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
+ protected TlsFatalAlert(SerializationInfo info, StreamingContext context)
: base(info, context)
{
m_alertDescription = info.GetByte("alertDescription");
}
- public override void GetObjectData(SerializationInfo info, StreamingContext context)
+#if NET8_0_OR_GREATER
+ [Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
+#endif
+ public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue("alertDescription", m_alertDescription);
diff --git a/crypto/src/tls/TlsFatalAlertReceived.cs b/crypto/src/tls/TlsFatalAlertReceived.cs
index 4e1a624812..03c92c9234 100644
--- a/crypto/src/tls/TlsFatalAlertReceived.cs
+++ b/crypto/src/tls/TlsFatalAlertReceived.cs
@@ -18,13 +18,22 @@ public TlsFatalAlertReceived(short alertDescription)
m_alertDescription = (byte)alertDescription;
}
- protected TlsFatalAlertReceived(SerializationInfo info, StreamingContext context)
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
+ protected TlsFatalAlertReceived(SerializationInfo info, StreamingContext context)
: base(info, context)
{
m_alertDescription = info.GetByte("alertDescription");
}
- public override void GetObjectData(SerializationInfo info, StreamingContext context)
+#if NET8_0_OR_GREATER
+ [Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
+#endif
+ public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue("alertDescription", m_alertDescription);
diff --git a/crypto/src/tls/TlsNoCloseNotifyException.cs b/crypto/src/tls/TlsNoCloseNotifyException.cs
index b0314a4066..5bb4af12f6 100644
--- a/crypto/src/tls/TlsNoCloseNotifyException.cs
+++ b/crypto/src/tls/TlsNoCloseNotifyException.cs
@@ -20,6 +20,12 @@ public TlsNoCloseNotifyException()
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected TlsNoCloseNotifyException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/tls/TlsTimeoutException.cs b/crypto/src/tls/TlsTimeoutException.cs
index 669352f54d..258a26d20c 100644
--- a/crypto/src/tls/TlsTimeoutException.cs
+++ b/crypto/src/tls/TlsTimeoutException.cs
@@ -23,6 +23,12 @@ public TlsTimeoutException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected TlsTimeoutException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/tls/crypto/TlsCryptoException.cs b/crypto/src/tls/crypto/TlsCryptoException.cs
index 9498ddf3ab..d64a4d3cc2 100644
--- a/crypto/src/tls/crypto/TlsCryptoException.cs
+++ b/crypto/src/tls/crypto/TlsCryptoException.cs
@@ -23,6 +23,12 @@ public TlsCryptoException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected TlsCryptoException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/tsp/TSPException.cs b/crypto/src/tsp/TSPException.cs
index 2fe7fdc904..c984ac56ae 100644
--- a/crypto/src/tsp/TSPException.cs
+++ b/crypto/src/tsp/TSPException.cs
@@ -22,6 +22,12 @@ public TspException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected TspException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/tsp/TSPValidationException.cs b/crypto/src/tsp/TSPValidationException.cs
index ca693fa38f..62c67710c2 100644
--- a/crypto/src/tsp/TSPValidationException.cs
+++ b/crypto/src/tsp/TSPValidationException.cs
@@ -26,12 +26,21 @@ public TspValidationException(string message, int failureCode)
m_failureCode = failureCode;
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected TspValidationException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
m_failureCode = info.GetInt32("failureCode");
}
+#if NET8_0_OR_GREATER
+ [Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
+#endif
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
diff --git a/crypto/src/util/MemoableResetException.cs b/crypto/src/util/MemoableResetException.cs
index 8a4deb142c..e537bac05a 100644
--- a/crypto/src/util/MemoableResetException.cs
+++ b/crypto/src/util/MemoableResetException.cs
@@ -29,6 +29,12 @@ public MemoableResetException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected MemoableResetException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/util/io/StreamOverflowException.cs b/crypto/src/util/io/StreamOverflowException.cs
index a36919780a..dd0be85beb 100644
--- a/crypto/src/util/io/StreamOverflowException.cs
+++ b/crypto/src/util/io/StreamOverflowException.cs
@@ -23,6 +23,12 @@ public StreamOverflowException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected StreamOverflowException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
diff --git a/crypto/src/util/io/pem/PemGenerationException.cs b/crypto/src/util/io/pem/PemGenerationException.cs
index b7f30672ea..01a94fc788 100644
--- a/crypto/src/util/io/pem/PemGenerationException.cs
+++ b/crypto/src/util/io/pem/PemGenerationException.cs
@@ -22,6 +22,12 @@ public PemGenerationException(string message, Exception innerException)
{
}
+#if NET8_0_OR_GREATER
+ [System.Obsolete(
+ "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.",
+ DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}"
+ )]
+#endif
protected PemGenerationException(SerializationInfo info, StreamingContext context)
: base(info, context)
{