Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Apple crash when creating seed with empty string passphrase #146

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ actual object PBKDF2SHA512 {
algorithm = kCCPBKDF2,
password = p,
passwordLen = p.length.convert(),
salt = saltPin.addressOf(0),
salt = if (saltPin.get().isNotEmpty()) saltPin.addressOf(0) else null,
saltLen = saltPin.get().size.convert(),
prf = kCCPRFHmacAlgSHA512,
rounds = rounds,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package io.iohk.atala.prism.apollo.derivation

import kotlin.test.Test
import kotlin.test.fail

class MnemonicTests {
@Test
fun testCreatingSeedWithEmptyPassphrase() {
val words = listOf(
"bicycle",
"monster",
"swap",
"cave",
"bulk",
"fossil",
"nominee",
"crisp",
"tail",
"parent",
"fossil",
"eyebrow",
"fold",
"manage",
"custom",
"burst",
"flight",
"lawn",
"survey",
"snake",
"brown",
"bridge",
"hard",
"perfect"
)
val passphrase = ""

assertDoesNotThrow {
MnemonicHelper.Companion.createSeed(words, passphrase)
}
}
}

/**
* Asserts that the given executable does not throw an exception.
*
* @param block The executable function to be tested.
* @throws AssertionError if the executable throws any exception.
*/
inline fun assertDoesNotThrow(block: () -> Unit) {
try {
block()
} catch (e: Exception) {
fail("Expected no exception to be thrown, but got ${e.stackTraceToString()}")
}
}
Loading