You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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();
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
The text was updated successfully, but these errors were encountered: