Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…-sdk into etmatrix-keepalive

# Conflicts:
#	build.gradle
#	cieidsdk/build.gradle
#	gradle/wrapper/gradle-wrapper.properties
  • Loading branch information
vixrt committed Oct 9, 2021
2 parents 1ffa550 + 21698d5 commit f765088
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cieidsdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ dependencies {
implementation "com.squareup.retrofit2:converter-scalars:$retrofit_version"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
implementation 'com.squareup.okio:okio:2.9.0'
implementation 'com.squareup.okio:okio:2.10.0'

//rxjava
implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
Expand Down
1 change: 1 addition & 0 deletions cieidsdk/src/main/java/it/ipzs/cieidsdk/common/CieIDSdk.kt
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ object CieIDSdk : NfcAdapter.ReaderCallback {
ias!!.getIdServizi()
ias!!.startSecureChannel(ciePin)
val certificate = ias!!.readCertCie()
ias!!.startKeepAlive()
call(certificate)

} catch (throwable: Throwable) {
Expand Down
19 changes: 16 additions & 3 deletions cieidsdk/src/main/java/it/ipzs/cieidsdk/nfc/Ias.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import it.ipzs.cieidsdk.nfc.extensions.hexStringToByteArray
import it.ipzs.cieidsdk.util.CieIDSdkLogger
import it.ipzs.cieidsdk.nfc.ApduResponse.SwError.*
import java.util.*
import java.util.concurrent.locks.ReentrantLock
import kotlin.experimental.or


Expand All @@ -26,6 +27,7 @@ internal class Ias constructor(val isoDep: IsoDep) {
internal class SendApduException(message : String) : IllegalArgumentException(message)


private var rlSign: ReentrantLock = ReentrantLock()
private var index = 0
private val CIE_AID = byteArrayOf(0xA0.toByte(), 0x00, 0x00, 0x00, 0x00, 0x39)
private var dh_g: ByteArray = byteArrayOf()
Expand Down Expand Up @@ -631,6 +633,7 @@ internal class Ias constructor(val isoDep: IsoDep) {

@Throws(Exception::class)
fun sign(dataToSign: ByteArray): ByteArray? {
rlSign.lock()
CieIDSdkLogger.log("sign()")
val setKey = byteArrayOf(0x00, 0x22, 0x41, 0xA4.toByte())
val val02 = byteArrayOf(0x02)
Expand Down Expand Up @@ -1681,7 +1684,17 @@ internal class Ias constructor(val isoDep: IsoDep) {
return resp
}




fun startKeepAlive() {
val id = 0x1003
Thread(Runnable {
while(rlSign.tryLock()) {
try {
sendApduSM(byteArrayOf(0x00, 0xa4.toByte(), 0x02, 0x04), byteArrayOf(HIBYTE(id), LOBYTE(id)), null)
} finally {
rlSign.unlock()
}
Thread.sleep(10)
}
}).start()
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Fri Jun 19 10:20:59 CEST 2020
#Wed Mar 31 09:08:05 CEST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down

0 comments on commit f765088

Please sign in to comment.