|
 |
|
|
Hi, We're using gpg4win, that uses a lates version of Gnu. It uses version 1.4.7, and when I run a sign and encrypt for a file that is over 900kb, is just hangs. It does work on smaller files, but I need it to work on files as bug as 50mb. Is there a solution for that?
Thanks
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
The process object becomes full and has to buffer out. Which, it cannot because you have not read the data out of the buffer yet(buffered output). You need to create a thread and read and write it your self.
Code--- // in the send string, add your reciepent email address where bhull@racetrac.com is.
static string send = "--homedir \"C:\\gnupg\" --yes --batch --encrypt --armor --recipient bhull@racetrac.com --verbose "; static ProcessStartInfo startinfo = new ProcessStartInfo(@"C:\gnupg\gpg.exe", send); static Process procstart; static string _outputString; startinfo.WorkingDirectory = GnupgHome; startinfo.CreateNoWindow = true; startinfo.UseShellExecute = false; startinfo.RedirectStandardInput = true; startinfo.RedirectStandardOutput = true; startinfo.RedirectStandardError = true; procstart = Process.Start(startinfo); procstart.StandardInput.AutoFlush = false;
Thread writer = new Thread(delegate() { procstart.StandardInput.WriteLine(_ResultSet); procstart.StandardInput.Close(); }); writer.Start(); // whatever you want to do here do it. write to file or whatever
writer.join();
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Prior to testing this wrapper, I installed gpg4win and used the WinPT desktop utility to create and import keys. But the wrapper always gave the error “public key not found”.
The cause turned out to be the location of the key files. With a little detective work I discovered that by default, pgp.exe keeps its key files under the user’s profile – in this folder:
C:\Documents and Settings\(user)\Application Data\gnupg
WinPT uses the default files, but GnuPGWrapper overrides this by supplying pgp.exe with a –homedir parameter taken from its “homedirectory” property. That meant that the wrapper was using a different set of key files from the WinPT tool. No wonder the public key was not found.
If you do not supply a home directory, then the wrapper cannot find the pgp.exe program, which it expects to find in the same folder as the keys. (This is not very tidy since one might well want to separate keys from executables.)
In fact, it turns out the wrapper does have a separate variable – bindirectory – for the pgp.exe path, but it is simply copies the homedirectory property into this variable (comment: “For now, let's assume the gpg.exe program is installed in the homedirectory too”). So we can improve things by removing the line below this comment, and adding an explict bindirectory property…
public string bindirectory { set { _bindirectory = value; } }
We can then supply this property with the path to pgp.exe, while leaving homedirectory unset. When called via the wrapper, pgp.exe then works OK using its default keys, as exposed by the WinPT GUI tool.
However, this solution means that the website or application that uses the wrapper must be running under the same user that ran WinPT to create the keys – or have administrator privileges – because the keys are saved in the users profile. Neither is particularly desirable. In fact you might want to run WinPT on your desktop while your application is on a production server.
An alternative solution would be to change the home directory used by WinPT. There is an option for this under Edt -> Preferences -> GPG preferences, but it’s greyed and cannot be changed. Gotya! Or maybe not…
Here’s my solution. Copy the key files from WinPT’s folder (C:\Documents and Settings\(user)\Application Data\gnupg ) to a folder that you know will be accessible to your application, and set homedirectory to point to that. The files to copy are secring.gpg, pubring.gpg and trustdb.gpg.
If you had the same problem, hope you find this useful.
-- modified at 6:56 Monday 30th July, 2007
|
| Sign In·View Thread·PermaLink | 1.67/5 (3 votes) |
|
|
|
 |
|
|
 |
|
|
Hi, I am facing the same problem. I am trying to solve this issue by generating a new key pair and then copying the pubring.gpg,secring.gpg,trustdb.gpg , gpg.exe into the accessible directory (ex: C:\chary\GnuPGDotNet_src\GnuPGDotNet\GnuPG )
Still i'm getting the same error when i click on encrypt button: gpg: you@yourcompany.com: skipped: public key not found gpg: [stdin]: encryption failed: public key not found.
Please can some one help me to solve this problem, it's urgent.
chary
|
| Sign In·View Thread·PermaLink | 2.00/5 (3 votes) |
|
|
|
 |
|
|
Hello, I am trying to decrypt a file using this code but I am coming across some errors. I will give you a little information about my project and hopefully you can help me with it.
I am creating a web site in ASP.NET (C#) that will allow a user to upload a file that will then be converted to a dataset. The files that will be uploaded will be encypted. As the file is being converted to a dataset, it will also decrypt it. Here is the code for the decryption:
//The DataSet to Return DataSet result = new DataSet();
GnuPGWrapper gpg = new GnuPGWrapper("Path"); //Open the file in a stream reader. StreamReader s = new StreamReader(File);
//Read the rest of the data in the file. string AllData = s.ReadToEnd();
gpg.passphrase = "passphrase"; gpg.command = Commands.Decrypt;
// Execute GnuPG string outputText = ""; gpg.ExecuteCommand(AllData, out outputText); AllData = outputText;
Basically, the text from the file is read into a string and then it should be decrypted. After that, the result should be put back into the string. I have done this successfully with files and the command line, but when I try it here I get the errors: gpg: no valid OpenPGP data found & gpg: decrypt_message failed: eof. Thank you for any help that you can give me.
----------------------------------------------------------------------------------------
I found that the problem with my code was with the file itself. As I read through these forums I found that this will only work with asc ASCII armored files. When I armored the files, everything worked fine.
-- modified at 15:07 Thursday 2nd August, 2007
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
In the code example provided you use a passphrase. I have been asked to be able to encrypt/decrypt based on the use of a public key. How would you use this code to work with the key instead of the passprase?
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
I feel bad for asking this, but I am stuck. I have an existing .pgp key and I would like to encrypt it using my c# application. However the file gets transferred to a unix platform and decrypted by gpg there.
Using Emmanuel's wrapper is it possible to do this? I am thinking if I already have a public key, it should be straight forward, but given the examples provided I cannot understand how to approach it.
I am very new to encryption so I am probing in the dark completely.
Thanks in advance, I would appreciate any help.
email: arkadyka@yahoo.com
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
It should be possible. Read GnuPG info if you must. If you can get it working manually using gpg command, you'll be able to use this wrapper in your .NET app.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I downloaded and unzipped the app. Converted to VS.NET 2005 with no problms. I click on the pgp.exe under the GnuPG folder and I got the same error listed below about the keys not being created. I then went out the GNU wesite and downloaded v1.2.2. There was no installer so I clicked on all the .exe in the unzipped folder and one of these created a folder on my root drive, however, there is something I am missing because I am not getting anywhere with this....
Can someone please point me in the right direction.
-Brian
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
that doesn't seem to be a recent version. are you sure you are downloading the windows binary? - it is an installer.
I have noticed however that pgp.exe itself was enough to work without installing the whole GnuPG application.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I've just started using this component, but I'm having some difficulties.
I installed GnuPG and I've added 2 key pairs. I can successfully encrypt and decrypt files with both pairs using gpg.exe.
But when I try to encrypt or decrypt with GnuPGWrapper, I get this message:
gpg: keyblock resource `C:/GnuPG" -se -a -r recipient@xxx.com -u signedby@xxx.com --no-verbose -o //myserver/encryption/sample.txt.pgp //myserver/encryption/sample.txt \secring.gpg': file open error
If I copy the bold part of the message and paste it after gpg.exe on the command line, it prompts me for the passphrase for signedby@xxx.com. When I enter it, the pgp file is successfully created.
Obviously I've tinkered with the code, adding support for working with files and using the shorter switch codes, but this same problem was happening with the original source as well.
Any ideas on why the keyblock resource error is coming up?
-Chris Payne
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I was having exactly the same problem, it turned out to be because the procedure BuildOptions() puts double quotes around the path for the --homedir command line argument. Changing those 3 lines to just:
optionsBuilder.Append("--homedir "); optionsBuilder.Append(_homedirectory); optionsBuilder.Append(" ");
fixes it for me. Hope that helps.
Hoots.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
A comment just above that piece of code says: To do... convert long names to the version with ~ in, which suggests that spaces might not work correctly. Anyway, removing the quotes worked for me, just make sure your home directory is c:\GnuPG which doesn't have spaces in. How'd you get on?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I'm finally getting back to this after a flurry of new priorities.
I removed the quotes from the homedir argument, but now it simply times out. I can copy & paste the command and arguments that are generated onto the command prompt and it works fine after prompting me to enter my passphrase, so I suspect the problem is in the redirected standard input.
Do I need to explicitly pass a carriage return with my passphrase, or should the StandardInput.WriteLine be taking care of that?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
All it's doing is putting together what you would be entering at the command prompt and then executing it whilst redirecting outputs. You say when you're entering the command at the prompt it then prompts you for your passphrase. This is probably why it's timing out when it's doing that in code as it will also be waiting for a passphrase. you need to find a way of including your passphrase in the command prompt and then changing the code so that this is included as well. Hope that's helpful
Hoots
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
i have installed the project in c:\inetpub/wwwroot but when i click the gpg.exe i get the message-
gpg:keyblock resource'c:/gnupg/secring.gpg':file open error gpg:keyblock resource'c:/gnupg/pubring.gpg':file open error gpg:Go ahead and type your message....
and nothing happens when i type the message
pls reply soon
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
Hi, Good Work.... I have created the pgp file (using Network Associates PGP Desktop Tool) with passpharse. Iam trying to decrypt using your wrapper class. Iam getting .No Data... Eof ... exception. Please help me
kind Regards, Prathap. Dubai.
|
| Sign In·View Thread·PermaLink | 2.67/5 (3 votes) |
|
|
|
 |
|
|
Hi,I am using your wrapper class for Decryption.Thanks for the articles. However i am facing problem in decrypting the binary files.I can see this working fine for ASCII files but binary files are not decrypting...
I have used the binary Reader to read the binary files instead of the stream writer in the Wrapper class and have overloaded the Execute command to accept char bytes as input instead of string....
I am getting erorr as "No valid PGP data found ".
But i have tested the same file to decrypt in command line and its working fine.i am using the following command to decrypt in command line (mean with the gnupg exe) -"gpg --decrypt filename" and it prompts me for the passphrase and then i am getting the decrpted message in the screen..
I am trying to use the following command in the Build Options : gpg - -decrypt --passpahrse -fd 0
passphrase - i am pasisng in standard input and have specified the name of the file but i am getitng error as usage: gpg [options] --decrypt [filename]
can you please help me in this bianry file decryption. Thanks in advance...Looking forward for your reply on this...
kalai
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
The posted implementation onle\y supports ASCII for encryption. Like you, I needed a decrypt from a source that was only able to provide binary. I modified two lines in the source code as follows:
The line:
public void ExecuteCommand(string inputText, out string outputText)
was changed to:
public void ExecuteCommand(byte [] inputText, out string outputText)
and the line:
_processObject.StandardInput.Write(inputText);
was changed to:
_processObject.StandardInput.BaseStream.Write(inputText, 0, inputText.Length);
Since I only needed to decrypt binary, I just changed the source. If you need to do both, then just add a new method changed as above.
My source is simply changed to pass a byte[] variable containing the binary data to the ExecuteCommand method.
Hope this helps.
Regards,
Joe
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Thanks Joe..Your piece of code works. And the same method works well for both ASCII and Binary file. I am able to decrpyt both ASCII and binary with the same Execute Comamnd method.
This is the first message i am posting to code Project...And happy about your response.Thanks
Kalai
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |