diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-11-12 22:57:06 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-11-12 22:57:06 +0700 |
commit | 809e86bbf8ed478e7aa7b9de8a3bfc3014289bd5 (patch) | |
tree | 9287ae725992c5972bed155ec4f4773fdace7b22 /crypto/src/asn1 | |
parent | Refactoring of "unused bits" changes (diff) | |
download | BouncyCastle.NET-ed25519-809e86bbf8ed478e7aa7b9de8a3bfc3014289bd5.tar.xz |
Review of culture-independent String comparison methods
Diffstat (limited to 'crypto/src/asn1')
-rw-r--r-- | crypto/src/asn1/DerGeneralizedTime.cs | 6 | ||||
-rw-r--r-- | crypto/src/asn1/DerObjectIdentifier.cs | 2 | ||||
-rw-r--r-- | crypto/src/asn1/anssi/ANSSINamedCurves.cs | 4 | ||||
-rw-r--r-- | crypto/src/asn1/sec/SECNamedCurves.cs | 4 | ||||
-rw-r--r-- | crypto/src/asn1/teletrust/TeleTrusTNamedCurves.cs | 4 | ||||
-rw-r--r-- | crypto/src/asn1/x509/GeneralName.cs | 5 | ||||
-rw-r--r-- | crypto/src/asn1/x509/X509Name.cs | 16 | ||||
-rw-r--r-- | crypto/src/asn1/x9/X962NamedCurves.cs | 4 |
8 files changed, 20 insertions, 25 deletions
diff --git a/crypto/src/asn1/DerGeneralizedTime.cs b/crypto/src/asn1/DerGeneralizedTime.cs index 17c42e7cf..79b008768 100644 --- a/crypto/src/asn1/DerGeneralizedTime.cs +++ b/crypto/src/asn1/DerGeneralizedTime.cs @@ -204,7 +204,7 @@ namespace Org.BouncyCastle.Asn1 string d = time; bool makeUniversal = false; - if (d.EndsWith("Z")) + if (Platform.EndsWith(d, "Z")) { if (HasFractionalSeconds) { @@ -223,7 +223,7 @@ namespace Org.BouncyCastle.Asn1 if (HasFractionalSeconds) { - int fCount = d.IndexOf("GMT") - 1 - d.IndexOf('.'); + int fCount = Platform.IndexOf(d, "GMT") - 1 - d.IndexOf('.'); formatStr = @"yyyyMMddHHmmss." + FString(fCount) + @"'GMT'zzz"; } else @@ -267,7 +267,7 @@ namespace Org.BouncyCastle.Asn1 * NOTE: DateTime.Kind and DateTimeStyles.AssumeUniversal not available in .NET 1.1 */ DateTimeStyles style = DateTimeStyles.None; - if (format.EndsWith("Z")) + if (Platform.EndsWith(format, "Z")) { try { diff --git a/crypto/src/asn1/DerObjectIdentifier.cs b/crypto/src/asn1/DerObjectIdentifier.cs index f9f6a79d6..563c637e5 100644 --- a/crypto/src/asn1/DerObjectIdentifier.cs +++ b/crypto/src/asn1/DerObjectIdentifier.cs @@ -83,7 +83,7 @@ namespace Org.BouncyCastle.Asn1 public virtual bool On(DerObjectIdentifier stem) { string id = Id, stemId = stem.Id; - return id.Length > stemId.Length && id[stemId.Length] == '.' && id.StartsWith(stemId); + return id.Length > stemId.Length && id[stemId.Length] == '.' && Platform.StartsWith(id, stemId); } internal DerObjectIdentifier(byte[] bytes) diff --git a/crypto/src/asn1/anssi/ANSSINamedCurves.cs b/crypto/src/asn1/anssi/ANSSINamedCurves.cs index c7f9545f2..d0c90ebf1 100644 --- a/crypto/src/asn1/anssi/ANSSINamedCurves.cs +++ b/crypto/src/asn1/anssi/ANSSINamedCurves.cs @@ -60,7 +60,7 @@ namespace Org.BouncyCastle.Asn1.Anssi DerObjectIdentifier oid, X9ECParametersHolder holder) { - objIds.Add(Platform.ToLowerInvariant(name), oid); + objIds.Add(Platform.ToUpperInvariant(name), oid); names.Add(oid, name); curves.Add(oid, holder); } @@ -99,7 +99,7 @@ namespace Org.BouncyCastle.Asn1.Anssi public static DerObjectIdentifier GetOid( string name) { - return (DerObjectIdentifier)objIds[Platform.ToLowerInvariant(name)]; + return (DerObjectIdentifier)objIds[Platform.ToUpperInvariant(name)]; } /** diff --git a/crypto/src/asn1/sec/SECNamedCurves.cs b/crypto/src/asn1/sec/SECNamedCurves.cs index ca71a4e66..b753ac5d1 100644 --- a/crypto/src/asn1/sec/SECNamedCurves.cs +++ b/crypto/src/asn1/sec/SECNamedCurves.cs @@ -1088,7 +1088,7 @@ namespace Org.BouncyCastle.Asn1.Sec DerObjectIdentifier oid, X9ECParametersHolder holder) { - objIds.Add(Platform.ToLowerInvariant(name), oid); + objIds.Add(Platform.ToUpperInvariant(name), oid); names.Add(oid, name); curves.Add(oid, holder); } @@ -1160,7 +1160,7 @@ namespace Org.BouncyCastle.Asn1.Sec public static DerObjectIdentifier GetOid( string name) { - return (DerObjectIdentifier)objIds[Platform.ToLowerInvariant(name)]; + return (DerObjectIdentifier)objIds[Platform.ToUpperInvariant(name)]; } /** diff --git a/crypto/src/asn1/teletrust/TeleTrusTNamedCurves.cs b/crypto/src/asn1/teletrust/TeleTrusTNamedCurves.cs index ba3eda620..9a82db319 100644 --- a/crypto/src/asn1/teletrust/TeleTrusTNamedCurves.cs +++ b/crypto/src/asn1/teletrust/TeleTrusTNamedCurves.cs @@ -387,7 +387,7 @@ namespace Org.BouncyCastle.Asn1.TeleTrust DerObjectIdentifier oid, X9ECParametersHolder holder) { - objIds.Add(Platform.ToLowerInvariant(name), oid); + objIds.Add(Platform.ToUpperInvariant(name), oid); names.Add(oid, name); curves.Add(oid, holder); } @@ -439,7 +439,7 @@ namespace Org.BouncyCastle.Asn1.TeleTrust public static DerObjectIdentifier GetOid( string name) { - return (DerObjectIdentifier)objIds[Platform.ToLowerInvariant(name)]; + return (DerObjectIdentifier)objIds[Platform.ToUpperInvariant(name)]; } /** diff --git a/crypto/src/asn1/x509/GeneralName.cs b/crypto/src/asn1/x509/GeneralName.cs index 710ddc922..16096623c 100644 --- a/crypto/src/asn1/x509/GeneralName.cs +++ b/crypto/src/asn1/x509/GeneralName.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.IO; using System.Text; +using Org.BouncyCastle.Utilities; using NetUtils = Org.BouncyCastle.Utilities.Net; namespace Org.BouncyCastle.Asn1.X509 @@ -356,11 +357,11 @@ namespace Org.BouncyCastle.Asn1.X509 private int[] parseIPv6(string ip) { - if (ip.StartsWith("::")) + if (Platform.StartsWith(ip, "::")) { ip = ip.Substring(1); } - else if (ip.EndsWith("::")) + else if (Platform.EndsWith(ip, "::")) { ip = ip.Substring(0, ip.Length - 1); } diff --git a/crypto/src/asn1/x509/X509Name.cs b/crypto/src/asn1/x509/X509Name.cs index fb404a3ec..01a7ec04a 100644 --- a/crypto/src/asn1/x509/X509Name.cs +++ b/crypto/src/asn1/x509/X509Name.cs @@ -399,7 +399,7 @@ namespace Org.BouncyCastle.Asn1.X509 if (derValue is IAsn1String && !(derValue is DerUniversalString)) { string v = ((IAsn1String)derValue).GetString(); - if (v.StartsWith("#")) + if (Platform.StartsWith(v, "#")) { v = "\\" + v; } @@ -499,12 +499,6 @@ namespace Org.BouncyCastle.Asn1.X509 } } -// private static bool IsEncoded( -// string s) -// { -// return s.StartsWith("#"); -// } - /** * Takes an X509 dir name as a string of the format "C=AU, ST=Victoria", or * some such, converting it into an ordered set of name attributes. @@ -581,7 +575,7 @@ namespace Org.BouncyCastle.Asn1.X509 string name, IDictionary lookUp) { - if (Platform.ToUpperInvariant(name).StartsWith("OID.")) + if (Platform.StartsWith(Platform.ToUpperInvariant(name), "OID.")) { return new DerObjectIdentifier(name.Substring(4)); } @@ -724,7 +718,7 @@ namespace Org.BouncyCastle.Asn1.X509 { string val = (string)values[i]; - if (val.StartsWith("\\#")) + if (Platform.StartsWith(val, "\\#")) { val = val.Substring(1); } @@ -911,7 +905,7 @@ namespace Org.BouncyCastle.Asn1.X509 { string v = Platform.ToLowerInvariant(s).Trim(); - if (v.StartsWith("#")) + if (Platform.StartsWith(v, "#")) { Asn1Object obj = decodeObject(v); @@ -987,7 +981,7 @@ namespace Org.BouncyCastle.Asn1.X509 int end = buf.Length; - if (val.StartsWith("\\#")) + if (Platform.StartsWith(val, "\\#")) { index += 2; } diff --git a/crypto/src/asn1/x9/X962NamedCurves.cs b/crypto/src/asn1/x9/X962NamedCurves.cs index 6fa4e7c4b..14f7f818a 100644 --- a/crypto/src/asn1/x9/X962NamedCurves.cs +++ b/crypto/src/asn1/x9/X962NamedCurves.cs @@ -666,7 +666,7 @@ namespace Org.BouncyCastle.Asn1.X9 DerObjectIdentifier oid, X9ECParametersHolder holder) { - objIds.Add(Platform.ToLowerInvariant(name), oid); + objIds.Add(Platform.ToUpperInvariant(name), oid); names.Add(oid, name); curves.Add(oid, holder); } @@ -727,7 +727,7 @@ namespace Org.BouncyCastle.Asn1.X9 public static DerObjectIdentifier GetOid( string name) { - return (DerObjectIdentifier)objIds[Platform.ToLowerInvariant(name)]; + return (DerObjectIdentifier)objIds[Platform.ToUpperInvariant(name)]; } /** |