annotate src/ch/ethz/ssh2/transport/KexManager.java @ 319:776a220dbcc6 ganymed

add ecdsa key support everywhere
author Carl Byington <carl@five-ten-sg.com>
date Thu, 31 Jul 2014 08:20:47 -0700
parents 071eccdff8ea
children 90537ba71897
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1 /*
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2 * Copyright (c) 2006-2011 Christian Plattner. All rights reserved.
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
3 * Please refer to the LICENSE.txt for licensing details.
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
4 */
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
5 package ch.ethz.ssh2.transport;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
6
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
7 import java.io.IOException;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
8 import java.io.InterruptedIOException;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
9 import java.security.DigestException;
280
51d5f434ef6b start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents: 278
diff changeset
10 import java.security.KeyPair;
51d5f434ef6b start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents: 278
diff changeset
11 import java.security.PrivateKey;
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
12 import java.security.SecureRandom;
280
51d5f434ef6b start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents: 278
diff changeset
13 import java.security.interfaces.DSAPrivateKey;
51d5f434ef6b start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents: 278
diff changeset
14 import java.security.interfaces.RSAPrivateKey;
51d5f434ef6b start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents: 278
diff changeset
15 import java.security.interfaces.ECPrivateKey;
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
16 import java.util.Arrays;
301
ca5dd224a87b add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 300
diff changeset
17 import java.util.Set;
ca5dd224a87b add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 300
diff changeset
18 import java.util.TreeSet;
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
19
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
20 import ch.ethz.ssh2.ConnectionInfo;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
21 import ch.ethz.ssh2.DHGexParameters;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
22 import ch.ethz.ssh2.compression.CompressionFactory;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
23 import ch.ethz.ssh2.compression.Compressor;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
24 import ch.ethz.ssh2.crypto.CryptoWishList;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
25 import ch.ethz.ssh2.crypto.KeyMaterial;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
26 import ch.ethz.ssh2.crypto.cipher.BlockCipher;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
27 import ch.ethz.ssh2.crypto.cipher.BlockCipherFactory;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
28 import ch.ethz.ssh2.crypto.digest.MAC;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
29 import ch.ethz.ssh2.log.Logger;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
30 import ch.ethz.ssh2.packets.PacketKexInit;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
31 import ch.ethz.ssh2.packets.PacketNewKeys;
280
51d5f434ef6b start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents: 278
diff changeset
32 import java.security.interfaces.DSAPrivateKey;
278
d7e088fa2123 start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents: 273
diff changeset
33 import java.security.interfaces.RSAPrivateKey;
280
51d5f434ef6b start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents: 278
diff changeset
34 import java.security.interfaces.ECPrivateKey;
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
35
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
36 /**
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
37 * @version $Id: KexManager.java 152 2014-04-28 11:02:23Z dkocher@sudo.ch $
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
38 */
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
39 public abstract class KexManager implements MessageHandler {
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
40 protected static final Logger log = Logger.getLogger(KexManager.class);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
41
300
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
42 private static final Set<String> HOSTKEY_ALGS = new TreeSet<String>();
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
43 static {
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
44 HOSTKEY_ALGS.add("ecdsa-sha2-nistp256");
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
45 HOSTKEY_ALGS.add("ecdsa-sha2-nistp384");
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
46 HOSTKEY_ALGS.add("ecdsa-sha2-nistp521");
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
47 HOSTKEY_ALGS.add("ssh-rsa");
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
48 HOSTKEY_ALGS.add("ssh-dss");
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
49 }
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
50
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
51 private static final Set<String> KEX_ALGS = new TreeSet<String>();
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
52 static {
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
53 KEX_ALGS.add("ecdh-sha2-nistp256");
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
54 KEX_ALGS.add("ecdh-sha2-nistp384");
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
55 KEX_ALGS.add("ecdh-sha2-nistp521");
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
56 KEX_ALGS.add("diffie-hellman-group-exchange-sha256");
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
57 KEX_ALGS.add("diffie-hellman-group-exchange-sha1");
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
58 KEX_ALGS.add("diffie-hellman-group14-sha1");
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
59 KEX_ALGS.add("diffie-hellman-group1-sha1");
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
60 }
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
61
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
62 KexState kxs;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
63 int kexCount = 0;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
64 KeyMaterial km;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
65 byte[] sessionId;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
66 ClientServerHello csh;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
67
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
68 final Object accessLock = new Object();
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
69 ConnectionInfo lastConnInfo = null;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
70
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
71 boolean connectionClosed = false;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
72
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
73 boolean ignore_next_kex_packet = false;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
74
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
75 final TransportManager tm;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
76
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
77 CryptoWishList nextKEXcryptoWishList;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
78 DHGexParameters nextKEXdhgexParameters;
285
486df527ddc5 start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents: 280
diff changeset
79 KeyPair nextKEXdsakey;
486df527ddc5 start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents: 280
diff changeset
80 KeyPair nextKEXrsakey;
300
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
81 KeyPair nextKEXeckey;
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
82
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
83 final SecureRandom rnd;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
84
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
85 public KexManager(TransportManager tm, ClientServerHello csh, CryptoWishList initialCwl, SecureRandom rnd) {
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
86 this.tm = tm;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
87 this.csh = csh;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
88 this.nextKEXcryptoWishList = initialCwl;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
89 this.nextKEXdhgexParameters = new DHGexParameters();
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
90 this.rnd = rnd;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
91 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
92
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
93 public ConnectionInfo getOrWaitForConnectionInfo(int minKexCount) throws IOException {
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
94 synchronized (accessLock) {
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
95 while (true) {
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
96 if ((lastConnInfo != null) && (lastConnInfo.keyExchangeCounter >= minKexCount)) {
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
97 return lastConnInfo;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
98 }
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
99
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
100 if (connectionClosed) {
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
101 throw tm.getReasonClosedCause();
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
102 }
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
103
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
104 try {
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
105 accessLock.wait();
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
106 }
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
107 catch (InterruptedException e) {
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
108 throw new InterruptedIOException(e.getMessage());
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
109 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
110 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
111 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
112 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
113
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
114 private String getFirstMatch(String[] client, String[] server) throws NegotiateException {
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
115 if (client == null || server == null) {
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
116 throw new IllegalArgumentException();
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
117 }
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
118
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
119 for (String c : client) {
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
120 for (String s : server) {
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
121 if (c.equals(s)) {
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
122 return c;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
123 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
124 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
125 }
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
126
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
127 throw new NegotiateException(String.format("Negotiation failed for %s", Arrays.toString(server)));
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
128 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
129
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
130 private boolean compareFirstOfNameList(String[] a, String[] b) {
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
131 if (a == null || b == null) {
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
132 throw new IllegalArgumentException();
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
133 }
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
134
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
135 if ((a.length == 0) && (b.length == 0)) {
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
136 return true;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
137 }
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
138
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
139 if ((a.length == 0) || (b.length == 0)) {
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
140 return false;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
141 }
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
142
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
143 return (a[0].equals(b[0]));
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
144 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
145
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
146 private boolean isGuessOK(KexParameters cpar, KexParameters spar) {
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
147 if (cpar == null || spar == null) {
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
148 throw new IllegalArgumentException();
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
149 }
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
150
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
151 if (!compareFirstOfNameList(cpar.kex_algorithms, spar.kex_algorithms)) {
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
152 return false;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
153 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
154
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
155 if (!compareFirstOfNameList(cpar.server_host_key_algorithms, spar.server_host_key_algorithms)) {
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
156 return false;
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
157 }
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
158
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
159 /*
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
160 * We do NOT check here if the other algorithms can be agreed on, this
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
161 * is just a check if kex_algorithms and server_host_key_algorithms were
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
162 * guessed right!
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
163 */
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
164 return true;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
165 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
166
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
167 protected NegotiatedParameters mergeKexParameters(KexParameters client, KexParameters server)
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
168 throws NegotiateException {
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
169 NegotiatedParameters np = new NegotiatedParameters();
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
170 np.kex_algo = getFirstMatch(client.kex_algorithms, server.kex_algorithms);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
171 log.info("kex_algo=" + np.kex_algo);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
172 np.server_host_key_algo = getFirstMatch(client.server_host_key_algorithms,
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
173 server.server_host_key_algorithms);
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
174 log.info("server_host_key_algo=" + np.server_host_key_algo);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
175 np.enc_algo_client_to_server = getFirstMatch(client.encryption_algorithms_client_to_server,
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
176 server.encryption_algorithms_client_to_server);
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
177 np.enc_algo_server_to_client = getFirstMatch(client.encryption_algorithms_server_to_client,
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
178 server.encryption_algorithms_server_to_client);
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
179 log.info("enc_algo_client_to_server=" + np.enc_algo_client_to_server);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
180 log.info("enc_algo_server_to_client=" + np.enc_algo_server_to_client);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
181 np.mac_algo_client_to_server = getFirstMatch(client.mac_algorithms_client_to_server,
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
182 server.mac_algorithms_client_to_server);
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
183 np.mac_algo_server_to_client = getFirstMatch(client.mac_algorithms_server_to_client,
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
184 server.mac_algorithms_server_to_client);
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
185 log.info("mac_algo_client_to_server=" + np.mac_algo_client_to_server);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
186 log.info("mac_algo_server_to_client=" + np.mac_algo_server_to_client);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
187 np.comp_algo_client_to_server = getFirstMatch(client.compression_algorithms_client_to_server,
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
188 server.compression_algorithms_client_to_server);
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
189 np.comp_algo_server_to_client = getFirstMatch(client.compression_algorithms_server_to_client,
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
190 server.compression_algorithms_server_to_client);
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
191 log.info("comp_algo_client_to_server=" + np.comp_algo_client_to_server);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
192 log.info("comp_algo_server_to_client=" + np.comp_algo_server_to_client);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
193 np.lang_client_to_server = getFirstMatch(client.languages_client_to_server,
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
194 server.languages_client_to_server);
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
195 np.lang_server_to_client = getFirstMatch(client.languages_server_to_client,
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
196 server.languages_server_to_client);
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
197
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
198 if (isGuessOK(client, server)) {
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
199 np.guessOK = true;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
200 }
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
201
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
202 return np;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
203 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
204
300
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
205 public synchronized void initiateKEX(CryptoWishList cwl, DHGexParameters dhgex, KeyPair dsa, KeyPair rsa, KeyPair ec)
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
206 throws IOException {
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
207 nextKEXcryptoWishList = cwl;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
208 nextKEXdhgexParameters = dhgex;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
209 nextKEXdsakey = dsa;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
210 nextKEXrsakey = rsa;
300
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
211 nextKEXeckey = ec;
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
212
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
213 if (kxs == null) {
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
214 kxs = new KexState();
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
215 kxs.local_dsa_key = dsa;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
216 kxs.local_rsa_key = rsa;
300
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
217 kxs.local_ec_key = ec;
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
218 kxs.dhgexParameters = nextKEXdhgexParameters;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
219 kxs.localKEX = new PacketKexInit(nextKEXcryptoWishList, rnd);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
220 tm.sendKexMessage(kxs.localKEX.getPayload());
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
221 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
222 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
223
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
224 private boolean establishKeyMaterial() throws IOException {
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
225 try {
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
226 int mac_cs_key_len = MAC.getKeyLen(kxs.np.mac_algo_client_to_server);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
227 int enc_cs_key_len = BlockCipherFactory.getKeySize(kxs.np.enc_algo_client_to_server);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
228 int enc_cs_block_len = BlockCipherFactory.getBlockSize(kxs.np.enc_algo_client_to_server);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
229 int mac_sc_key_len = MAC.getKeyLen(kxs.np.mac_algo_server_to_client);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
230 int enc_sc_key_len = BlockCipherFactory.getKeySize(kxs.np.enc_algo_server_to_client);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
231 int enc_sc_block_len = BlockCipherFactory.getBlockSize(kxs.np.enc_algo_server_to_client);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
232 km = KeyMaterial.create("SHA1", kxs.H, kxs.K, sessionId, enc_cs_key_len, enc_cs_block_len, mac_cs_key_len,
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
233 enc_sc_key_len, enc_sc_block_len, mac_sc_key_len);
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
234 }
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
235 catch (IllegalArgumentException e) {
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
236 return false;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
237 }
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
238
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
239 return true;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
240 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
241
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
242 protected void finishKex(boolean clientMode) throws IOException {
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
243 if (sessionId == null) {
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
244 sessionId = kxs.H;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
245 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
246
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
247 establishKeyMaterial();
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
248 /* Tell the other side that we start using the new material */
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
249 PacketNewKeys ign = new PacketNewKeys();
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
250 tm.sendKexMessage(ign.getPayload());
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
251 BlockCipher cbc;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
252 MAC mac;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
253 Compressor comp;
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
254
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
255 try {
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
256 cbc = BlockCipherFactory.createCipher(clientMode ? kxs.np.enc_algo_client_to_server
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
257 : kxs.np.enc_algo_server_to_client, true, clientMode ? km.enc_key_client_to_server
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
258 : km.enc_key_server_to_client, clientMode ? km.initial_iv_client_to_server
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
259 : km.initial_iv_server_to_client);
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
260
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
261 try {
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
262 mac = new MAC(clientMode ? kxs.np.mac_algo_client_to_server : kxs.np.mac_algo_server_to_client, clientMode
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
263 ? km.integrity_key_client_to_server : km.integrity_key_server_to_client);
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
264 }
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
265 catch (DigestException e) {
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
266 throw new IOException(e);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
267 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
268
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
269 comp = CompressionFactory.createCompressor(kxs.np.comp_algo_client_to_server);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
270 }
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 301
diff changeset
271 catch (IllegalArgumentException f) {
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
272 throw new IOException(String.format("Fatal error initializing ciphers. %s", f.getMessage()));
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
273 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
274
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
275 tm.changeSendCipher(cbc, mac);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
276 tm.changeSendCompression(comp);
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
277 tm.kexFinished();
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
278 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
279
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
280 public static String[] getDefaultServerHostkeyAlgorithmList() {
300
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
281 return HOSTKEY_ALGS.toArray(new String[HOSTKEY_ALGS.size()]);
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
282 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
283
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
284 public static void checkServerHostkeyAlgorithmsList(String[] algos) {
300
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
285 for (final String algo : algos) {
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
286 if (!HOSTKEY_ALGS.contains(algo))
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
287 throw new IllegalArgumentException("Unknown server host key algorithm '" + algo + "'");
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
288 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
289 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
290
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
291 public static String[] getDefaultClientKexAlgorithmList() {
300
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
292 return KEX_ALGS.toArray(new String[KEX_ALGS.size()]);
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
293 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
294
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
295 public static String[] getDefaultServerKexAlgorithmList() {
300
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
296 return KEX_ALGS.toArray(new String[KEX_ALGS.size()]);
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
297 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
298
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
299 public static void checkKexAlgorithmList(String[] algos) {
300
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
300 for (final String algo : algos) {
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
301 if (!KEX_ALGS.contains(algo))
349847b2e318 add ecdsa key support everywhere
Carl Byington <carl@five-ten-sg.com>
parents: 285
diff changeset
302 throw new IllegalArgumentException("Unknown kex algorithm '" + algo + "'");
273
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
303 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
304 }
91a31873c42a start conversion from trilead to ganymed
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
305 }