none
Passphrase problem with GPG

    Question

  •  

    ProcessStartInfo psi = new ProcessStartInfo("cmd.exe");

    psi.CreateNoWindow = false;

    psi.UseShellExecute = false;

    psi.RedirectStandardInput = true;

    psi.RedirectStandardOutput = true;

    psi.RedirectStandardError = true;

    psi.WorkingDirectory = "C:";

    System.Diagnostics.Process process = System.Diagnostics.Process.Start(psi);

    string sCommandLine = "echo test| gpg -es --passphrase-fd 0 --recipient jatinvmehta@gmail.com -o c:\test.gpg c:\test.txt";

    process.StandardInput.WriteLine(sCommandLine);

    process.StandardInput.Flush();

    process.StandardInput.Close();

    process.WaitForExit();

    process.Close();

     

    Same command run succesfully from commandline. I don't understand what is the problem.

     

    Thanks in advance.

    Friday, March 21, 2008 1:05 PM

Answers

  • I think the problem is in your string:

    string sCommandLine = "echo test| gpg -es --passphrase-fd 0 --recipient jatinvmehta@gmail.com -o c:\test.gpg c:\test.txt";


    \t is translated to a 'tab' character!

    it should be:

    string sCommandLine = @"echo test| gpg -es --passphrase-fd 0 --recipient jatinvmehta@gmail.com -o c:\test.gpg c:\test.txt";



    Saturday, March 22, 2008 2:06 PM

All replies

  • Moving from SourceSafe -> C# General.
    Friday, March 21, 2008 5:36 PM
  • Do you have an error codes, messages, or exceptions?

     

    Friday, March 21, 2008 9:18 PM
  • Perhaps the commands in the mutt-gnupg howto can give you some inspiration...

    set pgp_decode_command="gpg %?p?--passphrase-fd 0? --no-verbose --batch --output - %f"
    set pgp_verify_command="gpg --no-verbose --batch --output - --verify %s %f"
    set pgp_decrypt_command="gpg --passphrase-fd 0 --no-verbose --batch --output - %f"
    set pgp_sign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --detach-sign --textmode %?a?-u %a? %f"
    set pgp_clearsign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f"
    set pgp_encrypt_only_command="pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust --encrypt-to 0xC9C40C31 -- -r %r -- %f"
    set pgp_encrypt_sign_command="pgpewrap gpg --passphrase-fd 0 --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust --encrypt-to 0xC9C40C31 -- -r %r -- %f"

    And at http://www.codeproject.com/KB/security/gnupgdotnet.aspx you find a library that provides an adapter for gnupg...


    Saturday, March 22, 2008 12:53 PM
  • I think the problem is in your string:

    string sCommandLine = "echo test| gpg -es --passphrase-fd 0 --recipient jatinvmehta@gmail.com -o c:\test.gpg c:\test.txt";


    \t is translated to a 'tab' character!

    it should be:

    string sCommandLine = @"echo test| gpg -es --passphrase-fd 0 --recipient jatinvmehta@gmail.com -o c:\test.gpg c:\test.txt";



    Saturday, March 22, 2008 2:06 PM