summary refs log tree commit diff
path: root/crypto/src
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-06-29 14:47:32 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-06-29 14:47:32 +0700
commita395a34a769d3c7e6616129f4832b7014dbbfe98 (patch)
tree76a4749c2f548afff826c6758de3c8ce0b6fd646 /crypto/src
parentGenerics migration complete (diff)
downloadBouncyCastle.NET-ed25519-a395a34a769d3c7e6616129f4832b7014dbbfe98.tar.xz
Cleanup NewLine handling
Diffstat (limited to 'crypto/src')
-rw-r--r--crypto/src/asn1/util/Asn1Dump.cs3
-rw-r--r--crypto/src/asn1/x509/AuthorityInformationAccess.cs13
-rw-r--r--crypto/src/asn1/x509/CRLDistPoint.cs14
-rw-r--r--crypto/src/asn1/x509/DistributionPoint.cs25
-rw-r--r--crypto/src/asn1/x509/DistributionPointName.cs27
-rw-r--r--crypto/src/asn1/x509/GeneralNames.cs13
-rw-r--r--crypto/src/asn1/x509/IssuingDistributionPoint.cs32
-rw-r--r--crypto/src/bcpg/ArmoredOutputStream.cs21
-rw-r--r--crypto/src/pkix/PkixBuilderParameters.cs6
-rw-r--r--crypto/src/pkix/PkixCertPathBuilderResult.cs6
-rw-r--r--crypto/src/pkix/PkixCertPathValidatorResult.cs6
-rw-r--r--crypto/src/pkix/PkixNameConstraintValidator.cs3
-rw-r--r--crypto/src/pkix/PkixPolicyNode.cs9
-rw-r--r--crypto/src/pkix/TrustAnchor.cs12
-rw-r--r--crypto/src/util/Platform.cs2
-rw-r--r--crypto/src/util/io/pem/PemWriter.cs2
-rw-r--r--crypto/src/x509/X509Certificate.cs27
-rw-r--r--crypto/src/x509/X509Crl.cs35
-rw-r--r--crypto/src/x509/X509CrlEntry.cs15
19 files changed, 111 insertions, 160 deletions
diff --git a/crypto/src/asn1/util/Asn1Dump.cs b/crypto/src/asn1/util/Asn1Dump.cs
index faf9294df..7bae766c3 100644
--- a/crypto/src/asn1/util/Asn1Dump.cs
+++ b/crypto/src/asn1/util/Asn1Dump.cs
@@ -248,7 +248,8 @@ namespace Org.BouncyCastle.Asn1.Utilities
             else
             {
                 buf.Append(indent);
-                buf.AppendLine(obj.ToString());
+                buf.Append(obj);
+                buf.AppendLine();
             }
         }
 
diff --git a/crypto/src/asn1/x509/AuthorityInformationAccess.cs b/crypto/src/asn1/x509/AuthorityInformationAccess.cs
index 57868baea..382513674 100644
--- a/crypto/src/asn1/x509/AuthorityInformationAccess.cs
+++ b/crypto/src/asn1/x509/AuthorityInformationAccess.cs
@@ -94,18 +94,13 @@ namespace Org.BouncyCastle.Asn1.X509
             //return "AuthorityInformationAccess: Oid(" + this.descriptions[0].AccessMethod.Id + ")";
 
             StringBuilder buf = new StringBuilder();
-            string sep = Platform.NewLine;
-
-            buf.Append("AuthorityInformationAccess:");
-            buf.Append(sep);
-
+            buf.AppendLine("AuthorityInformationAccess:");
             foreach (AccessDescription description in descriptions)
             {
-                buf.Append("    ");
-                buf.Append(description);
-                buf.Append(sep);
+                buf.Append("    ")
+                   .Append(description)
+                   .AppendLine();
             }
-
             return buf.ToString();
         }
     }
