Skip to content

Cannot generate GPG keys #27

@gasull

Description

@gasull

First I try to set derivedkeymode 1. With both the OnlyKey app and onlykey-cli I am reminder to enter config mode pressing 6 for 5 seconds. After I press 6 for 5 seconds the light turns off, and I need to enter my PIN again. After entering the PIN the light is blinking red.

Then I can change the derived key mode to 1 ("button press required"). I've tried this with both the OnlyKey app and onlykey-cli.

I read that the way to exit config mode is to remove the OnlyKey and insert it again. But I've found repeatedly that if I do so then derivedkeymode is again set to 0 (Challenge Code Required).

So with the light still blinking red, I try to generate the GPG key pair:

$ onlykey-gpg init "example@example.com" --verbose 
2021-06-03 06:00:51,336 WARNING      This GPG tool is still in EXPERIMENTAL mode, so please note that the API and features may change without backwards compatibility! [__init__.py:128]
2021-06-03 06:00:51,366 INFO         device name: onlykey                                                                                 [__init__.py:136]
2021-06-03 06:00:51,367 INFO         GPG home directory: /home/user/.gnupg/onlykey                                                        [__init__.py:141]
2021-06-03 06:00:51,381 WARNING      NOTE: in order to re-generate the exact same GPG key later, run this command with "--time=0" commandline flag (to set the timestamp of the GPG key manually). [__init__.py:41]
2021-06-03 06:00:51,923 INFO         Requesting public key from key slot =132                                                             [onlykey.py:111]
2021-06-03 06:00:51,924 INFO         Identity to hash =b'gpg://example@example.com'                                                       [onlykey.py:125]
2021-06-03 06:00:51,924 INFO         Identity hash =9cd6f7bc1a8fd7d10742b6539e59967752512e67f85279d33e2d683122f12616                      [onlykey.py:129]
2021-06-03 06:00:51,927 INFO         curve name= 'ed25519'                                                                                [onlykey.py:145]
2021-06-03 06:00:53,433 INFO         received= []                                                                                         [onlykey.py:156]
2021-06-03 06:00:53,434 INFO         disconnected from OnlyKey                                                                            [onlykey.py:94]
2021-06-03 06:00:53,972 INFO         Requesting public key from key slot =132                                                             [onlykey.py:111]
2021-06-03 06:00:53,973 INFO         Identity to hash =b'gpg://example@example.com'                                                       [onlykey.py:125]
2021-06-03 06:00:53,974 INFO         Identity hash =9cd6f7bc1a8fd7d10742b6539e59967752512e67f85279d33e2d683122f12616                      [onlykey.py:129]
2021-06-03 06:00:53,977 INFO         curve name= 'curve25519'                                                                             [onlykey.py:145]
2021-06-03 06:00:54,454 INFO         disconnected from OnlyKey                                                                            [onlykey.py:94]
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.7/site-packages/libagent/device/onlykey.py", line 150, in pubkey
    ok_pubkey = self.ok.read_bytes(timeout_ms=100)
  File "/home/user/.local/lib/python3.7/site-packages/onlykey/client.py", line 336, in read_bytes
    out = self._hid.read(n, timeout_ms=timeout_ms)
  File "hid.pyx", line 122, in hid.device.read
OSError: read error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.local/bin/onlykey-gpg", line 10, in <module>
    sys.exit(gpg_tool())
  File "/home/user/.local/bin/onlykey_agent.py", line 6, in <lambda>
    gpg_tool = lambda: libagent.gpg.main(DeviceType)
  File "/home/user/.local/lib/python3.7/site-packages/libagent/gpg/__init__.py", line 375, in main
    return args.func(device_type=device_type, args=args)
  File "/home/user/.local/lib/python3.7/site-packages/libagent/gpg/__init__.py", line 207, in run_init
    export_public_key(device_type, args))
  File "/home/user/.local/lib/python3.7/site-packages/libagent/gpg/__init__.py", line 50, in export_public_key
    decryption_key = c.pubkey(identity=identity, ecdh=True)
  File "/home/user/.local/lib/python3.7/site-packages/libagent/gpg/client.py", line 29, in pubkey
    pubkey = self.device.pubkey(ecdh=ecdh, identity=identity)
  File "/home/user/.local/lib/python3.7/site-packages/libagent/device/onlykey.py", line 154, in pubkey
    raise interface.DeviceError(e)
libagent.device.interface.DeviceError: read error

There doesn't seem to be a workaround because, as said, if I remove the OnlyKey and insert it again, then I'm asked to enter a challenge code, and this will fail too:

$ onlykey-gpg init "example@example.com" --verbose 
2021-06-03 06:17:41,339 WARNING      This GPG tool is still in EXPERIMENTAL mode, so please note that the API and features may change without backwards compatibility! [__init__.py:128]
2021-06-03 06:17:41,345 INFO         device name: onlykey                                                                                 [__init__.py:136]
2021-06-03 06:17:41,346 INFO         GPG home directory: /home/user/.gnupg/onlykey                                                        [__init__.py:141]
2021-06-03 06:17:41,359 WARNING      NOTE: in order to re-generate the exact same GPG key later, run this command with "--time=0" commandline flag (to set the timestamp of the GPG key manually). [__init__.py:41]
2021-06-03 06:17:41,439 INFO         Requesting public key from key slot =132                                                             [onlykey.py:111]
2021-06-03 06:17:41,440 INFO         Identity to hash =b'gpg://example@example.com'                                                       [onlykey.py:125]
2021-06-03 06:17:41,441 INFO         Identity hash =9cd6f7bc1a8fd7d10742b6539e59967752512e67f85279d33e2d683122f12616                      [onlykey.py:129]
2021-06-03 06:17:41,444 INFO         curve name= 'ed25519'                                                                                [onlykey.py:145]
2021-06-03 06:17:41,761 INFO         received= [200, 199, 61, 114, 163, 35, 19, 53, 56, 210, 183, 48, 218, 126, 254, 140, 27, 197, 236, 239, 130, 233, 192, 58, 128, 82, 254, 225, 38, 53, 255, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [onlykey.py:156]
2021-06-03 06:17:41,761 INFO         Received Public Key generated by OnlyKey= 'c8c73d72a323133538d2b730da7efe8c1bc5ecef82e9c03a8052fee12635ff54' [onlykey.py:161]
2021-06-03 06:17:41,761 INFO         vk= <nacl.signing.VerifyKey object at 0x76ce5947d860>                                                [onlykey.py:164]
2021-06-03 06:17:41,762 INFO         disconnected from OnlyKey                                                                            [onlykey.py:94]
2021-06-03 06:17:41,827 INFO         Requesting public key from key slot =132                                                             [onlykey.py:111]
2021-06-03 06:17:41,828 INFO         Identity to hash =b'gpg://example@example.com'                                                       [onlykey.py:125]
2021-06-03 06:17:41,828 INFO         Identity hash =9cd6f7bc1a8fd7d10742b6539e59967752512e67f85279d33e2d683122f12616                      [onlykey.py:129]
2021-06-03 06:17:41,832 INFO         curve name= 'curve25519'                                                                             [onlykey.py:145]
2021-06-03 06:17:43,338 INFO         received= []                                                                                         [onlykey.py:156]
2021-06-03 06:17:43,339 INFO         disconnected from OnlyKey                                                                            [onlykey.py:94]
2021-06-03 06:17:43,343 INFO         creating new ed25519 GPG primary key for "example@example.com"                                       [__init__.py:73]
2021-06-03 06:17:43,345 INFO         please confirm GPG signature on OnlyKey for "<gpg://example@example.com|ed25519>"...                 [client.py:40]
2021-06-03 06:17:43,372 INFO         Identity to hash =b'gpg://example@example.com'                                                       [onlykey.py:243]
2021-06-03 06:17:43,372 INFO         Identity hash =b'\x9c\xd6\xf7\xbc\x1a\x8f\xd7\xd1\x07B\xb6S\x9eY\x96wRQ.g\xf8Ry\xd3>-h1"\xf1&\x16'   [onlykey.py:244]
2021-06-03 06:17:43,372 INFO         Key type ed25519                                                                                     [onlykey.py:251]
2021-06-03 06:17:43,372 INFO         Key Slot =201                                                                                        [onlykey.py:275]
Enter the 3 digit challenge code on OnlyKey to authorize <gpg://example@example.com|ed25519>
2 1 4

2021-06-03 06:17:46,213 INFO         received= [92, 164, 40, 87, 37, 126, 64, 146, 177, 95, 244, 44, 242, 75, 23, 127, 237, 239, 211, 158, 25, 40, 147, 157, 198, 226, 101, 18, 70, 66, 150, 90, 188, 21, 238, 198, 202, 167, 224, 222, 4, 130, 142, 110, 54, 183, 65, 73, 233, 18, 157, 159, 101, 112, 202, 126, 145, 68, 217, 63, 125, 110, 172, 9] [onlykey.py:291]
2021-06-03 06:17:46,213 INFO         disconnected from OnlyKey                                                                            [onlykey.py:294]
2021-06-03 06:17:46,216 INFO         disconnected from OnlyKey                                                                            [onlykey.py:94]
Traceback (most recent call last):
  File "/home/user/.local/bin/onlykey-gpg", line 10, in <module>
    sys.exit(gpg_tool())
  File "/home/user/.local/bin/onlykey_agent.py", line 6, in <lambda>
    gpg_tool = lambda: libagent.gpg.main(DeviceType)
  File "/home/user/.local/lib/python3.7/site-packages/libagent/gpg/__init__.py", line 375, in main
    return args.func(device_type=device_type, args=args)
  File "/home/user/.local/lib/python3.7/site-packages/libagent/gpg/__init__.py", line 207, in run_init
    export_public_key(device_type, args))
  File "/home/user/.local/lib/python3.7/site-packages/libagent/gpg/__init__.py", line 88, in export_public_key
    signer_func=signer_func)
  File "/home/user/.local/lib/python3.7/site-packages/libagent/gpg/encode.py", line 54, in create_subkey
    blob=(subkey.data() + secret_bytes))
  File "/home/user/.local/lib/python3.7/site-packages/libagent/gpg/protocol.py", line 221, in data
    blob = self.curve_info['serialize'](self.verifying_key)
  File "/home/user/.local/lib/python3.7/site-packages/libagent/gpg/protocol.py", line 96, in _serialize_ed25519
    util.bytes2num(vk.encode(encoder=nacl.encoding.RawEncoder)))
AttributeError: 'NoneType' object has no attribute 'encode'

My main reason for buying an OnlyKey was generating GPG keys in a trusted way :-(

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions