Crypt_GPG
[ class tree: Crypt_GPG ] [ index: Crypt_GPG ] [ all elements ]

Class: Crypt_GPG_PinEntry

Source Location: /Crypt_GPG-1.4.0b4/Crypt/GPG/PinEntry.php

Class Overview


A command-line dummy pinentry program for use with gpg-agent and Crypt_GPG


Author(s):

Copyright:

  • 2013 silverorange

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 72]
A command-line dummy pinentry program for use with gpg-agent and Crypt_GPG

This pinentry receives passphrases through en environment variable and automatically enters the PIN in response to gpg-agent requests. No user- interaction required.

Thie pinentry can be run independently for testing and debugging with the following syntax:

 Usage:
   crypt-gpg-pinentry [options]

 Options:
   -l log, --log=log  Optional location to log pinentry activity.
   -v, --verbose      Sets verbosity level. Use multiples for more detail
                      (e.g. "-vv").
   -h, --help         show this help message and exit
   --version          show the program version and exit



[ Top ]


Class Variables

$currentPin =  null

[line 207]

The PIN currently being requested by the Assuan server

If set, this is an associative array in the form:

  1.  <?php
  2.    array(
  3.      'keyId'  => $shortKeyId,
  4.      'userId' => $userIdString
  5.    );
  6.  ?>

  • Access: protected

Type:   array|null


[ Top ]

$logFile =  null

[line 126]

File handle for the log file if a log file is used
  • Access: protected

Type:   resource


[ Top ]

$moribund =  false

[line 133]

Whether or not this pinentry is finished and is exiting
  • Access: protected

Type:   boolean


[ Top ]

$parser =  null

[line 154]

The command-line interface parser for this pinentry
  • See: Crypt_GPG_PinEntry::getParser()
  • Access: protected

Type:   Console_CommandLine


[ Top ]

$pins = array()

[line 179]

PINs to be entered by this pinentry

An indexed array of associative arrays in the form:

  1.  <?php
  2.    array(
  3.      array(
  4.        'keyId'      => $keyId,
  5.        'passphrase' => $passphrase
  6.      ),
  7.      ...
  8.    );
  9.  ?>

This array is parsed from the environment variable PINENTRY_USER_DATA.


Type:   array


[ Top ]

$stdin =  null

[line 112]

File handle for the input stream
  • Access: protected

Type:   resource


[ Top ]

$stdout =  null

[line 119]

File handle for the output stream
  • Access: protected

Type:   resource


[ Top ]

$triedPins = array()

[line 190]

PINs that have been tried for the current PIN

This is an associative array indexed by the key identifier with values being the same as elements in the Crypt_GPG_PinEntry::$pins array.

  • Access: protected

Type:   array


[ Top ]

$verbosity =  self::VERBOSITY_NONE

[line 145]

Verbosity level

One of:

  • Access: protected

Type:   integer


[ Top ]



Method Detail

connect   [line 385]

Crypt_GPG_PinEntry connect( )

Connects this pinentry to the assuan server

Opens I/O streams and sends initial handshake.

  • Return: the current object, for fluent interface.
  • Access: protected

[ Top ]

disconnect   [line 510]

Crypt_GPG_PinEntry disconnect( )

Disconnects this pinentry from the Assuan server
  • Return: the current object, for fluent interface.
  • Access: protected

[ Top ]

getCommandLineParser   [line 341]

Console_CommandLine getCommandLineParser( )

Gets the CLI parser for this pinentry
  • Return: the CLI parser for this pinentry.
  • Access: protected

[ Top ]

getComment   [line 800]

string getComment( string $data)

Gets a comment ready to send to the assuan server

Parameters:

string   $data     the comment to send to the assuan server.

[ Top ]

getData   [line 778]

string getData( string $data)

Gets data ready to send to the assuan server

Data is appropriately escaped and long lines are wrapped.


Parameters:

string   $data     the data to send to the assuan server.

[ Top ]

getOK   [line 753]

string getOK( [string $data = null])

Gets an OK response to send to the assuan server
  • Return: the OK response.
  • Access: protected

Parameters:

string   $data     an optional message to include with the OK response.

[ Top ]

getUIXML   [line 318]

string getUIXML( )

Gets the CLI user-interface definition for this pinentry

Detects whether or not this package is PEAR-installed and appropriately locates the XML UI definition.

  • Return: the location of the CLI user-interface definition XML.
  • Access: protected

[ Top ]

getWordWrappedData   [line 827]

string getWordWrappedData( string $data, string $prefix)

Wraps strings at 1,000 bytes without splitting UTF-8 multibyte characters

Each line is prepended with the specified line prefix. Wrapped lines are automatically appended with \ characters.

Protocol strings are UTF-8 but maximum line length is 1,000 bytes. mb_strcut() is used so we can limit line length by bytes and not split characters across multiple lines.


Parameters:

