Пример #1
0
ok = OnlyKey()
print('Done')
print()

time.sleep(2)

ok.read_string(timeout_ms=100)
empty = 'a'
while not empty:
    empty = ok.read_string(timeout_ms=100)

print('You should see your OnlyKey blink 3 times')
print()

print('Setting ECC private...')
ok.set_ecc_key(101, (2 + 32), bob_private_key)
# Slot 101 - 132 for ECC
# Type 1 = Ed25519, Type 2 = p256r1, Type 3 = p256k1
# Key Features -
# if backup key = type + 128
# if signature key = type + 64
# if decryption key = type + 32
# if authentication key = type + 16
# For this example it will be a decryption key
time.sleep(1.5)
print(ok.read_string())

time.sleep(2)
print('You should see your OnlyKey blink 3 times')
print()
Пример #2
0
ok = OnlyKey()
print 'Done'
print

time.sleep(2)

ok.read_string(timeout_ms=100)
empty = 'a'
while not empty:
    empty = ok.read_string(timeout_ms=100)

print 'You should see your OnlyKey blink 3 times'
print

print 'Setting SSH private...'
ok.set_ecc_key(101, (1 + 64), privkey.to_seed())
# ok.set_ecc_privsend_message(msg=Message.OKSETPRIV, payload=privkey.to_seed())
time.sleep(1.5)
print ok.read_string()

time.sleep(2)
print 'You should see your OnlyKey blink 3 times'
print

print 'Trying to read the pubkey...'
ok.send_message(msg=Message.OKGETPUBKEY, payload=chr(101))  #, payload=[1, 1])
time.sleep(1.5)
for _ in xrange(10):
    ok_pubkey = ok.read_bytes(32, to_str=True)
    if len(ok_pubkey) == 32:
        break