diff --git a/crypto/src/asn1/x509/CRLDistPoint.cs b/crypto/src/asn1/x509/CRLDistPoint.cs
index 446bb19db..518bf3f00 100644
--- a/crypto/src/asn1/x509/CRLDistPoint.cs
+++ b/crypto/src/asn1/x509/CRLDistPoint.cs
@@ -72,16 +72,12 @@ namespace Org.BouncyCastle.Asn1.X509
 		public override string ToString()
 		{
 			StringBuilder buf = new StringBuilder();
-			string sep = Platform.NewLine;
-
-			buf.Append("CRLDistPoint:");
-			buf.Append(sep);
-			DistributionPoint[] dp = GetDistributionPoints();
-			for (int i = 0; i != dp.Length; i++)
+			buf.AppendLine("CRLDistPoint:");
+            foreach (DistributionPoint dp in GetDistributionPoints())
 			{
-				buf.Append("    ");
-				buf.Append(dp[i]);
-				buf.Append(sep);
+				buf.Append("    ")
+				   .Append(dp)
+                   .AppendLine();
 			}
 			return buf.ToString();
 		}
diff --git a/crypto/src/asn1/x509/DistributionPoint.cs b/crypto/src/asn1/x509/DistributionPoint.cs
index 54ab930a5..f35586016 100644
--- a/crypto/src/asn1/x509/DistributionPoint.cs
+++ b/crypto/src/asn1/x509/DistributionPoint.cs
@@ -106,43 +106,34 @@ namespace Org.BouncyCastle.Asn1.X509
 
 		public override string ToString()
 		{
-			string sep = Platform.NewLine;
 			StringBuilder buf = new StringBuilder();
-			buf.Append("DistributionPoint: [");
-			buf.Append(sep);
+			buf.AppendLine("DistributionPoint: [");
 			if (distributionPoint != null)
 			{
-				appendObject(buf, sep, "distributionPoint", distributionPoint.ToString());
+                AppendObject(buf, "distributionPoint", distributionPoint.ToString());
 			}
 			if (reasons != null)
 			{
-				appendObject(buf, sep, "reasons", reasons.ToString());
+                AppendObject(buf, "reasons", reasons.ToString());
 			}
 			if (cRLIssuer != null)
 			{
-				appendObject(buf, sep, "cRLIssuer", cRLIssuer.ToString());
+                AppendObject(buf, "cRLIssuer", cRLIssuer.ToString());
 			}
-			buf.Append("]");
-			buf.Append(sep);
+			buf.AppendLine("]");
 			return buf.ToString();
 		}
 
-		private void appendObject(
-			StringBuilder	buf,
-			string			sep,
-			string			name,
-			string			val)
+		private void AppendObject(StringBuilder buf, string name, string val)
 		{
 			string indent = "    ";
-
 			buf.Append(indent);
 			buf.Append(name);
-			buf.Append(":");
-			buf.Append(sep);
+			buf.AppendLine(":");
 			buf.Append(indent);
 			buf.Append(indent);
 			buf.Append(val);
-			buf.Append(sep);
+            buf.AppendLine();
 		}
 	}
 }
diff --git a/crypto/src/asn1/x509/DistributionPointName.cs b/crypto/src/asn1/x509/DistributionPointName.cs
index 43fdaf533..bca54fa06 100644
--- a/crypto/src/asn1/x509/DistributionPointName.cs
+++ b/crypto/src/asn1/x509/DistributionPointName.cs
@@ -92,39 +92,30 @@ namespace Org.BouncyCastle.Asn1.X509
 
 		public override string ToString()
 		{
-			string sep = Platform.NewLine;
 			StringBuilder buf = new StringBuilder();
-			buf.Append("DistributionPointName: [");
-			buf.Append(sep);
+			buf.AppendLine("DistributionPointName: [");
 			if (type == FullName)
 			{
-				appendObject(buf, sep, "fullName", name.ToString());
+				AppendObject(buf, "fullName", name.ToString());
 			}
 			else
 			{
-				appendObject(buf, sep, "nameRelativeToCRLIssuer", name.ToString());
+				AppendObject(buf, "nameRelativeToCRLIssuer", name.ToString());
 			}
-			buf.Append("]");
-			buf.Append(sep);
+			buf.AppendLine("]");
 			return buf.ToString();
 		}
 
-		private void appendObject(
-			StringBuilder	buf,
-			string			sep,
-			string			name,
-			string			val)
+		private void AppendObject(StringBuilder buf, string name, string val)
 		{
 			string indent = "    ";
-
 			buf.Append(indent);
 			buf.Append(name);
-			buf.Append(":");
-			buf.Append(sep);
+			buf.AppendLine(":");
 			buf.Append(indent);
 			buf.Append(indent);
 			buf.Append(val);
-			buf.Append(sep);
-		}
-	}
+            buf.AppendLine();
+        }
+    }
 }
