You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2018/10/31 05:03:10 UTC
[2/5] mina-sshd git commit: [SSHD-757] Added initial support for
reading PGP private key files
[SSHD-757] Added initial support for reading PGP private key files
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/259ee8c7
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/259ee8c7
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/259ee8c7
Branch: refs/heads/master
Commit: 259ee8c7fffd7355d08905d3bb69ab4ed31a6e0a
Parents: 403402f
Author: Lyor Goldstein <ly...@gmail.com>
Authored: Fri Sep 7 18:28:49 2018 +0300
Committer: Lyor Goldstein <lg...@apache.org>
Committed: Wed Oct 31 07:02:56 2018 +0200
----------------------------------------------------------------------
README.md | 38 ++
assembly/pom.xml | 5 +
assembly/src/main/components/modules.xml | 6 +-
assembly/src/main/legal/licenses/jpgpj.txt | 21 +
assembly/src/main/legal/notices.xml | 17 +
pom.xml | 1 +
.../common/config/keys/KeyEntryResolver.java | 15 +-
.../loader/AbstractKeyPairResourceParser.java | 5 +-
.../keys/loader/KeyPairResourceLoader.java | 35 +-
.../keys/loader/KeyPairResourceParser.java | 21 +-
.../openssh/OpenSSHKeyPairResourceParser.java | 28 +-
.../pem/AbstractPEMResourceKeyPairParser.java | 7 +-
.../loader/pem/DSSPEMResourceKeyPairParser.java | 2 +-
.../pem/ECDSAPEMResourceKeyPairParser.java | 4 +-
.../pem/PKCS8PEMResourceKeyPairParser.java | 6 +-
.../loader/pem/RSAPEMResourceKeyPairParser.java | 2 +-
.../BouncyCastleKeyPairResourceParser.java | 7 +-
sshd-openpgp/pom.xml | 104 +++++
.../openpgp/PGPKeyPairResourceParser.java | 445 +++++++++++++++++++
sshd-openpgp/src/main/resources/.gitignore | 0
.../openpgp/PGPKeyPairResourceParserTest.java | 186 ++++++++
.../src/test/resources/log4j.properties | 38 ++
.../loader/openpgp/DSA-2048-gpg4win-3.1.3.asc | 25 ++
.../keys/loader/openpgp/EC-348-v1p0-public.asc | 27 ++
.../loader/openpgp/RSA-2048-v1p0-public.asc | 56 +++
.../loader/openpgp/RSA-2048-v1p6p1-public.asc | 18 +
.../loader/openpgp/RSA-4096-vp2p0p8-public.asc | 76 ++++
.../loader/openpgp/ed25519-gpg4win-3.1.3.asc | 9 +
...secret-passphrase-DSA-2048-gpg4win-3.1.3.gpg | 27 ++
...er-secret-passphrase-EC-384-v1p0-private.gpg | 32 ++
...-secret-passphrase-RSA-2048-v1p0-private.gpg | 99 +++++
...ecret-passphrase-RSA-2048-v1p6p1-private.gpg | 32 ++
...ecret-passphrase-RSA-4096-v2p0p8-private.gpg | 133 ++++++
...-secret-passphrase-ed25519-gpg4win-3.1.3.gpg | 11 +
34 files changed, 1482 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index e739438..c5edc53 100644
--- a/README.md
+++ b/README.md
@@ -187,6 +187,8 @@ The code contains support for reading _ed25519_ [OpenSSH formatted private keys]
* *sshd-putty* - contains code that can parse [PUTTY](https://www.putty.org/) key files.
+* *sshd-openpgp* - contains code that can parse [OpenPGP](https://www.openpgp.org/) key files (with some limitations - see relevant section)
+
* *sshd-cli* - contains simple templates for command-line client/server - used to provide look-and-feel similar to the Linux *ssh/sshd* commands.
* *sshd-contrib* - **experimental** code that is currently under review and may find its way into one of the other artifacts
@@ -1849,6 +1851,42 @@ be included as an extra dependency:
</dependency>
```
+### [OpenPGP](https://www.openpgp.org/)
+
+The code contains the _sshd-openpgp_ module that enables using _OpenPGP_ private key files as identity providers.
+
+```xml
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-openpgp</artifactId>
+ <version>...same version as the rest of the artifacts...</version>
+ </dependency>
+```
+
+The [support](https://issues.apache.org/jira/browse/SSHD-757) for it is currently still in its infancy, and therefore
+this feature should be considered **experimental** for the time being. However, within its limitations it supports
+
+* RSA keys
+* DSA keys
+* ECDSA keys
+
+(*) For now `ed25519` keys are not supported by this module.
+
+The code reads **all** the available key pairs in the key file without any distinction between encryption, decryption,
+authentication or signature ones.
+
+This code relies on the [jpgpgj](https://github.com/justinludwig/jpgpj) support module
+
+```xml
+ <dependency>
+ <groupId>org.c02e.jpgpj</groupId>
+ <artifactId>jpgpj</artifactId>
+ <version>0.5</version>
+ </dependency>
+```
+
+(which in turn automatically uses _Bouncycastle_ - so if one does not want _Bouncycastle_ one cannot use this module).
+
## Useful extra components in _sshd-contrib_
* `InteractivePasswordIdentityProvider` - helps implement a `PasswordIdentityProvider` by delegating calls
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/assembly/pom.xml
----------------------------------------------------------------------
diff --git a/assembly/pom.xml b/assembly/pom.xml
index 9d65f2d..f38d050 100644
--- a/assembly/pom.xml
+++ b/assembly/pom.xml
@@ -100,6 +100,11 @@
</dependency>
<dependency>
<groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-openpgp</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
<artifactId>sshd-spring-sftp</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/assembly/src/main/components/modules.xml
----------------------------------------------------------------------
diff --git a/assembly/src/main/components/modules.xml b/assembly/src/main/components/modules.xml
index 461155b..3b34d7b 100644
--- a/assembly/src/main/components/modules.xml
+++ b/assembly/src/main/components/modules.xml
@@ -24,6 +24,7 @@
<exclude>org.apache.sshd:sshd-ldap</exclude>
<exclude>org.apache.sshd:sshd-contrib</exclude>
<exclude>org.apache.sshd:sshd-putty</exclude>
+ <exclude>org.apache.sshd:sshd-openpgp</exclude>
<exclude>org.apache.sshd:sshd-spring-sftp</exclude>
<exclude>org.springframework:*</exclude>
<exclude>org.springframework.retry:*</exclude>
@@ -34,6 +35,7 @@
<exclude>org.eclipse.jgit:*</exclude>
<exclude>com.jcraft:*</exclude>
<exclude>com.googlecode.javaewah:JavaEWAH</exclude>
+ <exclude>org.c02e.jpgpj:jpgpj</exclude>
</excludes>
<outputDirectory>lib</outputDirectory>
<useProjectArtifact>false</useProjectArtifact>
@@ -46,6 +48,7 @@
<include>org.apache.sshd:sshd-contrib</include>
<include>org.apache.sshd:sshd-putty</include>
<include>org.apache.sshd:sshd-spring-sftp</include>
+ <include>org.apache.sshd:sshd-openpgp</include>
</includes>
<outputDirectory>extras</outputDirectory>
<useProjectArtifact>false</useProjectArtifact>
@@ -60,7 +63,8 @@
<include>org.reactivestreams:*</include>
<include>commons-io:commons-io</include>
<include>com.jcraft:*</include>
- <include>com.googlecode.javaewah:JavaEWAH</include>
+ <include>com.googlecode.javaewah:JavaEWAH</include>
+ <include>org.c02e.jpgpj:jpgpj</include>
</includes>
<outputDirectory>dependencies</outputDirectory>
<useProjectArtifact>false</useProjectArtifact>
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/assembly/src/main/legal/licenses/jpgpj.txt
----------------------------------------------------------------------
diff --git a/assembly/src/main/legal/licenses/jpgpj.txt b/assembly/src/main/legal/licenses/jpgpj.txt
new file mode 100644
index 0000000..f47901d
--- /dev/null
+++ b/assembly/src/main/legal/licenses/jpgpj.txt
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2016 Justin Ludwig
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/assembly/src/main/legal/notices.xml
----------------------------------------------------------------------
diff --git a/assembly/src/main/legal/notices.xml b/assembly/src/main/legal/notices.xml
index e03833a..48235b3 100644
--- a/assembly/src/main/legal/notices.xml
+++ b/assembly/src/main/legal/notices.xml
@@ -171,4 +171,21 @@
</licenses>
</project>
</supplement>
+ <supplement>
+ <project>
+ <groupId>org.c02e.jpgpj</groupId>
+ <artifactId>jpgpj</artifactId>
+ <name>jpjpj</name>
+ <organization>
+ <name>jpgpj</name>
+ <url>https://github.com/justinludwig/jpgpj</url>
+ </organization>
+ <licenses>
+ <license>
+ <name>MIT License</name>
+ <url>https://raw.githubusercontent.com/justinludwig/jpgpj/master/LICENSE</url>
+ </license>
+ </licenses>
+ </project>
+ </supplement>
</supplementalDataModels>
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a67ae3b..5bb5762 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1324,6 +1324,7 @@
<modules>
<module>sshd-common</module>
<module>sshd-putty</module>
+ <module>sshd-openpgp</module>
<module>sshd-core</module>
<module>sshd-mina</module>
<module>sshd-netty</module>
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyEntryResolver.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyEntryResolver.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyEntryResolver.java
index 2dd52d1..8b6dcc8 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyEntryResolver.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyEntryResolver.java
@@ -41,7 +41,8 @@ import org.apache.sshd.common.util.io.IoUtils;
* @param <PRV> Type of {@link PrivateKey}
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public interface KeyEntryResolver<PUB extends PublicKey, PRV extends PrivateKey> extends IdentityResourceLoader<PUB, PRV> {
+public interface KeyEntryResolver<PUB extends PublicKey, PRV extends PrivateKey>
+ extends IdentityResourceLoader<PUB, PRV> {
/**
* @param keySize Key size in bits
* @return A {@link KeyPair} with the specified key size
@@ -72,10 +73,12 @@ public interface KeyEntryResolver<PUB extends PublicKey, PRV extends PrivateKey>
if (pubOriginal != null) {
Class<?> orgType = pubOriginal.getClass();
if (!pubExpected.isAssignableFrom(orgType)) {
- throw new InvalidKeyException("Mismatched public key types: expected=" + pubExpected.getSimpleName() + ", actual=" + orgType.getSimpleName());
+ throw new InvalidKeyException(
+ "Mismatched public key types: expected=" + pubExpected.getSimpleName() + ", actual=" + orgType.getSimpleName());
}
- pubCloned = clonePublicKey(pubExpected.cast(pubOriginal));
+ PUB castPub = pubExpected.cast(pubOriginal);
+ pubCloned = clonePublicKey(castPub);
}
PRV prvCloned = null;
@@ -84,10 +87,12 @@ public interface KeyEntryResolver<PUB extends PublicKey, PRV extends PrivateKey>
if (prvOriginal != null) {
Class<?> orgType = prvOriginal.getClass();
if (!prvExpected.isAssignableFrom(orgType)) {
- throw new InvalidKeyException("Mismatched private key types: expected=" + prvExpected.getSimpleName() + ", actual=" + orgType.getSimpleName());
+ throw new InvalidKeyException(
+ "Mismatched private key types: expected=" + prvExpected.getSimpleName() + ", actual=" + orgType.getSimpleName());
}
- prvCloned = clonePrivateKey(prvExpected.cast(prvOriginal));
+ PRV castPrv = prvExpected.cast(prvOriginal);
+ prvCloned = clonePrivateKey(castPrv);
}
return new KeyPair(pubCloned, prvCloned);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AbstractKeyPairResourceParser.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AbstractKeyPairResourceParser.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AbstractKeyPairResourceParser.java
index a83bf68..e9ad24e 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AbstractKeyPairResourceParser.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AbstractKeyPairResourceParser.java
@@ -78,7 +78,8 @@ public abstract class AbstractKeyPairResourceParser extends AbstractLoggingBean
}
@Override
- public boolean canExtractKeyPairs(String resourceKey, List<String> lines) throws IOException, GeneralSecurityException {
+ public boolean canExtractKeyPairs(String resourceKey, List<String> lines)
+ throws IOException, GeneralSecurityException {
return KeyPairResourceParser.containsMarkerLine(lines, getBeginners());
}
@@ -136,7 +137,7 @@ public abstract class AbstractKeyPairResourceParser extends AbstractLoggingBean
*/
public Collection<KeyPair> extractKeyPairs(
String resourceKey, String beginMarker, String endMarker, FilePasswordProvider passwordProvider, List<String> lines)
- throws IOException, GeneralSecurityException {
+ throws IOException, GeneralSecurityException {
return extractKeyPairs(resourceKey, beginMarker, endMarker, passwordProvider, KeyPairResourceParser.extractDataBytes(lines));
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/KeyPairResourceLoader.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/KeyPairResourceLoader.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/KeyPairResourceLoader.java
index 659870f..00c53cf 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/KeyPairResourceLoader.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/KeyPairResourceLoader.java
@@ -59,13 +59,15 @@ public interface KeyPairResourceLoader {
*/
KeyPairResourceLoader EMPTY = (resourceKey, passwordProvider, lines) -> Collections.emptyList();
- default Collection<KeyPair> loadKeyPairs(Path path, FilePasswordProvider passwordProvider, OpenOption... options)
- throws IOException, GeneralSecurityException {
+ default Collection<KeyPair> loadKeyPairs(
+ Path path, FilePasswordProvider passwordProvider, OpenOption... options)
+ throws IOException, GeneralSecurityException {
return loadKeyPairs(path, passwordProvider, StandardCharsets.UTF_8, options);
}
- default Collection<KeyPair> loadKeyPairs(Path path, FilePasswordProvider passwordProvider, Charset cs, OpenOption... options)
- throws IOException, GeneralSecurityException {
+ default Collection<KeyPair> loadKeyPairs(
+ Path path, FilePasswordProvider passwordProvider, Charset cs, OpenOption... options)
+ throws IOException, GeneralSecurityException {
try (InputStream stream = Files.newInputStream(path, options)) {
return loadKeyPairs(path.toString(), passwordProvider, stream, cs);
}
@@ -83,35 +85,40 @@ public interface KeyPairResourceLoader {
}
}
- default Collection<KeyPair> loadKeyPairs(String resourceKey, FilePasswordProvider passwordProvider, String data)
- throws IOException, GeneralSecurityException {
+ default Collection<KeyPair> loadKeyPairs(
+ String resourceKey, FilePasswordProvider passwordProvider, String data)
+ throws IOException, GeneralSecurityException {
try (Reader reader = new StringReader((data == null) ? "" : data)) {
return loadKeyPairs(resourceKey, passwordProvider, reader);
}
}
- default Collection<KeyPair> loadKeyPairs(String resourceKey, FilePasswordProvider passwordProvider, InputStream stream)
- throws IOException, GeneralSecurityException {
+ default Collection<KeyPair> loadKeyPairs(
+ String resourceKey, FilePasswordProvider passwordProvider, InputStream stream)
+ throws IOException, GeneralSecurityException {
return loadKeyPairs(resourceKey, passwordProvider, stream, StandardCharsets.UTF_8);
}
- default Collection<KeyPair> loadKeyPairs(String resourceKey, FilePasswordProvider passwordProvider, InputStream stream, Charset cs)
- throws IOException, GeneralSecurityException {
+ default Collection<KeyPair> loadKeyPairs(
+ String resourceKey, FilePasswordProvider passwordProvider, InputStream stream, Charset cs)
+ throws IOException, GeneralSecurityException {
try (Reader reader = new InputStreamReader(
Objects.requireNonNull(stream, "No stream instance"), Objects.requireNonNull(cs, "No charset"))) {
return loadKeyPairs(resourceKey, passwordProvider, reader);
}
}
- default Collection<KeyPair> loadKeyPairs(String resourceKey, FilePasswordProvider passwordProvider, Reader r)
- throws IOException, GeneralSecurityException {
+ default Collection<KeyPair> loadKeyPairs(
+ String resourceKey, FilePasswordProvider passwordProvider, Reader r)
+ throws IOException, GeneralSecurityException {
try (BufferedReader br = new BufferedReader(Objects.requireNonNull(r, "No reader instance"), IoUtils.DEFAULT_COPY_SIZE)) {
return loadKeyPairs(resourceKey, passwordProvider, br);
}
}
- default Collection<KeyPair> loadKeyPairs(String resourceKey, FilePasswordProvider passwordProvider, BufferedReader r)
- throws IOException, GeneralSecurityException {
+ default Collection<KeyPair> loadKeyPairs(
+ String resourceKey, FilePasswordProvider passwordProvider, BufferedReader r)
+ throws IOException, GeneralSecurityException {
return loadKeyPairs(resourceKey, passwordProvider, IoUtils.readAllLines(r));
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/KeyPairResourceParser.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/KeyPairResourceParser.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/KeyPairResourceParser.java
index 80fc2c5..f7e336a 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/KeyPairResourceParser.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/KeyPairResourceParser.java
@@ -44,13 +44,15 @@ public interface KeyPairResourceParser extends KeyPairResourceLoader {
*/
KeyPairResourceParser EMPTY = new KeyPairResourceParser() {
@Override
- public Collection<KeyPair> loadKeyPairs(String resourceKey, FilePasswordProvider passwordProvider, List<String> lines)
- throws IOException, GeneralSecurityException {
+ public Collection<KeyPair> loadKeyPairs(
+ String resourceKey, FilePasswordProvider passwordProvider, List<String> lines)
+ throws IOException, GeneralSecurityException {
return Collections.emptyList();
}
@Override
- public boolean canExtractKeyPairs(String resourceKey, List<String> lines) throws IOException, GeneralSecurityException {
+ public boolean canExtractKeyPairs(String resourceKey, List<String> lines)
+ throws IOException, GeneralSecurityException {
return false;
}
@@ -69,7 +71,7 @@ public interface KeyPairResourceParser extends KeyPairResourceLoader {
* the possibility to extract the key pairs
*/
boolean canExtractKeyPairs(String resourceKey, List<String> lines)
- throws IOException, GeneralSecurityException;
+ throws IOException, GeneralSecurityException;
/**
* Converts the lines assumed to contain BASE-64 encoded data into
@@ -94,7 +96,8 @@ public interface KeyPairResourceParser extends KeyPairResourceLoader {
}
static boolean containsMarkerLine(List<String> lines, String marker) {
- return containsMarkerLine(lines, Collections.singletonList(ValidateUtils.checkNotNullAndNotEmpty(marker, "No marker")));
+ return containsMarkerLine(
+ lines, Collections.singletonList(ValidateUtils.checkNotNullAndNotEmpty(marker, "No marker")));
}
static boolean containsMarkerLine(List<String> lines, List<String> markers) {
@@ -149,8 +152,9 @@ public interface KeyPairResourceParser extends KeyPairResourceLoader {
ValidateUtils.checkNotNullAndNotEmpty(parsers, "No parsers to aggregate");
return new KeyPairResourceParser() {
@Override
- public Collection<KeyPair> loadKeyPairs(String resourceKey, FilePasswordProvider passwordProvider, List<String> lines)
- throws IOException, GeneralSecurityException {
+ public Collection<KeyPair> loadKeyPairs(
+ String resourceKey, FilePasswordProvider passwordProvider, List<String> lines)
+ throws IOException, GeneralSecurityException {
Collection<KeyPair> keyPairs = Collections.emptyList();
for (KeyPairResourceParser p : parsers) {
if (!p.canExtractKeyPairs(resourceKey, lines)) {
@@ -173,7 +177,8 @@ public interface KeyPairResourceParser extends KeyPairResourceLoader {
}
@Override
- public boolean canExtractKeyPairs(String resourceKey, List<String> lines) throws IOException, GeneralSecurityException {
+ public boolean canExtractKeyPairs(String resourceKey, List<String> lines)
+ throws IOException, GeneralSecurityException {
for (KeyPairResourceParser p : parsers) {
if (p.canExtractKeyPairs(resourceKey, lines)) {
return true;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHKeyPairResourceParser.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHKeyPairResourceParser.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHKeyPairResourceParser.java
index 9f309ea..d531021 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHKeyPairResourceParser.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHKeyPairResourceParser.java
@@ -120,7 +120,7 @@ public class OpenSSHKeyPairResourceParser extends AbstractKeyPairResourceParser
byte[] kdfOptions = KeyEntryResolver.readRLEBytes(stream, MAX_KDF_OPTIONS_SIZE);
if (debugEnabled) {
log.debug("extractKeyPairs({}) KDF={}, options={}",
- resourceKey, kdfName, BufferUtils.toHex(':', kdfOptions));
+ resourceKey, kdfName, BufferUtils.toHex(':', kdfOptions));
}
int numKeys = KeyEntryResolver.decodeInt(stream);
@@ -139,7 +139,7 @@ public class OpenSSHKeyPairResourceParser extends AbstractKeyPairResourceParser
ValidateUtils.checkNotNull(pubKey, "Empty public key #%d in %s", index, resourceKey);
if (traceEnabled) {
log.trace("extractKeyPairs({}) read public key #{}: {} {}",
- resourceKey, index, KeyUtils.getKeyType(pubKey), KeyUtils.getFingerPrint(pubKey));
+ resourceKey, index, KeyUtils.getKeyType(pubKey), KeyUtils.getFingerPrint(pubKey));
}
publicKeys.add(pubKey);
}
@@ -168,7 +168,7 @@ public class OpenSSHKeyPairResourceParser extends AbstractKeyPairResourceParser
protected List<KeyPair> readPrivateKeys(
String resourceKey, OpenSSHParserContext context, Collection<? extends PublicKey> publicKeys,
FilePasswordProvider passwordProvider, InputStream stream)
- throws IOException, GeneralSecurityException {
+ throws IOException, GeneralSecurityException {
if (GenericUtils.isEmpty(publicKeys)) {
return Collections.emptyList();
}
@@ -178,7 +178,7 @@ public class OpenSSHKeyPairResourceParser extends AbstractKeyPairResourceParser
int check2 = KeyEntryResolver.decodeInt(stream);
if (traceEnabled) {
log.trace("readPrivateKeys({}) check1=0x{}, check2=0x{}",
- resourceKey, Integer.toHexString(check1), Integer.toHexString(check2));
+ resourceKey, Integer.toHexString(check1), Integer.toHexString(check2));
}
List<KeyPair> keyPairs = new ArrayList<>(publicKeys.size());
@@ -187,7 +187,7 @@ public class OpenSSHKeyPairResourceParser extends AbstractKeyPairResourceParser
int keyIndex = keyPairs.size() + 1;
if (traceEnabled) {
log.trace("extractKeyPairs({}) read private key #{}: {}",
- resourceKey, keyIndex, pubType);
+ resourceKey, keyIndex, pubType);
}
Map.Entry<PrivateKey, String> prvData = readPrivateKey(resourceKey, context, pubType, passwordProvider, stream);
@@ -196,12 +196,12 @@ public class OpenSSHKeyPairResourceParser extends AbstractKeyPairResourceParser
String prvType = KeyUtils.getKeyType(prvKey);
ValidateUtils.checkTrue(Objects.equals(pubType, prvType),
- "Mismatched public (%s) vs. private (%s) key type #%d in %s",
- pubType, prvType, keyIndex, resourceKey);
+ "Mismatched public (%s) vs. private (%s) key type #%d in %s",
+ pubType, prvType, keyIndex, resourceKey);
if (traceEnabled) {
log.trace("extractKeyPairs({}) add private key #{}: {} {}",
- resourceKey, keyIndex, prvType, prvData.getValue());
+ resourceKey, keyIndex, prvType, prvData.getValue());
}
keyPairs.add(new KeyPair(pubKey, prvKey));
}
@@ -211,7 +211,7 @@ public class OpenSSHKeyPairResourceParser extends AbstractKeyPairResourceParser
protected SimpleImmutableEntry<PrivateKey, String> readPrivateKey(
String resourceKey, OpenSSHParserContext context, String keyType, FilePasswordProvider passwordProvider, InputStream stream)
- throws IOException, GeneralSecurityException {
+ throws IOException, GeneralSecurityException {
String prvType = KeyEntryResolver.decodeString(stream, MAX_KEY_TYPE_NAME_LENGTH);
if (!Objects.equals(keyType, prvType)) {
throw new StreamCorruptedException("Mismatched private key type: "
@@ -255,7 +255,7 @@ public class OpenSSHKeyPairResourceParser extends AbstractKeyPairResourceParser
/**
* @param decoder The decoder to register
* @throws IllegalArgumentException if no decoder or not key type or no
- * supported names for the decoder
+ * supported names for the decoder
* @see PrivateKeyEntryDecoder#getPublicKeyType()
* @see PrivateKeyEntryDecoder#getSupportedTypeNames()
*/
@@ -269,7 +269,8 @@ public class OpenSSHKeyPairResourceParser extends AbstractKeyPairResourceParser
BY_KEY_CLASS_DECODERS_MAP.put(prvType, decoder);
}
- Collection<String> names = ValidateUtils.checkNotNullAndNotEmpty(decoder.getSupportedTypeNames(), "No supported key type");
+ Collection<String> names =
+ ValidateUtils.checkNotNullAndNotEmpty(decoder.getSupportedTypeNames(), "No supported key type");
synchronized (BY_KEY_TYPE_DECODERS_MAP) {
for (String n : names) {
PrivateKeyEntryDecoder<?, ?> prev = BY_KEY_TYPE_DECODERS_MAP.put(n, decoder);
@@ -283,7 +284,7 @@ public class OpenSSHKeyPairResourceParser extends AbstractKeyPairResourceParser
/**
* @param keyType The {@code OpenSSH} key type string - e.g., {@code ssh-rsa, ssh-dss}
- * - ignored if {@code null}/empty
+ * - ignored if {@code null}/empty
* @return The registered {@link PrivateKeyEntryDecoder} or {code null} if not found
*/
public static PrivateKeyEntryDecoder<?, ?> getPrivateKeyEntryDecoder(String keyType) {
@@ -331,8 +332,7 @@ public class OpenSSHKeyPairResourceParser extends AbstractKeyPairResourceParser
}
/**
- * @param keyType The key {@link Class} - ignored if {@code null} or not a {@link Key}
- * compatible type
+ * @param keyType The key {@link Class} - ignored if {@code null} or not a {@link Key} compatible type
* @return The registered {@link PrivateKeyEntryDecoder} or {code null} if no match found
*/
public static PrivateKeyEntryDecoder<?, ?> getPrivateKeyEntryDecoder(Class<?> keyType) {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/AbstractPEMResourceKeyPairParser.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/AbstractPEMResourceKeyPairParser.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/AbstractPEMResourceKeyPairParser.java
index 6778610..1528790 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/AbstractPEMResourceKeyPairParser.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/AbstractPEMResourceKeyPairParser.java
@@ -54,7 +54,8 @@ public abstract class AbstractPEMResourceKeyPairParser
private final String algo;
private final String algId;
- protected AbstractPEMResourceKeyPairParser(String algo, String algId, List<String> beginners, List<String> enders) {
+ protected AbstractPEMResourceKeyPairParser(
+ String algo, String algId, List<String> beginners, List<String> enders) {
super(beginners, enders);
this.algo = ValidateUtils.checkNotNullAndNotEmpty(algo, "No encryption algorithm provided");
this.algId = ValidateUtils.checkNotNullAndNotEmpty(algId, "No algorithm identifier provided");
@@ -173,7 +174,9 @@ public abstract class AbstractPEMResourceKeyPairParser
return super.extractKeyPairs(resourceKey, beginMarker, endMarker, passwordProvider, dataLines);
}
- protected byte[] applyPrivateKeyCipher(byte[] bytes, PrivateKeyEncryptionContext encContext, boolean encryptIt) throws GeneralSecurityException {
+ protected byte[] applyPrivateKeyCipher(
+ byte[] bytes, PrivateKeyEncryptionContext encContext, boolean encryptIt)
+ throws GeneralSecurityException {
String cipherName = encContext.getCipherName();
PrivateKeyObfuscator o = encContext.resolvePrivateKeyObfuscator();
if (o == null) {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/DSSPEMResourceKeyPairParser.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/DSSPEMResourceKeyPairParser.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/DSSPEMResourceKeyPairParser.java
index 5347495..c68a815 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/DSSPEMResourceKeyPairParser.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/DSSPEMResourceKeyPairParser.java
@@ -69,7 +69,7 @@ public class DSSPEMResourceKeyPairParser extends AbstractPEMResourceKeyPairParse
@Override
public Collection<KeyPair> extractKeyPairs(
String resourceKey, String beginMarker, String endMarker, FilePasswordProvider passwordProvider, InputStream stream)
- throws IOException, GeneralSecurityException {
+ throws IOException, GeneralSecurityException {
KeyPair kp = decodeDSSKeyPair(SecurityUtils.getKeyFactory(KeyUtils.DSS_ALGORITHM), stream, false);
return Collections.singletonList(kp);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/ECDSAPEMResourceKeyPairParser.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/ECDSAPEMResourceKeyPairParser.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/ECDSAPEMResourceKeyPairParser.java
index a2075e4..768c30f 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/ECDSAPEMResourceKeyPairParser.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/ECDSAPEMResourceKeyPairParser.java
@@ -73,7 +73,7 @@ public class ECDSAPEMResourceKeyPairParser extends AbstractPEMResourceKeyPairPar
@Override
public Collection<KeyPair> extractKeyPairs(
String resourceKey, String beginMarker, String endMarker, FilePasswordProvider passwordProvider, InputStream stream)
- throws IOException, GeneralSecurityException {
+ throws IOException, GeneralSecurityException {
Map.Entry<ECPublicKeySpec, ECPrivateKeySpec> spec = decodeECPrivateKeySpec(stream, false);
if (!SecurityUtils.isECCSupported()) {
throw new NoSuchProviderException("ECC not supported");
@@ -163,7 +163,7 @@ public class ECDSAPEMResourceKeyPairParser extends AbstractPEMResourceKeyPairPar
// TODO make sure params object tag is 0xA0
- final List<Integer> curveOID;
+ List<Integer> curveOID;
try (DERParser paramsParser = paramsObject.createParser()) {
ASN1Object namedCurve = paramsParser.readObject();
if (namedCurve == null) {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/PKCS8PEMResourceKeyPairParser.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/PKCS8PEMResourceKeyPairParser.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/PKCS8PEMResourceKeyPairParser.java
index cce1fc8..1967719 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/PKCS8PEMResourceKeyPairParser.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/PKCS8PEMResourceKeyPairParser.java
@@ -66,7 +66,7 @@ public class PKCS8PEMResourceKeyPairParser extends AbstractPEMResourceKeyPairPar
@Override
public Collection<KeyPair> extractKeyPairs(
String resourceKey, String beginMarker, String endMarker, FilePasswordProvider passwordProvider, InputStream stream)
- throws IOException, GeneralSecurityException {
+ throws IOException, GeneralSecurityException {
// Save the data before getting the algorithm OID since we will need it
byte[] encBytes = IoUtils.toByteArray(stream);
List<Integer> oidAlgorithm = getPKCS8AlgorithmIdentifier(encBytes);
@@ -79,14 +79,14 @@ public class PKCS8PEMResourceKeyPairParser extends AbstractPEMResourceKeyPairPar
public static PrivateKey decodePEMPrivateKeyPKCS8(
List<Integer> oidAlgorithm, byte[] keyBytes, FilePasswordProvider passwordProvider)
- throws GeneralSecurityException {
+ throws GeneralSecurityException {
ValidateUtils.checkNotNullAndNotEmpty(oidAlgorithm, "No PKCS8 algorithm OID");
return decodePEMPrivateKeyPKCS8(GenericUtils.join(oidAlgorithm, '.'), keyBytes, passwordProvider);
}
public static PrivateKey decodePEMPrivateKeyPKCS8(
String oid, byte[] keyBytes, FilePasswordProvider passwordProvider)
- throws GeneralSecurityException {
+ throws GeneralSecurityException {
KeyPairPEMResourceParser parser =
PEMResourceParserUtils.getPEMResourceParserByOid(
ValidateUtils.checkNotNullAndNotEmpty(oid, "No PKCS8 algorithm OID"));
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/RSAPEMResourceKeyPairParser.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/RSAPEMResourceKeyPairParser.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/RSAPEMResourceKeyPairParser.java
index e7698f9..988c210 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/RSAPEMResourceKeyPairParser.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/RSAPEMResourceKeyPairParser.java
@@ -70,7 +70,7 @@ public class RSAPEMResourceKeyPairParser extends AbstractPEMResourceKeyPairParse
@Override
public Collection<KeyPair> extractKeyPairs(
String resourceKey, String beginMarker, String endMarker, FilePasswordProvider passwordProvider, InputStream stream)
- throws IOException, GeneralSecurityException {
+ throws IOException, GeneralSecurityException {
KeyPair kp = decodeRSAKeyPair(SecurityUtils.getKeyFactory(KeyUtils.RSA_ALGORITHM), stream, false);
return Collections.singletonList(kp);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-common/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleKeyPairResourceParser.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleKeyPairResourceParser.java b/sshd-common/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleKeyPairResourceParser.java
index c2da507..1433de0 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleKeyPairResourceParser.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleKeyPairResourceParser.java
@@ -77,7 +77,7 @@ public class BouncyCastleKeyPairResourceParser extends AbstractKeyPairResourcePa
@Override
public Collection<KeyPair> extractKeyPairs(
String resourceKey, String beginMarker, String endMarker, FilePasswordProvider passwordProvider, List<String> lines)
- throws IOException, GeneralSecurityException {
+ throws IOException, GeneralSecurityException {
StringBuilder writer = new StringBuilder(beginMarker.length() + endMarker.length() + lines.size() * 80);
writer.append(beginMarker).append(IoUtils.EOL);
lines.forEach(l -> writer.append(l).append(IoUtils.EOL));
@@ -93,7 +93,7 @@ public class BouncyCastleKeyPairResourceParser extends AbstractKeyPairResourcePa
@Override
public Collection<KeyPair> extractKeyPairs(
String resourceKey, String beginMarker, String endMarker, FilePasswordProvider passwordProvider, InputStream stream)
- throws IOException, GeneralSecurityException {
+ throws IOException, GeneralSecurityException {
KeyPair kp = loadKeyPair(resourceKey, stream, passwordProvider);
return (kp == null) ? Collections.emptyList() : Collections.singletonList(kp);
}
@@ -103,7 +103,8 @@ public class BouncyCastleKeyPairResourceParser extends AbstractKeyPairResourcePa
try (PEMParser r = new PEMParser(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
Object o = r.readObject();
- SecurityProviderRegistrar registrar = SecurityUtils.getRegisteredProvider(SecurityUtils.BOUNCY_CASTLE);
+ SecurityProviderRegistrar registrar =
+ SecurityUtils.getRegisteredProvider(SecurityUtils.BOUNCY_CASTLE);
if (registrar == null) {
throw new NoSuchProviderException(SecurityUtils.BOUNCY_CASTLE + " registrar not available");
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-openpgp/pom.xml
----------------------------------------------------------------------
diff --git a/sshd-openpgp/pom.xml b/sshd-openpgp/pom.xml
new file mode 100644
index 0000000..0616662
--- /dev/null
+++ b/sshd-openpgp/pom.xml
@@ -0,0 +1,104 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+
+ <!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd</artifactId>
+ <version>2.1.1-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>sshd-openpgp</artifactId>
+ <name>Apache Mina SSHD :: OpenPGP key files support utilities</name>
+ <packaging>jar</packaging>
+ <inceptionYear>2018</inceptionYear>
+
+ <properties>
+ <projectRoot>${project.basedir}/..</projectRoot>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcpg-jdk15on</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcpkix-jdk15on</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.c02e.jpgpj</groupId>
+ <artifactId>jpgpj</artifactId>
+ <version>0.5</version>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-common</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <reportsDirectory>${project.build.directory}/surefire-reports-putty</reportsDirectory>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-openpgp/src/main/java/org/apache/sshd/common/config/keys/loader/openpgp/PGPKeyPairResourceParser.java
----------------------------------------------------------------------
diff --git a/sshd-openpgp/src/main/java/org/apache/sshd/common/config/keys/loader/openpgp/PGPKeyPairResourceParser.java b/sshd-openpgp/src/main/java/org/apache/sshd/common/config/keys/loader/openpgp/PGPKeyPairResourceParser.java
new file mode 100644
index 0000000..8bfb8e4
--- /dev/null
+++ b/sshd-openpgp/src/main/java/org/apache/sshd/common/config/keys/loader/openpgp/PGPKeyPairResourceParser.java
@@ -0,0 +1,445 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.config.keys.loader.openpgp;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StreamCorruptedException;
+import java.math.BigInteger;
+import java.net.ProtocolException;
+import java.nio.charset.StandardCharsets;
+import java.security.GeneralSecurityException;
+import java.security.InvalidKeyException;
+import java.security.KeyFactory;
+import java.security.KeyPair;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.interfaces.DSAParams;
+import java.security.interfaces.DSAPrivateKey;
+import java.security.interfaces.DSAPublicKey;
+import java.security.interfaces.ECPrivateKey;
+import java.security.interfaces.ECPublicKey;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.DSAPrivateKeySpec;
+import java.security.spec.DSAPublicKeySpec;
+import java.security.spec.ECParameterSpec;
+import java.security.spec.ECPoint;
+import java.security.spec.ECPrivateKeySpec;
+import java.security.spec.ECPublicKeySpec;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.KeySpec;
+import java.security.spec.RSAPrivateCrtKeySpec;
+import java.security.spec.RSAPublicKeySpec;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
+import org.apache.sshd.common.cipher.ECCurves;
+import org.apache.sshd.common.config.keys.FilePasswordProvider;
+import org.apache.sshd.common.config.keys.FilePasswordProvider.ResourceDecodeResult;
+import org.apache.sshd.common.config.keys.KeyUtils;
+import org.apache.sshd.common.config.keys.loader.AbstractKeyPairResourceParser;
+import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.buffer.BufferUtils;
+import org.apache.sshd.common.util.security.SecurityUtils;
+import org.bouncycastle.asn1.ASN1ObjectIdentifier;
+import org.bouncycastle.bcpg.BCPGKey;
+import org.bouncycastle.bcpg.DSAPublicBCPGKey;
+import org.bouncycastle.bcpg.DSASecretBCPGKey;
+import org.bouncycastle.bcpg.ECDSAPublicBCPGKey;
+import org.bouncycastle.bcpg.ECPublicBCPGKey;
+import org.bouncycastle.bcpg.ECSecretBCPGKey;
+import org.bouncycastle.bcpg.EdDSAPublicBCPGKey;
+import org.bouncycastle.bcpg.EdSecretBCPGKey;
+import org.bouncycastle.bcpg.PublicKeyPacket;
+import org.bouncycastle.bcpg.RSAPublicBCPGKey;
+import org.bouncycastle.bcpg.RSASecretBCPGKey;
+import org.bouncycastle.openpgp.PGPException;
+import org.bouncycastle.openpgp.PGPPrivateKey;
+import org.bouncycastle.openpgp.PGPPublicKey;
+import org.c02e.jpgpj.Key;
+import org.c02e.jpgpj.Subkey;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class PGPKeyPairResourceParser extends AbstractKeyPairResourceParser {
+ public static final String BEGIN_MARKER = "BEGIN PGP PRIVATE KEY BLOCK";
+ public static final List<String> BEGINNERS =
+ Collections.unmodifiableList(Collections.singletonList(BEGIN_MARKER));
+
+ public static final String END_MARKER = "END PGP PRIVATE KEY BLOCK";
+ public static final List<String> ENDERS =
+ Collections.unmodifiableList(Collections.singletonList(END_MARKER));
+
+ public static final PGPKeyPairResourceParser INSTANCE = new PGPKeyPairResourceParser();
+
+ public PGPKeyPairResourceParser() {
+ super(BEGINNERS, ENDERS);
+ }
+
+ @Override
+ public Collection<KeyPair> extractKeyPairs(
+ String resourceKey, String beginMarker, String endMarker, FilePasswordProvider passwordProvider, List<String> lines)
+ throws IOException, GeneralSecurityException {
+ // We need to re-construct the original data - including start/end markers
+ String eol = System.lineSeparator();
+ int numLines = GenericUtils.size(lines);
+ StringBuilder sb = new StringBuilder(
+ beginMarker.length() + endMarker.length() + 4 + numLines * 80)
+ .append(beginMarker);
+ if (numLines > 0) {
+ for (String l : lines) {
+ sb.append(eol).append(l);
+ }
+ }
+ sb.append(eol).append(endMarker).append(eol);
+
+ String keyData = sb.toString();
+ byte[] dataBytes = keyData.getBytes(StandardCharsets.US_ASCII);
+ return extractKeyPairs(resourceKey, beginMarker, endMarker, passwordProvider, dataBytes);
+ }
+
+ @Override
+ public Collection<KeyPair> extractKeyPairs(
+ String resourceKey, String beginMarker, String endMarker, FilePasswordProvider passwordProvider, InputStream stream)
+ throws IOException, GeneralSecurityException {
+ for (int retryCount = 1;; retryCount++) {
+ String password = (passwordProvider == null) ? null : passwordProvider.getPassword(resourceKey);
+ Collection<KeyPair> keys;
+ try {
+ if (retryCount > 1) {
+ stream.reset();
+ }
+
+ Key key = new Key(stream, password);
+ if (GenericUtils.isEmpty(password)) {
+ key.setNoPassphrase(true);
+ } else {
+ key.setPassphrase(password);
+ }
+
+ keys = extractKeyPairs(resourceKey, key.getSubkeys());
+ } catch (IOException | GeneralSecurityException | PGPException | RuntimeException e) {
+ ResourceDecodeResult result = (passwordProvider != null)
+ ? passwordProvider.handleDecodeAttemptResult(resourceKey, password, e)
+ : ResourceDecodeResult.TERMINATE;
+ if (result == null) {
+ result = ResourceDecodeResult.TERMINATE;
+ }
+
+ switch (result) {
+ case TERMINATE:
+ if (e instanceof PGPException) {
+ throw new StreamCorruptedException(
+ "Failed (" + e.getClass().getSimpleName() + ")"
+ + " to decode " + resourceKey + ": " + e.getMessage());
+ } else if (e instanceof IOException) {
+ throw (IOException) e;
+ } else if (e instanceof GeneralSecurityException) {
+ throw (GeneralSecurityException) e;
+ } else {
+ throw (RuntimeException) e;
+ }
+ case RETRY:
+ continue;
+ case IGNORE:
+ return Collections.emptyList();
+ default:
+ throw new ProtocolException("Unsupported decode attempt result (" + result + ") for " + resourceKey);
+ }
+ }
+
+ if (passwordProvider != null) {
+ passwordProvider.handleDecodeAttemptResult(resourceKey, password, null);
+ }
+ return keys;
+ }
+ }
+
+ public List<KeyPair> extractKeyPairs(String resourceKey, Collection<? extends Subkey> subKeys)
+ throws IOException, GeneralSecurityException {
+ if (GenericUtils.isEmpty(subKeys)) {
+ return Collections.emptyList();
+ }
+
+ List<KeyPair> kpList = new ArrayList<>(subKeys.size());
+ boolean debugEnabled = log.isDebugEnabled();
+ for (Subkey sk : subKeys) {
+ PublicKey pubKey;
+ try {
+ pubKey = extractPublicKey(resourceKey, sk);
+ if (pubKey == null) {
+ if (debugEnabled) {
+ log.debug("extractKeyPairs({}) no public key extracted from {}", resourceKey, sk);
+ }
+ continue;
+ }
+ } catch (IOException | GeneralSecurityException | RuntimeException | Error e) {
+ log.error("extractKeyPairs({}) failed ({}) to extract public key of {}: {}",
+ resourceKey, e.getClass().getSimpleName(), sk, e.getMessage());
+ throw e;
+ }
+
+ PrivateKey prvKey;
+ try {
+ prvKey = extractPrivateKey(resourceKey, sk, pubKey);
+ if (prvKey == null) {
+ if (debugEnabled) {
+ log.debug("extractKeyPairs({}) no private key extracted from {}", resourceKey, sk);
+ }
+ continue;
+ }
+ } catch (IOException | GeneralSecurityException | RuntimeException | Error e) {
+ log.error("extractKeyPairs({}) failed ({}) to extract private key of {}: {}",
+ resourceKey, e.getClass().getSimpleName(), sk, e.getMessage());
+ throw e;
+ } catch (PGPException e) {
+ log.error("extractKeyPairs({}) failed ({}) to parse private key of {}: {}",
+ resourceKey, e.getClass().getSimpleName(), sk, e.getMessage());
+ throw new StreamCorruptedException("Failed to parse " + resourceKey + " sub-key=" + sk + ": " + e.getMessage());
+ }
+
+ KeyPair kp = new KeyPair(pubKey, prvKey);
+ KeyPair prev = kpList.isEmpty()
+ ? null
+ : kpList.stream()
+ .filter(e -> KeyUtils.compareKeyPairs(e, kp))
+ .findFirst()
+ .orElse(null);
+ if (prev != null) {
+ if (debugEnabled) {
+ log.debug("extractKeyPairs({}) skip duplicate sub-key={}", resourceKey, sk);
+ }
+ continue;
+ }
+
+ kpList.add(kp);
+ }
+
+ return kpList;
+ }
+
+ public PublicKey extractPublicKey(String resourceKey, Subkey sk) throws IOException, GeneralSecurityException {
+ if (sk == null) {
+ return null;
+ }
+
+ PGPPublicKey pgpKey = Objects.requireNonNull(sk.getPublicKey(), "Missing sub-key public key");
+ PublicKeyPacket pgpPacket = Objects.requireNonNull(pgpKey.getPublicKeyPacket(), "Missing public key packet");
+ BCPGKey bcKey = Objects.requireNonNull(pgpPacket.getKey(), "Missing BC key");
+ if (bcKey instanceof RSAPublicBCPGKey) {
+ return extractRSAPublicKey(resourceKey, (RSAPublicBCPGKey) bcKey);
+ } else if (bcKey instanceof ECPublicBCPGKey) {
+ return extractECPublicKey(resourceKey, (ECPublicBCPGKey) bcKey);
+ } else if (bcKey instanceof DSAPublicBCPGKey) {
+ return extractDSSPublicKey(resourceKey, (DSAPublicBCPGKey) bcKey);
+ } else {
+ throw new NoSuchAlgorithmException("Unsupported BC public key type: " + bcKey.getClass().getSimpleName());
+ }
+ }
+
+ public RSAPublicKey extractRSAPublicKey(String resourceKey, RSAPublicBCPGKey bcKey) throws GeneralSecurityException {
+ if (bcKey == null) {
+ return null;
+ }
+
+ BigInteger e = bcKey.getPublicExponent();
+ BigInteger n = bcKey.getModulus();
+ return generatePublicKey(KeyUtils.RSA_ALGORITHM, RSAPublicKey.class, new RSAPublicKeySpec(n, e));
+ }
+
+ public PublicKey extractECPublicKey(String resourceKey, ECPublicBCPGKey bcKey) throws GeneralSecurityException {
+ if (bcKey == null) {
+ return null;
+ } else if (bcKey instanceof EdDSAPublicBCPGKey) {
+ return extractEdDSAPublicKey(resourceKey, (EdDSAPublicBCPGKey) bcKey);
+ } else if (bcKey instanceof ECDSAPublicBCPGKey) {
+ return extractECDSAPublicKey(resourceKey, (ECDSAPublicBCPGKey) bcKey);
+ } else {
+ throw new NoSuchAlgorithmException("Unsupported EC public key type: " + bcKey.getClass().getSimpleName());
+ }
+ }
+
+ public ECPublicKey extractECDSAPublicKey(String resourceKey, ECDSAPublicBCPGKey bcKey) throws GeneralSecurityException {
+ if (bcKey == null) {
+ return null;
+ }
+
+ ASN1ObjectIdentifier asnId = bcKey.getCurveOID();
+ String oid = asnId.getId();
+ ECCurves curve = ECCurves.fromOID(oid);
+ if (curve == null) {
+ throw new InvalidKeySpecException("Not an EC curve OID: " + oid);
+ }
+
+ if (!SecurityUtils.isECCSupported()) {
+ throw new NoSuchProviderException("ECC not supported");
+ }
+
+ BigInteger encPoint = bcKey.getEncodedPoint();
+ byte[] octets = encPoint.toByteArray();
+ ECPoint w;
+ try {
+ w = ECCurves.octetStringToEcPoint(octets);
+ if (w == null) {
+ throw new InvalidKeySpecException("No ECPoint generated for curve=" + curve.getName()
+ + " from octets=" + BufferUtils.toHex(':', octets));
+ }
+ } catch (RuntimeException e) {
+ throw new InvalidKeySpecException("Failed (" + e.getClass().getSimpleName() + ")"
+ + " to generate ECPoint for curve=" + curve.getName()
+ + " from octets=" + BufferUtils.toHex(':', octets)
+ + ": " + e.getMessage());
+ }
+
+ ECParameterSpec paramSpec = curve.getParameters();
+ return generatePublicKey(KeyUtils.EC_ALGORITHM, ECPublicKey.class, new ECPublicKeySpec(w, paramSpec));
+ }
+
+ public PublicKey extractEdDSAPublicKey(String resourceKey, EdDSAPublicBCPGKey bcKey) throws GeneralSecurityException {
+ if (bcKey == null) {
+ return null;
+ }
+
+ if (!SecurityUtils.isEDDSACurveSupported()) {
+ throw new NoSuchProviderException("EdDSA not supported");
+ }
+
+ throw new NoSuchAlgorithmException("Unsupported EdDSA public key type: " + bcKey.getClass().getSimpleName());
+ }
+
+ public DSAPublicKey extractDSSPublicKey(String resourceKey, DSAPublicBCPGKey bcKey) throws GeneralSecurityException {
+ if (bcKey == null) {
+ return null;
+ }
+
+ BigInteger p = bcKey.getP();
+ BigInteger q = bcKey.getQ();
+ BigInteger g = bcKey.getG();
+ BigInteger y = bcKey.getY();
+ return generatePublicKey(KeyUtils.DSS_ALGORITHM, DSAPublicKey.class, new DSAPublicKeySpec(y, p, q, g));
+ }
+
+ protected <K extends PublicKey> K generatePublicKey(String algorithm, Class<K> keyType, KeySpec keySpec)
+ throws GeneralSecurityException {
+ KeyFactory factory = getKeyFactory(algorithm);
+ PublicKey pubKey = factory.generatePublic(keySpec);
+ return keyType.cast(pubKey);
+ }
+
+ public PrivateKey extractPrivateKey(String resourceKey, Subkey sk, PublicKey pubKey)
+ throws IOException, GeneralSecurityException, PGPException {
+ if (sk == null) {
+ return null;
+ }
+
+ PGPPrivateKey pgpKey = Objects.requireNonNull(sk.getPrivateKey(), "Missing sub-key private key");
+ BCPGKey bcKey = Objects.requireNonNull(pgpKey.getPrivateKeyDataPacket(), "Missing BC key");
+ if (bcKey instanceof RSASecretBCPGKey) {
+ return extractRSAPrivateKey(resourceKey, (RSAPublicKey) pubKey, (RSASecretBCPGKey) bcKey);
+ } else if (bcKey instanceof ECSecretBCPGKey) {
+ return extractECDSAPrivateKey(resourceKey, (ECPublicKey) pubKey, (ECSecretBCPGKey) bcKey);
+ } else if (bcKey instanceof EdSecretBCPGKey) {
+ return extractEdDSAPrivateKey(resourceKey, pubKey, (EdSecretBCPGKey) bcKey);
+ } else if (bcKey instanceof DSASecretBCPGKey) {
+ return extractDSSPrivateKey(resourceKey, (DSAPublicKey) pubKey, (DSASecretBCPGKey) bcKey);
+ } else {
+ throw new NoSuchAlgorithmException("Unsupported BC public key type: " + bcKey.getClass().getSimpleName());
+ }
+ }
+
+ public ECPrivateKey extractECDSAPrivateKey(String resourceKey, ECPublicKey pubKey, ECSecretBCPGKey bcKey)
+ throws GeneralSecurityException {
+ if (bcKey == null) {
+ return null;
+ }
+
+ if (!SecurityUtils.isECCSupported()) {
+ throw new NoSuchProviderException("ECC not supported");
+ }
+
+ ECParameterSpec params = pubKey.getParams();
+ BigInteger x = bcKey.getX();
+ return generatePrivateKey(KeyUtils.EC_ALGORITHM, ECPrivateKey.class, new ECPrivateKeySpec(x, params));
+ }
+
+ public PrivateKey extractEdDSAPrivateKey(String resourceKey, PublicKey pubKey, EdSecretBCPGKey bcKey)
+ throws GeneralSecurityException {
+ if (bcKey == null) {
+ return null;
+ }
+
+ if (!SecurityUtils.isEDDSACurveSupported()) {
+ throw new NoSuchProviderException("EdDSA not supported");
+ }
+
+ throw new NoSuchAlgorithmException("Unsupported EdDSA private key type: " + bcKey.getClass().getSimpleName());
+ }
+
+ public RSAPrivateKey extractRSAPrivateKey(String resourceKey, RSAPublicKey pubKey, RSASecretBCPGKey bcKey)
+ throws GeneralSecurityException {
+ if (bcKey == null) {
+ return null;
+ }
+
+ return generatePrivateKey(KeyUtils.RSA_ALGORITHM, RSAPrivateKey.class,
+ new RSAPrivateCrtKeySpec(
+ bcKey.getModulus(),
+ pubKey.getPublicExponent(),
+ bcKey.getPrivateExponent(),
+ bcKey.getPrimeP(),
+ bcKey.getPrimeQ(),
+ bcKey.getPrimeExponentP(),
+ bcKey.getPrimeExponentQ(),
+ bcKey.getCrtCoefficient()));
+ }
+
+ public DSAPrivateKey extractDSSPrivateKey(String resourceKey, DSAPublicKey pubKey, DSASecretBCPGKey bcKey)
+ throws GeneralSecurityException {
+ if (bcKey == null) {
+ return null;
+ }
+
+ DSAParams params = pubKey.getParams();
+ if (params == null) {
+ throw new InvalidKeyException("Missing parameters in public key");
+ }
+
+ return generatePrivateKey(KeyUtils.DSS_ALGORITHM, DSAPrivateKey.class,
+ new DSAPrivateKeySpec(bcKey.getX(), params.getP(), params.getQ(), params.getG()));
+ }
+
+ protected <K extends PrivateKey> K generatePrivateKey(String algorithm, Class<K> keyType, KeySpec keySpec)
+ throws GeneralSecurityException {
+ KeyFactory factory = getKeyFactory(algorithm);
+ PrivateKey prvKey = factory.generatePrivate(keySpec);
+ return keyType.cast(prvKey);
+ }
+
+ protected KeyFactory getKeyFactory(String algorithm) throws GeneralSecurityException {
+ return SecurityUtils.getKeyFactory(algorithm);
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-openpgp/src/main/resources/.gitignore
----------------------------------------------------------------------
diff --git a/sshd-openpgp/src/main/resources/.gitignore b/sshd-openpgp/src/main/resources/.gitignore
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-openpgp/src/test/java/org/apache/sshd/common/config/keys/loader/openpgp/PGPKeyPairResourceParserTest.java
----------------------------------------------------------------------
diff --git a/sshd-openpgp/src/test/java/org/apache/sshd/common/config/keys/loader/openpgp/PGPKeyPairResourceParserTest.java b/sshd-openpgp/src/test/java/org/apache/sshd/common/config/keys/loader/openpgp/PGPKeyPairResourceParserTest.java
new file mode 100644
index 0000000..3a121d9
--- /dev/null
+++ b/sshd-openpgp/src/test/java/org/apache/sshd/common/config/keys/loader/openpgp/PGPKeyPairResourceParserTest.java
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.config.keys.loader.openpgp;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.GeneralSecurityException;
+import java.security.KeyPair;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.sshd.common.config.keys.FilePasswordProvider;
+import org.apache.sshd.common.config.keys.FilePasswordProvider.ResourceDecodeResult;
+import org.apache.sshd.common.config.keys.KeyUtils;
+import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.util.test.JUnit4ClassRunnerWithParametersFactory;
+import org.apache.sshd.util.test.JUnitTestSupport;
+import org.apache.sshd.util.test.NoIoTestCase;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.MethodSorters;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.junit.runners.Parameterized.UseParametersRunnerFactory;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@RunWith(Parameterized.class) // see https://github.com/junit-team/junit/wiki/Parameterized-tests
+@UseParametersRunnerFactory(JUnit4ClassRunnerWithParametersFactory.class)
+@Category({ NoIoTestCase.class })
+public class PGPKeyPairResourceParserTest extends JUnitTestSupport {
+ public static final String PASSWORD = "super secret passphrase";
+
+ private final String resourceName;
+ private final ResourceDecodeResult result;
+ private final FilePasswordProvider passwordProvider;
+ private final AtomicInteger retriesCount = new AtomicInteger(0);
+ private final int maxRetries = 3;
+
+ public PGPKeyPairResourceParserTest(String resourceName, ResourceDecodeResult result, String password) {
+ this.resourceName = resourceName;
+ this.result = result;
+ this.passwordProvider = new FilePasswordProvider() {
+
+ @Override
+ @SuppressWarnings("synthetic-access")
+ public String getPassword(String resourceKey) throws IOException {
+ switch (result) {
+ case IGNORE:
+ case TERMINATE:
+ return "qweryuiop123456!@#$%^";
+ case RETRY: {
+ int count = retriesCount.incrementAndGet();
+ if (count == maxRetries) {
+ return PASSWORD;
+ } else {
+ return "retry #" + count;
+ }
+ }
+ default:
+ throw new UnsupportedOperationException("Unknown decode result type: " + result);
+ }
+ }
+
+ @Override
+ @SuppressWarnings("synthetic-access")
+ public ResourceDecodeResult handleDecodeAttemptResult(
+ String resourceKey, String password, Exception err)
+ throws IOException, GeneralSecurityException {
+ if (err == null) {
+ return null;
+ }
+
+ if (result == ResourceDecodeResult.RETRY) {
+ if (retriesCount.get() >= maxRetries) {
+ return ResourceDecodeResult.TERMINATE;
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return FilePasswordProvider.class.getSimpleName() + "[" + result + "]";
+ }
+ };
+ }
+
+ @Parameters(name = "{0} / {1}")
+ public static List<Object[]> parameters() {
+ return Collections.unmodifiableList(new ArrayList<Object[]>() {
+ // Not serializing it
+ private static final long serialVersionUID = 1L;
+
+ {
+ for (ResourceDecodeResult result : ResourceDecodeResult.values()) {
+ add(new Object[] {"super-secret-passphrase-RSA-2048-v1p0-private.gpg", result, PASSWORD});
+ add(new Object[] {"super-secret-passphrase-RSA-2048-v1p6p1-private.gpg", result, PASSWORD});
+ add(new Object[] {"super-secret-passphrase-RSA-4096-v2p0p8-private.gpg", result, PASSWORD});
+ add(new Object[] {"super-secret-passphrase-DSA-2048-gpg4win-3.1.3.gpg", result, PASSWORD});
+ add(new Object[] {"super-secret-passphrase-EC-384-v1p0-private.gpg", result, PASSWORD});
+ // TODO add(new Object[] {"super-secret-passphrase-ed25519-gpg4win-3.1.3.gpg, result", PASSWORD});
+ }
+ }
+ });
+ }
+
+ @Test
+ public void testDecodePrivateKeyPair() throws IOException, GeneralSecurityException {
+ InputStream stream = getClass().getResourceAsStream(resourceName);
+ assertNotNull("Missing " + resourceName, stream);
+
+ Collection<KeyPair> keys;
+ try {
+ keys = PGPKeyPairResourceParser.INSTANCE.loadKeyPairs(resourceName, passwordProvider, stream);
+ } catch (Exception e) {
+ if (result != ResourceDecodeResult.TERMINATE) {
+ fail("Mismatched result mode for " + e.getClass().getSimpleName() + "[" + e.getMessage() + "]");
+ }
+ return;
+ } finally {
+ stream.close();
+ }
+
+ switch (result) {
+ case IGNORE:
+ assertTrue("Unexpected keys recovered", GenericUtils.isEmpty(keys));
+ return;
+
+ case RETRY:
+ assertFalse("No keys recovered", GenericUtils.isEmpty(keys));
+ break;
+
+ case TERMINATE: // fall through...
+ default:
+ fail("Unexpected return value on request=" + result + ": " + keys);
+ }
+
+ for (KeyPair kp : keys) {
+ PublicKey pubKey = kp.getPublic();
+ PrivateKey prvKey = kp.getPrivate();
+ assertNotNull("No public key for private=" + prvKey, pubKey);
+ assertNotNull("No private key for public=" + pubKey, prvKey);
+
+ String pubType = KeyUtils.getKeyType(pubKey);
+ String prvType = KeyUtils.getKeyType(prvKey);
+ assertEquals("Mismatched public/private key types", pubType, prvType);
+
+ int pubSize = KeyUtils.getKeySize(pubKey);
+ int prvSize = KeyUtils.getKeySize(prvKey);
+ assertEquals("Mismatched public/private key size", pubSize, prvSize);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "[" + resourceName + "/" + result + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-openpgp/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/sshd-openpgp/src/test/resources/log4j.properties b/sshd-openpgp/src/test/resources/log4j.properties
new file mode 100644
index 0000000..e3f24df
--- /dev/null
+++ b/sshd-openpgp/src/test/resources/log4j.properties
@@ -0,0 +1,38 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+#
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=INFO, stdout, logfile
+#log4j.logger.org.apache.sshd=TRACE
+#log4j.logger.org.apache.sshd.common.channel.Window=DEBUG
+
+# CONSOLE appender
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.logfile=org.apache.log4j.FileAppender
+log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
+log4j.appender.logfile.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.logfile.file=target/sshd-pgp-tests.log
+log4j.appender.logfile.append=true
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-openpgp/src/test/resources/org/apache/sshd/common/config/keys/loader/openpgp/DSA-2048-gpg4win-3.1.3.asc
----------------------------------------------------------------------
diff --git a/sshd-openpgp/src/test/resources/org/apache/sshd/common/config/keys/loader/openpgp/DSA-2048-gpg4win-3.1.3.asc b/sshd-openpgp/src/test/resources/org/apache/sshd/common/config/keys/loader/openpgp/DSA-2048-gpg4win-3.1.3.asc
new file mode 100644
index 0000000..cd12896
--- /dev/null
+++ b/sshd-openpgp/src/test/resources/org/apache/sshd/common/config/keys/loader/openpgp/DSA-2048-gpg4win-3.1.3.asc
@@ -0,0 +1,25 @@
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+
+mQMuBFuT5zARCADAPwVpS4++wgCKgYNq/J0afO3lAsBKGBdRIPKNS4aFpEZNxVxF
+QbeazCE9qKh360hYy8bO0JeJeto59ZdZ1DxPmLm7RSpkvvDLcZzgEqa0HTPH4WaZ
+5xANi1p1SgCs6BHKcuPVj42BPNMmxGSXVW7/dsr8GKOAq45nXllwJrUC3Vs9AEtz
+nSCjudw5os03OhPj31+EYnGnFvQSgZIpWVyDyjapd0fmnYGKg3G+cKuw4KZ6zR9G
+LY5/hu6QPmilBwQFhmJhnd5vSQTFiLpLXvHgfdQ6CtMPng4njydBKCTL7a/qP5t1
+c2t3Tc1JGmN0vq1lH2/weug12icfI2VARgX/AQCL2NCPIv0b5XtvHd/YEijPkapL
+AfxwCA0K55/lqjFMlwf+KB9MY1xl0r0FBx+x+1xa/pvgBXjQwh1g+mvxWY1f2YZo
+VIGWBRD+b1m2MJKgDZFgJ4bAhUWmll96+7Scxy7fO1PBWKdxiXBfwxjYgTipaxOB
+oDYEVwt/ZEm7oI1NXyZMIRNkINwz1L5AvZg9zAXVAhaxJvwpWJU7YK42QMzJkaF8
+AIlfjbrh7g4ordGj6OH/pzxB8fTYmM79hg7oN1syXdxiUX8h37tnvBehlCOyD68k
+UoEmP8EEaeukHSUXbSObHNyPAJmEjzkpEfSPNGeuU3VaLeca5Ofw5tBRgzAyjj9j
+7VG2yfn34ox2t4CfCS+Lrn1yvLuhd/AUgHfC7T0+Zwf/R/Pq7JFIT/nWgZQIf4TC
+7Up6fj1QoOy8qwQ2oh6ugCtSGO6pxCcebjZntg18NUQwMBW1h+gASi3vAWhOcsEh
+cRr5ZQE3wgxSfIvNiFNJmxjBqQztN1Ur+eXSPUX3eS+xiTyKGIYoAv1p3vSkrGd/
+8pb5rq0i4xaOFrAgMQhe/vby0KRULZpYjog4lzDbLHDcg+qyOusJ1wsKYWhGlJe3
+edb75xE9lpT/jEyLFkFU9KOhtw4kpbU3/KpaZBTPbTv2cZqaYrtve4j7Qi3rBsJq
+uURZlAWCeJjtmRlVEtKOzCd+ba4Afmy+pBkngy7qb/Ms2HFO4QeAjvMQROgJRo9I
+rLQmTHlvciBHb2xkc3RlaW4gPGxnb2xkc3RlaW5AYXBhY2hlLm9yZz6IkAQTEQgA
+OBYhBEiwzOjxhisPStdn64wXeSM70ePABQJbk+cwAhsjBQsJCAcCBhUKCQgLAgQW
+AgMBAh4BAheAAAoJEIwXeSM70ePAL/0BAIqWxD6K6llI9NWK5jXTppBeHfEGC182
+Y9EAkbxGLtAMAP0RYt41Cuhj6uodcZGooW/2/pO3fbb6ZeGDAN5o80bBgQ==
+=DtpZ
+-----END PGP PUBLIC KEY BLOCK-----
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-openpgp/src/test/resources/org/apache/sshd/common/config/keys/loader/openpgp/EC-348-v1p0-public.asc
----------------------------------------------------------------------
diff --git a/sshd-openpgp/src/test/resources/org/apache/sshd/common/config/keys/loader/openpgp/EC-348-v1p0-public.asc b/sshd-openpgp/src/test/resources/org/apache/sshd/common/config/keys/loader/openpgp/EC-348-v1p0-public.asc
new file mode 100644
index 0000000..683a6a9
--- /dev/null
+++ b/sshd-openpgp/src/test/resources/org/apache/sshd/common/config/keys/loader/openpgp/EC-348-v1p0-public.asc
@@ -0,0 +1,27 @@
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: Keybase OpenPGP v1.0.0
+Comment: https://keybase.io/crypto
+
+xm8EW5NNmBMFK4EEACIDAwT0MDx4JzYywOIpKKCGMKkrSVT4AeTOpQHhrIWRmK9R
+bJhYSsUj3G2qT4z6Rgw7MPs7ltyCkujfNxxet0RKvYZhbc9XH/F9qOSssHX9fC6v
+xL4/JX2hrz7ONgEX/0C4UhXNSUx5b3IgR29sZHN0ZWluIChBcGFjaGUgU1NIRCBF
+Q0MgMzQ4IFBHUCB0ZXN0IGtleSkgPGxnb2xkc3RlaW5AYXBhY2hlLm9yZz7CjwQT
+EwoAFwUCW5NNmAIbLwMLCQcDFQoIAh4BAheAAAoJEOF1BlV7wP+2gbABfil1RHzd
+GJ63mt6RW74DbTsKgZx09Oqd2r4s0IBEQms6rXJZ+Zx/xxvyM4pCdLlM/QF/cxyV
+2vndOsNLQH4iKrT1ViQBBM6Nyc2GO/HoaqiBhNMX7/2d1D8WK7MXxM2Sjcw9zlIE
+W5NNmBMIKoZIzj0DAQcCAwQqZJVpapgY4NsWFowJXeflzHofgKhoYhoIoEDGGnFq
+Yi8K9R/c14PyYse2b6SvF6DH42m36T3HrlvqvZr52mrRwsAnBBgTCgAPBQJbk02Y
+BQkPCZwAAhsuAGoJEOF1BlV7wP+2XyAEGRMKAAYFAluTTZgACgkQpwAX8HS3WvpD
+tQEAhpJAjrEKh7K9Pl6eUUKaIWI1YxzJ4WFeTcalW5xRM3cBALg1uyXQYsZE1zmu
+lTpEKwGulyBXas3zifpNqg1Qfnre3a0BgMv+Q0mRVjf8tjnOHHUfqm5q8cGVhp1a
+Bpzao3h/stGHSFXbnbbc9dZ9d6A4AJAswwF/X9qlxyCdVVPx/J4isAjtXcXOWNr8
+lKiC5cnIKi+6cEDKrog3NPt2JqW17AZ1r0DizlIEW5NNmBMIKoZIzj0DAQcCAwQU
+Kaq9zh1Srht7PhNpV4i8zwn1YkFAGC4SSb5DdoiBKqA6ab5gHenwAnAB46P1X7ja
+qY9lBj6Turyall4JvXsUwsAnBBgTCgAPBQJbk02YBQkPCZwAAhsuAGoJEOF1BlV7
+wP+2XyAEGRMKAAYFAluTTZgACgkQLSNkcETmDCOLcwD6Akxg6Va0EPnG/TLaYwHm
++ZbsE1Kstd5KSoamgD//u1YA/A+tbAX+volyjRSm4Svj7AZRzOe1EnPgxL1PFfq+
+zGI9p78Bf1ne6pkw7pX85ifcpSutP4zvfAFoYUkva5zS/Lf9zF8bHmHQmLool4w+
+3KdtIqu5WgGAreha4/QmpUMdP5DGnzbc2bmuG7YS+1l8DrNNr8S9aO2No5JU13Mw
+xFOYZmFpXlGj
+=30E1
+-----END PGP PUBLIC KEY BLOCK-----
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-openpgp/src/test/resources/org/apache/sshd/common/config/keys/loader/openpgp/RSA-2048-v1p0-public.asc
----------------------------------------------------------------------
diff --git a/sshd-openpgp/src/test/resources/org/apache/sshd/common/config/keys/loader/openpgp/RSA-2048-v1p0-public.asc b/sshd-openpgp/src/test/resources/org/apache/sshd/common/config/keys/loader/openpgp/RSA-2048-v1p0-public.asc
new file mode 100644
index 0000000..cb3449f
--- /dev/null
+++ b/sshd-openpgp/src/test/resources/org/apache/sshd/common/config/keys/loader/openpgp/RSA-2048-v1p0-public.asc
@@ -0,0 +1,56 @@
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: Keybase OpenPGP v1.0.0
+Comment: https://keybase.io/crypto
+
+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
+yqQD
+=csQY
+-----END PGP PUBLIC KEY BLOCK-----
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/259ee8c7/sshd-openpgp/src/test/resources/org/apache/sshd/common/config/keys/loader/openpgp/RSA-2048-v1p6p1-public.asc
----------------------------------------------------------------------
diff --git a/sshd-openpgp/src/test/resources/org/apache/sshd/common/config/keys/loader/openpgp/RSA-2048-v1p6p1-public.asc b/sshd-openpgp/src/test/resources/org/apache/sshd/common/config/keys/loader/openpgp/RSA-2048-v1p6p1-public.asc
new file mode 100644
index 0000000..db72826
--- /dev/null
+++ b/sshd-openpgp/src/test/resources/org/apache/sshd/common/config/keys/loader/openpgp/RSA-2048-v1p6p1-public.asc
@@ -0,0 +1,18 @@
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: BCPG C# v1.6.1.0
+
+mQENBFuTTP0BCACGwHfOtKlKSNPophndVpK+M3OhxjFT/rKTBAr3zzzVAn1ofdbS
+oi0AysA95P++5mffGryhiNjLzLG8zehtU4/eij0NN1OFOtxILc0wViRqe6Ldikit
+fV6crknwA3q09vTWuzqQDus+lC1qxl36CA6FbnYWNQNt0iLL2rE3doOHAX4rSaIf
+JI19LKlJMsCQKAJhNq65ORg2hnOaycwtybmVhVXSGAw8La1TgbOp2M+loWhNDoFT
+H0tpUPNuNkadv3BqGMb90tG/uQLE9GrxJGOFsgRxertGNXesY1+JofCVJQuxXp1A
+yLTo6tr28oSLFOcfsDMuDAejnokP0QnEinGRABEBAAG0FWxnb2xkc3RlaW5AYXBh
+Y2hlLm9yZ4kBHAQQAQIABgUCW5NM/QAKCRDB8+7vuObR4GWUB/9QaGm5xLSLtxNo
+GTStJtenkNNM/urRsu7iZHvj1ELrOUffDS7da/uIqXtWh6xtR8vDG9ByCm+Wp47N
+6amCbmpt3oYKTKQhBxZ9w7Ic3EaHSmcAL+riLnZts313PCm7NZASNO/3H6I4R8TH
+NUtP0UdwymK0O7vhDlhj094faKS0XeSyckZs5NQY63rcGK9+Dj3TGlO2jZo/JnYO
+Bc3DxICtC2/HoXfkGhZPw0DjOfMYDhWRxDdfP4ftpHHiOQTLSyEq6enQhNOlwg0K
+PjQmvH62iWoRSOCcKqM0PBlftzjssFRqICsAIpE0urzRaGawzzG348GoXjP3bEVS
+wznsBe9q
+=wQIr
+-----END PGP PUBLIC KEY BLOCK-----