Hello to all,
I've got a problem in my Application, which is really strange.
I've an error when I want to sign a digital signature, based on RSA 1024, in Android 4.2.2, but when I run my App on Android 4.0.4 it just runs correctly.
Here's the code
1. I locate the file to decrypt.
2. I decrypt the file , and I've already made a Log and it decrypts it correctly.
3. When I run the key_.PrivateKeyFromBytes(xbytes) line the App 'crashes', and I got this Log error.
Is there a problem running the App on Android 4.2.2?
I can't get where the problem lives, and mostly, why when I run it on 4.0.4 it just plays perfectly.
Thank you all.
Best regards.
I've got a problem in my Application, which is really strange.
I've an error when I want to sign a digital signature, based on RSA 1024, in Android 4.2.2, but when I run my App on Android 4.0.4 it just runs correctly.
Here's the code
B4X:
Dim xbytes() As Byte
Dim xchave As String
Dim sf As StringFunctions
Dim str As String
str = File.ReadString(File.DirAssets, "file.txt")
str = sf.Decrypt(str)
xchave = str
Dim private_key_byte As StringUtils
xbytes = private_key_byte.DecodeBase64(xchave)
Dim key_ As KeyPairGenerator
key_.Initialize("RSA",1024)
key_.PrivateKeyFromBytes(xbytes)
1. I locate the file to decrypt.
2. I decrypt the file , and I've already made a Log and it decrypts it correctly.
3. When I run the key_.PrivateKeyFromBytes(xbytes) line the App 'crashes', and I got this Log error.
B4X:
java.security.spec.InvalidKeySpecException: java.lang.RuntimeException: error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
at org.apache.harmony.xnet.provider.jsse.OpenSSLRSAKeyFactory.engineGeneratePrivate(OpenSSLRSAKeyFactory.java:77)
at java.security.KeyFactory.generatePrivate(KeyFactory.java:186)
at anywheresoftware.b4a.agraham.encryption.CipherWrapper$KeyPairGeneratorWrapper.PrivateKeyFromBytes(CipherWrapper.java:457)
at b4a.tapinvoice.cls_doccab._certificadocumentosaftpt(cls_doccab.java:1439)
at b4a.tapinvoice.main._funcao_finaliza_documento(main.java:7864)
at b4a.tapinvoice.main._botao_imprimir_click(main.java:2465)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:173)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:161)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:157)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:66)
at android.view.View.performClick(View.java:4207)
at android.view.View$PerformClick.run(View.java:17372)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5042)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
at org.apache.harmony.xnet.provider.jsse.NativeCrypto.d2i_PKCS8_PRIV_KEY_INFO(Native Method)
at org.apache.harmony.xnet.provider.jsse.OpenSSLRSAKeyFactory.engineGeneratePrivate(OpenSSLRSAKeyFactory.java:73)
... 22 more
Is there a problem running the App on Android 4.2.2?
I can't get where the problem lives, and mostly, why when I run it on 4.0.4 it just plays perfectly.
Thank you all.
Best regards.