ArrayIndexOutOfBoundsException from com.colendi.ecies.Encryption:199.
2021-02-03 16:09:45.356 18014-18084/com.bracedotto D/BlockstackSession: getFile: path: links/My List/1607409583257-USoa-iRXm.json options: {"decrypt":true,"verify":false,"username":null,"app":null,"zoneFileLookupURL":null}
2021-02-03 16:09:45.402 18014-18084/com.bracedotto W/System.err: java.lang.ArrayIndexOutOfBoundsException: src.length=31 srcPos=0 dst.length=32 dstPos=0 length=32
2021-02-03 16:09:45.402 18014-18084/com.bracedotto W/System.err: at java.lang.System.arraycopy(Native Method)
2021-02-03 16:09:45.402 18014-18084/com.bracedotto W/System.err: at com.colendi.ecies.Encryption.sharedSecretToKeys(Encryption.java:199)
2021-02-03 16:09:45.402 18014-18084/com.bracedotto W/System.err: at com.colendi.ecies.Encryption.getMacKeyAndAesKey(Encryption.java:194)
2021-02-03 16:09:45.402 18014-18084/com.bracedotto W/System.err: at com.colendi.ecies.Encryption.decrypt(Encryption.java:159)
2021-02-03 16:09:45.402 18014-18084/com.bracedotto W/System.err: at com.colendi.ecies.Encryption.decryptWithPrivateKey(Encryption.java:62)
2021-02-03 16:09:45.402 18014-18084/com.bracedotto W/System.err: at com.colendi.ecies.Encryption.decryptWithPrivateKey(Encryption.java:58)
2021-02-03 16:09:45.402 18014-18084/com.bracedotto W/System.err: at org.blockstack.android.sdk.BlockstackSession$getFile$2.invokeSuspend(BlockstackSession.kt:263)
2021-02-03 16:09:45.402 18014-18084/com.bracedotto W/System.err: at org.blockstack.android.sdk.BlockstackSession$getFile$2.invoke(Unknown Source:10)
2021-02-03 16:09:45.402 18014-18084/com.bracedotto W/System.err: at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:91)
2021-02-03 16:09:45.402 18014-18084/com.bracedotto W/System.err: at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:165)
2021-02-03 16:09:45.402 18014-18084/com.bracedotto W/System.err: at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1)
2021-02-03 16:09:45.402 18014-18084/com.bracedotto W/System.err: at org.blockstack.android.sdk.BlockstackSession.getFile(BlockstackSession.kt:232)
2021-02-03 16:09:45.402 18014-18084/com.bracedotto W/System.err: at org.blockstack.reactnative.RNBlockstackSdkModule$getFile$1.invokeSuspend(RNBlockstackSdkModule.kt:240)
2021-02-03 16:09:45.402 18014-18084/com.bracedotto W/System.err: at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
2021-02-03 16:09:45.402 18014-18084/com.bracedotto W/System.err: at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
2021-02-03 16:09:45.403 18014-18084/com.bracedotto W/System.err: at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
2021-02-03 16:09:45.403 18014-18084/com.bracedotto W/System.err: at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
2021-02-03 16:09:45.403 18014-18084/com.bracedotto W/System.err: at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
2021-02-03 16:09:45.403 18014-18084/com.bracedotto W/System.err: at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Number of bytes from BigIntegers can be less than or more than 32. In case of less than 32, there will be an error. So I've added a check and if it's less than 32, the array is copied to the right of the destination array. I got it from Colendi-ECIES.
'not connected to gaia' Error because gaiaHubConfig is null.
This can happen when listFiles or deleteFile is called before getFile or putFile as gaiaHubConfig will be initialized in these two methods only. I think, it shouldn't be the case i.e. an app can call listFiles first at the start. So I've made a change with the idea that gaiaHubConfig is lazily initialized and there are 4 methods (getFile, putFile, deleteFile, and listFiles) that can initialize gaiaHubConfig if it hasn't yet. Also, I've set it to null when user signs out.
Type of Change
[ ] New feature
[X] Bug fix
[ ] API reference/documentation update
[ ] Other
Does this introduce a breaking change?
No
Are documentation updates required?
No
Testing information
I just tested on my app and the examples. All of them work.
Description
This pull request fixes 2 issues.
Number of bytes from BigIntegers can be less than or more than 32. In case of less than 32, there will be an error. So I've added a check and if it's less than 32, the array is copied to the right of the destination array. I got it from Colendi-ECIES.
This can happen when listFiles or deleteFile is called before getFile or putFile as gaiaHubConfig will be initialized in these two methods only. I think, it shouldn't be the case i.e. an app can call listFiles first at the start. So I've made a change with the idea that gaiaHubConfig is lazily initialized and there are 4 methods (getFile, putFile, deleteFile, and listFiles) that can initialize gaiaHubConfig if it hasn't yet. Also, I've set it to null when user signs out.
Type of Change
Does this introduce a breaking change?
No
Are documentation updates required?
No
Testing information
I just tested on my app and the examples. All of them work.