|
Lines 25-30
define( 'GPGSTDOUT', 1 );
|
Link Here
|
|---|
|
define( 'GPGSTDERR', 2 ); | define( 'GPGSTDERR', 2 ); |
define( 'STATUS_FD', 5 ); | define( 'STATUS_FD', 5 ); |
define( 'PASSPHRASE_FD', 7 ); | define( 'PASSPHRASE_FD', 7 ); |
|
define( 'PASSPHRASE_FD2', 8 ); |
define( 'CHECKPASSWORD_FD', 3 ); | define( 'CHECKPASSWORD_FD', 3 ); |
| |
// from gnupg include/cipher.h | // from gnupg include/cipher.h |
|
|
GPGSTDERR => array( 'pipe', 'w' ), // stderr | GPGSTDERR => array( 'pipe', 'w' ), // stderr |
STATUS_FD => array( 'pipe', 'w' ), | STATUS_FD => array( 'pipe', 'w' ), |
PASSPHRASE_FD => array( 'pipe', 'r' ) | PASSPHRASE_FD => array( 'pipe', 'r' ) |
|
PASSPHRASE_FD2 => array( 'pipe', 'r' ) |
); | ); |
| |
//These variables control the environmental variables that we try to set before executing the gpg binary | //These variables control the environmental variables that we try to set before executing the gpg binary |
|
|
default: | default: |
$this->printDebug("This action: " . $this->action . " isn't written to allow passing of the passphrase."); | $this->printDebug("This action: " . $this->action . " isn't written to allow passing of the passphrase."); |
$this->closePipe(PASSPHRASE_FD); | $this->closePipe(PASSPHRASE_FD); |
|
$this->closePipe(PASSPHRASE_FD2); |
$this->setError("NOSTATUS","Couldn't handle the status"); | $this->setError("NOSTATUS","Couldn't handle the status"); |
break; | break; |
} | } |
|
|
case "BEGIN ENCRYPTION": | case "BEGIN ENCRYPTION": |
$this->printDebug("Encryption begun."); | $this->printDebug("Encryption begun."); |
$this->closePipe( PASSPHRASE_FD ); | $this->closePipe( PASSPHRASE_FD ); |
|
$this->closePipe( PASSPHRASE_FD2 ); |
break; | break; |
} | } |
} //end [GNUPG]: if | } //end [GNUPG]: if |
|
|
{ | { |
if ($this->passphrase) { | if ($this->passphrase) { |
$this->printDebug( "Sending Passphrase" ); | $this->printDebug( "Sending Passphrase" ); |
$this->writeData( $this->passphrase."\n", PASSPHRASE_FD ); |
$this->writeData( $this->passphrase."\n", PASSPHRASE_FD2 ); |
$this->printDebug( "Done Sending Passphrase" ); | $this->printDebug( "Done Sending Passphrase" ); |
} else { | } else { |
$keyIndex = $this->getKeyIndexFromFingerprint( $fingerprint ); | $keyIndex = $this->getKeyIndexFromFingerprint( $fingerprint ); |
|
|
if( $keyIndex !== false && $this->keys[ $keyIndex ]->passphrase!='' ) | if( $keyIndex !== false && $this->keys[ $keyIndex ]->passphrase!='' ) |
{ | { |
$this->printDebug( "Sending Passphrase" ); | $this->printDebug( "Sending Passphrase" ); |
$this->writeData( $this->keys[ $keyIndex]->passphrase."\n", PASSPHRASE_FD ); |
$this->writeData( $this->keys[ $keyIndex]->passphrase."\n", PASSPHRASE_FD2 ); |
$this->printDebug( "Done Sending Passphrase" ); | $this->printDebug( "Done Sending Passphrase" ); |
} | } |
else { | else { |
$this->printDebug( "No Password: " . $this->keys[ $keyIndex ]->passphrase . '?' ); | $this->printDebug( "No Password: " . $this->keys[ $keyIndex ]->passphrase . '?' ); |
$this->writeData("\n", PASSPHRASE_FD ); |
$this->writeData("\n", PASSPHRASE_FD2 ); |
} | } |
} | } |
// $this->closePipe( PASSPHRASE_FD ); | // $this->closePipe( PASSPHRASE_FD ); |
|
|
{ | { |
if ($this->newpassphrase) { | if ($this->newpassphrase) { |
$this->printDebug("Writing new passphrase." ); | $this->printDebug("Writing new passphrase." ); |
$this->writeData($this->newpassphrase."\n",PASSPHRASE_FD ); |
$this->writeData($this->newpassphrase."\n",PASSPHRASE_FD2 ); |
$this->writeData($this->newpassphrase."\n",PASSPHRASE_FD ); |
$this->writeData($this->newpassphrase."\n",PASSPHRASE_FD2 ); |
} else { | } else { |
$this->printDebug("Failed to find new passphrase." ); | $this->printDebug("Failed to find new passphrase." ); |
} | } |
|
|
$lastSecondCommands=''; | $lastSecondCommands=''; |
| |
if( $usePassphrase ) | if( $usePassphrase ) |
$lastSecondCommands .= ' --command-fd '.PASSPHRASE_FD; |
$lastSecondCommands .= ' --batch --command-fd '.PASSPHRASE_FD . ' --passphrase-fd='.PASSPHRASE_FD2; |
else | else |
$lastSecondCommands .= ' --batch'; | $lastSecondCommands .= ' --batch'; |
| |