summary refs log tree commit diff
path: root/crypto/src/x509
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/x509
parentGenerics migration complete (diff)
downloadBouncyCastle.NET-ed25519-a395a34a769d3c7e6616129f4832b7014dbbfe98.tar.xz
Cleanup NewLine handling
Diffstat (limited to 'crypto/src/x509')
-rw-r--r--crypto/src/x509/X509Certificate.cs27
-rw-r--r--crypto/src/x509/X509Crl.cs35
-rw-r--r--crypto/src/x509/X509CrlEntry.cs15
3 files changed, 37 insertions, 40 deletions
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());