Compare commits
No commits in common. "cef5e06f0bad2e627c9cd102f6e8f511b1ba68b5" and "e34de8de946542d900366f70134c05ff158bae10" have entirely different histories.
cef5e06f0b
...
e34de8de94
@ -9,7 +9,7 @@ val logback_version="1.2.10"
|
||||
|
||||
|
||||
group = "net.sergeych"
|
||||
version = "0.2.6-SNAPSHOT"
|
||||
version = "0.2.2"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@ -24,9 +24,9 @@ repositories {
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
// compilations.all {
|
||||
// kotlinOptions.jvmTarget = "1.8"
|
||||
// }
|
||||
compilations.all {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
withJava()
|
||||
testRuns["test"].executionTask.configure {
|
||||
useJUnitPlatform()
|
||||
@ -51,8 +51,9 @@ kotlin {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.3")
|
||||
// api("net.sergeych:unikrypto:1.2.2-SNAPSHOT")
|
||||
api("net.sergeych:parsec3:0.4.6")
|
||||
api("net.sergeych:unikrypto:1.2.2-SNAPSHOT")
|
||||
api("net.sergeych:parsec3:0.4.3-SNAPSHOT")
|
||||
api("net.sergeych:boss-serialization-mp:0.2.4-SNAPSHOT")
|
||||
api("net.sergeych:unikrypto:1.2.5")
|
||||
}
|
||||
}
|
||||
|
@ -19,19 +19,14 @@ data class RegistrationArgs(
|
||||
val packedACO: ByteArray,
|
||||
val extraData: ByteArray? = null
|
||||
) {
|
||||
@Suppress("unused")
|
||||
|
||||
inline fun <reified T>toSuccess(loginToken: ByteArray, extraData: T): AuthenticationResult.Success {
|
||||
return AuthenticationResult.Success(
|
||||
loginName, loginToken, BossEncoder.encode(extraData)
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
inline fun <reified T>decodeOrNull(): T? = extraData?.decodeBoss<T>()
|
||||
|
||||
@Suppress("unused")
|
||||
inline fun <reified T: Any>decodeOrThrow(): T = extraData?.decodeBoss<T>()
|
||||
inline fun <reified T>decodeOrNull(): T? = extraData?.let { it.decodeBoss<T>() }
|
||||
inline fun <reified T: Any>decodeOrThrow(): T = extraData?.let { it.decodeBoss<T>() }
|
||||
?: throw IllegalArgumentException("missing require extra data of type ${T::class.simpleName}")
|
||||
}
|
||||
|
||||
@ -49,11 +44,6 @@ sealed class AuthenticationResult {
|
||||
@SerialName("LoginUnavailable")
|
||||
object LoginUnavailable: AuthenticationResult()
|
||||
|
||||
@Serializable
|
||||
@SerialName("OtherError")
|
||||
class OtherError(val reason: String,val packedData: ByteArray?=null): AuthenticationResult()
|
||||
|
||||
|
||||
@Serializable
|
||||
@SerialName("LoginIdUnavailable")
|
||||
object LoginIdUnavailable: AuthenticationResult()
|
||||
|
@ -34,7 +34,6 @@ class Registration(
|
||||
val pbkdfRounds: Int = 15000,
|
||||
) : LogTag("SLREG") {
|
||||
|
||||
@Suppress("unused")
|
||||
sealed class Result {
|
||||
/**
|
||||
* Login is already in use or is somehow else invalid
|
||||
@ -54,8 +53,6 @@ class Registration(
|
||||
val encodedData: ByteArray?) : Result() {
|
||||
inline fun <reified D>data() = encodedData?.let { BossDecoder.decodeFrom<D>(it)}
|
||||
}
|
||||
|
||||
class OtherError(val code: String,val packedData: ByteArray?=null): Result()
|
||||
}
|
||||
|
||||
private var lastPasswordHash: ByteArray? = null
|
||||
@ -93,7 +90,7 @@ class Registration(
|
||||
val nonce = adapter.invokeCommand(api.slGetNonce)
|
||||
val loginPrivateKey = deferredLoginKey.await()
|
||||
val spl = SuperloginRestoreAccessPayload(login, loginPrivateKey, dataKey)
|
||||
repeat(3) {
|
||||
repeat(10) {
|
||||
val (restoreKey, restoreData) = AccessControlObject.pack(passwordKeys!!.loginAccessKey, spl)
|
||||
try {
|
||||
val packedArgs = SignedRecord.pack(
|
||||
@ -125,8 +122,6 @@ class Registration(
|
||||
|
||||
AuthenticationResult.LoginUnavailable -> return Result.InvalidLogin
|
||||
|
||||
is AuthenticationResult.OtherError -> return Result.OtherError(result.reason, result.packedData)
|
||||
|
||||
is AuthenticationResult.Success -> {
|
||||
return Result.Success(
|
||||
restoreKey.secret,
|
||||
|
@ -18,7 +18,7 @@ internal class AccessControlObjectTest {
|
||||
val pk1 = SymmetricKeys.random()
|
||||
val pk2 = SymmetricKeys.random()
|
||||
val (rk, packed1) = AccessControlObject.pack(pk1, 117)
|
||||
// println(rk.secret)
|
||||
println(rk.secret)
|
||||
val ac1 = AccessControlObject.unpackWithKey<Int>(packed1,pk1)
|
||||
assertNotNull(ac1)
|
||||
assertEquals(117, ac1.payload)
|
||||
|
@ -59,7 +59,7 @@ data class TestSession(val s: TestStorage) : SLServerSession<TestData>() {
|
||||
}
|
||||
|
||||
override suspend fun loginByToken(token: ByteArray): AuthenticationResult {
|
||||
println("requested login by token ${token.encodeToBase64Compact()}")
|
||||
println("requested login by tokeb ${token.encodeToBase64Compact()}")
|
||||
println(" ${s.byToken[token.toList()]}")
|
||||
println(" ${s.byToken.size} / ${s.byLoginId.size}")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user