diff --git a/ChangeLog.md b/ChangeLog.md index eaff456c..bcf02a56 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,7 @@ * Added support for the blowfish-ctr algorithm from [RFC 4344](https://datatracker.ietf.org/doc/html/rfc4344) * Fix bug where ext-info-c was incorrectly advertised during rekeying * According to [RFC 8308 section 2.1](https://datatracker.ietf.org/doc/html/rfc8308#section-2.1), ext-info-c should only advertised during the first key exchange + * Address [#77](https://github.com/mwiede/jsch/issues/77) by attempting to add compatibility with older [Bouncy Castle](https://www.bouncycastle.org/) releases * [0.1.66](https://github.com/mwiede/jsch/releases/tag/jsch-0.1.66) * Added support for [RFC 8308](https://datatracker.ietf.org/doc/html/rfc8308) extension negotiation and server-sig-algs extension * This support is enabled by default, but can be controlled via the enable_server_sig_algs config option (or `jsch.enable_server_sig_algs` system property) diff --git a/src/main/java/com/jcraft/jsch/bc/ChaCha20Poly1305.java b/src/main/java/com/jcraft/jsch/bc/ChaCha20Poly1305.java index 8ab84dc9..dc548a7e 100644 --- a/src/main/java/com/jcraft/jsch/bc/ChaCha20Poly1305.java +++ b/src/main/java/com/jcraft/jsch/bc/ChaCha20Poly1305.java @@ -68,8 +68,8 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception{ System.arraycopy(key, 0, K_2, 0, bsize/2); this.mode=mode; try{ - K_1_spec=new KeyParameter(K_1); - K_2_spec=new KeyParameter(K_2); + K_1_spec=new KeyParameter(K_1, 0, K_1.length); + K_2_spec=new KeyParameter(K_2, 0, K_2.length); header_cipher=new ChaChaEngine(); main_cipher=new ChaChaEngine(); } @@ -85,8 +85,8 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception{ public void update(int foo) throws Exception{ ByteBuffer nonce=ByteBuffer.allocate(8); nonce.putLong(0, foo); - header_cipher.init(this.mode==ENCRYPT_MODE, new ParametersWithIV(K_1_spec, nonce.array())); - main_cipher.init(this.mode==ENCRYPT_MODE, new ParametersWithIV(K_2_spec, nonce.array())); + header_cipher.init(this.mode==ENCRYPT_MODE, new ParametersWithIV(K_1_spec, nonce.array(), 0, nonce.array().length)); + main_cipher.init(this.mode==ENCRYPT_MODE, new ParametersWithIV(K_2_spec, nonce.array(), 0, nonce.array().length)); // Trying to reinit the cipher again with same nonce results in InvalidKeyException // So just read entire first 64-byte block, which should increment global counter from 0->1 byte[] poly_key = new byte[32]; diff --git a/src/main/java/com/jcraft/jsch/bc/SignatureEdDSA.java b/src/main/java/com/jcraft/jsch/bc/SignatureEdDSA.java index a0ae6ff6..872c26d9 100644 --- a/src/main/java/com/jcraft/jsch/bc/SignatureEdDSA.java +++ b/src/main/java/com/jcraft/jsch/bc/SignatureEdDSA.java @@ -63,11 +63,11 @@ public void init() throws Exception{ public void setPubKey(byte[] y_arr) throws Exception{ try { if(getAlgo().equals("Ed25519")){ - Ed25519PublicKeyParameters pubKey = new Ed25519PublicKeyParameters(y_arr); + Ed25519PublicKeyParameters pubKey = new Ed25519PublicKeyParameters(y_arr, 0); signature.init(false, pubKey); } else{ - Ed448PublicKeyParameters pubKey = new Ed448PublicKeyParameters(y_arr); + Ed448PublicKeyParameters pubKey = new Ed448PublicKeyParameters(y_arr, 0); signature.init(false, pubKey); } } @@ -80,11 +80,11 @@ public void setPubKey(byte[] y_arr) throws Exception{ public void setPrvKey(byte[] bytes) throws Exception{ try { if(getAlgo().equals("Ed25519")){ - Ed25519PrivateKeyParameters prvKey = new Ed25519PrivateKeyParameters(bytes); + Ed25519PrivateKeyParameters prvKey = new Ed25519PrivateKeyParameters(bytes, 0); signature.init(true, prvKey); } else{ - Ed448PrivateKeyParameters prvKey = new Ed448PrivateKeyParameters(bytes); + Ed448PrivateKeyParameters prvKey = new Ed448PrivateKeyParameters(bytes, 0); signature.init(true, prvKey); } } diff --git a/src/main/java/com/jcraft/jsch/bc/XDH.java b/src/main/java/com/jcraft/jsch/bc/XDH.java index da06b158..e6e306b3 100644 --- a/src/main/java/com/jcraft/jsch/bc/XDH.java +++ b/src/main/java/com/jcraft/jsch/bc/XDH.java @@ -69,7 +69,7 @@ public byte[] getSecret(byte[] Q) throws Exception{ if(name.equals("X25519")){ X25519PublicKeyParameters publicKey = null; try{ - publicKey = new X25519PublicKeyParameters(Q); + publicKey = new X25519PublicKeyParameters(Q, 0); } catch(Exception e){ throw new InvalidKeyException(e); @@ -86,7 +86,7 @@ public byte[] getSecret(byte[] Q) throws Exception{ else{ X448PublicKeyParameters publicKey = null; try{ - publicKey = new X448PublicKeyParameters(Q); + publicKey = new X448PublicKeyParameters(Q, 0); } catch(Exception e){ throw new InvalidKeyException(e);