Skip to content

Commit

Permalink
[android] Use tutasdk for argon2id
Browse files Browse the repository at this point in the history
  • Loading branch information
paw-hub committed Aug 9, 2024
1 parent e6d1928 commit e8bedc6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ class CompatibilityTest {
}

@Test
fun argon2idTest() {
fun argon2idTest() = runBlocking {
for (td in testData.argon2idTests) {
val key = hexToBytes(td.keyHex)
val salt = hexToBytes(td.saltHex)
val password = td.password.toByteArray()
assertArrayEquals(key, crypto.argon2idHashRawImpl(password, salt, ARGON2ID_TIME_COST, ARGON2ID_MEMORY_COST, ARGON2ID_PARALLELISM, ARGON2ID_HASH_LENGTH))
val password = td.password
assertArrayEquals(key, crypto.argon2idGeneratePassphraseKey(password, salt.wrap()).data)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,36 +158,13 @@ class AndroidNativeCryptoFacade(
}

@Throws(CryptoError::class)
override suspend fun argon2idHashRaw(
password: DataWrapper,
override suspend fun argon2idGeneratePassphraseKey(
passphrase: String,
salt: DataWrapper,
timeCost: Int,
memoryCost: Int,
parallelism: Int,
hashLength: Int
): DataWrapper {
return DataWrapper(
this.argon2idHashRawImpl(
password.data,
salt.data,
timeCost,
memoryCost,
parallelism,
hashLength
)
)
return DataWrapper(de.tutao.tutasdk.argon2idGenerateKeyFromPassphrase(passphrase, salt.data))
}

@Throws(CryptoError::class)
external fun argon2idHashRawImpl(
password: ByteArray,
salt: ByteArray,
timeCost: Int,
memoryCost: Int,
parallelism: Int,
hashLength: Int
): ByteArray

@Throws(CryptoError::class)
override suspend fun rsaEncrypt(
publicKey: RsaPublicKey,
Expand Down

0 comments on commit e8bedc6

Please sign in to comment.