I'm trying to operate gpg through proc_open. I can encrypt this way, just
fine, but when I try to decrypt I get:
gpg: cannot open `/dev/tty': Device not configured
Here's what I'm using; the same basic code works fine for encrypting:
<?php
$cmd =
'/usr/bin/gpg '.
'--decrypt '.
'--homedir /usr/home/userid/.gnupg';
$message =
'-----BEGIN PGP MESSAGE-----
Version: GnuPG v1.2.2 (FreeBSD)
[Yada, yada]
-----END PGP MESSAGE-----';
$pass =
'[passphrase]';
$descriptors = array(
0 => array('pipe', 'r'),
1 => array('pipe', 'w'),
2 => array('file', '/usr/home/userid/error.gpg', 'a')
);
$process = proc_open($cmd, $descriptors, $pipes);
list($stdin, $stdout, $stderr) = $pipes;
fputs($stdin, $message);
while (!feof($stdout)) {
$line = fgets($stdout);
echo $line;
}
fputs($stdin, $pass);
fclose($stdin);
while (!feof($stdout)) {
$line = fgets($stdout);
echo $line;
}
?>
--
Alan Little
Phorm PHP Form Processor http://www.phorm.com/ 5 6328
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Alan Little wrote: I'm trying to operate gpg through proc_open. I can encrypt this way, just fine, but when I try to decrypt I get:
gpg: cannot open `/dev/tty': Device not configured
Here's what I'm using; the same basic code works fine for encrypting:
Calling "gpg" with proc_open or similar methods is a mess... consider using
the PECL GPG extension - have a look at http://pecl.php.net .
- --
- ----------------------------------
Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net
Gentlemen, start your flamethrowers.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
iD8DBQFEXfBr3jcQ2mg3Pc8RAtMfAJ4p7iYqjSF/EO5mN/UjH+K4jH2t3wCfWnee
PvzDOkIh6dVaS+EtQnBFYJE=
=VXdM
-----END PGP SIGNATURE-----
Alan Little wrote: I'm trying to operate gpg through proc_open. I can encrypt this way, just fine, but when I try to decrypt I get:
gpg: cannot open `/dev/tty': Device not configured
GPG doesn't read the pass phrase from STDIN -- it reads it from the
terminal. It might seem like a minor difference, but the effect is that
you can't pass the passphrase in via STDIN.
You could try including the options "--no-tty --passphrase-fd 0".
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Carved in mystic runes upon the very living rock, the last words of
Iván Sánchez Ortega of comp.lang.php make plain: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Alan Little wrote:
I'm trying to operate gpg through proc_open. I can encrypt this way, just fine, but when I try to decrypt I get:
gpg: cannot open `/dev/tty': Device not configured
Here's what I'm using; the same basic code works fine for encrypting:
Calling "gpg" with proc_open or similar methods is a mess... consider using the PECL GPG extension - have a look at http://pecl.php.net .
Thanks for your response. Do you think it will be easier to sort out the
proc_open() method, or to figure out how to compile and install the
extension? And if I want to include this in distributed code later, does
that make a difference?
--
Alan Little
Phorm PHP Form Processor http://www.phorm.com/
Carved in mystic runes upon the very living rock, the last words of Toby
Inkster of comp.lang.php make plain: Alan Little wrote:
I'm trying to operate gpg through proc_open. I can encrypt this way, just fine, but when I try to decrypt I get:
gpg: cannot open `/dev/tty': Device not configured
GPG doesn't read the pass phrase from STDIN -- it reads it from the terminal. It might seem like a minor difference, but the effect is that you can't pass the passphrase in via STDIN.
You could try including the options "--no-tty --passphrase-fd 0".
Thanks; I wasn't aware of those options.
Now my script just hangs. I'm not sure where; I put limiters on the read
loops, and it still hangs. I noticed in the docs for proc_open, it says:
The file descriptor numbers are not limited to 0, 1 and 2 - you
may specify any valid file descriptor number and it will be
passed to the child process. This allows your script to interoperate
with other scripts that run as "co-processes". In particular, this
is useful for passing passphrases to programs like PGP, GPG and
openssl in a more secure manner.
It specifically mentions passing passphrases to GPG. I tried the
following changes in my script, but it still hangs:
$cmd =
'/usr/bin/gpg '.
'--decrypt '.
'--homedir /usr/home/userid/.gnupg '.
'--no-tty '.
'--passphrase-fd 3';
$descriptors = array(
0 => array('pipe', 'r'),
1 => array('pipe', 'w'),
2 => array('file', '/usr/home/thebest/error.gpg', 'a'),
3 => array('pipe', 'r')
);
list($stdin, $stdout, $stderr, $passpipe) = $pipes;
fputs($passpipe, $pass);
--
Alan Little
Phorm PHP Form Processor http://www.phorm.com/
Carved in mystic runes upon the very living rock, the last words of Alan
Little of comp.lang.php make plain: I'm trying to operate gpg through proc_open. I can encrypt this way, just fine, but when I try to decrypt I get:
I got it:
$cmd =
'/usr/bin/gpg '.
'--decrypt '.
'--homedir /usr/home/userid/.gnupg '.
'--no-tty '.
'--passphrase-fd 3';
$message = '[encrypted message]';
$pass = '[passphrase]';
$descriptors = array(
0 => array('pipe', 'r'),
1 => array('pipe', 'w'),
2 => array('file', '/usr/home/userid/error.gpg', 'a'),
3 => array('pipe', 'r')
);
$process = proc_open($cmd, $descriptors, $pipes);
list($stdin, $stdout, $stderr, $passpipe) = $pipes;
fputs($stdin, $message);
fclose($stdin);
fputs($passpipe, $pass);
fclose($passpipe);
while (!feof($stdout)) {
$line = fgets($stdout);
echo $line;
}
--
Alan Little
Phorm PHP Form Processor http://www.phorm.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mark Hanford |
last post by:
I've been setting up a new MySQL/PHP site which will contain store
some CC details, and have been wondering how to pass the keys.
CC's are written in a similar way to:
INSERT INTO cc (ccName,...
|
by: Benoît |
last post by:
Hi,
I have generated two keys :
"C:>openssl req -nodes -new -x509 -keyout ben.key -out ben.crt -days
3650"
I try to encrypt/decrypt a string like "JOHN" with these asymetrics
keys. With the...
|
by: Jimski |
last post by:
Hello all,
I am having a problem where I get an error message when I call
FlushFinalBlock when decrypting my encrypted text. I am using the
Rijndael algorithm.
The error message is "Length...
|
by: Gidi |
last post by:
Hi,
Is there Buid-In fuction in C# that Encrypt and Decrypt strings?
i have a textbox which i'm writing into file, and i want to encrypt it
before writing, i'm not looking for something fancy,...
|
by: Dica |
last post by:
i've used the sample code from msdn to create an encyption/decryption
assembly as found here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT10.asp
i'm...
|
by: Hannibal111111 |
last post by:
I found this code on a site for doing string encryption/decryption.
The string will encrypt fine, but I get this error when I try to
decrypt. Any idea why? I posted the code below.
The error...
|
by: JDeats |
last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting
and decrypting a file.
http://support.microsoft.com/kb/307010
In .NET 2.0 this approach is not fully supported (a .NET 2.0...
|
by: MimiMi |
last post by:
I'm trying to decrypt a byte array in java that was encrypted in C#. I don't get any error messages, just a result that's completely not what I was hoping for.
I think I am using the same type of...
|
by: MimiMi |
last post by:
I'm trying to decrypt a byte array in java that was encrypted in C#. I don't get any error messages, just a result that's completely not what I was hoping for.
I think I am using the same type of...
|
by: bferguson94 |
last post by:
Design a program that allows the user to encrypt or decrypt a file.
This means you will need to ask the user the direction to shift (left or right) and the number of places to shift (should they...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |