File: configure_nist_test_key

package info (click to toggle)
python-yubico 1.3.3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 460 kB
  • sloc: python: 2,367; ansic: 128; xml: 20; makefile: 7
file content (31 lines) | stat: -rwxr-xr-x 814 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
"""
Set up a YubiKey with a NIST PUB 198 A.2
20 bytes test vector in Slot 2 (variable input)
"""

import sys
import struct
import yubico
import six

slot=2

try:
    YK = yubico.find_yubikey(debug=True)
    print("Version : %s " % YK.version())

    Cfg = YK.init_config()
    key = b'h:303132333435363738393a3b3c3d3e3f40414243'
    Cfg.mode_challenge_response(key, type='HMAC', variable=True)
    Cfg.extended_flag('SERIAL_API_VISIBLE', True)

    user_input = six.moves.input('Write configuration to slot %i of YubiKey? [y/N] : ' % slot )
    if user_input in ('y', 'ye', 'yes'):
        YK.write_config(Cfg, slot=slot)
        print("\nSuccess!")
    else:
        print("\nAborted")
except yubico.yubico_exception.YubicoError as inst:
    print("ERROR: %s" % inst.reason)
    sys.exit(1)