Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
matrix-android-sdk
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Circles
matrix-android-sdk
Commits
c30f112c
Commit
c30f112c
authored
9 months ago
by
Taras
Browse files
Options
Downloads
Patches
Plain Diff
New random key for create dehydrated device
parent
0f535dfd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/dehydrated/DehydratedDevicesManager.kt
+11
-5
11 additions, 5 deletions
...dk/internal/crypto/dehydrated/DehydratedDevicesManager.kt
with
11 additions
and
5 deletions
matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/dehydrated/DehydratedDevicesManager.kt
+
11
−
5
View file @
c30f112c
...
...
@@ -44,13 +44,15 @@ internal class DehydratedDevicesManager @Inject constructor(
if
(
isDehydrationRunning
||
isDeviceDehydrationRequired
().
not
())
return
isDehydrationRunning
=
true
Timber
.
tag
(
LOG_TAG
).
d
(
"start"
)
val
ssPickleKey
=
getPickleKey
()
val
(
defaultKeyId
,
bsSpekeKey
)
=
getDefaultSSKey
()
val
ssPickleKey
=
getPickleKey
(
defaultKeyId
,
bsSpekeKey
)
val
existingDehydratedDevice
=
getDehydratedDevice
()
Timber
.
tag
(
LOG_TAG
).
d
(
"existing device $existingDehydratedDevice"
)
existingDehydratedDevice
?.
deviceId
?.
let
{
deviceId
->
rehydrateDevice
(
ssPickleKey
,
deviceId
,
existingDehydratedDevice
.
deviceData
)
}
createDehydratedDevice
(
ssPickleKey
)
val
newPickleKey
=
generateAndStoreDehydratedDeviceKey
(
defaultKeyId
,
bsSpekeKey
)
createDehydratedDevice
(
newPickleKey
)
saveLastDehydrationTime
()
Timber
.
tag
(
LOG_TAG
).
d
(
"dehydration time ${System.currentTimeMillis()}"
)
}
catch
(
e
:
Exception
)
{
...
...
@@ -71,13 +73,17 @@ internal class DehydratedDevicesManager @Inject constructor(
private
fun
getLastDehydrationTimeKey
():
String
=
DEHYDRATION_TIME_PREFIX
+
myDeviceId
private
suspend
fun
getPickleKey
():
ByteArray
{
private
suspend
fun
getPickleKey
(
defaultKeyId
:
String
,
bsSpekeKey
:
ByteArray
):
ByteArray
{
return
getDehydratedDeviceKey
(
defaultKeyId
,
bsSpekeKey
)
?:
generateAndStoreDehydratedDeviceKey
(
defaultKeyId
,
bsSpekeKey
)
}
private
fun
getDefaultSSKey
():
Pair
<
String
,
ByteArray
>
{
val
defaultKeyId
=
(
ssssService
.
getDefaultKey
()
as
?
KeyInfoResult
.
Success
)
?.
keyInfo
?.
id
?:
throw
IllegalStateException
(
"Default key not found"
)
val
bsSpekeKey
=
ssssService
.
getBsSpekePrivateKey
(
defaultKeyId
)
?:
throw
IllegalStateException
(
"BsSpeke key not found"
)
return
getDehydratedDeviceKey
(
defaultKeyId
,
bsSpekeKey
)
?:
generateAndStoreDehydratedDeviceKey
(
defaultKeyId
,
bsSpekeKey
)
return
defaultKeyId
to
bsSpekeKey
}
private
suspend
fun
rehydrateDevice
(
pickleKey
:
ByteArray
,
deviceId
:
String
,
deviceData
:
Map
<
String
,
String
>)
{
...
...
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