diff --git a/crypto/src/asn1/x509/GeneralNames.cs b/crypto/src/asn1/x509/GeneralNames.cs
index c105f3b6e..acf263f84 100644
--- a/crypto/src/asn1/x509/GeneralNames.cs
+++ b/crypto/src/asn1/x509/GeneralNames.cs
@@ -78,18 +78,13 @@ namespace Org.BouncyCastle.Asn1.X509
 		public override string ToString()
 		{
 			StringBuilder buf = new StringBuilder();
-			string sep = Platform.NewLine;
-
-			buf.Append("GeneralNames:");
-			buf.Append(sep);
-
+			buf.AppendLine("GeneralNames:");
 			foreach (GeneralName name in names)
 			{
-				buf.Append("    ");
-				buf.Append(name);
-				buf.Append(sep);
+				buf.Append("    ")
+				   .Append(name)
+				   .AppendLine();
 			}
-
 			return buf.ToString();
 		}
 	}
diff --git a/crypto/src/asn1/x509/IssuingDistributionPoint.cs b/crypto/src/asn1/x509/IssuingDistributionPoint.cs
index 8e9362b90..a05efffa4 100644
--- a/crypto/src/asn1/x509/IssuingDistributionPoint.cs
+++ b/crypto/src/asn1/x509/IssuingDistributionPoint.cs
@@ -192,56 +192,46 @@ namespace Org.BouncyCastle.Asn1.X509
 
 		public override string ToString()
 		{
-			string sep = Platform.NewLine;
 			StringBuilder buf = new StringBuilder();
-
-			buf.Append("IssuingDistributionPoint: [");
-			buf.Append(sep);
+			buf.AppendLine("IssuingDistributionPoint: [");
 			if (_distributionPoint != null)
 			{
-				appendObject(buf, sep, "distributionPoint", _distributionPoint.ToString());
+				AppendObject(buf, "distributionPoint", _distributionPoint.ToString());
 			}
 			if (_onlyContainsUserCerts)
 			{
-				appendObject(buf, sep, "onlyContainsUserCerts", _onlyContainsUserCerts.ToString());
+				AppendObject(buf, "onlyContainsUserCerts", _onlyContainsUserCerts.ToString());
 			}
 			if (_onlyContainsCACerts)
 			{
-				appendObject(buf, sep, "onlyContainsCACerts", _onlyContainsCACerts.ToString());
+				AppendObject(buf, "onlyContainsCACerts", _onlyContainsCACerts.ToString());
 			}
 			if (_onlySomeReasons != null)
 			{
-				appendObject(buf, sep, "onlySomeReasons", _onlySomeReasons.ToString());
+				AppendObject(buf, "onlySomeReasons", _onlySomeReasons.ToString());
 			}
 			if (_onlyContainsAttributeCerts)
 			{
-				appendObject(buf, sep, "onlyContainsAttributeCerts", _onlyContainsAttributeCerts.ToString());
+				AppendObject(buf, "onlyContainsAttributeCerts", _onlyContainsAttributeCerts.ToString());
 			}
 			if (_indirectCRL)
 			{
-				appendObject(buf, sep, "indirectCRL", _indirectCRL.ToString());
+				AppendObject(buf, "indirectCRL", _indirectCRL.ToString());
 			}
-			buf.Append("]");
-			buf.Append(sep);
+			buf.AppendLine("]");
 			return buf.ToString();
 		}
 
-		private void appendObject(
-			StringBuilder	buf,
-			string			sep,
-			string			name,
-			string			val)
+		private void AppendObject(StringBuilder buf, string name, string val)
 		{
 			string indent = "    ";
-
 			buf.Append(indent);
 			buf.Append(name);
-			buf.Append(":");
-			buf.Append(sep);
+			buf.AppendLine(":");
 			buf.Append(indent);
 			buf.Append(indent);
 			buf.Append(val);
-			buf.Append(sep);
+			buf.AppendLine();
 		}
 	}
 }
