only open for tests/debug
This commit is contained in:
parent
3d93e4d84d
commit
bf3fe19a4e
4 changed files with 14 additions and 4 deletions
build.gradle
omnipod-dash
build.gradle
src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util
|
@ -55,6 +55,7 @@ buildscript {
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
|
||||||
classpath 'com.hiya:jacoco-android:0.2'
|
classpath 'com.hiya:jacoco-android:0.2'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
apply plugin: 'kotlin-kapt'
|
apply plugin: 'kotlin-kapt'
|
||||||
|
apply plugin: 'kotlin-allopen'
|
||||||
apply plugin: 'com.hiya.jacoco-android'
|
apply plugin: 'com.hiya.jacoco-android'
|
||||||
apply plugin: "io.gitlab.arturbosch.detekt" // TODO move to `subprojects` section in global build.gradle
|
apply plugin: "io.gitlab.arturbosch.detekt" // TODO move to `subprojects` section in global build.gradle
|
||||||
apply plugin: "org.jlleitschuh.gradle.ktlint" // TODO move to `subprojects` section in global build.gradle
|
apply plugin: "org.jlleitschuh.gradle.ktlint" // TODO move to `subprojects` section in global build.gradle
|
||||||
|
@ -16,6 +17,10 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allOpen {
|
||||||
|
annotation 'info.nightscout.androidaps.plugins.pump.omnipod.dash.annotations.OpenClass'
|
||||||
|
}
|
||||||
|
|
||||||
detekt { // TODO move to `subprojects` section in global build.gradle
|
detekt { // TODO move to `subprojects` section in global build.gradle
|
||||||
toolVersion = "1.15.0-RC2"
|
toolVersion = "1.15.0-RC2"
|
||||||
config = files("./detekt-config.yml") // TODO move to global space and use "../detekt-config.yml"
|
config = files("./detekt-config.yml") // TODO move to global space and use "../detekt-config.yml"
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util
|
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.annotations.OpenForTesting
|
||||||
import java.security.SecureRandom
|
import java.security.SecureRandom
|
||||||
|
|
||||||
open class RandomByteGenerator {
|
@OpenForTesting
|
||||||
|
class RandomByteGenerator {
|
||||||
private val secureRandom = SecureRandom()
|
private val secureRandom = SecureRandom()
|
||||||
|
|
||||||
open fun nextBytes(length: Int): ByteArray = ByteArray(length).also(secureRandom::nextBytes)
|
fun nextBytes(length: Int): ByteArray = ByteArray(length).also(secureRandom::nextBytes)
|
||||||
}
|
}
|
|
@ -1,10 +1,12 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util
|
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util
|
||||||
|
|
||||||
import com.google.crypto.tink.subtle.X25519
|
import com.google.crypto.tink.subtle.X25519
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.annotations.OpenForTesting
|
||||||
|
|
||||||
open class X25519KeyGenerator {
|
@OpenForTesting
|
||||||
|
class X25519KeyGenerator {
|
||||||
|
|
||||||
open fun generatePrivateKey(): ByteArray = X25519.generatePrivateKey()
|
fun generatePrivateKey(): ByteArray = X25519.generatePrivateKey()
|
||||||
fun publicFromPrivate(privateKey: ByteArray): ByteArray = X25519.publicFromPrivate(privateKey)
|
fun publicFromPrivate(privateKey: ByteArray): ByteArray = X25519.publicFromPrivate(privateKey)
|
||||||
fun computeSharedSecret(privateKey: ByteArray, publicKey: ByteArray): ByteArray =
|
fun computeSharedSecret(privateKey: ByteArray, publicKey: ByteArray): ByteArray =
|
||||||
X25519.computeSharedSecret(privateKey, publicKey)
|
X25519.computeSharedSecret(privateKey, publicKey)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue