39cad7d
diff -up azureus-5.3.0.0/com/aelitis/azureus/core/security/impl/CryptoHandlerECC.java.no-bundled-bouncycastle azureus-5.3.0.0/com/aelitis/azureus/core/security/impl/CryptoHandlerECC.java
20321a2
--- azureus-5.3.0.0/com/aelitis/azureus/core/security/impl/CryptoHandlerECC.java.no-bundled-bouncycastle	2012-07-12 22:36:34.000000000 +0200
20321a2
+++ azureus-5.3.0.0/com/aelitis/azureus/core/security/impl/CryptoHandlerECC.java	2014-03-06 18:07:37.000000000 +0100
7840028
@@ -29,6 +29,7 @@ import java.security.KeyPair;
7840028
 import java.security.PrivateKey;
7840028
 import java.security.PublicKey;
7840028
 import java.security.SecureRandom;
7840028
+import java.security.Security;
7840028
 import java.security.Signature;
7840028
 import java.security.spec.AlgorithmParameterSpec;
7840028
 import java.util.Arrays;
20321a2
@@ -37,9 +38,10 @@ import javax.crypto.BadPaddingException;
39cad7d
 import javax.crypto.Cipher;
39cad7d
 import javax.crypto.IllegalBlockSizeException;
39cad7d
 
39cad7d
-import org.bouncycastle.jce.provider.JCEIESCipher;
20321a2
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
39cad7d
 import org.bouncycastle.jce.spec.IEKeySpec;
39cad7d
 import org.bouncycastle.jce.spec.IESParameterSpec;
20321a2
+
39cad7d
 import org.gudy.azureus2.core3.config.COConfigurationManager;
20321a2
 import org.gudy.azureus2.core3.util.Base32;
20321a2
 import org.gudy.azureus2.core3.util.Debug;
20321a2
@@ -79,7 +81,9 @@ CryptoHandlerECC
7840028
 		CryptoManagerImpl		_manager,
7840028
 		int						_instance_id )
7840028
 	{
7840028
-		manager	= _manager;
7840028
+		Security.addProvider(new BouncyCastleProvider());
7840028
+
7840028
+	        manager	= _manager;
7840028
 		
7840028
 		CONFIG_PREFIX += _instance_id + ".";
7840028
 		
20321a2
@@ -225,11 +229,11 @@ CryptoHandlerECC
39cad7d
 			
39cad7d
 			IESParameterSpec param = new IESParameterSpec( d, e, 128);
39cad7d
 		
39cad7d
-			InternalECIES	cipher = new InternalECIES();
39cad7d
+			Cipher cipher = Cipher.getInstance("ECIES");
39cad7d
 	
39cad7d
-			cipher.internalEngineInit( Cipher.ENCRYPT_MODE, key_spec, param, null ); 
39cad7d
+			cipher.init( Cipher.ENCRYPT_MODE, key_spec, param, null ); 
39cad7d
 		
39cad7d
-			byte[]	encrypted = cipher.internalEngineDoFinal(data, 0, data.length );
39cad7d
+			byte[]	encrypted = cipher.doFinal(data, 0, data.length );
39cad7d
 			
39cad7d
 			byte[] result = new byte[32+encrypted.length];
39cad7d
 			
20321a2
@@ -268,12 +272,11 @@ CryptoHandlerECC
39cad7d
 			
39cad7d
 			IESParameterSpec param = new IESParameterSpec( d, e, 128);
39cad7d
 		
39cad7d
-			InternalECIES	cipher = new InternalECIES();
39cad7d
-	
39cad7d
-			cipher.internalEngineInit( Cipher.DECRYPT_MODE, key_spec, param, null ); 
39cad7d
-		
39cad7d
-			return( cipher.internalEngineDoFinal( data, 32, data.length - 32 ));
39cad7d
-			
39cad7d
+			Cipher cipher = Cipher.getInstance("ECIES");
39cad7d
+
39cad7d
+			cipher.init( Cipher.DECRYPT_MODE, key_spec, param, null ); 
39cad7d
+
39cad7d
+			return( cipher.doFinal( data, 32, data.length - 32 ));
39cad7d
 		}catch( CryptoManagerException e ){
39cad7d
 			
39cad7d
 			throw( e );
20321a2
@@ -860,32 +863,4 @@ CryptoHandlerECC
39cad7d
 		return((int)COConfigurationManager.getIntParameter( CONFIG_PREFIX + "pwtype", CryptoManagerPasswordHandler.HANDLER_TYPE_USER ));
39cad7d
 	}
39cad7d
 	
39cad7d
-	class InternalECIES 
39cad7d
-		extends JCEIESCipher.ECIES
39cad7d
-	{
39cad7d
-			// we use this class to obtain compatability with BC
39cad7d
-
39cad7d
-		public void 
39cad7d
-		internalEngineInit(
39cad7d
-			int                     opmode,
39cad7d
-			Key                     key,
39cad7d
-			AlgorithmParameterSpec  params,
39cad7d
-			SecureRandom            random ) 
39cad7d
-		
39cad7d
-			throws InvalidKeyException, InvalidAlgorithmParameterException
39cad7d
-		{
39cad7d
-			engineInit(opmode, key, params, random);
39cad7d
-		}
39cad7d
-
39cad7d
-		protected byte[] 
39cad7d
-		internalEngineDoFinal(
39cad7d
-			byte[]  input,
39cad7d
-			int     inputOffset,
39cad7d
-			int     inputLen ) 
39cad7d
-		
39cad7d
-			throws IllegalBlockSizeException, BadPaddingException
39cad7d
-		{
39cad7d
-			return engineDoFinal(input, inputOffset, inputLen);
39cad7d
-		}
39cad7d
-	}
39cad7d
 }
