-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(configs): impl HybridConfig ailas
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
tink/src/androidMain/kotlin/io/github/ryunen344/tink/hybrid/HybridConfig.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,11 @@ | ||
package io.github.ryunen344.tink.hybrid | ||
|
||
import com.google.crypto.tink.hybrid.HybridConfig | ||
import io.github.ryunen344.tink.exception.GeneralSecurityException | ||
|
||
actual class HybridConfig { | ||
@Throws(GeneralSecurityException::class) | ||
actual fun register() { | ||
HybridConfig.register() | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
tink/src/commonMain/kotlin/io/github/ryunen344/tink/hybrid/HybridConfig.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,8 @@ | ||
package io.github.ryunen344.tink.hybrid | ||
|
||
import io.github.ryunen344.tink.exception.GeneralSecurityException | ||
|
||
expect class HybridConfig { | ||
@Throws(GeneralSecurityException::class) | ||
fun register() | ||
} |
22 changes: 22 additions & 0 deletions
22
tink/src/iosMain/kotlin/io/github/ryunen344/tink/hybrid/HybridConfig.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,22 @@ | ||
package io.github.ryunen344.tink.hybrid | ||
|
||
import io.github.ryunen344.tink.exception.GeneralSecurityException | ||
import io.github.ryunen344.tink.util.asThrowable | ||
import kotlinx.cinterop.ObjCObjectVar | ||
import kotlinx.cinterop.alloc | ||
import kotlinx.cinterop.memScoped | ||
import kotlinx.cinterop.ptr | ||
import kotlinx.cinterop.value | ||
import platform.Foundation.NSError | ||
|
||
actual class HybridConfig { | ||
@Throws(GeneralSecurityException::class) | ||
actual fun register() { | ||
memScoped { | ||
val error = alloc<ObjCObjectVar<NSError?>>() | ||
val hybridConfig = TINKHybridConfig(error.ptr) | ||
TINKConfig.registerConfig(config = hybridConfig, error = error.ptr) | ||
error.value?.let { throw GeneralSecurityException(cause = it.asThrowable()) } | ||
} | ||
} | ||
} |