diff options
author | Sebastien Pouliot <sebastien@ximian.com> | 2004-02-24 17:15:30 +0300 |
---|---|---|
committer | Sebastien Pouliot <sebastien@ximian.com> | 2004-02-24 17:15:30 +0300 |
commit | 67e7c141024aafd74b9e683e8fe7a9164b7ee6d2 (patch) | |
tree | 97a71c9598cfa62fbad8bce1d6eecc99986cde56 /mcs/class/Mono.Security/Mono.Security.X509 | |
parent | 5df5ba5a5e30e92807cf023cddeeb4d65395e1c2 (diff) |
2004-02-24 Sebastien Pouliot <sebastien@ximian.com>
* X509Certificate.cs: Add support for the OID "1.3.14.3.2.29" (SHA1
with RSA). Added a fix for "really" null algorithm parameters.
* X509CertificateCollection.cs: Fixed Contains and IndexOf (worked
on objects but not for the same certificate in a different object).
svn path=/trunk/mcs/; revision=23398
Diffstat (limited to 'mcs/class/Mono.Security/Mono.Security.X509')
3 files changed, 40 insertions, 4 deletions
diff --git a/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog b/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog index 09e7ad5eca9..d0bab130d8d 100644 --- a/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog +++ b/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog @@ -1,3 +1,10 @@ +2004-02-24 Sebastien Pouliot <sebastien@ximian.com> + + * X509Certificate.cs: Add support for the OID "1.3.14.3.2.29" (SHA1 + with RSA). Added a fix for "really" null algorithm parameters. + * X509CertificateCollection.cs: Fixed Contains and IndexOf (worked + on objects but not for the same certificate in a different object). + 2004-02-23 Sebastien Pouliot <sebastien@ximian.com> * TestAnchors.cs: Removed - no need to be hardcoded anymore. diff --git a/mcs/class/Mono.Security/Mono.Security.X509/X509Certificate.cs b/mcs/class/Mono.Security/Mono.Security.X509/X509Certificate.cs index 582e9cd3409..9eb3edda78a 100644 --- a/mcs/class/Mono.Security/Mono.Security.X509/X509Certificate.cs +++ b/mcs/class/Mono.Security/Mono.Security.X509/X509Certificate.cs @@ -119,7 +119,7 @@ namespace Mono.Security.X509 { // parameters ANY DEFINED BY algorithm OPTIONAL // so we dont ask for a specific (Element) type and return DER ASN1 parameters = algorithm [1]; - m_keyalgoparams = parameters.GetBytes (); + m_keyalgoparams = ((algorithm.Count > 1) ? parameters.GetBytes () : null); ASN1 subjectPublicKey = subjectPublicKeyInfo.Element (1, 0x03); // we must drop th first byte (which is the number of unused bits @@ -239,6 +239,7 @@ namespace Mono.Security.X509 { hash = MD5.Create (); break; case "1.2.840.113549.1.1.5": // SHA-1 with RSA Encryption + case "1.3.14.3.2.29": // SHA1 with RSA signature case "1.2.840.10040.4.3": // SHA1-1 with DSA hash = SHA1.Create (); break; @@ -311,6 +312,7 @@ namespace Mono.Security.X509 { case "1.2.840.113549.1.1.2": // MD2 with RSA encryption case "1.2.840.113549.1.1.4": // MD5 with RSA encryption case "1.2.840.113549.1.1.5": // SHA-1 with RSA Encryption + case "1.3.14.3.2.29": // SHA1 with RSA signature return signature; case "1.2.840.10040.4.3": // SHA-1 with DSA ASN1 sign = new ASN1 (signature); @@ -393,6 +395,7 @@ namespace Mono.Security.X509 { break; // SHA-1 with RSA Encryption case "1.2.840.113549.1.1.5": + case "1.3.14.3.2.29": v.SetHashAlgorithm ("SHA1"); break; default: diff --git a/mcs/class/Mono.Security/Mono.Security.X509/X509CertificateCollection.cs b/mcs/class/Mono.Security/Mono.Security.X509/X509CertificateCollection.cs index 8962f2a8d2d..25b7373cf0a 100755 --- a/mcs/class/Mono.Security/Mono.Security.X509/X509CertificateCollection.cs +++ b/mcs/class/Mono.Security/Mono.Security.X509/X509CertificateCollection.cs @@ -4,7 +4,7 @@ // // Authors: // Lawrence Pit (loz@cable.a2000.nl) -// Sebastien Pouliot (spouliot@motus.com) +// Sebastien Pouliot <sebastien@ximian.com> // using System; @@ -64,7 +64,7 @@ namespace Mono.Security.X509 { public bool Contains (X509Certificate value) { - return InnerList.Contains (value); + return (IndexOf (value) != -1); } public void CopyTo (X509Certificate[] array, int index) @@ -89,7 +89,16 @@ namespace Mono.Security.X509 { public int IndexOf (X509Certificate value) { - return InnerList.IndexOf (value); + if (value == null) + throw new ArgumentNullException ("value"); + + byte[] hash = value.Hash; + for (int i=0; i < InnerList.Count; i++) { + X509Certificate x509 = (X509Certificate) InnerList [i]; + if (Compare (x509.Hash, hash)) + return i; + } + return -1; } public void Insert (int index, X509Certificate value) @@ -102,6 +111,23 @@ namespace Mono.Security.X509 { InnerList.Remove (value); } + // private stuff + + private bool Compare (byte[] array1, byte[] array2) + { + if ((array1 == null) && (array2 == null)) + return true; + if ((array1 == null) || (array2 == null)) + return false; + if (array1.Length != array2.Length) + return false; + for (int i=0; i < array1.Length; i++) { + if (array1 [i] != array2 [i]) + return false; + } + return true; + } + // Inner Class public class X509CertificateEnumerator : IEnumerator { |