Skip to content

Commit cfe79b5

Browse files
committed
Merge upstream master branch
2 parents 563512f + 4ee3dad commit cfe79b5

23 files changed

+601
-1073
lines changed

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Sun, 12 Feb 2017 15:38:57 -0800
1+
#Sun, 19 Aug 2018 00:26:58 +0200
22
# Project-wide Gradle settings.
33

44
# IDE (e.g. Android Studio) users:
@@ -18,12 +18,12 @@
1818
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1919
# org.gradle.parallel=true
2020

21-
version=2.2.6-SNAPSHOT
21+
version=2.2.6
2222
group=org.connectbot
2323
description=SSH library used in the ConnectBot app
2424

2525
bintrayUser=dummyUser
2626
bintrayApiKey=dummyApiKey
2727

28-
officialJdk=oraclejdk7
28+
officialJdk=oraclejdk9
2929
gitHubUrl=https\://github.com/connectbot/sshlib

sshlib/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ dependencies {
2424
testCompile 'commons-io:commons-io:2.6'
2525
testCompile 'commons-codec:commons-codec:1.11'
2626
}
27+
28+
compileJava {
29+
sourceCompatibility = '1.7'
30+
targetCompatibility = '1.7'
31+
}

sshlib/src/main/java/com/trilead/ssh2/Connection.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.trilead.ssh2.crypto.CryptoWishList;
1818
import com.trilead.ssh2.crypto.cipher.BlockCipherFactory;
1919
import com.trilead.ssh2.crypto.digest.MAC;
20+
import com.trilead.ssh2.crypto.digest.MACs;
2021
import com.trilead.ssh2.log.Logger;
2122
import com.trilead.ssh2.packets.PacketIgnore;
2223
import com.trilead.ssh2.transport.KexManager;
@@ -74,7 +75,7 @@ public static synchronized String[] getAvailableCiphers()
7475
*/
7576
public static synchronized String[] getAvailableMACs()
7677
{
77-
return MAC.getMacList();
78+
return MACs.getMacList();
7879
}
7980

