Skip to content

Commit 460205f

Browse files
committed
fix: silent authentication failure
1 parent c8ee0d3 commit 460205f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/main/kotlin/Cipher.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ data class Cipher(val cryptography: Cryptography, val key: CipherKey? = null, va
2525
fun decrypt(associatedData: AssociatedData, ciphertext: Ciphertext): State<Cipher, Plaintext>? =
2626
nonce.increment().let { n ->
2727
checkNotNull(n) { "Too many messages" }
28-
key?.let {
29-
cryptography.decrypt(it, nonce, associatedData, ciphertext)?.let { p -> State(copy(nonce = n), p) }
30-
} ?: State(this, ciphertext.plaintext)
28+
if (key == null) return State(this, ciphertext.plaintext)
29+
cryptography.decrypt(key, nonce, associatedData, ciphertext)?.let { p -> State(copy(nonce = n), p) }
3130
}
3231
}

0 commit comments

Comments
 (0)