Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

password vs passphrase #34

Open
yoshie902a opened this issue Feb 4, 2014 · 3 comments
Open

password vs passphrase #34

yoshie902a opened this issue Feb 4, 2014 · 3 comments

Comments

@yoshie902a
Copy link

In the example below, I have tried password and passphrase. Neither seem to allow me to run my code without a openpgp box prompting for the passphrase, the following message:

Pinentry Mac
"Please enter the passphrase to unlock the secret key for the OpenPGP certificate"
What do I need to change to allow my code to run without the prompt? I know my password is correct in the code.

I have tried :
ctx = GPGME::Ctx.new :password=> 'password'
and this:
ctx = GPGME::Ctx.new :passphrase_callback => method(:passfunc)

But both do not seem to work. Any advice is appreciated.

  def self.passfunc(obj, uid_hint, passphrase_info, prev_was_bad, fd)
    io = IO.for_fd(fd, 'w')
    io.puts 'password'
    io.flush
  end

  def self.decrypt_file(local_file, decrypted_file = nil)
    # Set decrypted file path if one is not provided
    decrypted_file = local_file.chomp(File.extname(local_file)) + ".csv" if decrypted_file == nil
    encrypted_data = GPGME::Data.new(File.open(local_file))

    # Set the password and GPG Key to decryption
    ctx = GPGME::Ctx.new :password=> 'password'

    # I have tried the passphrase call back
    #ctx = GPGME::Ctx.new :passphrase_callback => method(:passfunc)

    #KEY= GPGME::Data.new(File.open("key.gpg"))
    ctx.import_keys Rebal::Config::KEY

    # Decrypt the data
    decrypted = ctx.decrypt encrypted_data
    decrypted.seek(0)

    #Write the data to a file
    File.write(decrypted_file, decrypted.read)

    #return path
    decrypted_file
  end
@dansketcher
Copy link
Collaborator

In my experience you need to use GPG 1.x to not have to pin entry program activate. It's a feature of GPG 2 to force the pinentry program
This probably needs to be in the docs, seems like a common problem.

Dan

On 4 Feb 2014, at 23:20, yoshie902a [email protected] wrote:

In the example below, I have tried password and passphrase. Neither seem to allow me to run my code without a openpgp box prompting for the passphrase, the following message:

Pinentry Mac
"Please enter the passphrase to unlock the secret key for the OpenPGP certificate"
What do I need to change to allow my code to run without the prompt? I know my password is correct in the code.

I have tried :
ctx = GPGME::Ctx.new :password=> 'password'
and this:
ctx = GPGME::Ctx.new :passphrase_callback => method(:passfunc)

But both do not seem to work. Any advice is appreciated.

def self.passfunc(obj, uid_hint, passphrase_info, prev_was_bad, fd)
io = IO.for_fd(fd, 'w')
io.puts 'password'
io.flush
end

def self.decrypt_file(local_file, decrypted_file = nil)
# Set decrypted file path if one is not provided
decrypted_file = local_file.chomp(File.extname(local_file)) + ".csv" if decrypted_file == nil
encrypted_data = GPGME::Data.new(File.open(local_file))

# Set the password and GPG Key to decryption
ctx = GPGME::Ctx.new :password=> 'password'

# I have tried the passphrase call back
#ctx = GPGME::Ctx.new :passphrase_callback => method(:passfunc)

#KEY= GPGME::Data.new(File.open("key.gpg"))
ctx.import_keys Rebal::Config::KEY

# Decrypt the data
decrypted = ctx.decrypt encrypted_data
decrypted.seek(0)

#Write the data to a file
File.write(decrypted_file, decrypted.read)

#return path
decrypted_file

end

Reply to this email directly or view it on GitHub.

@yoshie902a
Copy link
Author

  1. What is the difference between password and passphrase in my example above?

  2. Is there a way to use GPG2 and use code to prevent the pin entry box? I found this link...
    http://dilawarnotes.wordpress.com/2013/02/13/disable-gpg-gui-asking-for-paraphrase/
    and it disables the pin entry, but I get an "GPGME::Error::BadPassphrase: Bad passphrase" error. What could be causing this?

Currently, I downgraded from GPG2 to GPG 1.4 and it seems to be working, but would love to understand how to get GPG2 to work.

Thanks

@ueno
Copy link
Owner

ueno commented Feb 5, 2014

Unfortunately, you cannot pass passphrase programmatically with GPG 2.0. See #11.
(GPG 2.1 has pinentry-mode option which simulates GPG 1.4 behavior, but it is still in development)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants