diff --git a/crypto/src/util/ssh/OpenSSHPrivateKeyUtil.cs b/crypto/src/crypto/util/OpenSshPrivateKeyUtilities.cs
index 0ddd90773..187ecc39e 100644
--- a/crypto/src/util/ssh/OpenSSHPrivateKeyUtil.cs
+++ b/crypto/src/crypto/util/OpenSshPrivateKeyUtilities.cs
@@ -5,12 +5,12 @@ using Org.BouncyCastle.Asn1.Nist;
using Org.BouncyCastle.Asn1.Pkcs;
using Org.BouncyCastle.Asn1.Sec;
using Org.BouncyCastle.Asn1.X9;
-using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Math;
using Org.BouncyCastle.Pkcs;
+using Org.BouncyCastle.Utilities;
-namespace Org.BouncyCastle.Utilities.SSH
+namespace Org.BouncyCastle.Crypto.Utilities
{
public static class OpenSshPrivateKeyUtilities
{
@@ -94,7 +94,7 @@ namespace Org.BouncyCastle.Utilities.SSH
pkBuild.WriteBlock(Arrays.Concatenate(ed25519PrivateKey.GetEncoded(), pubKeyEncoded));
// Comment for this private key (empty)
- pkBuild.WriteString("");
+ pkBuild.WriteString("");
builder.WriteBlock(pkBuild.GetPaddedBytes());
}
@@ -177,7 +177,7 @@ namespace Org.BouncyCastle.Utilities.SSH
{
SshBuffer kIn = new SshBuffer(AUTH_MAGIC, blob);
- String cipherName = kIn.ReadString();
+ string cipherName = kIn.ReadString();
if (!"none".Equals(cipherName))
{
throw new InvalidOperationException("encrypted keys not supported");
@@ -214,7 +214,7 @@ namespace Org.BouncyCastle.Utilities.SSH
throw new InvalidOperationException("private key check values are not the same");
}
- String keyType = pkIn.ReadString();
+ string keyType = pkIn.ReadString();
if ("ssh-ed25519".Equals(keyType))
{
@@ -231,7 +231,7 @@ namespace Org.BouncyCastle.Utilities.SSH
}
else if (keyType.StartsWith("ecdsa"))
{
- DerObjectIdentifier oid = SshNamedCurves.GetByName(Strings.FromByteArray(pkIn.ReadBlock())) ??
+ DerObjectIdentifier oid = SshNamedCurves.GetByName(Strings.FromByteArray(pkIn.ReadBlock())) ??
throw new InvalidOperationException("OID not found for: " + keyType);
X9ECParameters curveParams = NistNamedCurves.GetByOid(oid) ?? throw new InvalidOperationException("Curve not found for: " + oid);
@@ -287,16 +287,16 @@ namespace Org.BouncyCastle.Utilities.SSH
/**
* allIntegers returns true if the sequence holds only DerInteger types.
**/
- private static Boolean AllIntegers(Asn1Sequence sequence)
+ private static bool AllIntegers(Asn1Sequence sequence)
{
for (int t = 0; t < sequence.Count; t++)
{
if (!(sequence[t] is DerInteger))
- {
- return false;
+ {
+ return false;
+ }
}
+ return true;
}
- return true;
}
}
-}
diff --git a/crypto/src/util/ssh/OpenSSHPublicKeyUtil.cs b/crypto/src/crypto/util/OpenSshPublicKeyUtilities.cs
index 02e6928e0..cdb16b06a 100644
--- a/crypto/src/util/ssh/OpenSSHPublicKeyUtil.cs
+++ b/crypto/src/crypto/util/OpenSshPublicKeyUtilities.cs
@@ -2,18 +2,17 @@
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.X9;
-using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Math;
-namespace Org.BouncyCastle.Utilities.SSH
+namespace Org.BouncyCastle.Crypto.Utilities
{
public static class OpenSshPublicKeyUtilities
{
- private static readonly String RSA = "ssh-rsa";
- private static readonly String ECDSA = "ecdsa";
- private static readonly String ED_25519 = "ssh-ed25519";
- private static readonly String DSS = "ssh-dss";
+ private static readonly string RSA = "ssh-rsa";
+ private static readonly string ECDSA = "ecdsa";
+ private static readonly string ED_25519 = "ssh-ed25519";
+ private static readonly string DSS = "ssh-dss";
/**
* Parse a public key.
@@ -67,7 +66,7 @@ namespace Org.BouncyCastle.Utilities.SSH
//
// checked for named curve parameters..
//
- String name = SshNamedCurves.GetNameForParameters(ecPublicKey.Parameters);
+ string name = SshNamedCurves.GetNameForParameters(ecPublicKey.Parameters);
if (name == null)
{
@@ -130,9 +129,9 @@ namespace Org.BouncyCastle.Utilities.SSH
}
else if (magic.StartsWith(ECDSA))
{
- String curveName = buffer.ReadString();
+ string curveName = buffer.ReadString();
DerObjectIdentifier oid = SshNamedCurves.GetByName(curveName);
- X9ECParameters x9ECParameters = SshNamedCurves.GetParameters(oid) ??
+ X9ECParameters x9ECParameters = SshNamedCurves.GetParameters(oid) ??
throw new InvalidOperationException("unable to find curve for " + magic + " using curve name " + curveName);
var curve = x9ECParameters.Curve;
byte[] pointRaw = buffer.ReadBlock();
diff --git a/crypto/src/util/ssh/SSHBuffer.cs b/crypto/src/crypto/util/SshBuffer.cs
index 795641032..094b85364 100644
--- a/crypto/src/util/ssh/SSHBuffer.cs
+++ b/crypto/src/crypto/util/SshBuffer.cs
@@ -1,8 +1,9 @@
using System;
using Org.BouncyCastle.Math;
+using Org.BouncyCastle.Utilities;
-namespace Org.BouncyCastle.Utilities.SSH
+namespace Org.BouncyCastle.Crypto.Utilities
{
internal class SshBuffer
{
@@ -30,7 +31,7 @@ namespace Org.BouncyCastle.Utilities.SSH
public int ReadU32()
{
- if (pos > (buffer.Length - 4))
+ if (pos > buffer.Length - 4)
{
throw new ArgumentOutOfRangeException("4 bytes for U32 exceeds buffer.");
}
@@ -38,12 +39,12 @@ namespace Org.BouncyCastle.Utilities.SSH
int i = (buffer[pos++] & 0xFF) << 24;
i |= (buffer[pos++] & 0xFF) << 16;
i |= (buffer[pos++] & 0xFF) << 8;
- i |= (buffer[pos++] & 0xFF);
+ i |= buffer[pos++] & 0xFF;
return i;
}
- public String ReadString()
+ public string ReadString()
{
return Strings.FromByteArray(ReadBlock());
}
@@ -56,7 +57,7 @@ namespace Org.BouncyCastle.Utilities.SSH
return new byte[0];
}
- if (pos > (buffer.Length - len))
+ if (pos > buffer.Length - len)
{
throw new ArgumentException("not enough data for block");
}
@@ -68,7 +69,7 @@ namespace Org.BouncyCastle.Utilities.SSH
public void SkipBlock()
{
int len = ReadU32();
- if (pos > (buffer.Length - len))
+ if (pos > buffer.Length - len)
{
throw new ArgumentException("not enough data for block");
}
@@ -89,7 +90,7 @@ namespace Org.BouncyCastle.Utilities.SSH
return new byte[0];
}
- if (pos > (buffer.Length - len))
+ if (pos > buffer.Length - len)
{
throw new ArgumentException("not enough data for block");
}
@@ -143,7 +144,7 @@ namespace Org.BouncyCastle.Utilities.SSH
return Arrays.Clone(buffer);
}
- public Boolean HasRemaining()
+ public bool HasRemaining()
{
return pos < buffer.Length;
}
diff --git a/crypto/src/util/ssh/SSHBuilder.cs b/crypto/src/crypto/util/SshBuilder.cs
index 24121d0d8..9f2f35360 100644
--- a/crypto/src/util/ssh/SSHBuilder.cs
+++ b/crypto/src/crypto/util/SshBuilder.cs
@@ -2,8 +2,9 @@
using System.IO;
using Org.BouncyCastle.Math;
+using Org.BouncyCastle.Utilities;
-namespace Org.BouncyCastle.Utilities.SSH
+namespace Org.BouncyCastle.Crypto.Utilities
{
internal class SshBuilder
{
@@ -11,9 +12,9 @@ namespace Org.BouncyCastle.Utilities.SSH
public void U32(uint value)
{
- bos.WriteByte(Convert.ToByte((value >> 24) & 0xFF));
- bos.WriteByte(Convert.ToByte((value >> 16) & 0xFF));
- bos.WriteByte(Convert.ToByte((value >> 8) & 0xFF));
+ bos.WriteByte(Convert.ToByte(value >> 24 & 0xFF));
+ bos.WriteByte(Convert.ToByte(value >> 16 & 0xFF));
+ bos.WriteByte(Convert.ToByte(value >> 8 & 0xFF));
bos.WriteByte(Convert.ToByte(value & 0xFF));
}
@@ -47,7 +48,7 @@ namespace Org.BouncyCastle.Utilities.SSH
}
}
- public void WriteString(String str)
+ public void WriteString(string str)
{
WriteBlock(Strings.ToByteArray(str));
}
diff --git a/crypto/src/util/ssh/SSHNamedCurves.cs b/crypto/src/crypto/util/SshNamedCurves.cs
index 6839627b8..d97c2476e 100644
--- a/crypto/src/util/ssh/SSHNamedCurves.cs
+++ b/crypto/src/crypto/util/SshNamedCurves.cs
@@ -9,7 +9,7 @@ using Org.BouncyCastle.Crypto.EC;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Math.EC;
-namespace Org.BouncyCastle.Utilities.SSH
+namespace Org.BouncyCastle.Crypto.Utilities
{
public class SshNamedCurves
{
@@ -31,7 +31,7 @@ namespace Org.BouncyCastle.Utilities.SSH
};
- private static readonly Dictionary<string, string> CurveNameToSSHName =
+ private static readonly Dictionary<string, string> CurveNameToSSHName =
new Dictionary<string, string>
{
{"secp256r1", "nistp256"},
@@ -48,7 +48,7 @@ namespace Org.BouncyCastle.Utilities.SSH
{"sect571k1", "nistt571"}
};
- private static readonly Dictionary<ECCurve, string> CurveMap =
+ private static readonly Dictionary<ECCurve, string> CurveMap =
CustomNamedCurves.Names.ToDictionary(k => CustomNamedCurves.GetByNameLazy(k).Curve, v => v);
private static readonly Dictionary<DerObjectIdentifier, string> OidToName =
diff --git a/crypto/test/src/crypto/test/OpenSSHKeyParsingTests.cs b/crypto/test/src/crypto/test/OpenSshKeyParsingTest.cs
index a647ba652..46cac0f4c 100644
--- a/crypto/test/src/crypto/test/OpenSSHKeyParsingTests.cs
+++ b/crypto/test/src/crypto/test/OpenSshKeyParsingTest.cs
@@ -6,12 +6,12 @@ using NUnit.Framework;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Crypto.Signers;
+using Org.BouncyCastle.Crypto.Utilities;
using Org.BouncyCastle.Math;
using Org.BouncyCastle.Security;
using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.Utilities.Encoders;
using Org.BouncyCastle.Utilities.IO.Pem;
-using Org.BouncyCastle.Utilities.SSH;
namespace Org.BouncyCastle.Crypto.Tests
{
|