// See bouncycastle.txt for license.
//
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
using System;
using System.Collections;
using System.IO;
static private int recommendedIterationCount = 2000;
- private int _version;
+ //private int _version;
private byte[] _password;
private ArrayList _keyBags;
private X509CertificateCollection _certs;
_safeBags = new ArrayList ();
}
- public PKCS12 (byte[] data) : this (data, null) {}
+ public PKCS12 (byte[] data)
+ : this ()
+ {
+ Password = null;
+ Decode (data);
+ }
/*
* PFX ::= SEQUENCE {
* bagAttributes SET OF PKCS12Attribute OPTIONAL
* }
*/
- public PKCS12 (byte[] data, string password) : this ()
+ public PKCS12 (byte[] data, string password)
+ : this ()
{
Password = password;
-
+ Decode (data);
+ }
+#if NET_2_0
+ public PKCS12 (byte[] data, byte[] password)
+ : this ()
+ {
+ _password = password;
+ Decode (data);
+ }
+#endif
+ private void Decode (byte[] data)
+ {
ASN1 pfx = new ASN1 (data);
if (pfx.Tag != 0x30)
throw new ArgumentException ("invalid data");
ASN1 version = pfx [0];
if (version.Tag != 0x02)
throw new ArgumentException ("invalid PFX version");
- _version = version.Value [0];
+ //_version = version.Value [0];
PKCS7.ContentInfo authSafe = new PKCS7.ContentInfo (pfx [1]);
if (authSafe.ContentType != PKCS7.Oid.data)