Skip to content

Commit

Permalink
throw SecurityException in Loader, because that gets caught in Restor…
Browse files Browse the repository at this point in the history
…eCoordinator
  • Loading branch information
grote committed Oct 7, 2024
1 parent 715fa6c commit 4355aaa
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/src/main/java/com/stevesoltys/seedvault/repo/Loader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import java.io.ByteArrayInputStream
import java.io.File
import java.io.InputStream
import java.io.SequenceInputStream
import java.security.GeneralSecurityException
import java.util.Enumeration

internal class Loader(
Expand Down Expand Up @@ -79,11 +78,11 @@ internal class Loader(
// check SHA-256 hash first thing
val sha256 = crypto.sha256(cipherText).toHexString()
if (sha256 != expectedHash) {
throw GeneralSecurityException("File had wrong SHA-256 hash: $handle")
throw SecurityException("File had wrong SHA-256 hash: $handle")
}
// check that we can handle the version of that snapshot
val version = cipherText[0]
if (version <= 1) throw GeneralSecurityException("Unexpected version: $version")
if (version <= 1) throw SecurityException("Unexpected version: $version")
if (version > VERSION) throw UnsupportedVersionException(version)
// cache ciperText in cacheFile, if existing
try {
Expand Down

0 comments on commit 4355aaa

Please sign in to comment.