diff --git a/crypto/src/bcpg/ArmoredOutputStream.cs b/crypto/src/bcpg/ArmoredOutputStream.cs
index a3d86429c..4a726e2dd 100644
--- a/crypto/src/bcpg/ArmoredOutputStream.cs
+++ b/crypto/src/bcpg/ArmoredOutputStream.cs
@@ -1,3 +1,4 @@
+using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.IO;
@@ -91,7 +92,7 @@ namespace Org.BouncyCastle.Bcpg
 
         private string          type;
 
-        private static readonly string    nl = Platform.NewLine;
+        private static readonly string    NewLine = Environment.NewLine;
         private static readonly string    headerStart = "-----BEGIN PGP ";
         private static readonly string    headerTail = "-----";
         private static readonly string    footerStart = "-----END PGP ";
@@ -219,8 +220,8 @@ namespace Org.BouncyCastle.Bcpg
                 throw new IOException("unknown hash algorithm tag in beginClearText: " + hashAlgorithm);
             }
 
-            DoWrite("-----BEGIN PGP SIGNED MESSAGE-----" + nl);
-            DoWrite("Hash: " + hash + nl + nl);
+            DoWrite("-----BEGIN PGP SIGNED MESSAGE-----" + NewLine);
+            DoWrite("Hash: " + hash + NewLine + NewLine);
 
             clearText = true;
             newLine = true;
@@ -288,7 +289,7 @@ namespace Org.BouncyCastle.Bcpg
                     break;
                 }
 
-                DoWrite(headerStart + type + headerTail + nl);
+                DoWrite(headerStart + type + headerTail + NewLine);
 
                 if (m_headers.TryGetValue(HeaderVersion, out var versionHeaders))
                 {
@@ -307,7 +308,7 @@ namespace Org.BouncyCastle.Bcpg
                     }
                 }
 
-                DoWrite(nl);
+                DoWrite(NewLine);
 
                 start = false;
             }
@@ -318,7 +319,7 @@ namespace Org.BouncyCastle.Bcpg
                 bufPtr = 0;
                 if ((++chunkCount & 0xf) == 0)
                 {
-                    DoWrite(nl);
+                    DoWrite(NewLine);
                 }
             }
 
@@ -367,7 +368,7 @@ namespace Org.BouncyCastle.Bcpg
                 Encode(outStream, buf, bufPtr);
             }
 
-            DoWrite(nl + '=');
+            DoWrite(NewLine + '=');
 
             int crcV = crc.Value;
 
@@ -377,11 +378,11 @@ namespace Org.BouncyCastle.Bcpg
 
             Encode(outStream, buf, 3);
 
-            DoWrite(nl);
+            DoWrite(NewLine);
             DoWrite(footerStart);
             DoWrite(type);
             DoWrite(footerTail);
-            DoWrite(nl);
+            DoWrite(NewLine);
 
             outStream.Flush();
         }
@@ -390,7 +391,7 @@ namespace Org.BouncyCastle.Bcpg
             string name,
             string v)
         {
-            DoWrite(name + ": " + v + nl);
+            DoWrite(name + ": " + v + NewLine);
         }
 
         private void DoWrite(
diff --git a/crypto/src/pkix/PkixBuilderParameters.cs b/crypto/src/pkix/PkixBuilderParameters.cs
index b76c97874..998b9550c 100644
--- a/crypto/src/pkix/PkixBuilderParameters.cs
+++ b/crypto/src/pkix/PkixBuilderParameters.cs
@@ -133,13 +133,13 @@ namespace Org.BouncyCastle.Pkix
 
 		public override string ToString()
 		{
-			string nl = Platform.NewLine;
 			StringBuilder s = new StringBuilder();
-			s.Append("PkixBuilderParameters [" + nl);
+			s.AppendLine("PkixBuilderParameters [");
 			s.Append(base.ToString());
 			s.Append("  Maximum Path Length: ");
 			s.Append(MaxPathLength);
-			s.Append(nl + "]" + nl);
+			s.AppendLine();
+			s.AppendLine("]");
 			return s.ToString();
 		}
 	}
diff --git a/crypto/src/pkix/PkixCertPathBuilderResult.cs b/crypto/src/pkix/PkixCertPathBuilderResult.cs
index 639009a37..a9dfc6722 100644
--- a/crypto/src/pkix/PkixCertPathBuilderResult.cs
+++ b/crypto/src/pkix/PkixCertPathBuilderResult.cs
@@ -36,9 +36,9 @@ namespace Org.BouncyCastle.Pkix
 		{
 			StringBuilder sb = new StringBuilder();
 			sb.AppendLine("SimplePKIXCertPathBuilderResult: [");
-			sb.Append("  Certification Path: ").AppendLine(CertPath.ToString());
-			sb.Append("  Trust Anchor: ").AppendLine(TrustAnchor.TrustedCert.IssuerDN.ToString());
-			sb.Append("  Subject Public Key: ").AppendLine(SubjectPublicKey.ToString());
+			sb.Append("  Certification Path: ").Append(CertPath).AppendLine();
+			sb.Append("  Trust Anchor: ").Append(TrustAnchor.TrustedCert.IssuerDN).AppendLine();
+			sb.Append("  Subject Public Key: ").Append(SubjectPublicKey).AppendLine();
 			return sb.ToString();
 		}
 	}
diff --git a/crypto/src/pkix/PkixCertPathValidatorResult.cs b/crypto/src/pkix/PkixCertPathValidatorResult.cs
index 7df3eab21..693ded89c 100644
--- a/crypto/src/pkix/PkixCertPathValidatorResult.cs
+++ b/crypto/src/pkix/PkixCertPathValidatorResult.cs
@@ -59,9 +59,9 @@ namespace Org.BouncyCastle.Pkix
 		{
 			StringBuilder sb = new StringBuilder();
 			sb.AppendLine("PKIXCertPathValidatorResult: [");
-			sb.Append("  Trust Anchor: ").AppendLine(TrustAnchor.ToString());
-			sb.Append("  Policy Tree: ").AppendLine(PolicyTree.ToString());
-			sb.Append("  Subject Public Key: ").AppendLine(SubjectPublicKey.ToString());
+			sb.Append("  Trust Anchor: ").Append(TrustAnchor).AppendLine();
+			sb.Append("  Policy Tree: ").Append(PolicyTree).AppendLine();
+			sb.Append("  Subject Public Key: ").Append(SubjectPublicKey).AppendLine();
 			return sb.ToString();
 		}
 	}
diff --git a/crypto/src/pkix/PkixNameConstraintValidator.cs b/crypto/src/pkix/PkixNameConstraintValidator.cs
index 5ad4de6f8..ad59702c5 100644
--- a/crypto/src/pkix/PkixNameConstraintValidator.cs
+++ b/crypto/src/pkix/PkixNameConstraintValidator.cs
@@ -1849,7 +1849,8 @@ namespace Org.BouncyCastle.Pkix
         {
             sb.Append(name);
             sb.AppendLine(":");
-            sb.AppendLine(value.ToString());
+            sb.Append(value);
+            sb.AppendLine();
         }
     }
 }
diff --git a/crypto/src/pkix/PkixPolicyNode.cs b/crypto/src/pkix/PkixPolicyNode.cs
index 0ea80b258..5a29d7b13 100644
--- a/crypto/src/pkix/PkixPolicyNode.cs
+++ b/crypto/src/pkix/PkixPolicyNode.cs
@@ -110,14 +110,12 @@ namespace Org.BouncyCastle.Pkix
 			return ToString("");
 		}
 
-		public virtual string ToString(
-			string indent)
+		public virtual string ToString(string indent)
 		{
 			StringBuilder buf = new StringBuilder();
 			buf.Append(indent);
 			buf.Append(mValidPolicy);
-			buf.Append(" {");
-			buf.Append(Platform.NewLine);
+			buf.AppendLine(" {");
 
 			foreach (PkixPolicyNode child in mChildren)
 			{
@@ -125,8 +123,7 @@ namespace Org.BouncyCastle.Pkix
 			}
 
 			buf.Append(indent);
-			buf.Append("}");
-			buf.Append(Platform.NewLine);
+			buf.AppendLine("}");
 			return buf.ToString();
 		}
 