8081
/**
@@ -1273,7 +1274,7 @@ public synchronized void setClient2ServerMACs(String[] macs)
12731274
if ((macs == null) || (macs.length == 0))
12741275
throw new IllegalArgumentException();
12751276
macs = removeDuplicates(macs);
1276-
MAC.checkMacList(macs);
1277+
MACs.checkMacList(macs);
12771278
cryptoWishList.c2s_mac_algos = macs;
12781279
}
12791280

@@ -1319,7 +1320,7 @@ public synchronized void setServer2ClientMACs(String[] macs)
13191320
throw new IllegalArgumentException();
13201321

13211322
macs = removeDuplicates(macs);
1322-
MAC.checkMacList(macs);
1323+
MACs.checkMacList(macs);
13231324
cryptoWishList.s2c_mac_algos = macs;
13241325
}
13251326

sshlib/src/main/java/com/trilead/ssh2/crypto/CryptoWishList.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import com.trilead.ssh2.compression.CompressionFactory;
55
import com.trilead.ssh2.crypto.cipher.BlockCipherFactory;
6-
import com.trilead.ssh2.crypto.digest.MAC;
6+
import com.trilead.ssh2.crypto.digest.MACs;
77
import com.trilead.ssh2.transport.KexManager;
88

99

@@ -19,8 +19,8 @@ public class CryptoWishList
1919
public String[] serverHostKeyAlgorithms = KexManager.getDefaultServerHostkeyAlgorithmList();
2020
public String[] c2s_enc_algos = BlockCipherFactory.getDefaultCipherList();
2121
public String[] s2c_enc_algos = BlockCipherFactory.getDefaultCipherList();
22-
public String[] c2s_mac_algos = MAC.getMacList();
23-
public String[] s2c_mac_algos = MAC.getMacList();
22+
public String[] c2s_mac_algos = MACs.getMacList();
23+
public String[] s2c_mac_algos = MACs.getMacList();
2424
public String[] c2s_comp_algos = CompressionFactory.getDefaultCompressorList();
2525
public String[] s2c_comp_algos = CompressionFactory.getDefaultCompressorList();
2626
}

sshlib/src/main/java/com/trilead/ssh2/crypto/PEMDecoder.java

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
import com.trilead.ssh2.crypto.cipher.AES;
3131
import com.trilead.ssh2.crypto.cipher.BlockCipher;
32-
import com.trilead.ssh2.crypto.cipher.CBCMode;
3332
import com.trilead.ssh2.crypto.cipher.DES;
3433
import com.trilead.ssh2.crypto.cipher.DESede;
3534
import com.trilead.ssh2.packets.TypesReader;
@@ -60,7 +59,7 @@ public class PEMDecoder
6059
'o', 'p', 'e', 'n', 's', 's', 'h', '-', 'k', 'e', 'y', '-', 'v', '1', '\0',
6160
};
6261

63-
private static final int hexToInt(char c)
62+
private static int hexToInt(char c)
6463
{
6564
if ((c >= 'a') && (c <= 'f'))
6665
{
@@ -276,41 +275,36 @@ public static final PEMStructure parsePEM(char[] pem) throws IOException
276275
return ps;
277276
}
278277

279-
private static final byte[] decryptData(byte[] data, byte[] pw, byte[] salt, int rounds, String algo) throws IOException
278+
private static byte[] decryptData(byte[] data, byte[] pw, byte[] salt, int rounds, String algo) throws IOException
280279
{
281-
BlockCipher rawCipher;
282280
BlockCipher bc;
283281
int keySize;
284282

285283
String algoLower = algo.toLowerCase(Locale.US);
286284
if (algoLower.equals("des-ede3-cbc"))
287285
{
288-
rawCipher = new DESede();
286+
bc = new DESede.CBC();
289287
keySize = 24;
290-
bc = new CBCMode(rawCipher, salt, false);
291288
}
292289
else if (algoLower.equals("des-cbc"))
293290
{
294-
rawCipher = new DES();
291+
bc = new DES.CBC();
295292
keySize = 8;
296-
bc = new CBCMode(rawCipher, salt, false);
297293
}
298294
else if (algoLower.equals("aes-128-cbc") || algoLower.equals("aes128-cbc"))
299295
{
300-
rawCipher = new AES();
296+
bc = new AES.CBC();
301297
keySize = 16;
302-
bc = new CBCMode(rawCipher, salt, false);
303298
}
304299
else if (algoLower.equals("aes-192-cbc") || algoLower.equals("aes192-cbc"))
305300
{
306-
rawCipher = new AES();
301+
bc = new AES.CBC();
307302
keySize = 24;
308303
}
309304
else if (algoLower.equals("aes-256-cbc") || algoLower.equals("aes256-cbc"))
310305
{
311-
rawCipher = new AES();
306+
bc = new AES.CBC();
312307
keySize = 32;
313-
bc = new CBCMode(rawCipher, salt, false);
314308
}
315309
else
316310
{
@@ -319,13 +313,12 @@ else if (algoLower.equals("aes-256-cbc") || algoLower.equals("aes256-cbc"))
319313

320314
if (rounds == -1)
321315
{
322-
rawCipher.init(false, generateKeyFromPasswordSaltWithMD5(pw, salt, keySize));
323-
bc = new CBCMode(rawCipher, salt, false);
316+
bc.init(false, generateKeyFromPasswordSaltWithMD5(pw, salt, keySize), salt);
324317
}
325318
else
326319
{
327320
byte[] key = new byte[keySize];
328-
byte[] iv = new byte[rawCipher.getBlockSize()];
321+
byte[] iv = new byte[bc.getBlockSize()];
329322

330323
byte[] keyAndIV = new byte[key.length + iv.length];
331324

@@ -334,8 +327,7 @@ else if (algoLower.equals("aes-256-cbc") || algoLower.equals("aes256-cbc"))
334327
System.arraycopy(keyAndIV, 0, key, 0, key.length);
335328
System.arraycopy(keyAndIV, key.length, iv, 0, iv.length);
336329

337-
rawCipher.init(false, key);
338-
bc = new CBCMode(rawCipher, iv, false);
330+
bc.init(false, key, iv);
339331
}
340332

341333

@@ -360,7 +352,7 @@ else if (algoLower.equals("aes-256-cbc") || algoLower.equals("aes256-cbc"))
360352
}
361353
}
362354

363-
private static final void decryptPEM(PEMStructure ps, byte[] pw) throws IOException
355+
private static void decryptPEM(PEMStructure ps, byte[] pw) throws IOException
364356
{
365357
if (ps.dekInfo == null)
366358
throw new IOException("Broken PEM, no mode and salt given, but encryption enabled");

0 commit comments

Comments
 (0)