Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Elixxir dApps SDK Kotlin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile
android
Elixxir dApps SDK Kotlin
Commits
bf617a35
Commit
bf617a35
authored
Aug 12, 2022
by
Kamal Bramwell
Browse files
Options
Downloads
Patches
Plain Diff
Updated SessionKeystore constructor and factory method
parent
abdf8875
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/io/elixxir/dapp/session/data/SessionKeyStore.kt
+10
-7
10 additions, 7 deletions
...main/java/io/elixxir/dapp/session/data/SessionKeyStore.kt
with
10 additions
and
7 deletions
app/src/main/java/io/elixxir/dapp/session/data/SessionKeyStore.kt
+
10
−
7
View file @
bf617a35
...
...
@@ -5,12 +5,12 @@ import android.security.keystore.KeyGenParameterSpec
import
android.security.keystore.KeyInfo
import
android.security.keystore.KeyProperties
import
bindings.Bindings
import
io.elixxir.dapp.DappSdk.Companion.defaultDispatcher
import
io.elixxir.dapp.preferences.KeyStorePreferences
import
io.elixxir.dapp.session.model.SessionPassword
import
io.elixxir.dapp.util.fromBase64toByteArray
import
io.elixxir.dapp.util.toBase64String
import
kotlinx.coroutines.CoroutineDispatcher
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.withContext
import
timber.log.Timber
import
java.security.*
...
...
@@ -35,11 +35,11 @@ class SecureHardwareException : Exception() {
class
DappSessionKeystore
private
constructor
(
private
val
preferences
:
KeyStorePreferences
,
private
val
d
efaultD
ispatcher
:
CoroutineDispatcher
=
Dispatchers
.
IO
private
val
dispatcher
:
CoroutineDispatcher
)
:
SessionKeyStore
{
override
suspend
fun
createSessionPassword
(
requireSecureHardware
:
Boolean
):
Result
<
Unit
>
=
withContext
(
d
efaultD
ispatcher
)
{
withContext
(
dispatcher
)
{
if
(
requireSecureHardware
&&
!
isHardwareBackedKeyStore
())
{
return
@withContext
Result
.
failure
(
SecureHardwareException
())
}
...
...
@@ -190,7 +190,7 @@ class DappSessionKeystore private constructor(
IllegalBlockSizeException
::
class
,
BadPaddingException
::
class
)
override
suspend
fun
rsaDecryptPassword
():
SessionPassword
=
withContext
(
d
efaultD
ispatcher
)
{
override
suspend
fun
rsaDecryptPassword
():
SessionPassword
=
withContext
(
dispatcher
)
{
val
encryptedBytes
=
preferences
.
userSecret
.
fromBase64toByteArray
()
val
key
=
getPrivateKey
()
val
cipher1
=
Cipher
.
getInstance
(
KEYSTORE_ALGORITHM
)
...
...
@@ -234,8 +234,11 @@ class DappSessionKeystore private constructor(
)
private
const
val
PASSWORD_LENGTH
=
64L
internal
fun
newInstance
(
preferences
:
KeyStorePreferences
,
):
DappSessionKeystore
=
DappSessionKeystore
(
preferences
)
internal
fun
newInstance
(
preferences
:
KeyStorePreferences
):
DappSessionKeystore
{
return
DappSessionKeystore
(
preferences
,
defaultDispatcher
)
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment