-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/wireapp/kalium into feat…
…/e2ei/rotate-conversation-with-e2ei-certificate
- Loading branch information
Showing
28 changed files
with
830 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
logic/src/appleMain/kotlin/com/wire/kalium/logic/feature/e2ei/CertificateStatusChecker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.feature.e2ei | ||
|
||
actual interface CertificateStatusChecker { | ||
actual fun status(notAfterTimestamp: Long): CertificateStatus | ||
} | ||
|
||
actual class CertificateStatusCheckerImpl : CertificateStatusChecker { | ||
override fun status(notAfterTimestamp: Long): CertificateStatus { | ||
TODO("Not yet implemented") | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
logic/src/appleMain/kotlin/com/wire/kalium/logic/feature/e2ei/PemCertificateDecoder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.feature.e2ei | ||
|
||
actual interface PemCertificateDecoder { | ||
actual fun decode(certificate: String): E2eiCertificate | ||
} | ||
|
||
actual class PemCertificateDecoderImpl actual constructor( | ||
private val x509CertificateGenerator: X509CertificateGenerator, | ||
private val certificateStatusChecker: CertificateStatusChecker | ||
) : PemCertificateDecoder { | ||
override fun decode(certificate: String): E2eiCertificate { | ||
TODO("Not yet implemented") | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
logic/src/appleMain/kotlin/com/wire/kalium/logic/feature/e2ei/PlatformX509Certificate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.feature.e2ei | ||
|
||
actual class PlatformX509Certificate |
28 changes: 28 additions & 0 deletions
28
logic/src/appleMain/kotlin/com/wire/kalium/logic/feature/e2ei/X509CertificateGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.feature.e2ei | ||
|
||
actual interface X509CertificateGenerator { | ||
actual fun generate(certificateByteArray: ByteArray): PlatformX509Certificate | ||
} | ||
|
||
actual class X509CertificateGeneratorImpl : X509CertificateGenerator { | ||
override fun generate(certificateByteArray: ByteArray): PlatformX509Certificate { | ||
TODO("Not yet implemented") | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...rc/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/e2ei/CertificateStatusChecker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.feature.e2ei | ||
|
||
import java.util.Date | ||
|
||
actual interface CertificateStatusChecker { | ||
actual fun status(notAfterTimestamp: Long): CertificateStatus | ||
} | ||
|
||
actual class CertificateStatusCheckerImpl : CertificateStatusChecker { | ||
override fun status(notAfterTimestamp: Long): CertificateStatus { | ||
// TODO check for revoked from coreCrypto when API is ready | ||
|
||
val current = Date() | ||
println("current timestap is ${current.time}") | ||
if (current.time >= notAfterTimestamp) | ||
return CertificateStatus.EXPIRED | ||
return CertificateStatus.VALID | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...c/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/e2ei/PemCertificateDecoder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.feature.e2ei | ||
|
||
import com.wire.kalium.logic.util.serialNumber | ||
|
||
actual interface PemCertificateDecoder { | ||
actual fun decode(certificate: String): E2eiCertificate | ||
} | ||
|
||
actual class PemCertificateDecoderImpl actual constructor( | ||
private val x509CertificateGenerator: X509CertificateGenerator, | ||
private val certificateStatusChecker: CertificateStatusChecker | ||
) : PemCertificateDecoder { | ||
override fun decode(certificate: String): E2eiCertificate { | ||
x509CertificateGenerator.generate(certificate.toByteArray()).also { | ||
return E2eiCertificate( | ||
issuer = it.value.issuerX500Principal.name, | ||
status = certificateStatusChecker.status(it.value.notAfter.time), | ||
serialNumber = it.value.serialNumber.toString(BASE_16).serialNumber(), | ||
certificateDetail = certificate | ||
) | ||
} | ||
} | ||
} | ||
|
||
private const val BASE_16 = 16 |
24 changes: 24 additions & 0 deletions
24
...src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/e2ei/PlatformX509Certificate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.feature.e2ei | ||
|
||
import java.security.cert.X509Certificate | ||
|
||
actual class PlatformX509Certificate( | ||
val value: X509Certificate | ||
) |
37 changes: 37 additions & 0 deletions
37
...rc/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/e2ei/X509CertificateGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.feature.e2ei | ||
|
||
import java.io.ByteArrayInputStream | ||
import java.security.cert.CertificateFactory | ||
import java.security.cert.X509Certificate | ||
|
||
actual interface X509CertificateGenerator { | ||
actual fun generate(certificateByteArray: ByteArray): PlatformX509Certificate | ||
} | ||
|
||
actual class X509CertificateGeneratorImpl : X509CertificateGenerator { | ||
override fun generate(certificateByteArray: ByteArray): PlatformX509Certificate { | ||
return PlatformX509Certificate( | ||
CertificateFactory.getInstance(TYPE) | ||
.generateCertificate(ByteArrayInputStream(certificateByteArray)) as X509Certificate | ||
) | ||
} | ||
} | ||
|
||
private const val TYPE = "X.509" |
33 changes: 33 additions & 0 deletions
33
logic/src/commonMain/kotlin/com/wire/kalium/logic/data/e2ei/E2eiCertificateRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.data.e2ei | ||
|
||
import com.wire.kalium.logic.E2EIFailure | ||
import com.wire.kalium.logic.data.conversation.ClientId | ||
import com.wire.kalium.logic.functional.Either | ||
|
||
interface E2eiCertificateRepository { | ||
fun getE2eiCertificate(clientId: ClientId): Either<E2EIFailure, String> | ||
} | ||
|
||
class E2eiCertificateRepositoryImpl : E2eiCertificateRepository { | ||
override fun getE2eiCertificate(clientId: ClientId): Either<E2EIFailure, String> { | ||
// TODO get certificate from CoreCrypto | ||
return Either.Left(E2EIFailure(Exception())) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/CertificateStatus.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.feature.e2ei | ||
|
||
enum class CertificateStatus { | ||
REVOKED, | ||
EXPIRED, | ||
VALID | ||
} |
24 changes: 24 additions & 0 deletions
24
logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/CertificateStatusChecker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.feature.e2ei | ||
|
||
expect interface CertificateStatusChecker { | ||
fun status(notAfterTimestamp: Long): CertificateStatus | ||
} | ||
|
||
expect class CertificateStatusCheckerImpl() : CertificateStatusChecker |
Oops, something went wrong.