diff options
-rw-r--r-- | crypto/src/asn1/pkcs/AuthenticatedSafe.cs | 4 | ||||
-rw-r--r-- | crypto/src/asn1/pkcs/CertBag.cs | 4 | ||||
-rw-r--r-- | crypto/src/asn1/pkcs/Pfx.cs | 4 | ||||
-rw-r--r-- | crypto/src/asn1/pkcs/SafeBag.cs | 4 | ||||
-rw-r--r-- | crypto/src/pkcs/Pkcs12Store.cs | 9 | ||||
-rw-r--r-- | crypto/src/pkcs/Pkcs12Utilities.cs | 4 | ||||
-rw-r--r-- | crypto/test/src/pkcs/test/PKCS12StoreTest.cs | 11 |
7 files changed, 12 insertions, 28 deletions
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; diff --git a/crypto/test/src/pkcs/test/PKCS12StoreTest.cs b/crypto/test/src/pkcs/test/PKCS12StoreTest.cs index fbceffe58..1b49a5d02 100644 --- a/crypto/test/src/pkcs/test/PKCS12StoreTest.cs +++ b/crypto/test/src/pkcs/test/PKCS12StoreTest.cs @@ -1343,23 +1343,18 @@ namespace Org.BouncyCastle.Pkcs.Tests // // check algorithm types. // - Asn1InputStream aIn = new Asn1InputStream(bOut.ToArray()); - - Pfx pfx = new Pfx((Asn1Sequence)aIn.ReadObject()); + Pfx pfx = Pfx.GetInstance(bOut.ToArray()); ContentInfo cInfo = pfx.AuthSafe; Asn1OctetString auth = (Asn1OctetString)cInfo.Content; - aIn = new Asn1InputStream(auth.GetOctets()); - Asn1Sequence s1 = (Asn1Sequence)aIn.ReadObject(); + Asn1Sequence s1 = Asn1Sequence.GetInstance(auth.GetOctets()); ContentInfo c1 = ContentInfo.GetInstance(s1[0]); ContentInfo c2 = ContentInfo.GetInstance(s1[1]); - aIn = new Asn1InputStream(((Asn1OctetString)c1.Content).GetOctets()); - - SafeBag sb = new SafeBag((Asn1Sequence)(((Asn1Sequence)aIn.ReadObject())[0])); + SafeBag sb = SafeBag.GetInstance(Asn1Sequence.GetInstance(((Asn1OctetString)c1.Content).GetOctets())[0]); EncryptedPrivateKeyInfo encInfo = EncryptedPrivateKeyInfo.GetInstance(sb.BagValue); |