simple_rsa icon indicating copy to clipboard operation
simple_rsa copied to clipboard

falied to decrypt

Open amervelic opened this issue 6 years ago • 1 comments

java.security.spec.InvalidKeySpecException: java.lang.RuntimeException: error:0c0890ba:ASN.1 encoding routines:asn1_check_tlen:WRONG_TAG W/System.err(14558): at com.android.org.conscrypt.OpenSSLKey.getPrivateKey(OpenSSLKey.java:283) W/System.err(14558): at com.android.org.conscrypt.OpenSSLRSAKeyFactory.engineGeneratePrivate(OpenSSLRSAKeyFactory.java:64) W/System.err(14558): at java.security.KeyFactory.generatePrivate(KeyFactory.java:187) W/System.err(14558): at com.juanito21.simplersa.SimpleRsaPlugin.loadPrivateKey(SimpleRsaPlugin.kt:146) W/System.err(14558): at com.juanito21.simplersa.SimpleRsaPlugin.decryptData(SimpleRsaPlugin.kt:154) W/System.err(14558): at com.juanito21.simplersa.SimpleRsaPlugin.onMethodCall(SimpleRsaPlugin.kt:62) W/System.err(14558): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:200) W/System.err(14558): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163) W/System.err(14558): at android.os.MessageQueue.nativePollOnce(Native Method) W/System.err(14558): at android.os.MessageQueue.next(MessageQueue.java:323) W/System.err(14558): at android.os.Looper.loop(Looper.java:144) W/System.err(14558): at android.app.ActivityThread.main(ActivityThread.java:5885) W/System.err(14558): at java.lang.reflect.Method.invoke(Native Method) W/System.err(14558): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797) W/System.err(14558): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687) W/System.err(14558): Caused by: java.lang.RuntimeException: error:0c0890ba:ASN.1 encoding routines:asn1_check_tlen:WRONG_TAG W/System.err(14558): at com.android.org.conscrypt.NativeCrypto.d2i_PKCS8_PRIV_KEY_INFO(Native Method) W/System.err(14558): at com.android.org.conscrypt.OpenSSLKey.getPrivateKey(OpenSSLKey.java:281) W/System.err(14558): ... 14 more I/flutter (14558): Failed decoded string: 'Decrypt failure.'.

amervelic avatar Feb 11 '19 17:02 amervelic

You might want to try removing the opening and closing tags

String publicKey = rsaPublickey; // how ever you choose to parse your key
publicKey = publicKey.replaceAll("-----BEGIN PUBLIC KEY-----", "").replaceAll("-----END PUBLIC KEY-----", "");

There's a pending pull request ( #7 ) to do this automatically

riftninja avatar Feb 17 '19 12:02 riftninja