Repository: mina-sshd Updated Branches: refs/heads/master 7f74b0c86 -> ce89260e6
Activated RegexpSingleline Checkstyle rule to detect trailing whitespace Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/ce89260e Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/ce89260e Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/ce89260e Branch: refs/heads/master Commit: ce89260e63bf0f7c61cd711ae889583025f7a175 Parents: 9ef29e4 Author: Goldstein Lyor <[email protected]> Authored: Wed Aug 29 09:29:57 2018 +0300 Committer: Goldstein Lyor <[email protected]> Committed: Wed Aug 29 09:30:23 2018 +0300 ---------------------------------------------------------------------- sshd-checkstyle.xml | 11 +++---- .../OpenSSHEd25519PrivateKeyEntryDecoder.java | 32 ++++++++++---------- .../forward/AbstractServerCloseTestSupport.java | 8 ++--- .../forward/ApacheServerApacheClientTest.java | 4 +-- .../testReadGlobalHostsConfigEntries.config.txt | 7 ++--- .../sshd/common/subsystem/sftp/SftpHelper.java | 2 +- 6 files changed, 31 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ce89260e/sshd-checkstyle.xml ---------------------------------------------------------------------- diff --git a/sshd-checkstyle.xml b/sshd-checkstyle.xml index f698bac..649e5e2 100644 --- a/sshd-checkstyle.xml +++ b/sshd-checkstyle.xml @@ -263,12 +263,6 @@ <module name="ArrayTypeStyle" /> <module name="FinalParameters" /> --> - <!-- - <module name="GenericIllegalRegexp"> - <property name="format" value="\s+$" /> - <property name="message" value="Line has trailing spaces." /> - </module> - --> <!-- DISABLED <module name="TodoComment"> <property name="format" value="TODO" /> @@ -310,6 +304,11 @@ <property name="fileExtensions" value="java"/> </module> <!-- <module name="RegexpHeader" /> --> + <module name="RegexpSingleline"> + <property name="format" value="\s+$"/> + <property name="message" value="Trailing whitespace"/> + <!-- <property name="fileExtensions" value="......" /> --> + </module> <module name="FileLength"> <property name="max" value="4096" /> </module> http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ce89260e/sshd-core/src/main/java/org/apache/sshd/common/util/security/eddsa/OpenSSHEd25519PrivateKeyEntryDecoder.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/security/eddsa/OpenSSHEd25519PrivateKeyEntryDecoder.java b/sshd-core/src/main/java/org/apache/sshd/common/util/security/eddsa/OpenSSHEd25519PrivateKeyEntryDecoder.java index 7e839e4..4888818 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/util/security/eddsa/OpenSSHEd25519PrivateKeyEntryDecoder.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/util/security/eddsa/OpenSSHEd25519PrivateKeyEntryDecoder.java @@ -68,67 +68,67 @@ public class OpenSSHEd25519PrivateKeyEntryDecoder extends AbstractPrivateKeyEntr if (!SecurityUtils.isEDDSACurveSupported()) { throw new NoSuchAlgorithmException(SecurityUtils.EDDSA + " provider not supported"); } - + // ed25519 bernstein naming: pk .. public key, sk .. secret key // we expect to find two byte arrays with the following structure (type:size): // [pk:32], [sk:32,pk:32] - + byte[] pk = KeyEntryResolver.readRLEBytes(keyData); byte[] keypair = KeyEntryResolver.readRLEBytes(keyData); - + if (pk.length != PK_SIZE) { throw new InvalidKeyException(String.format(Locale.ENGLISH, "Unexpected pk size: %s (expected %s)", pk.length, PK_SIZE)); } - + if (keypair.length != KEYPAIR_SIZE) { throw new InvalidKeyException(String.format(Locale.ENGLISH, "Unexpected keypair size: %s (expected %s)", keypair.length, KEYPAIR_SIZE)); } - + byte[] sk = Arrays.copyOf(keypair, SK_SIZE); - + // verify that the keypair contains the expected pk // yes, it's stored redundant, this seems to mimic the output structure of the keypair generation interface if (!Arrays.equals(pk, Arrays.copyOfRange(keypair, SK_SIZE, KEYPAIR_SIZE))) { throw new InvalidKeyException("Keypair did not contain the public key."); } - + // create the private key EdDSAParameterSpec params = EdDSANamedCurveTable.getByName(EdDSASecurityProviderUtils.CURVE_ED25519_SHA512); EdDSAPrivateKey privateKey = generatePrivateKey(new EdDSAPrivateKeySpec(sk, params)); - + // the private key class contains the calculated public key (Abyte) // pointers to the corresponding code: // EdDSAPrivateKeySpec.EdDSAPrivateKeySpec(byte[], EdDSAParameterSpec): A = spec.getB().scalarMultiply(a); // EdDSAPrivateKey.EdDSAPrivateKey(EdDSAPrivateKeySpec): this.Abyte = this.A.toByteArray(); - + // we can now verify the generated pk matches the one we read if (!Arrays.equals(privateKey.getAbyte(), pk)) { throw new InvalidKeyException("The provided pk does NOT match the computed pk for the given sk."); } - + return privateKey; } @Override public String encodePrivateKey(OutputStream s, EdDSAPrivateKey key) throws IOException { Objects.requireNonNull(key, "No private key provided"); - + // ed25519 bernstein naming: pk .. public key, sk .. secret key // we are expected to write the following arrays (type:size): // [pk:32], [sk:32,pk:32] - + byte[] sk = key.getSeed(); byte[] pk = key.getAbyte(); - + Objects.requireNonNull(sk, "No seed"); - + byte[] keypair = new byte[KEYPAIR_SIZE]; System.arraycopy(sk, 0, keypair, 0, SK_SIZE); System.arraycopy(pk, 0, keypair, SK_SIZE, PK_SIZE); - + KeyEntryResolver.writeRLEBytes(s, pk); KeyEntryResolver.writeRLEBytes(s, keypair); - + return KeyPairProvider.SSH_ED25519; } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ce89260e/sshd-core/src/test/java/org/apache/sshd/common/forward/AbstractServerCloseTestSupport.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/common/forward/AbstractServerCloseTestSupport.java b/sshd-core/src/test/java/org/apache/sshd/common/forward/AbstractServerCloseTestSupport.java index ab5194f..87a66fc 100644 --- a/sshd-core/src/test/java/org/apache/sshd/common/forward/AbstractServerCloseTestSupport.java +++ b/sshd-core/src/test/java/org/apache/sshd/common/forward/AbstractServerCloseTestSupport.java @@ -191,13 +191,13 @@ public abstract class AbstractServerCloseTestSupport extends BaseTestSupport { protected abstract int startLocalPF() throws Exception; - protected boolean hasLocalPFStarted(int port) { + protected boolean hasLocalPFStarted(int port) { return true; - } + } protected boolean hasRemotePFStarted(int port) { return true; - } + } /* * Connect to test server via port forward and read real quick with one big @@ -246,7 +246,7 @@ public abstract class AbstractServerCloseTestSupport extends BaseTestSupport { public void testLocalPortForwardLoop() throws Exception { readInLoop(startLocalPF()); } - + @Test public void testHasLocalPortForwardingStarted() throws Exception { int port = startLocalPF(); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ce89260e/sshd-core/src/test/java/org/apache/sshd/common/forward/ApacheServerApacheClientTest.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/common/forward/ApacheServerApacheClientTest.java b/sshd-core/src/test/java/org/apache/sshd/common/forward/ApacheServerApacheClientTest.java index ed0a57e..054db03 100644 --- a/sshd-core/src/test/java/org/apache/sshd/common/forward/ApacheServerApacheClientTest.java +++ b/sshd-core/src/test/java/org/apache/sshd/common/forward/ApacheServerApacheClientTest.java @@ -111,12 +111,12 @@ public class ApacheServerApacheClientTest extends AbstractServerCloseTestSupport SshdSocketAddress bound = session.startLocalPortForwarding(local, remote); return bound.getPort(); } - + @Override protected boolean hasLocalPFStarted(int port) { return session.isLocalPortForwardingStartedForPort(port); } - + @Override protected boolean hasRemotePFStarted(int port) { return session.isRemotePortForwardingStartedForPort(port); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ce89260e/sshd-core/src/test/resources/org/apache/sshd/client/config/hosts/testReadGlobalHostsConfigEntries.config.txt ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/resources/org/apache/sshd/client/config/hosts/testReadGlobalHostsConfigEntries.config.txt b/sshd-core/src/test/resources/org/apache/sshd/client/config/hosts/testReadGlobalHostsConfigEntries.config.txt index a0be861..5f772cd 100644 --- a/sshd-core/src/test/resources/org/apache/sshd/client/config/hosts/testReadGlobalHostsConfigEntries.config.txt +++ b/sshd-core/src/test/resources/org/apache/sshd/client/config/hosts/testReadGlobalHostsConfigEntries.config.txt @@ -12,12 +12,11 @@ Host *.apache.org # Port override Host *.github.com Port 443 - + # Host name override Host 10.*.*.* HostName 7.3.6.5 - + # Identity override Host 192.168.*.* - IdentityFile ~/.ssh/internal.key - \ No newline at end of file + IdentityFile ~/.ssh/internal.key http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ce89260e/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpHelper.java ---------------------------------------------------------------------- diff --git a/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpHelper.java b/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpHelper.java index d0d87e7..8a6f9a3 100644 --- a/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpHelper.java +++ b/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpHelper.java @@ -81,7 +81,7 @@ public final class SftpHelper { public static final boolean DEFAULT_APPEND_END_OF_LIST_INDICATOR = true; public static final Map<Integer, String> DEFAULT_SUBSTATUS_MESSAGE; - + static { Map<Integer, String> map = new TreeMap<>(Comparator.naturalOrder()); map.put(SftpConstants.SSH_FX_OK, "Success");
