Yubico / yubikit-android

Yubico Mobile Android SDK - YubiKit
Apache License 2.0
103 stars 38 forks source link

NotSupportedOperation using YubiKeyConfigurationApplication->calculateHmacSha1() function with Yubikey 5 NFC #32

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hi, when using the YubiKeyConfigurationApplication.calculateHmacSha1() function I sometimes get a "NotSupportedOperation" error, saying version must be 2.2+. I logged the output of YubiKeyConfigurationApplication.getVersion and get changing values every time i instantiate a new YubiKeyConfigurationApplication object.

With some "versions" the function is running, some "versions" cause an error:

73.60.254 -> Error 83.97.127 -> OK 5.36.229 -> Error 56.75.170 -> Error

I use a Yubikey 5 NFC.

My NfcSessionListener

val nfcListener = NfcSessionListener { session ->

    val challenge: ByteArray = "Sample #2".toByteArray()

    val application = YubiKeyConfigurationApplication(session)

    Log.d(TAG, application.version.toString())

    application.use {
        val response = application.calculateHmacSha1(challenge, Slot.TWO)
        Log.d(TAG, response.toString())
    }
}

Stacktrace:

2020-07-02 18:30:39.263 27331-27331/de.marcoboehrs.yubichalres D/nfcListener: 56.75.170 2020-07-02 18:30:39.285 27331-27331/de.marcoboehrs.yubichalres D/AndroidRuntime: Shutting down VM 2020-07-02 18:30:39.292 27331-27331/de.marcoboehrs.yubichalres E/AndroidRuntime: FATAL EXCEPTION: main ... Caused by: com.yubico.yubikit.exceptions.NotSupportedOperation: This operation is supported for version 2.2+ at com.yubico.yubikit.configurator.YubiKeyConfigurationApplication.calculateHmacSha1(YubiKeyConfigurationApplication.java:127) at de.marcoboehrs.yubichalres.MainActivity$nfcListener$1.onSessionReceived(MainActivity.kt:28) at com.yubico.yubikit.YubiKitManager$NfcInternalListener$1.run(YubiKitManager.java:139) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:205) at android.app.ActivityThread.main(ActivityThread.java:6983) at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:884) 

dainnilsson commented 4 years ago

Thanks for the detailed report! I've just pushed a commit om master (https://github.com/Yubico/yubikit-android/commit/e1253f7dc87c6449ceedff2b12d56e6240321e8b) with a fix.

Would you be able to test that out and see if that resolves your issue?

ghost commented 4 years ago

Works great now! Thank you very much!

Am Fr., 3. Juli 2020 um 09:53 Uhr schrieb Dain Nilsson < notifications@github.com>:

Thanks for the detailed report! I've just pushed a commit om master (e1253f7 https://github.com/Yubico/yubikit-android/commit/e1253f7dc87c6449ceedff2b12d56e6240321e8b) with a fix.

Would you be able to test that out and see if that resolves your issue?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Yubico/yubikit-android/issues/32#issuecomment-653407336, or unsubscribe https://github.com/notifications/unsubscribe-auth/APPCIKJ7KN7V42DKESFH4JLRZWE6HANCNFSM4OPCDYQA .