39cad7d
diff -up azureus-5.3.0.0/com/aelitis/azureus/core/security/impl/CryptoSTSEngineImpl.java.no-bundled-bouncycastle azureus-5.3.0.0/com/aelitis/azureus/core/security/impl/CryptoSTSEngineImpl.java
39cad7d
--- azureus-5.3.0.0/com/aelitis/azureus/core/security/impl/CryptoSTSEngineImpl.java.no-bundled-bouncycastle	2013-05-08 22:11:40.000000000 +0200
20321a2
+++ azureus-5.3.0.0/com/aelitis/azureus/core/security/impl/CryptoSTSEngineImpl.java	2014-03-06 17:57:31.000000000 +0100
5c759c9
@@ -30,10 +30,12 @@ import java.security.KeyPair;
5c759c9
 import java.security.PrivateKey;
5c759c9
 import java.security.PublicKey;
5c759c9
 import java.security.SecureRandom;
5c759c9
+import java.security.Security;
5c759c9
 import java.security.Signature;
5c759c9
 
5c759c9
+import javax.crypto.KeyAgreement;
5c759c9
+
5c759c9
 import org.bouncycastle.jce.provider.BouncyCastleProvider;
5c759c9
-import org.bouncycastle.jce.provider.JCEECDHKeyAgreement;
5c759c9
 
5c759c9
 import com.aelitis.azureus.core.security.CryptoECCUtils;
5c759c9
 import com.aelitis.azureus.core.security.CryptoManagerException;
5c759c9
@@ -57,7 +59,7 @@ CryptoSTSEngineImpl
5c759c9
 	private PublicKey 	remotePubKey;
5c759c9
 	private byte[] 		sharedSecret;
5c759c9
 	
5c759c9
-	private InternalDH	ecDH;
5c759c9
+        private KeyAgreement	ecDH;
5c759c9
 	
5c759c9
 	/**
5c759c9
 	 * 
5c759c9
@@ -76,9 +78,9 @@ CryptoSTSEngineImpl
5c759c9
 		ephemeralKeyPair = CryptoECCUtils.createKeys();
5c759c9
 		
5c759c9
 		try{
5c759c9
-			ecDH = new InternalDH();
5c759c9
-			
5c759c9
-			//ecDH = KeyAgreement.getInstance("ECDH", BouncyCastleProvider.PROVIDER_NAME);
5c759c9
+		        Security.addProvider(new BouncyCastleProvider());
5c759c9
+
2cad8bd
+			ecDH = KeyAgreement.getInstance("ECDH");
5c759c9
 			
5c759c9
 			ecDH.init(ephemeralKeyPair.getPrivate());
5c759c9
 			
5c759c9
@@ -402,38 +404,4 @@ CryptoSTSEngineImpl
5c759c9
 			throw( new CryptoManagerException( "Failed to put byte[]", e ));
5c759c9
 		}
5c759c9
 	}
5c759c9
-	
5c759c9
-	class 
5c759c9
-	InternalDH 
5c759c9
-		extends JCEECDHKeyAgreement.DH
5c759c9
-	{
5c759c9
-			// we use this class to obtain compatability with BC
5c759c9
-		
5c759c9
-		public void
5c759c9
-		init(
5c759c9
-			Key		key )
5c759c9
-
5c759c9
-			throws InvalidKeyException, InvalidAlgorithmParameterException
5c759c9
-		{
5c759c9
-			engineInit( key, null );
5c759c9
-		}
5c759c9
-
5c759c9
-		public Key
5c759c9
-		doPhase(
5c759c9
-			Key		key,
5c759c9
-			boolean	lastPhase )
5c759c9
-
5c759c9
-			throws InvalidKeyException, IllegalStateException
5c759c9
-		{
5c759c9
-			return( engineDoPhase( key, lastPhase ));
5c759c9
-		}
5c759c9
-
5c759c9
-		public byte[] 
5c759c9
-		generateSecret() 
5c759c9
-		
5c759c9
-			throws IllegalStateException
5c759c9
-		{
5c759c9
-			return( engineGenerateSecret());
5c759c9
-		}
5c759c9
-	}
5c759c9
-}
5c759c9
\ No newline at end of file
5c759c9
+}
39cad7d
diff -up azureus-5.3.0.0/org/gudy/azureus2/core3/security/impl/SESecurityManagerBC.java.no-bundled-bouncycastle azureus-5.3.0.0/org/gudy/azureus2/core3/security/impl/SESecurityManagerBC.java
39cad7d
--- azureus-5.3.0.0/org/gudy/azureus2/core3/security/impl/SESecurityManagerBC.java.no-bundled-bouncycastle	2013-08-13 17:32:46.000000000 +0200
20321a2
+++ azureus-5.3.0.0/org/gudy/azureus2/core3/security/impl/SESecurityManagerBC.java	2014-03-06 17:57:31.000000000 +0100
5c759c9
@@ -39,6 +39,7 @@ import java.util.Calendar;
5c759c9
 import org.bouncycastle.jce.*;
5c759c9
 import org.bouncycastle.jce.provider.BouncyCastleProvider;
5c759c9
 import org.bouncycastle.asn1.x509.X509Name;
5c759c9
+import org.bouncycastle.x509.X509V3CertificateGenerator;
5c759c9
 import org.gudy.azureus2.core3.util.Constants;
5c759c9
 import org.gudy.azureus2.core3.util.Debug;
5c759c9
 import org.gudy.azureus2.core3.util.RandomUtils;