From 3a65080db3abaa0cfc1e59d0f43323ec8779e89d Mon Sep 17 00:00:00 2001 From: sergeych Date: Fri, 2 Dec 2022 20:09:29 +0100 Subject: [PATCH] removed unused field in ACO data --- .../net.sergeych.superlogin/AccessControlObject.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/commonMain/kotlin/net.sergeych.superlogin/AccessControlObject.kt b/src/commonMain/kotlin/net.sergeych.superlogin/AccessControlObject.kt index 55afbc8..c797c81 100644 --- a/src/commonMain/kotlin/net.sergeych.superlogin/AccessControlObject.kt +++ b/src/commonMain/kotlin/net.sergeych.superlogin/AccessControlObject.kt @@ -34,6 +34,7 @@ import kotlin.reflect.typeOf * @param passwordKey the password-derived key that could be used to unpack the [packed] data * @param data contains necessary data to keep and operate the ACO */ +@Suppress("OPT_IN_USAGE") class AccessControlObject( val payloadType: KType, val packed: ByteArray, @@ -62,7 +63,6 @@ class AccessControlObject( class Data( val restoreId: ByteArray, val derivedRestoreKey: SymmetricKey, - val passwordKey: SymmetricKey, val payload: T, ) @@ -71,7 +71,7 @@ class AccessControlObject( * Use [packed] property on the result to save updated copy. */ inline fun updatePayload(newPayload: R): AccessControlObject { - val data = Data(restoreId, data.derivedRestoreKey, passwordKey, newPayload) + val data = Data(restoreId, data.derivedRestoreKey, newPayload) return AccessControlObject( typeOf>(), Container.encrypt( @@ -87,7 +87,7 @@ class AccessControlObject( * [newPasswordKey] only. The [payload] is not changed. */ fun updatePasswordKey(newPasswordKey: SymmetricKey): AccessControlObject { - val data = Data(restoreId, data.derivedRestoreKey, newPasswordKey, payload) + val data = Data(restoreId, data.derivedRestoreKey, payload) return AccessControlObject( payloadType, Container.encryptData( @@ -119,7 +119,7 @@ class AccessControlObject( ): Pair { val restoreKey = RestoreKey.generate() return restoreKey to Container.encrypt( - Data(restoreKey.restoreId, restoreKey.key, passwordKey,payload), + Data(restoreKey.restoreId, restoreKey.key, payload), passwordKey, restoreKey.key ) } @@ -146,7 +146,7 @@ class AccessControlObject( */ suspend inline fun unpackWithSecret(packed: ByteArray, secret: String): AccessControlObject? { try { - val (id, key) = RestoreKey.parse(secret) + val (_, key) = RestoreKey.parse(secret) return unpackWithKey(packed, key) } catch(_: RestoreKey.InvalidSecretException) {