mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
Guard against invalid seeds
This commit is contained in:
parent
80be7e37d0
commit
313acacedf
@ -76,7 +76,13 @@ class SeedActivity : BaseActionBarActivity() {
|
|||||||
|
|
||||||
// region Updating
|
// region Updating
|
||||||
private fun updateSeed() {
|
private fun updateSeed() {
|
||||||
seed = Curve25519.getInstance("best").generateSeed(16)
|
val seed = Curve25519.getInstance(Curve25519.BEST).generateSeed(16)
|
||||||
|
try {
|
||||||
|
IdentityKeyUtil.generateIdentityKeyPair(this, seed + seed)
|
||||||
|
} catch (exception: Exception) {
|
||||||
|
return updateSeed()
|
||||||
|
}
|
||||||
|
this.seed = seed
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateUI() {
|
private fun updateUI() {
|
||||||
@ -138,9 +144,12 @@ class SeedActivity : BaseActionBarActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IdentityKeyUtil.save(this, IdentityKeyUtil.lokiSeedKey, Hex.toStringCondensed(seed))
|
val hexEncodedSeed = Hex.toStringCondensed(seed)
|
||||||
|
IdentityKeyUtil.save(this, IdentityKeyUtil.lokiSeedKey, hexEncodedSeed)
|
||||||
if (seed.count() == 16) seed = seed + seed
|
if (seed.count() == 16) seed = seed + seed
|
||||||
IdentityKeyUtil.generateIdentityKeyPair(this, seed)
|
if (mode == Mode.Restore) {
|
||||||
|
IdentityKeyUtil.generateIdentityKeyPair(this, seed)
|
||||||
|
}
|
||||||
val keyPair = IdentityKeyUtil.getIdentityKeyPair(this)
|
val keyPair = IdentityKeyUtil.getIdentityKeyPair(this)
|
||||||
val publicKey = keyPair.publicKey
|
val publicKey = keyPair.publicKey
|
||||||
val hexEncodedPublicKey = keyPair.hexEncodedPublicKey
|
val hexEncodedPublicKey = keyPair.hexEncodedPublicKey
|
||||||
|
Loading…
x
Reference in New Issue
Block a user