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

Class: Crypt_GPG_PinEntry

Source Location: /Crypt_GPG-1.6.4/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 71]
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.

The 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 195]

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 125]

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

Type:   resource


[ Top ]

$moribund =  false

[line 132]

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

Type:   boolean


[ Top ]

$parser =  null

[line 153]

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

Type:   Console_CommandLine


[ Top ]

$pins = array()

[line 178]

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 111]

File handle for the input stream
  • Access: protected

Type:   resource


[ Top ]

$stdout =  null

[line 118]

File handle for the output stream
  • Access: protected

Type:   resource


[ Top ]

$verbosity =  self::VERBOSITY_NONE

[line 144]

Verbosity level

One of:

  • Access: protected

Type:   integer


[ Top ]



Method Detail

connect   [line 376]

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 494]

Crypt_GPG_PinEntry disconnect( )

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

[ Top ]

getCommandLineParser   [line 332]

Console_CommandLine getCommandLineParser( )

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

[ Top ]

getComment   [line 778]

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 756]

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 731]

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 306]

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 805]

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 465]

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 352]

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 413]

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 840]

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 604]

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 700]

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 573]

Crypt_GPG_PinEntry sendConfirm( )

Tells the assuan server to confirm the operation
  • Return: the current object, for fluent interface.
  • Access: protected

[ Top ]

sendGetInfo   [line 663]

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 685]

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 617]

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 587]

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 524]

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 715]

Crypt_GPG_PinEntry sendReset( )

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

[ Top ]

sendSetDescription   [line 540]

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 271]

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 254]

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 205]

void __invoke( )

Runs this pinentry
  • Access: public

[ Top ]


Documentation generated on Sun, 22 Mar 2020 08:01:07 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.