|
| 1 | +/* |
| 2 | + * Copyright (c) 2022 New Vector Ltd |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.matrix.android.sdk.internal.crypto.keysbackup.algorithm |
| 18 | + |
| 19 | +import org.matrix.android.sdk.api.crypto.MXCRYPTO_ALGORITHM_AES_256_BACKUP |
| 20 | +import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysVersionResult |
| 21 | +import org.matrix.android.sdk.api.session.crypto.keysbackup.MegolmBackupAes256AuthData |
| 22 | +import org.matrix.android.sdk.api.session.crypto.keysbackup.MegolmBackupAuthData |
| 23 | +import org.matrix.android.sdk.api.util.JsonDict |
| 24 | +import org.matrix.android.sdk.internal.crypto.MegolmSessionData |
| 25 | +import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysBackupData |
| 26 | + |
| 27 | +internal class KeysBackupAes256Algorithm(keysVersions: KeysVersionResult) : KeysBackupAlgorithm { |
| 28 | + |
| 29 | + override val untrusted: Boolean = true |
| 30 | + |
| 31 | + private val aesAuthData: MegolmBackupAes256AuthData |
| 32 | + |
| 33 | + init { |
| 34 | + if (keysVersions.algorithm != MXCRYPTO_ALGORITHM_AES_256_BACKUP) { |
| 35 | + throw IllegalStateException("Algorithm doesn't match") |
| 36 | + } |
| 37 | + aesAuthData = keysVersions.getAuthDataAsMegolmBackupAuthData() as MegolmBackupAes256AuthData |
| 38 | + } |
| 39 | + |
| 40 | + override fun encryptSession(sessionData: MegolmSessionData): JsonDict? { |
| 41 | + TODO("Not yet implemented") |
| 42 | + } |
| 43 | + |
| 44 | + override fun decryptSessions(recoveryKey: String, data: KeysBackupData): List<MegolmSessionData> { |
| 45 | + TODO("Not yet implemented") |
| 46 | + } |
| 47 | + |
| 48 | + override fun release() { |
| 49 | + TODO("Not yet implemented") |
| 50 | + } |
| 51 | + |
| 52 | + override val authData: MegolmBackupAuthData = aesAuthData |
| 53 | + |
| 54 | + override fun keyMatches(key: String): Boolean { |
| 55 | + TODO("Not yet implemented") |
| 56 | + } |
| 57 | +} |
0 commit comments