Skip to content

Commit a2b831a

Browse files
Add should_default_ccid helper
1 parent 30b9d19 commit a2b831a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/nitrokey/should_use_ccid.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import ctypes
2+
import sys
3+
from importlib.util import find_spec
4+
5+
6+
def should_default_ccid() -> bool:
7+
if find_spec("smartcard") is None:
8+
return False
9+
10+
if sys.platform != "win32" and sys.platform != "cygwin":
11+
# Linux or MacOS don't need admin to access with CTAPHID
12+
return False
13+
14+
try:
15+
if ctypes.windll.shell32.IsUserAnAdmin():
16+
return False
17+
else:
18+
return True
19+
except Exception:
20+
return False

0 commit comments

Comments
 (0)