From c1c9c9ad03d363522a0e2ed9b3fead4016f6a01b Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 14 Oct 2021 16:29:46 +0700 Subject: Some Obsolete cleanup --- crypto/src/asn1/pkcs/AuthenticatedSafe.cs | 4 +--- crypto/src/asn1/pkcs/CertBag.cs | 4 +--- crypto/src/asn1/pkcs/Pfx.cs | 4 +--- crypto/src/asn1/pkcs/SafeBag.cs | 4 +--- crypto/src/pkcs/Pkcs12Store.cs | 9 +++------ crypto/src/pkcs/Pkcs12Utilities.cs | 4 ++-- 6 files changed, 9 insertions(+), 20 deletions(-) (limited to 'crypto/src') diff --git a/crypto/src/asn1/pkcs/AuthenticatedSafe.cs b/crypto/src/asn1/pkcs/AuthenticatedSafe.cs index 6a112d9df..6f3b4c8c3 100644 --- a/crypto/src/asn1/pkcs/AuthenticatedSafe.cs +++ b/crypto/src/asn1/pkcs/AuthenticatedSafe.cs @@ -24,9 +24,7 @@ namespace Org.BouncyCastle.Asn1.Pkcs private readonly ContentInfo[] info; private readonly bool isBer; - [Obsolete("Use 'GetInstance' instead")] - public AuthenticatedSafe( - Asn1Sequence seq) + private AuthenticatedSafe(Asn1Sequence seq) { info = new ContentInfo[seq.Count]; diff --git a/crypto/src/asn1/pkcs/CertBag.cs b/crypto/src/asn1/pkcs/CertBag.cs index 61165c087..ddaa353fb 100644 --- a/crypto/src/asn1/pkcs/CertBag.cs +++ b/crypto/src/asn1/pkcs/CertBag.cs @@ -17,9 +17,7 @@ namespace Org.BouncyCastle.Asn1.Pkcs private readonly DerObjectIdentifier certID; private readonly Asn1Object certValue; - [Obsolete("Use 'GetInstance' instead")] - public CertBag( - Asn1Sequence seq) + private CertBag(Asn1Sequence seq) { if (seq.Count != 2) throw new ArgumentException("Wrong number of elements in sequence", "seq"); diff --git a/crypto/src/asn1/pkcs/Pfx.cs b/crypto/src/asn1/pkcs/Pfx.cs index e73701342..c1399e560 100644 --- a/crypto/src/asn1/pkcs/Pfx.cs +++ b/crypto/src/asn1/pkcs/Pfx.cs @@ -23,9 +23,7 @@ namespace Org.BouncyCastle.Asn1.Pkcs private readonly ContentInfo contentInfo; private readonly MacData macData; - [Obsolete("Use 'GetInstance' instead")] - public Pfx( - Asn1Sequence seq) + private Pfx(Asn1Sequence seq) { DerInteger version = DerInteger.GetInstance(seq[0]); if (!version.HasValue(3)) diff --git a/crypto/src/asn1/pkcs/SafeBag.cs b/crypto/src/asn1/pkcs/SafeBag.cs index 7951d4892..0ec9fa4ad 100644 --- a/crypto/src/asn1/pkcs/SafeBag.cs +++ b/crypto/src/asn1/pkcs/SafeBag.cs @@ -39,9 +39,7 @@ namespace Org.BouncyCastle.Asn1.Pkcs this.bagAttributes = bagAttributes; } - [Obsolete("Use 'GetInstance' instead")] - public SafeBag( - Asn1Sequence seq) + private SafeBag(Asn1Sequence seq) { this.bagID = (DerObjectIdentifier)seq[0]; this.bagValue = ((DerTaggedObject)seq[1]).GetObject(); diff --git a/crypto/src/pkcs/Pkcs12Store.cs b/crypto/src/pkcs/Pkcs12Store.cs index 2d7de67e6..832367e6b 100644 --- a/crypto/src/pkcs/Pkcs12Store.cs +++ b/crypto/src/pkcs/Pkcs12Store.cs @@ -304,7 +304,7 @@ namespace Org.BouncyCastle.Pkcs foreach (Asn1Sequence subSeq in seq) { - SafeBag b = new SafeBag(subSeq); + SafeBag b = SafeBag.GetInstance(subSeq); if (b.BagID.Equals(PkcsObjectIdentifiers.CertBag)) { @@ -334,7 +334,7 @@ namespace Org.BouncyCastle.Pkcs foreach (SafeBag b in certBags) { - CertBag certBag = new CertBag((Asn1Sequence)b.BagValue); + CertBag certBag = CertBag.GetInstance(b.BagValue); byte[] octets = ((Asn1OctetString)certBag.CertValue).GetOctets(); X509Certificate cert = new X509CertificateParser().ReadCertificate(octets); @@ -1030,10 +1030,7 @@ namespace Org.BouncyCastle.Pkcs // Pfx pfx = new Pfx(mainInfo, macData); - Asn1OutputStream derOut = Asn1OutputStream.Create(stream, - useDerEncoding ? Asn1Encodable.Der : Asn1Encodable.Ber); - - derOut.WriteObject(pfx); + pfx.EncodeTo(stream, useDerEncoding ? Asn1Encodable.Der : Asn1Encodable.Ber); } internal static byte[] CalculatePbeMac( diff --git a/crypto/src/pkcs/Pkcs12Utilities.cs b/crypto/src/pkcs/Pkcs12Utilities.cs index 923eca5a5..2fbb82de5 100644 --- a/crypto/src/pkcs/Pkcs12Utilities.cs +++ b/crypto/src/pkcs/Pkcs12Utilities.cs @@ -22,7 +22,7 @@ namespace Org.BouncyCastle.Pkcs public static byte[] ConvertToDefiniteLength( byte[] berPkcs12File) { - Pfx pfx = new Pfx(Asn1Sequence.GetInstance(Asn1Object.FromByteArray(berPkcs12File))); + Pfx pfx = Pfx.GetInstance(berPkcs12File); return pfx.GetEncoded(Asn1Encodable.Der); } @@ -40,7 +40,7 @@ namespace Org.BouncyCastle.Pkcs byte[] berPkcs12File, char[] passwd) { - Pfx pfx = new Pfx(Asn1Sequence.GetInstance(Asn1Object.FromByteArray(berPkcs12File))); + Pfx pfx = Pfx.GetInstance(berPkcs12File); ContentInfo info = pfx.AuthSafe; -- cgit 1.5.1