Skip to content

GPG_ERROR_CODES reports "incorrect passphrase" when in fact the secret key is missing #157

@vsajip

Description

@vsajip

Original report by Anonymous.


Discovered this by trying to decrypt a file for which the secret key is not loaded.

import gnupg

gpg = gnupg.GPG(gnupghome='/home/user/gnupg/')

with open('priv-key.asc') as fd:
    content = fd.read()
res = gpg.import_keys(content)

with open('file.gpg', 'rb') as gpgfile:
    decrypted = gpg.decrypt_file(gpgfile, passphrase='password', output='file')

print(decrypted.ok)   # prints False
print(decrypted.GPG_ERROR_CODES) # {11: 'incorrect passphrase'}

I'm using an elliptic curve key with ed25519.

The logs with logging.DEBUG on (paraphrased):

  • gpg: encrypted with ECDH key, ID
  • [GNUPG:] NO_SECKEY
  • [GNUPG:] BEGIN_DECRYPTION
  • [GNUPG:] DECRYPTION_FAILED
  • gpg: decryption failed: No secret key
  • [GNUPG:] END_DECRYPTION

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmajor

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions