aboutsummaryrefslogtreecommitdiffstats
path: root/sshlib/src/main/java/com/trilead/ssh2/auth
diff options
context:
space:
mode:
authorhsm <hsm@lamia.panaceas.james.local>2016-05-29 04:17:53 +0100
committerhsm <hsm@lamia.panaceas.james.local>2016-05-29 17:13:25 +0100
commitf8fffe5e29f55856b93b5e21f1a672bb1a0fec40 (patch)
tree298bb1053031648aaac04931061ae98e041498aa /sshlib/src/main/java/com/trilead/ssh2/auth
parent362e6695b48ddf3d37fea426b4f48b2d0f07d9a0 (diff)
downloadsshlib-f8fffe5e29f55856b93b5e21f1a672bb1a0fec40.tar.gz
sshlib-f8fffe5e29f55856b93b5e21f1a672bb1a0fec40.tar.bz2
sshlib-f8fffe5e29f55856b93b5e21f1a672bb1a0fec40.zip
Add support for auth with open-keychain
Diffstat (limited to 'sshlib/src/main/java/com/trilead/ssh2/auth')
-rw-r--r--sshlib/src/main/java/com/trilead/ssh2/auth/AuthenticationManager.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/sshlib/src/main/java/com/trilead/ssh2/auth/AuthenticationManager.java b/sshlib/src/main/java/com/trilead/ssh2/auth/AuthenticationManager.java
index dfafcbd..117ed57 100644
--- a/sshlib/src/main/java/com/trilead/ssh2/auth/AuthenticationManager.java
+++ b/sshlib/src/main/java/com/trilead/ssh2/auth/AuthenticationManager.java
@@ -33,6 +33,8 @@ import com.trilead.ssh2.signature.DSASHA1Verify;
import com.trilead.ssh2.signature.ECDSASHA2Verify;
import com.trilead.ssh2.signature.Ed25519Verify;
import com.trilead.ssh2.signature.RSASHA1Verify;
+import com.trilead.ssh2.signature.TokenRSAPrivateKey;
+import com.trilead.ssh2.signature.TokenRSASHA1Verify;
import com.trilead.ssh2.transport.MessageHandler;
import com.trilead.ssh2.transport.TransportManager;
@@ -246,6 +248,37 @@ public class AuthenticationManager implements MessageHandler
tm.sendMessage(ua.getPayload());
}
+ else if (key instanceof TokenRSAPrivateKey)
+ {
+ TokenRSAPrivateKey pk = (TokenRSAPrivateKey) key;
+
+ byte[] pk_enc = RSASHA1Verify.encodeSSHRSAPublicKey((RSAPublicKey) pair.getPublic());
+
+ TypesWriter tw = new TypesWriter();
+ {
+ byte[] H = tm.getSessionIdentifier();
+
+ tw.writeString(H, 0, H.length);
+ tw.writeByte(Packets.SSH_MSG_USERAUTH_REQUEST);
+ tw.writeString(user);
+ tw.writeString("ssh-connection");
+ tw.writeString("publickey");
+ tw.writeBoolean(true);
+ tw.writeString("ssh-rsa");
+ tw.writeString(pk_enc, 0, pk_enc.length);
+ }
+
+ byte[] msg = tw.getBytes();
+
+ byte[] ds = TokenRSASHA1Verify.generateSignature(msg, pk);
+
+ byte[] rsa_sig_enc = RSASHA1Verify.encodeSSHRSASignature(ds);
+
+ PacketUserauthRequestPublicKey ua = new PacketUserauthRequestPublicKey("ssh-connection", user,
+ "ssh-rsa", pk_enc, rsa_sig_enc);
+
+ tm.sendMessage(ua.getPayload());
+ }
else if (key instanceof ECPrivateKey)
{
ECPrivateKey pk = (ECPrivateKey) key;