Open muellermartin opened 5 years ago
Hi @muellermartin ! Thank you for the report. This actually is done on purpose, since the original hidapi library / Homebrew provided is not working in our case. For libnitrokey we use our fork - https://github.com/Nitrokey/hidapi.
Was your build working for you?
To do:
hidapi
library, and the reason, to avoid confusion.I'm using hidapi stable 0.8.0-rc1 from Homebrew with my patch in PR #141 and the build works so far, although I did not test it extensively.
As you mentioned, I didn't know that the upstream hidapi is known not to work because this is not documented in an obvious way.
Was your build working for you?
Yes, I've successfully built libnitrokey with COMPILE_TESTS=ON
and ran ./test_safe
with following result:
[Mon Jan 14 11:58:18 2019][DEBUG_L1] => GET_DEVICE_STATUS
..........
[Mon Jan 14 11:58:19 2019][DEBUG_L1] Busy retry: status 2, 80ms, counter 54, progress: 0
...
[Mon Jan 14 11:58:19 2019][DEBUG_L1] <= GET_DEVICE_STATUS 0 1
[Mon Jan 14 11:58:19 2019][DEBUG_L1] => GET_PASSWORD_RETRY_COUNT
[Mon Jan 14 11:58:19 2019][DEBUG_L1] <= GET_PASSWORD_RETRY_COUNT 0 0
[Mon Jan 14 11:58:19 2019][DEBUG_L1] => GET_DEVICE_STATUS
.....
[Mon Jan 14 11:58:19 2019][DEBUG_L1] <= GET_DEVICE_STATUS 0 1
[Mon Jan 14 11:58:19 2019][DEBUG_L1] => GET_USER_PASSWORD_RETRY_COUNT
[Mon Jan 14 11:58:20 2019][DEBUG_L1] <= GET_USER_PASSWORD_RETRY_COUNT 0 0
[Mon Jan 14 11:58:20 2019][DEBUG_L1] => GET_DEVICE_STATUS
.....
[Mon Jan 14 11:58:20 2019][DEBUG_L1] <= GET_DEVICE_STATUS 0 1
transmission_data.dissect(): _padding:
0000 00 00 00 00 00 00 00 00 00 00 00 00 00 03 2e 01 ................
0010 00 00 -- -- -- -- -- -- -- -- -- -- -- -- -- -- ..
(int) SendCounter_u8: 0
(int) SendDataType_u8: 3
(int) FollowBytesFlag_u8: 0
(int) SendSize_u8: 28
MagicNumber_StickConfig_u16: 13080
(int) ReadWriteFlagUncryptedVolume_u8: 0
(int) ReadWriteFlagCryptedVolume_u8: 0
(int) ReadWriteFlagHiddenVolume_u8: 0
(int) versionInfo.major: 0
(int) versionInfo.minor: 53
(int) versionInfo.build_iteration: 0
(int) FirmwareLocked_u8: 0
(int) NewSDCardFound_u8: 1
(int) NewSDCardFound_st.NewCard: 1
(int) NewSDCardFound_st.Counter: 0
(int) SDFillWithRandomChars_u8: 1
ActiveSD_CardID_u32: 748145556
(int) VolumeActiceFlag_u8: 1
(int) VolumeActiceFlag_st.unencrypted: 1
(int) VolumeActiceFlag_st.encrypted: 0
(int) VolumeActiceFlag_st.hidden: 0
(int) NewSmartCardFound_u8: 0
(int) UserPwRetryCount: 3
(int) AdminPwRetryCount: 3
ActiveSmartCardID_u32: 327680
(int) StickKeysNotInitiated: 0
[Mon Jan 14 11:58:20 2019][DEBUG_L1] => GET_DEVICE_STATUS
......
[Mon Jan 14 11:58:20 2019][DEBUG_L1] <= GET_DEVICE_STATUS 0 1
00050000
[Mon Jan 14 11:58:20 2019][DEBUG_L1] => GET_DEVICE_STATUS
......
[Mon Jan 14 11:58:20 2019][DEBUG_L1] <= GET_DEVICE_STATUS 0 1
[Mon Jan 14 11:58:20 2019][DEBUG_L1] => GET_DEVICE_STATUS
......
[Mon Jan 14 11:58:21 2019][DEBUG_L1] <= GET_DEVICE_STATUS 0 1
===============================================================================
All tests passed (18 assertions in 6 test cases)
If you want, I could also run the other tests.
Thank you for the details! That is odd, I will check on my side.
If you are interested, and have no own data on the Storage device yet, it would be helpful to run other tests as well. I am specifically interested in Python's test_pro.py
and test_storage.py
, as mentioned in https://github.com/Nitrokey/libnitrokey#python-tests - whether it mostly passes or fails.
I remember from my last testing with the homebrew's version, that some cases were not passing.
Note: some TOTP related tests may fail (due to the device's internal clock, and making the tests on the edge of time window), as well as slot edition. Please make sure the PINs are set to default.
I only have a Nitrokey Storage 2, should I only run test_storage.py
then?
For Storage device, both test_pro
and test_storage
are usable.
As requested, here are the log files for the test_pro
and test_storage
tests. I did the test once for the HIDAPI by Nitrokey and the upstream version provided by Homebrew:
Apparently there are only a few differences in the test_pro
test, but I don't know how to interpret them. Mosty it's xfail
vs. XPASS
– maybe that's what was noted for the TOTP related test…
Note: I've created the log file with script
to preserve the ANSI color code sequences for easier readability e.g. with less
(created with script -q test_pro_nitrokey_hidapi_$(date '+%Y-%m-%d-%H-%M-%S').log py.test -v test_pro.py
).
Thank you! It looks like indeed everything works on your side. I will update here once confirmed in my environment.
You're welcome.
I've already a Homebrew Formula ready, but with a patch for this issue, which from my experience will lead to rejection. Therefore I will wait with the submission of the Formula until this is confirmed and resolved.
When HIDAPI is installed externally (e.g. via a package manager like Homebrew:
brew install hidapi
) and the tarball of libnitrokey is used, the current version of theCMakeLists.txt
is not able to find this installation and fails with an error message like this:This is because the CMake script searches for
hidapi/mac/hid.c
(see CMakeLists.txt line 78) in the current directory.