From 3d42f0ca2e58089a0f6c743b06960c905c55fa52 Mon Sep 17 00:00:00 2001 From: raphael Date: Tue, 14 Dec 2021 22:02:19 +0100 Subject: [PATCH] adds integer parse for fernet iteration --- app/src/main/java/com/example/bump/MessageProcessor.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/example/bump/MessageProcessor.kt b/app/src/main/java/com/example/bump/MessageProcessor.kt index b87efda..e9af93e 100644 --- a/app/src/main/java/com/example/bump/MessageProcessor.kt +++ b/app/src/main/java/com/example/bump/MessageProcessor.kt @@ -11,6 +11,7 @@ import com.macasaet.fernet.Token import com.macasaet.fernet.StringValidator import com.macasaet.fernet.Validator import com.maenle.bump.MainActivity +import java.math.BigInteger import java.time.Duration import java.time.temporal.TemporalAmount @@ -34,11 +35,11 @@ class MessageProcessor { // Data from encryption val decoded : ByteArray = Base64.getUrlDecoder().decode(message) val salt = decoded.copyOfRange(0, 16) - val iter = decoded.copyOfRange(16, 20) + val iter : Int = BigInteger(decoded.copyOfRange(16, 20)).toInt() val str_token = String(Base64.getUrlEncoder().encode(decoded.copyOfRange(20, decoded.size))) // Derive Fernet key - val saltedKey = deriveKey(key, salt, 100_000) + val saltedKey = deriveKey(key, salt, iter) val fernetKey = Key(saltedKey) val token =