Hello world. Currently I am working on an Android application, was a time I do a key exchange between the mobile and a J2EE server, I use the Diffie Hellman, here is how I did for the initialization:
Security.addProvider (new BouncyCastleProvider ()); Provider provider = new BouncyCastleProvider (); String algorithm = "DH"; random = new SecureRandom (); pInteger = new BigInteger (p); pInteger BigInteger.probablePrime = (keysize, random); gInteger = new BigInteger (g); gInteger BigInteger.probablePrime = (keysize, random); DHParameterSpec = new DHParameterSpec (pInteger, gInteger); KeyPairGenerator KeyPairGenerator.getInstance = (algorithm, provider); keyPairGenerator.initialize (DHParameterSpec); KeyPair keyPairGenerator.generateKeyPair = (); KeyFactory KeyFactory.getInstance = (algorithm, provider); keyAgreement KeyAgreement.getInstance = (algorithm, provider); keyPair.getPrivate = PrivateKey (); publicKey keyPair.getPublic = (); Everything works fine on both sides until the moment I have generated the key secret on both sides with this code: keyAgreement.init (PrivateKey); keyAgreement.doPhase (publicKey, true); SecretKey keyAgreement.generateSecret = (algorithm); They'll generate an error: WARN / System.err (623): java.security.InvalidKeyException: DHPublicKey KeyAgreement not for this! Actually I tried with two mobile Android and my code works without problems, and when I try with mobile and server it generates an error. Thank you for your help in advance. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

