[pgsqlclient-checkins] pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.X509 PKCS12.cs,1.4,1
Status: Inactive
Brought to you by:
carlosga_fb
From: Carlos G. Á. <car...@us...> - 2005-04-04 21:11:35
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.X509 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1823/Mono.Security.X509 Modified Files: PKCS12.cs X501Name.cs X509Certificate.cs X509CertificateBuilder.cs X509Chain.cs X509Extension.cs X509Store.cs X520Attributes.cs Log Message: Update with the same sources existente in the Mono SVN Index: X509Extension.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.X509/X509Extension.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** X509Extension.cs 20 Jul 2004 17:45:50 -0000 1.3 --- X509Extension.cs 4 Apr 2005 21:10:53 -0000 1.4 *************** *** 6,12 **** // // (C) 2003 Motus Technologies Inc. (http://www.motus.com) ! // (C) 2004 Novell (http://www.novell.com) ! // ! // // Permission is hereby granted, free of charge, to any person obtaining --- 6,10 ---- // // (C) 2003 Motus Technologies Inc. (http://www.motus.com) ! // Copyright (C) 2004 Novell, Inc (http://www.novell.com) // // Permission is hereby granted, free of charge, to any person obtaining *************** *** 160,164 **** byte[] value = extnValue.Value; int p = pos; - StringBuilder preview = new StringBuilder (); for (int j=0; j < 8; j++) { if (j < n) { --- 158,161 ---- Index: X509Certificate.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.X509/X509Certificate.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** X509Certificate.cs 20 Jul 2004 17:45:50 -0000 1.5 --- X509Certificate.cs 4 Apr 2005 21:10:53 -0000 1.6 *************** *** 6,12 **** // // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) ! // (C) 2004 Novell (http://www.novell.com) ! // ! // // Permission is hereby granted, free of charge, to any person obtaining --- 6,10 ---- // // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) ! // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com) // // Permission is hereby granted, free of charge, to any person obtaining *************** *** 89,94 **** private byte[] serialnumber; ! private byte[] issuerUniqueID; ! private byte[] subjectUniqueID; private X509ExtensionCollection extensions; --- 87,92 ---- private byte[] serialnumber; ! // private byte[] issuerUniqueID; ! // private byte[] subjectUniqueID; private X509ExtensionCollection extensions; *************** *** 126,130 **** // Certificate / TBSCertificate / AlgorithmIdentifier ! ASN1 signatureAlgo = tbsCertificate.Element (tbs++, 0x30); ASN1 issuer = tbsCertificate.Element (tbs++, 0x30); --- 124,129 ---- // Certificate / TBSCertificate / AlgorithmIdentifier ! tbs++; ! // ASN1 signatureAlgo = tbsCertificate.Element (tbs++, 0x30); ASN1 issuer = tbsCertificate.Element (tbs++, 0x30); *************** *** 176,180 **** if (issuerUID != null) { tbs++; ! issuerUniqueID = issuerUID.Value; } --- 175,179 ---- if (issuerUID != null) { tbs++; ! // issuerUniqueID = issuerUID.Value; } *************** *** 183,187 **** if (subjectUID != null) { tbs++; ! subjectUniqueID = subjectUID.Value; } --- 182,186 ---- if (subjectUID != null) { tbs++; ! // subjectUniqueID = subjectUID.Value; } *************** *** 263,267 **** --- 262,270 ---- case "1.2.840.113549.1.1.2": // MD2 with RSA encryption // maybe someone installed MD2 ? + #if INSIDE_CORLIB hash = HashAlgorithm.Create ("MD2"); + #else + hash = Mono.Security.Cryptography.MD2.Create (); + #endif break; case "1.2.840.113549.1.1.4": // MD5 with RSA encryption *************** *** 336,340 **** public virtual byte[] RawData { ! get { return (byte[]) m_encodedcert.Clone (); } } --- 339,347 ---- public virtual byte[] RawData { ! get { ! if (m_encodedcert == null) ! return null; ! return (byte[]) m_encodedcert.Clone (); ! } } Index: X509Chain.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.X509/X509Chain.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** X509Chain.cs 20 Jul 2004 17:45:50 -0000 1.5 --- X509Chain.cs 4 Apr 2005 21:10:53 -0000 1.6 *************** *** 10,16 **** // // (C) 2003 Motus Technologies Inc. (http://www.motus.com) ! // (C) 2004 Novell (http://www.novell.com) ! // ! // // Permission is hereby granted, free of charge, to any person obtaining --- 10,14 ---- // // (C) 2003 Motus Technologies Inc. (http://www.motus.com) ! // Copyright (C) 2004 Novell, Inc (http://www.novell.com) // // Permission is hereby granted, free of charge, to any person obtaining *************** *** 135,139 **** if (x != null) { _chain.Add (x); ! tmp = x; // last valid } } --- 133,137 ---- if (x != null) { _chain.Add (x); ! x = tmp; // last valid } } *************** *** 192,196 **** roots = null; // this force a reload certs.Clear (); ! _chain.Clear (); } --- 190,195 ---- roots = null; // this force a reload certs.Clear (); ! if (_chain != null) ! _chain.Clear (); } Index: X520Attributes.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.X509/X520Attributes.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** X520Attributes.cs 20 Jul 2004 17:45:50 -0000 1.4 --- X520Attributes.cs 4 Apr 2005 21:10:53 -0000 1.5 *************** *** 31,34 **** --- 31,35 ---- using System; + using System.Globalization; using System.Text; *************** *** 82,86 **** public string Value { get { return attrValue; } ! set { attrValue = value; } } --- 83,93 ---- public string Value { get { return attrValue; } ! set { ! if ((attrValue != null) && (attrValue.Length > upperBound)) { ! string msg = "Value length bigger than upperbound ({0})."; ! throw new FormatException (String.Format (msg, upperBound)); ! } ! attrValue = value; ! } } Index: X501Name.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.X509/X501Name.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** X501Name.cs 20 Jul 2004 17:45:50 -0000 1.3 --- X501Name.cs 4 Apr 2005 21:10:53 -0000 1.4 *************** *** 65,69 **** static byte[] stateOrProvinceName = { 0x55, 0x04, 0x08 }; static byte[] streetAddress = { 0x55, 0x04, 0x09 }; ! static byte[] serialNumber = { 0x55, 0x04, 0x05 }; static byte[] domainComponent = { 0x09, 0x92, 0x26, 0x89, 0x93, 0xF2, 0x2C, 0x64, 0x01, 0x19 }; static byte[] userid = { 0x09, 0x92, 0x26, 0x89, 0x93, 0xF2, 0x2C, 0x64, 0x01, 0x01 }; --- 65,69 ---- static byte[] stateOrProvinceName = { 0x55, 0x04, 0x08 }; static byte[] streetAddress = { 0x55, 0x04, 0x09 }; ! //static byte[] serialNumber = { 0x55, 0x04, 0x05 }; static byte[] domainComponent = { 0x09, 0x92, 0x26, 0x89, 0x93, 0xF2, 0x2C, 0x64, 0x01, 0x19 }; static byte[] userid = { 0x09, 0x92, 0x26, 0x89, 0x93, 0xF2, 0x2C, 0x64, 0x01, 0x01 }; *************** *** 79,142 **** for (int i = 0; i < seq.Count; i++) { ASN1 entry = seq [i]; ! ASN1 pair = entry [0]; ! ASN1 s = pair [1]; ! if (s == null) ! continue; ! ASN1 poid = pair [0]; ! if (poid == null) ! continue; ! if (poid.CompareValue (countryName)) ! sb.Append ("C="); ! else if (poid.CompareValue (organizationName)) ! sb.Append ("O="); ! else if (poid.CompareValue (organizationalUnitName)) ! sb.Append ("OU="); ! else if (poid.CompareValue (commonName)) ! sb.Append ("CN="); ! else if (poid.CompareValue (localityName)) ! sb.Append ("L="); ! else if (poid.CompareValue (stateOrProvinceName)) ! sb.Append ("S="); // NOTE: RFC2253 uses ST= ! else if (poid.CompareValue (streetAddress)) ! sb.Append ("STREET="); ! else if (poid.CompareValue (domainComponent)) ! sb.Append ("DC="); ! else if (poid.CompareValue (userid)) ! sb.Append ("UID="); ! else if (poid.CompareValue (email)) ! sb.Append ("E="); // NOTE: Not part of RFC2253 ! else { ! // unknown OID ! sb.Append ("OID."); // NOTE: Not present as RFC2253 ! sb.Append (ASN1Convert.ToOid (poid)); ! sb.Append ("="); ! } ! string sValue = null; ! // 16bits or 8bits string ? TODO not complete (+special chars!) ! if (s.Tag == 0x1E) { ! // BMPSTRING ! StringBuilder sb2 = new StringBuilder (); ! for (int j = 1; j < s.Value.Length; j+=2) ! sb2.Append ((char) s.Value[j]); ! sValue = sb2.ToString (); ! } ! else { ! sValue = System.Text.Encoding.UTF8.GetString (s.Value); ! // in some cases we must quote (") the value ! // Note: this doesn't seems to conform to RFC2253 ! char[] specials = { ',', '+', '"', '\\', '<', '>', ';' }; ! if (sValue.IndexOfAny(specials, 0, sValue.Length) > 0) ! sValue = "\"" + sValue + "\""; ! else if (sValue.StartsWith (" ")) ! sValue = "\"" + sValue + "\""; ! else if (sValue.EndsWith (" ")) ! sValue = "\"" + sValue + "\""; ! } ! sb.Append (sValue); // separator (not on last iteration) --- 79,147 ---- for (int i = 0; i < seq.Count; i++) { ASN1 entry = seq [i]; ! // multiple entries are valid ! for (int k = 0; k < entry.Count; k++) { ! ASN1 pair = entry [k]; ! ASN1 s = pair [1]; ! if (s == null) ! continue; ! ASN1 poid = pair [0]; ! if (poid == null) ! continue; ! if (poid.CompareValue (countryName)) ! sb.Append ("C="); ! else if (poid.CompareValue (organizationName)) ! sb.Append ("O="); ! else if (poid.CompareValue (organizationalUnitName)) ! sb.Append ("OU="); ! else if (poid.CompareValue (commonName)) ! sb.Append ("CN="); ! else if (poid.CompareValue (localityName)) ! sb.Append ("L="); ! else if (poid.CompareValue (stateOrProvinceName)) ! sb.Append ("S="); // NOTE: RFC2253 uses ST= ! else if (poid.CompareValue (streetAddress)) ! sb.Append ("STREET="); ! else if (poid.CompareValue (domainComponent)) ! sb.Append ("DC="); ! else if (poid.CompareValue (userid)) ! sb.Append ("UID="); ! else if (poid.CompareValue (email)) ! sb.Append ("E="); // NOTE: Not part of RFC2253 ! else { ! // unknown OID ! sb.Append ("OID."); // NOTE: Not present as RFC2253 ! sb.Append (ASN1Convert.ToOid (poid)); ! sb.Append ("="); ! } ! string sValue = null; ! // 16bits or 8bits string ? TODO not complete (+special chars!) ! if (s.Tag == 0x1E) { ! // BMPSTRING ! StringBuilder sb2 = new StringBuilder (); ! for (int j = 1; j < s.Value.Length; j += 2) ! sb2.Append ((char)s.Value[j]); ! sValue = sb2.ToString (); ! } else { ! sValue = System.Text.Encoding.UTF8.GetString (s.Value); ! // in some cases we must quote (") the value ! // Note: this doesn't seems to conform to RFC2253 ! char[] specials = { ',', '+', '"', '\\', '<', '>', ';' }; ! if (sValue.IndexOfAny (specials, 0, sValue.Length) > 0) ! sValue = "\"" + sValue + "\""; ! else if (sValue.StartsWith (" ")) ! sValue = "\"" + sValue + "\""; ! else if (sValue.EndsWith (" ")) ! sValue = "\"" + sValue + "\""; ! } ! sb.Append (sValue); ! // separator (not on last iteration) ! if (k < entry.Count - 1) ! sb.Append (", "); ! } // separator (not on last iteration) Index: X509CertificateBuilder.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.X509/X509CertificateBuilder.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** X509CertificateBuilder.cs 20 Jul 2004 17:45:50 -0000 1.3 --- X509CertificateBuilder.cs 4 Apr 2005 21:10:53 -0000 1.4 *************** *** 223,227 **** // TBSCertificate / SubjectPublicKeyInfo ! ASN1 keyInfo = tbsCert.Add (SubjectPublicKeyInfo ()); if (version > 1) { --- 223,227 ---- // TBSCertificate / SubjectPublicKeyInfo ! tbsCert.Add (SubjectPublicKeyInfo ()); if (version > 1) { Index: PKCS12.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.X509/PKCS12.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PKCS12.cs 20 Jul 2004 17:45:50 -0000 1.4 --- PKCS12.cs 4 Apr 2005 21:10:52 -0000 1.5 *************** *** 270,274 **** static private int recommendedIterationCount = 2000; ! private int _version; private byte[] _password; private ArrayList _keyBags; --- 270,274 ---- static private int recommendedIterationCount = 2000; ! //private int _version; private byte[] _password; private ArrayList _keyBags; *************** *** 328,332 **** if (version.Tag != 0x02) throw new ArgumentException ("invalid PFX version"); ! _version = version.Value [0]; PKCS7.ContentInfo authSafe = new PKCS7.ContentInfo (pfx [1]); --- 328,332 ---- if (version.Tag != 0x02) throw new ArgumentException ("invalid PFX version"); ! //_version = version.Value [0]; PKCS7.ContentInfo authSafe = new PKCS7.ContentInfo (pfx [1]); Index: X509Store.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.X509/X509Store.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** X509Store.cs 20 Jul 2004 17:45:50 -0000 1.3 --- X509Store.cs 4 Apr 2005 21:10:53 -0000 1.4 *************** *** 5,11 **** // Sebastien Pouliot <seb...@xi...> // ! // (C) 2004 Novell (http://www.novell.com) ! // ! // // Permission is hereby granted, free of charge, to any person obtaining --- 5,9 ---- // Sebastien Pouliot <seb...@xi...> // ! // Copyright (C) 2004 Novell, Inc (http://www.novell.com) // // Permission is hereby granted, free of charge, to any person obtaining *************** *** 107,113 **** public void Import (X509Certificate certificate) { ! if (!Directory.Exists (_storePath)) { ! Directory.CreateDirectory (_storePath); ! } string filename = Path.Combine (_storePath, GetUniqueName (certificate)); --- 105,109 ---- public void Import (X509Certificate certificate) { ! CheckStore (_storePath, true); string filename = Path.Combine (_storePath, GetUniqueName (certificate)); *************** *** 184,195 **** } ! private X509CertificateCollection BuildCertificatesCollection (string storeName) { ! string path = Path.Combine (_storePath, storeName); ! if (!Directory.Exists (path)) { Directory.CreateDirectory (path); } X509CertificateCollection coll = new X509CertificateCollection (); string[] files = Directory.GetFiles (path, "*.cer"); if ((files != null) && (files.Length > 0)) { --- 180,205 ---- } ! private bool CheckStore (string path, bool throwException) { ! try { ! if (Directory.Exists (path)) ! return true; Directory.CreateDirectory (path); + return Directory.Exists (path); } + catch { + if (throwException) + throw; + return false; + } + } + private X509CertificateCollection BuildCertificatesCollection (string storeName) + { X509CertificateCollection coll = new X509CertificateCollection (); + string path = Path.Combine (_storePath, storeName); + if (!CheckStore (path, false)) + return coll; // empty collection + string[] files = Directory.GetFiles (path, "*.cer"); if ((files != null) && (files.Length > 0)) { *************** *** 214,217 **** --- 224,230 ---- ArrayList list = new ArrayList (); string path = Path.Combine (_storePath, storeName); + if (!CheckStore (path, false)) + return list; // empty list + string[] files = Directory.GetFiles (path, "*.crl"); if ((files != null) && (files.Length > 0)) { |