diff --git a/crypto/src/pkix/TrustAnchor.cs b/crypto/src/pkix/TrustAnchor.cs
index 22078baf2..c8937e8c8 100644
--- a/crypto/src/pkix/TrustAnchor.cs
+++ b/crypto/src/pkix/TrustAnchor.cs
@@ -236,22 +236,20 @@ namespace Org.BouncyCastle.Pkix
 		public override string ToString()
 		{
 			// TODO Some of the sub-objects might not implement ToString() properly
-			string nl = Platform.NewLine;
 			StringBuilder sb = new StringBuilder();
-			sb.Append("[");
-			sb.Append(nl);
+			sb.AppendLine("[");
 			if (this.pubKey != null)
 			{
-				sb.Append("  Trusted CA Public Key: ").Append(this.pubKey).Append(nl);
-				sb.Append("  Trusted CA Issuer Name: ").Append(this.caName).Append(nl);
+				sb.Append("  Trusted CA Public Key: ").Append(this.pubKey).AppendLine();
+				sb.Append("  Trusted CA Issuer Name: ").Append(this.caName).AppendLine();
 			}
 			else
 			{
-				sb.Append("  Trusted CA cert: ").Append(this.TrustedCert).Append(nl);
+				sb.Append("  Trusted CA cert: ").Append(this.TrustedCert).AppendLine();
 			}
 			if (nc != null)
 			{
-				sb.Append("  Name Constraints: ").Append(nc).Append(nl);
+				sb.Append("  Name Constraints: ").Append(nc).AppendLine();
 			}
 			return sb.ToString();
 		}
diff --git a/crypto/src/util/Platform.cs b/crypto/src/util/Platform.cs
index b25d76dae..7e79c64e1 100644
--- a/crypto/src/util/Platform.cs
+++ b/crypto/src/util/Platform.cs
@@ -31,8 +31,6 @@ namespace Org.BouncyCastle.Utilities
             return null == obj ? 0 : obj.GetHashCode();
         }
 
-        internal static readonly string NewLine = Environment.NewLine;
-
         internal static void Dispose(IDisposable d)
         {
             d.Dispose();
diff --git a/crypto/src/util/io/pem/PemWriter.cs b/crypto/src/util/io/pem/PemWriter.cs
index 87968a727..fbb8b0f2d 100644
--- a/crypto/src/util/io/pem/PemWriter.cs
+++ b/crypto/src/util/io/pem/PemWriter.cs
@@ -27,7 +27,7 @@ namespace Org.BouncyCastle.Utilities.IO.Pem
 				throw new ArgumentNullException("writer");
 
 			this.writer = writer;
-			this.nlLength = Platform.NewLine.Length;
+			this.nlLength = Environment.NewLine.Length;
 		}
 
 		public TextWriter Writer
diff --git a/crypto/src/x509/X509Certificate.cs b/crypto/src/x509/X509Certificate.cs
index 275b3f19e..75efdfbb1 100644
--- a/crypto/src/x509/X509Certificate.cs
+++ b/crypto/src/x509/X509Certificate.cs
@@ -565,24 +565,23 @@ namespace Org.BouncyCastle.X509
         public override string ToString()
         {
             StringBuilder buf = new StringBuilder();
-            string nl = Platform.NewLine;
 
-            buf.Append("  [0]         Version: ").Append(this.Version).Append(nl);
-            buf.Append("         SerialNumber: ").Append(this.SerialNumber).Append(nl);
-            buf.Append("             IssuerDN: ").Append(this.IssuerDN).Append(nl);
-            buf.Append("           Start Date: ").Append(this.NotBefore).Append(nl);
-            buf.Append("           Final Date: ").Append(this.NotAfter).Append(nl);
-            buf.Append("            SubjectDN: ").Append(this.SubjectDN).Append(nl);
-            buf.Append("           Public Key: ").Append(this.GetPublicKey()).Append(nl);
-            buf.Append("  Signature Algorithm: ").Append(this.SigAlgName).Append(nl);
+            buf.Append("  [0]         Version: ").Append(this.Version).AppendLine();
+            buf.Append("         SerialNumber: ").Append(this.SerialNumber).AppendLine();
+            buf.Append("             IssuerDN: ").Append(this.IssuerDN).AppendLine();
+            buf.Append("           Start Date: ").Append(this.NotBefore).AppendLine();
+            buf.Append("           Final Date: ").Append(this.NotAfter).AppendLine();
+            buf.Append("            SubjectDN: ").Append(this.SubjectDN).AppendLine();
+            buf.Append("           Public Key: ").Append(this.GetPublicKey()).AppendLine();
+            buf.Append("  Signature Algorithm: ").Append(this.SigAlgName).AppendLine();
 
             byte[] sig = this.GetSignature();
-            buf.Append("            Signature: ").Append(Hex.ToHexString(sig, 0, 20)).Append(nl);
+            buf.Append("            Signature: ").Append(Hex.ToHexString(sig, 0, 20)).AppendLine();
 
             for (int i = 20; i < sig.Length; i += 20)
             {
                 int len = System.Math.Min(20, sig.Length - i);
-                buf.Append("                       ").Append(Hex.ToHexString(sig, i, len)).Append(nl);
+                buf.Append("                       ").Append(Hex.ToHexString(sig, i, len)).AppendLine();
             }
 
             X509Extensions extensions = c.TbsCertificate.Extensions;
@@ -632,18 +631,18 @@ namespace Org.BouncyCastle.X509
                             {
                                 buf.Append(oid.Id);
                                 buf.Append(" value = ").Append(Asn1Dump.DumpAsString(obj));
-                                //buf.Append(" value = ").Append("*****").Append(nl);
+                                //buf.Append(" value = ").Append("*****").AppendLine();
                             }
                         }
                         catch (Exception)
                         {
                             buf.Append(oid.Id);
-                            //buf.Append(" value = ").Append(new string(Hex.encode(ext.getValue().getOctets()))).Append(nl);
+                            //buf.Append(" value = ").Append(new string(Hex.encode(ext.getValue().getOctets()))).AppendLine();
                             buf.Append(" value = ").Append("*****");
                         }
                     }
 
-                    buf.Append(nl);
+                    buf.AppendLine();
                 }
                 while (e.MoveNext());
             }
diff --git a/crypto/src/x509/X509Crl.cs b/crypto/src/x509/X509Crl.cs
index 921e9881b..8a7c51a1d 100644
--- a/crypto/src/x509/X509Crl.cs
+++ b/crypto/src/x509/X509Crl.cs
@@ -312,24 +312,23 @@ namespace Org.BouncyCastle.X509
 		public override string ToString()
 		{
 			StringBuilder buf = new StringBuilder();
-			string nl = Platform.NewLine;
 
-			buf.Append("              Version: ").Append(this.Version).Append(nl);
-			buf.Append("             IssuerDN: ").Append(this.IssuerDN).Append(nl);
-			buf.Append("          This update: ").Append(this.ThisUpdate).Append(nl);
-			buf.Append("          Next update: ").Append(this.NextUpdate).Append(nl);
-			buf.Append("  Signature Algorithm: ").Append(this.SigAlgName).Append(nl);
+			buf.Append("              Version: ").Append(this.Version).AppendLine();
+			buf.Append("             IssuerDN: ").Append(this.IssuerDN).AppendLine();
+			buf.Append("          This update: ").Append(this.ThisUpdate).AppendLine();
+			buf.Append("          Next update: ").Append(this.NextUpdate).AppendLine();
+			buf.Append("  Signature Algorithm: ").Append(this.SigAlgName).AppendLine();
 
 			byte[] sig = this.GetSignature();
 
 			buf.Append("            Signature: ");
-			buf.Append(Hex.ToHexString(sig, 0, 20)).Append(nl);
+			buf.Append(Hex.ToHexString(sig, 0, 20)).AppendLine();
 
 			for (int i = 20; i < sig.Length; i += 20)
 			{
 				int count = System.Math.Min(20, sig.Length - i);
 				buf.Append("                       ");
-				buf.Append(Hex.ToHexString(sig, i, count)).Append(nl);
+				buf.Append(Hex.ToHexString(sig, i, count)).AppendLine();
 			}
 
 			X509Extensions extensions = c.TbsCertList.Extensions;
@@ -340,7 +339,7 @@ namespace Org.BouncyCastle.X509
 
 				if (e.MoveNext())
 				{
-					buf.Append("           Extensions: ").Append(nl);
+					buf.Append("           Extensions: ").AppendLine();
 				}
 
 				do
@@ -357,7 +356,7 @@ namespace Org.BouncyCastle.X509
 						{
 							if (oid.Equals(X509Extensions.CrlNumber))
 							{
-								buf.Append(new CrlNumber(DerInteger.GetInstance(asn1Value).PositiveValue)).Append(nl);
+								buf.Append(new CrlNumber(DerInteger.GetInstance(asn1Value).PositiveValue)).AppendLine();
 							}
 							else if (oid.Equals(X509Extensions.DeltaCrlIndicator))
 							{
@@ -365,37 +364,37 @@ namespace Org.BouncyCastle.X509
 									"Base CRL: "
 									+ new CrlNumber(DerInteger.GetInstance(
 									asn1Value).PositiveValue))
-									.Append(nl);
+									.AppendLine();
 							}
 							else if (oid.Equals(X509Extensions.IssuingDistributionPoint))
 							{
-								buf.Append(IssuingDistributionPoint.GetInstance((Asn1Sequence) asn1Value)).Append(nl);
+								buf.Append(IssuingDistributionPoint.GetInstance((Asn1Sequence) asn1Value)).AppendLine();
 							}
 							else if (oid.Equals(X509Extensions.CrlDistributionPoints))
 							{
-								buf.Append(CrlDistPoint.GetInstance((Asn1Sequence) asn1Value)).Append(nl);
+								buf.Append(CrlDistPoint.GetInstance((Asn1Sequence) asn1Value)).AppendLine();
 							}
 							else if (oid.Equals(X509Extensions.FreshestCrl))
 							{
-								buf.Append(CrlDistPoint.GetInstance((Asn1Sequence) asn1Value)).Append(nl);
+								buf.Append(CrlDistPoint.GetInstance((Asn1Sequence) asn1Value)).AppendLine();
 							}
 							else
 							{
 								buf.Append(oid.Id);
 								buf.Append(" value = ").Append(
 									Asn1Dump.DumpAsString(asn1Value))
-									.Append(nl);
+									.AppendLine();
 							}
 						}
 						catch (Exception)
 						{
 							buf.Append(oid.Id);
-							buf.Append(" value = ").Append("*****").Append(nl);
+							buf.Append(" value = ").Append("*****").AppendLine();
 						}
 					}
 					else
 					{
-						buf.Append(nl);
+						buf.AppendLine();
 					}
 				}
 				while (e.MoveNext());