string   $data     the data to wrap.
string   $prefix     a single character to use as the line prefix. For example, 'D' or '#'.

[ Top ]

initPinsFromENV   [line 481]

Crypt_GPG_PinEntry initPinsFromENV( )

Initializes the PINs to be entered by this pinentry from the environment variable PINENTRY_USER_DATA

The PINs are parsed from a JSON-encoded string.

  • Return: the current object, for fluent interface.
  • Access: protected

[ Top ]

log   [line 361]

Crypt_GPG_PinEntry log( string $data, integer $level)

Logs a message at the specified verbosity level

If a log file is used, the message is written to the log. Otherwise, the message is sent to STDERR.

  • Return: the current object, for fluent interface.
  • Access: protected

Parameters:

string   $data     the message to log.
integer   $level     the verbosity level above which the message should be logged.

[ Top ]

parseCommand   [line 422]

Crypt_GPG_PinEntry parseCommand( string $line)

Parses an assuan command and performs the appropriate action

Documentation of the assuan commands for pinentry is limited to non-existent. Most of these commands were taken from the C source code to gpg-agent and pinentry.

Additional context was provided by using strace -f when calling the gpg-agent.

  • Return: the current object, for fluent interface.
  • Access: protected

Parameters:

string   $line     the assuan command line to parse

[ Top ]

send   [line 862]

Crypt_GPG_PinEntry send( string $data)

Sends raw data to the assuan server
  • Return: the current object, for fluent interface.
  • Access: protected

Parameters:

string   $data     the data to send.

[ Top ]

sendButtonInfo   [line 625]

Crypt_GPG_PinEntry sendButtonInfo( string $text)

Sends information about pressed buttons to the assuan server

This is used to fake a user-interface for this pinentry.

  • Return: the current object, for fluent interface.
  • Access: protected

Parameters:

string   $text     the button status to send.

[ Top ]

sendBye   [line 721]

Crypt_GPG_PinEntry sendBye( )

Flags this pinentry for disconnection and sends an OK response
  • Return: the current object, for fluent interface.
  • Access: protected

[ Top ]

sendConfirm   [line 594]

Crypt_GPG_PinEntry sendConfirm( )

Tells the assuan server the PIN entry was confirmed (not cancelled) by pressing the fake 'close' button
  • Return: the current object, for fluent interface.
  • Access: protected

[ Top ]

sendGetInfo   [line 684]

Crypt_GPG_PinEntry sendGetInfo( string $data)

Sends information about this pinentry
  • Return: the current object, for fluent interface.
  • Access: protected

Parameters:

string   $data     the information requested by the assuan server. Currently only 'pid' is supported. Other requests return no information.

[ Top ]

sendGetInfoPID   [line 706]

Crypt_GPG_PinEntry sendGetInfoPID( )

Sends the PID of this pinentry to the assuan server
  • Return: the current object, for fluent interface.
  • Access: protected

[ Top ]

sendGetPin   [line 638]

Crypt_GPG_PinEntry sendGetPin( )

Sends the PIN value for the currently requested key
  • Return: the current object, for fluent interface.
  • Access: protected

[ Top ]

sendMessage   [line 608]

Crypt_GPG_PinEntry sendMessage( )

Tells the assuan server that any requested pop-up messages were confirmed by pressing the fake 'close' button
  • Return: the current object, for fluent interface.
  • Access: protected

[ Top ]

sendNotImplementedOK   [line 540]

Crypt_GPG_PinEntry sendNotImplementedOK( )

Sends an OK response for a not implemented feature
  • Return: the current object, for fluent interface.
  • Access: protected

[ Top ]

sendReset   [line 736]

Crypt_GPG_PinEntry sendReset( )

Resets this pinentry and sends an OK response
  • Return: the current object, for fluent interface.
  • Access: protected

[ Top ]

sendSetDescription   [line 556]

Crypt_GPG_PinEntry sendSetDescription( string $text)

Parses the currently requested key identifier and user identifier from the description passed to this pinentry
  • Return: the current object, for fluent interface.
  • Access: protected

Parameters:

string   $text     the raw description sent from gpg-agent.

[ Top ]

setLogFilename   [line 283]

Crypt_GPG_PinEntry setLogFilename( string $filename)

Sets the log file location
  • Return: the current object, for fluent interface.
  • Access: public

Parameters:

string   $filename     the new log filename to use. If an empty string is used, file-based logging is disabled.

[ Top ]

setVerbosity   [line 266]

Crypt_GPG_PinEntry setVerbosity( integer $verbosity)

Sets the verbosity of logging for this pinentry

Verbosity levels are:

  • Return: the current object, for fluent interface.
  • Access: public

Parameters:

integer   $verbosity     the level of verbosity of this pinentry.

[ Top ]

__invoke   [line 217]

void __invoke( )

Runs this pinentry
  • Access: public

[ Top ]


Documentation generated on Wed, 13 Mar 2013 18:30:11 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.