Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Q spongy castle issue #48

Open
suriyaKalidoss123 opened this issue Jul 20, 2019 · 0 comments
Open

Android Q spongy castle issue #48

suriyaKalidoss123 opened this issue Jul 20, 2019 · 0 comments

Comments

@suriyaKalidoss123
Copy link

suriyaKalidoss123 commented Jul 20, 2019

From API level 28, Google has restricted Security provider feature(bouncy castle issue). So alternatively we have added Security provider using spongy castle Now we can able to generate a keypair. But the key pair is not matching with the previous one. We can't get Private keyThis is we used previously,Old code api 27:

KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC", "BC");
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
keyGen.initialize(256, random);
KeyFactory kaif = KeyFactory.getInstance("EC", "BC");
KeyPair pair = keyGen.generateKeyPair();
PrivateKey privateKey = pair.getPrivate();
PublicKey publicKey = pair.getPublic();

After the API level issue, we have removed "BC" and added Bouncy Castle manually by adding the below lineSecurity.insertProviderAt(BouncyCastleProvider(), 1); by implementing Bouncy castle in dependencies, implementation "com.madgag.spongycastle:core:1.58.0.0" implementation "com.madgag.spongycastle:prov:1.58.0.0" But the key pair is not matching with the previous one. New Code:api 28
Security.insertProviderAt(new org.spongycastle.jce.provider.BouncyCastleProvider(), 1);
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC");
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
keyGen.initialize(256, random);
KeyFactory kaif = KeyFactory.getInstance("EC");
KeyPair pair = keyGen.generateKeyPair();
PrivateKey privateKey = pair.getPrivate();
PublicKey publicKey = pair.getPublic();

**Issue:
EC Private Key [f5:ac:ed:47:79:86:8b:7f:ee:54:ed:a3:37:1c:19:e7:8e:43:71:65]
X: 644540eb3c2dba45cb1085c4c063cd5f89d4514585f2108102a94faae8357a11
Y: 11087095e61da377e4a9fb9369a6074c3ba7cf472e0ed9bc57326d60d42de39

EC Public Key [f5:ac:ed:47:79:86:8b:7f:ee:54:ed:a3:37:1c:19:e7:8e:43:71:65]
X: 644540eb3c2dba45cb1085c4c063cd5f89d4514585f2108102a94faae8357a11
Y: 11087095e61da377e4a9fb9369a6074c3ba7cf472e0ed9bc57326d60d42de39

Expectation:
EC Private Key
S: c831bb8b5682e1960b14902b9f4d80b36eb481dabb9ce5b43fa4f8413e3a7198
EC Public Key
X: 1b6015f63670cee9058950e9ad553dbe4bc8f0f0d7b3b366ef7a284b916f3a71
Y: e562f35d5fe84e867525c5b26fd125e56582a1491adb2a21602a27f106b1d5ae**
Private key values differs
MyApplication.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant