Skip to content

Commit

Permalink
feat(configs): impl HybridConfig ailas
Browse files Browse the repository at this point in the history
  • Loading branch information
RyuNen344 committed Apr 18, 2023
1 parent f816121 commit c040f94
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
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()
}
}
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()
}
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()) }
}
}
}

0 comments on commit c040f94

Please sign in to comment.