diff -up azureus-5.7.2.0/com/aelitis/azureus/core/security/impl/CryptoHandlerECC.java.no-bundled-bouncycastle azureus-5.7.2.0/com/aelitis/azureus/core/security/impl/CryptoHandlerECC.java
--- azureus-5.7.2.0/com/aelitis/azureus/core/security/impl/CryptoHandlerECC.java.no-bundled-bouncycastle 2016-04-13 20:20:34.000000000 +0200
+++ azureus-5.7.2.0/com/aelitis/azureus/core/security/impl/CryptoHandlerECC.java 2016-05-31 21:42:05.163196609 +0200
@@ -26,6 +26,7 @@ import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
+import java.security.Security;
import java.security.Signature;
import java.security.spec.AlgorithmParameterSpec;
import java.util.Arrays;
@@ -39,10 +40,11 @@ import org.gudy.azureus2.core3.util.Base
import org.gudy.azureus2.core3.util.Debug;
import org.gudy.azureus2.core3.util.RandomUtils;
import org.gudy.azureus2.core3.util.SystemTime;
-import org.gudy.bouncycastle.jce.provider.JCEIESCipher;
import org.gudy.bouncycastle.jce.spec.IEKeySpec;
import org.gudy.bouncycastle.jce.spec.IESParameterSpec;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+
import com.aelitis.azureus.core.security.CryptoECCUtils;
import com.aelitis.azureus.core.security.CryptoHandler;
import com.aelitis.azureus.core.security.CryptoManager;
@@ -76,7 +78,9 @@ CryptoHandlerECC
CryptoManagerImpl _manager,
int _instance_id )
{
- manager = _manager;
+ Security.addProvider(new BouncyCastleProvider());
+
+ manager = _manager;
CONFIG_PREFIX += _instance_id + ".";
@@ -222,11 +226,11 @@ CryptoHandlerECC
IESParameterSpec param = new IESParameterSpec( d, e, 128);
- InternalECIES cipher = new InternalECIES();
+ Cipher cipher = Cipher.getInstance("ECIES");
- cipher.internalEngineInit( Cipher.ENCRYPT_MODE, key_spec, param, null );
+ cipher.init( Cipher.ENCRYPT_MODE, key_spec, param, null );
- byte[] encrypted = cipher.internalEngineDoFinal(data, 0, data.length );
+ byte[] encrypted = cipher.doFinal(data, 0, data.length );
byte[] result = new byte[32+encrypted.length];
@@ -265,12 +269,11 @@ CryptoHandlerECC
IESParameterSpec param = new IESParameterSpec( d, e, 128);
- InternalECIES cipher = new InternalECIES();
-
- cipher.internalEngineInit( Cipher.DECRYPT_MODE, key_spec, param, null );
-
- return( cipher.internalEngineDoFinal( data, 32, data.length - 32 ));
-
+ Cipher cipher = Cipher.getInstance("ECIES");
+
+ cipher.init( Cipher.DECRYPT_MODE, key_spec, param, null );
+
+ return( cipher.doFinal( data, 32, data.length - 32 ));
}catch( CryptoManagerException e ){
throw( e );
@@ -867,32 +870,4 @@ CryptoHandlerECC
return((int)COConfigurationManager.getIntParameter( CONFIG_PREFIX + "pwtype", CryptoManagerPasswordHandler.HANDLER_TYPE_USER ));
}
- class InternalECIES
- extends JCEIESCipher.ECIES
- {
- // we use this class to obtain compatability with BC
-
- public void
- internalEngineInit(
- int opmode,
- Key key,
- AlgorithmParameterSpec params,
- SecureRandom random )
-
- throws InvalidKeyException, InvalidAlgorithmParameterException
- {
- engineInit(opmode, key, params, random);
- }
-
- protected byte[]
- internalEngineDoFinal(
- byte[] input,
- int inputOffset,
- int inputLen )
-
- throws IllegalBlockSizeException, BadPaddingException
- {
- return engineDoFinal(input, inputOffset, inputLen);
- }
- }
}
diff -up azureus-5.7.2.0/com/aelitis/azureus/core/security/impl/CryptoSTSEngineImpl.java.no-bundled-bouncycastle azureus-5.7.2.0/com/aelitis/azureus/core/security/impl/CryptoSTSEngineImpl.java
--- azureus-5.7.2.0/com/aelitis/azureus/core/security/impl/CryptoSTSEngineImpl.java.no-bundled-bouncycastle 2016-04-13 20:20:34.000000000 +0200
+++ azureus-5.7.2.0/com/aelitis/azureus/core/security/impl/CryptoSTSEngineImpl.java 2016-05-31 21:34:02.347582804 +0200
@@ -27,15 +27,16 @@ import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
+import java.security.Security;
import java.security.Signature;
-import org.gudy.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.gudy.bouncycastle.jce.provider.JCEECDHKeyAgreement;
+import javax.crypto.KeyAgreement;
import com.aelitis.azureus.core.security.CryptoECCUtils;
import com.aelitis.azureus.core.security.CryptoManagerException;
import com.aelitis.azureus.core.security.CryptoSTSEngine;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
/**
@@ -54,7 +55,7 @@ CryptoSTSEngineImpl
private PublicKey remotePubKey;
private byte[] sharedSecret;
- private InternalDH ecDH;
+ private KeyAgreement ecDH;
/**
*
@@ -73,9 +74,9 @@ CryptoSTSEngineImpl
ephemeralKeyPair = CryptoECCUtils.createKeys();
try{
- ecDH = new InternalDH();
-
- //ecDH = KeyAgreement.getInstance("ECDH", BouncyCastleProvider.PROVIDER_NAME);
+ Security.addProvider(new BouncyCastleProvider());
+
+ ecDH = KeyAgreement.getInstance("ECDH");
ecDH.init(ephemeralKeyPair.getPrivate());
@@ -399,38 +400,4 @@ CryptoSTSEngineImpl
throw( new CryptoManagerException( "Failed to put byte[]", e ));
}
}
-
- class
- InternalDH
- extends JCEECDHKeyAgreement.DH
- {
- // we use this class to obtain compatability with BC
-
- public void
- init(
- Key key )
-
- throws InvalidKeyException, InvalidAlgorithmParameterException
- {
- engineInit( key, null );
- }
-
- public Key
- doPhase(
- Key key,
- boolean lastPhase )
-
- throws InvalidKeyException, IllegalStateException
- {
- return( engineDoPhase( key, lastPhase ));
- }
-
- public byte[]
- generateSecret()
-
- throws IllegalStateException
- {
- return( engineGenerateSecret());
- }
- }
-}
\ No newline at end of file
+}