isislovecruft / python-gnupg

A modified version of python-gnupg, including security patches, extensive documentation, and extra features.
Other
424 stars 172 forks source link

My private keys are being read as public keys. #216

Open programmingwithalex opened 6 years ago

programmingwithalex commented 6 years ago

I'm not sure what's causing this issue. I am using Python 3.6.1 :: Anaconda 4.4.0 (64-bit) and gnupg version 2.3.1.

My code is as follows:

import gnupg

gpg = gnupg.GPG(binary='C:/GnuPG/bin/gpg.exe', homedir='./pgp')
pri_key = 'pri_key.pgp'
pub_key = 'pub_key.pgp'

key_data = open(pri_key, 'rb').read()
import_result = gpg.import_keys(key_data)
print(import_result.results)

gpg.list_keys(secret=True) # []
gpg.list_keys() 
'''
[{'algo': '1',
  'date': '1510176716',
  'dummy': '',
  'expires': '',
  'fingerprint': '...',
  'keyid': '...',
  'length': '2048',
  'ownertrust': '-',
  'rev': {},
  'sigs': {'Alex F <alexf@outlook.com>': []},
  'subkeys': [['...', 'e']],
  'trust': '-',
  'type': 'pub',
  'uids': ['Alex F <alexf@outlook.com>']}]
'''

My private key is as follows:

-----BEGIN PGP PRIVATE KEY BLOCK----- Version: OpenPGP.js v2.0.0 Comment: http://openpgpjs.org

xcLYB... -----END PGP PRIVATE KEY BLOCK-----

I am able to read in public keys fine as well.

fuglede commented 6 years ago

Note that this was cross-posted to SO, and that the post there may contain useful information.

programmingwithalex commented 6 years ago

@fuglede I know, I was the one who posted it. Thanks for trying to help though.

fuglede commented 6 years ago

The comment was meant merely as a service for anybody else coming across this issue.