cklester Well-Known Member Licensed User Dec 14, 2020 #1 Not sure what this error means, nor how to resolve it. Does anybody know how to fix this? I just installed the new B4J, but I'm not 100% sure this error coincides with the upgrade... but it seems to be. This was definitely working earlier today... B4X: Copy Error occurred on line: 111 (KeyValueStore) org.bouncycastle.crypto.InvalidCipherTextException: pad block corrupted at org.bouncycastle.crypto.paddings.PKCS7Padding.padCount(Unknown Source) at org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher.doFinal(Unknown Source) at anywheresoftware.b4x.object.B4XEncryption.Decrypt(B4XEncryption.java:73) at b4j.example.keyvaluestore._getencrypted(keyvaluestore.java:63) at b4j.example.page_signin._bttn_login_click(page_signin.java:122) at b4j.example.page_signin._txt_loginpassword_action(page_signin.java:197) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91) at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98) at anywheresoftware.b4a.BA$1.run(BA.java:216) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428) at java.base/java.security.AccessController.doPrivileged(Native Method) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96) at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174) at java.base/java.lang.Thread.run(Thread.java:834)
Not sure what this error means, nor how to resolve it. Does anybody know how to fix this? I just installed the new B4J, but I'm not 100% sure this error coincides with the upgrade... but it seems to be. This was definitely working earlier today... B4X: Copy Error occurred on line: 111 (KeyValueStore) org.bouncycastle.crypto.InvalidCipherTextException: pad block corrupted at org.bouncycastle.crypto.paddings.PKCS7Padding.padCount(Unknown Source) at org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher.doFinal(Unknown Source) at anywheresoftware.b4x.object.B4XEncryption.Decrypt(B4XEncryption.java:73) at b4j.example.keyvaluestore._getencrypted(keyvaluestore.java:63) at b4j.example.page_signin._bttn_login_click(page_signin.java:122) at b4j.example.page_signin._txt_loginpassword_action(page_signin.java:197) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91) at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98) at anywheresoftware.b4a.BA$1.run(BA.java:216) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428) at java.base/java.security.AccessController.doPrivileged(Native Method) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96) at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174) at java.base/java.lang.Thread.run(Thread.java:834)
cklester Well-Known Member Licensed User Dec 14, 2020 #2 OK, it's crashing when I attempt to use the wrong password in GetEncrypted(). I'm pretty sure it was not crashing prior to my upgrading of B4J... And I'm not sure it should crash just because I use the wrong password. Upvote 0
OK, it's crashing when I attempt to use the wrong password in GetEncrypted(). I'm pretty sure it was not crashing prior to my upgrading of B4J... And I'm not sure it should crash just because I use the wrong password.
LucaMs Expert Licensed User Longtime User Dec 14, 2020 #3 I think you are talking about KeyValueStore2 which has PutEncrypted and GetEncrypted methods. Now among the internal libraries there is the KeyValueStore library (B4Xlib) which does not have these methods. Upvote 0
I think you are talking about KeyValueStore2 which has PutEncrypted and GetEncrypted methods. Now among the internal libraries there is the KeyValueStore library (B4Xlib) which does not have these methods.
cklester Well-Known Member Licensed User Dec 14, 2020 #4 LucaMs said: I think you are talking about KeyValueStore2 which has PutEncrypted and GetEncrypted methods. Now among the internal libraries there is the KeyValueStore library (B4Xlib) which does not have these methods. Click to expand... Yes, it's a KVS. Upvote 0
LucaMs said: I think you are talking about KeyValueStore2 which has PutEncrypted and GetEncrypted methods. Now among the internal libraries there is the KeyValueStore library (B4Xlib) which does not have these methods. Click to expand... Yes, it's a KVS.
LucaMs Expert Licensed User Longtime User Dec 14, 2020 #5 So you used KeyValueStore2 to save the data but now you have selected KeyValueStore which is a different library. https://www.b4x.com/android/forum/threads/b4x-kvs2-keyvaluestore2-library.120234/#content [read the spoiler] Upvote 0
So you used KeyValueStore2 to save the data but now you have selected KeyValueStore which is a different library. https://www.b4x.com/android/forum/threads/b4x-kvs2-keyvaluestore2-library.120234/#content [read the spoiler]
LucaMs Expert Licensed User Longtime User Dec 14, 2020 #6 Tested. Attachments KVSEncrypted.zip KVSEncrypted.zip 8.8 KB · Views: 561 Upvote 0
cklester Well-Known Member Licensed User Dec 14, 2020 #7 It only crashes when I try the wrong password, not when I use the correct one. Attachments test_kvs_encrypted.zip test_kvs_encrypted.zip 936 bytes · Views: 593 Upvote 0
LucaMs Expert Licensed User Longtime User Dec 14, 2020 #8 cklester said: It only crashes when I try the wrong password, not when I use the correct one. Click to expand... It's true but even with older B4J versions. Upvote 0
cklester said: It only crashes when I try the wrong password, not when I use the correct one. Click to expand... It's true but even with older B4J versions.
LucaMs Expert Licensed User Longtime User Dec 14, 2020 #9 B4X: Copy Dim Name As String Dim Password As String = "MyWrongPW" Try Name = kvsSettings.GetEncrypted("Name", Password) xui.MsgboxAsync(Name, "Decrypted") Catch xui.MsgboxAsync("Wrong password", "Settings") End Try Upvote 0
B4X: Copy Dim Name As String Dim Password As String = "MyWrongPW" Try Name = kvsSettings.GetEncrypted("Name", Password) xui.MsgboxAsync(Name, "Decrypted") Catch xui.MsgboxAsync("Wrong password", "Settings") End Try
cklester Well-Known Member Licensed User Dec 14, 2020 #10 LucaMs said: It's true but even with older B4J versions. Click to expand... I swear this was working fine before... Code: Copy Dim ud As Map = App.userData.GetEncrypted("user_data",pw) If ud.IsInitialized Then 'password worked I think it should return null if it fails. @Erel , can we get this to pass back a null instead? @LucaMs I will try that Try-Catch block in the meantime. Thanks! Upvote 0
LucaMs said: It's true but even with older B4J versions. Click to expand... I swear this was working fine before... Code: Copy Dim ud As Map = App.userData.GetEncrypted("user_data",pw) If ud.IsInitialized Then 'password worked I think it should return null if it fails. @Erel , can we get this to pass back a null instead? @LucaMs I will try that Try-Catch block in the meantime. Thanks!
LucaMs Expert Licensed User Longtime User Dec 14, 2020 #11 cklester said: I swear this was working fine before... Click to expand... I tested it with B4J 8.50 and it crashed (again only with the wrong password, of course). Upvote 0
cklester said: I swear this was working fine before... Click to expand... I tested it with B4J 8.50 and it crashed (again only with the wrong password, of course).
cklester Well-Known Member Licensed User Dec 14, 2020 #12 LucaMs said: B4X: Copy Try...Catch...End Try Click to expand... That works fine, @LucaMs . Thank you for the help! Upvote 0
LucaMs said: B4X: Copy Try...Catch...End Try Click to expand... That works fine, @LucaMs . Thank you for the help!
Erel B4X founder Staff member Licensed User Longtime User Dec 15, 2020 #13 It always throws an error when the password is wrong. This is the code from the example project: Code: Copy 'encrypt the list Starter.kvs.PutEncrypted( "encrypted list", list1, "topsecret") Try Log("An error message will be printed in debug mode...") list2 = Starter.kvs.GetEncrypted("encrypted list", "wrong password") Catch Log("Wrong password!") End Try Upvote 0
It always throws an error when the password is wrong. This is the code from the example project: Code: Copy 'encrypt the list Starter.kvs.PutEncrypted( "encrypted list", list1, "topsecret") Try Log("An error message will be printed in debug mode...") list2 = Starter.kvs.GetEncrypted("encrypted list", "wrong password") Catch Log("Wrong password!") End Try
cklester Well-Known Member Licensed User Dec 15, 2020 #14 Erel said: It always throws an error when the password is wrong. Click to expand... Good to know. Thank you! Upvote 0
Erel said: It always throws an error when the password is wrong. Click to expand... Good to know. Thank you!
LucaMs Expert Licensed User Longtime User Dec 15, 2020 #15 Erel said: It always throws an error when the password is wrong. This is the code from the example project: Code: Copy 'encrypt the list Starter.kvs.PutEncrypted( "encrypted list", list1, "topsecret") Try Log("An error message will be printed in debug mode...") list2 = Starter.kvs.GetEncrypted("encrypted list", "wrong password") Catch Log("Wrong password!") End Try Click to expand... https://www.b4x.com/android/forum/t...rypted-with-wrong-password.125567/post-784156 ?? Upvote 0
Erel said: It always throws an error when the password is wrong. This is the code from the example project: Code: Copy 'encrypt the list Starter.kvs.PutEncrypted( "encrypted list", list1, "topsecret") Try Log("An error message will be printed in debug mode...") list2 = Starter.kvs.GetEncrypted("encrypted list", "wrong password") Catch Log("Wrong password!") End Try Click to expand... https://www.b4x.com/android/forum/t...rypted-with-wrong-password.125567/post-784156 ??
Erel B4X founder Staff member Licensed User Longtime User Dec 15, 2020 #16 LucaMs said: https://www.b4x.com/android/forum/t...rypted-with-wrong-password.125567/post-784156 Click to expand... I saw your post, I wanted to add that it always behaved like this. Upvote 0
LucaMs said: https://www.b4x.com/android/forum/t...rypted-with-wrong-password.125567/post-784156 Click to expand... I saw your post, I wanted to add that it always behaved like this.