@@ -407,7 +406,7 @@ namespace Org.BouncyCastle.X509
 				foreach (X509CrlEntry entry in certSet)
 				{
 					buf.Append(entry);
-					buf.Append(nl);
+					buf.AppendLine();
 				}
 			}
 
diff --git a/crypto/src/x509/X509CrlEntry.cs b/crypto/src/x509/X509CrlEntry.cs
index 30e0da2db..87fc2e37a 100644
--- a/crypto/src/x509/X509CrlEntry.cs
+++ b/crypto/src/x509/X509CrlEntry.cs
@@ -165,11 +165,10 @@ namespace Org.BouncyCastle.X509
 		public override string ToString()
 		{
 			StringBuilder buf = new StringBuilder();
-			string nl = Platform.NewLine;
 
-			buf.Append("        userCertificate: ").Append(this.SerialNumber).Append(nl);
-			buf.Append("         revocationDate: ").Append(this.RevocationDate).Append(nl);
-			buf.Append("      certificateIssuer: ").Append(this.GetCertificateIssuer()).Append(nl);
+			buf.Append("        userCertificate: ").Append(this.SerialNumber).AppendLine();
+			buf.Append("         revocationDate: ").Append(this.RevocationDate).AppendLine();
+			buf.Append("      certificateIssuer: ").Append(this.GetCertificateIssuer()).AppendLine();
 
 			X509Extensions extensions = c.Extensions;
 
@@ -178,7 +177,7 @@ namespace Org.BouncyCastle.X509
 				var e = extensions.ExtensionOids.GetEnumerator();
 				if (e.MoveNext())
 				{
-					buf.Append("   crlEntryExtensions:").Append(nl);
+					buf.Append("   crlEntryExtensions:").AppendLine();
 
 					do
 					{
@@ -208,17 +207,17 @@ namespace Org.BouncyCastle.X509
 									buf.Append(oid.Id);
 									buf.Append(" value = ").Append(Asn1Dump.DumpAsString(obj));
 								}
-								buf.Append(nl);
+								buf.AppendLine();
 							}
 							catch (Exception)
 							{
 								buf.Append(oid.Id);
-								buf.Append(" value = ").Append("*****").Append(nl);
+								buf.Append(" value = ").Append("*****").AppendLine();
 							}
 						}
 						else
 						{
-							buf.Append(nl);
+							buf.AppendLine();
 						}
 					}
 					while (e.MoveNext());