File/plugins/gpg/gpg_functions.php

Description

gpg_functions.php

GPG plugin functions file

Copyright (c) 1999-2005 The SquirrelMail development team Licensed under the GNU GPL. For full terms see the file COPYING.

portions of this file Copyright (c) 1999-2002 the Squirrelmail Development Team

Copyright (c) 2002-2005 Braverock Ventures Copyright (c) 2007 The NaSMail Project

  • author: Brian Peterson
  • version: $Id: gpg_functions.php 969 2007-11-02 15:18:13Z tokul $
Includes
 require_once (SM_PATH.'plugins/gpg/functions/pref.php') (line 32)
 require_once (SM_PATH.'functions/mime.php') (line 31)
 require_once (SM_PATH.'functions/addressbook.php') (line 30)

load required functions and config

Functions
createTempDir (line 305)

Creates a temporary directory in the system's temporary directory.

Original Source: Horde.php (class Horde)

  • return: The pathname to the new temporary directory. Returns false if directory not created.
string createTempDir ([optional $delete = true])
  • optional $delete: boolean $delete Delete the temporary directory at the end of the request?
deleteAtShutdown (line 354)

Removes given elements at request shutdown.

Original Source: Horde.php (class Horde)

If called with a filename will delete that file at request shutdown; if called with a directory will remove that directory and all files in that directory at request shutdown.

If called with no arguments, return all elements to be deleted (this should only be done by _deleteAtShutdown).

The first time it is called, it initializes the array and registers _deleteAtShutdown() as a shutdown function - no need to do so manually.

The second parameter allows the unregistering of previously registered elements.

  • access: public
void deleteAtShutdown ([optional $filename = false], [optional $register = true])
  • optional $filename: string $filename The filename to be deleted at the end of the request.
  • optional $register: boolean $register If true, then register the element for deletion, otherwise, unregister it.
gpg_add_help_link (line 610)

Create an HTML TAG Link to display help files This will only create the first half of the A Tag pair

  • return: HTML link Tag prefix
  • todo: we should check for attempted security breach here, stripping . and /'s, etc and making sure that the file actually exists, otherwise go to base.php
string gpg_add_help_link ([string $_help_file = 'base'], [boolean $fullscreen = false])
  • string $_help_file: name of help file to load
  • boolean $fullscreen: link can stay within same frame or popup small window
gpg_add_navigation_tags (line 1058)

Adds hidden html tags with navigation information

  • since: 2.1.nsm
void gpg_add_navigation_tags ([array $defaults = array()])
  • array $defaults: Array with default 'pos', 'sort', 'desc', 'srch', 'ring' values
gpg_add_navigation_urls (line 1078)

Adds navigation params to url

  • return: Url with navigation parameters
  • since: 2.1.nsm
string gpg_add_navigation_urls (string $url, boolean $link, [array $defaults = array()])
  • array $defaults: Array with default 'pos', 'sort', 'desc', 'srch', 'ring' values
  • string $url: Original url
  • boolean $link: Is it link (html sanitized) or redirect (html is not sanitized)
gpg_add_system_keyring (line 1235)

Adds system trust arguments to gpg execution parameters

string gpg_add_system_keyring ([boolean $trust = true])
  • boolean $trust: Controls inclusion of systemtrustedkey
gpg_clear_cached_passphrase (line 496)

Clears the Cached Passphrase from secure storage Overwrite first with gibberish, just in case.

  • return: string true if cleared, false or error
boolean gpg_clear_cached_passphrase ()
gpg_download_entity (line 1165)

Downloads an entity (part of a message) and returns a temporary filename for it

  • return: with $return['filename'] and $return['errors']
array gpg_download_entity (imapConnection $imap_stream, mailbox $mailbox, string $id, string $ent_id, [string $filename = ''], [ $passbody = false], [boolean $maxsize = 0], [ $with_header = false])
  • imapConnection $imap_stream: connection to imap server
  • mailbox $mailbox
  • string $id: of the message
  • string $ent_id: entity id, which part of the message to download
  • string $filename: optional filename to download to
  • boolean $maxsize: adds MIME headers. Used in PGP/MIME
  • $passbody
  • $with_header
gpg_error_box (line 1139)

Prints error boxes

Own error box function is used for better layout controls

  • since: 2.1.nsm
void gpg_error_box (string $title, string $message)
  • string $title: title of error box
  • string $message: message (html formating is allowed)
gpg_getTempDir (line 171)

Determine the location of the system temporary directory.

If a specific setting cannot be found, it defaults to /tmp

Original Source: Horde.php (class Horde)

Function was renamed in 2.1.nsm in order to avoid name collisions.

  • return: A directory name which can be used for temp files. Returns false if one could not be found.
  • since: 2.1.nsm
string gpg_getTempDir ()
gpg_getTempFile (line 243)

Create a temporary filename for the lifetime of the script, and (optionally) register it to be deleted at request shutdown.

Original Source: Horde.php (class Horde)

Function was renamed in 2.1.nsm in order to avoid name collisions.

  • return: Returns the full path-name to the temporary file. Returns false if a temp file could not be created.
  • since: 2.1.nsm
  • access: public
string gpg_getTempFile ([string $prefix = 'GPGPlugin'], [optional $delete = true], [optional $dir = ''])
  • string $prefix: Prefix to make the temporary name more recognizable.
  • optional $delete: boolean $delete Delete the file at the end of the request?
  • optional $dir: string $dir Directory to create the temporary file in.
gpg_get_cached_passphrase (line 470)

Get/retrieve the Cached Passphrase from secure storage

  • return: or 'false'
string gpg_get_cached_passphrase ()
gpg_get_signing_key_id (line 135)
void gpg_get_signing_key_id ()
gpg_https_connection (line 55)

This function is called to check whether the user has an SSL connection Returns 0 for false and 1 for true (SSL)

Use whenever you are expecting input from the user (passphrase, etc.)

  • return: 0|1 1=true
boolean gpg_https_connection ([void 0 = ])
  • void 0
gpg_is_passphrase_cacheable (line 537)

This function checks all the options to see if passphrase caching is enabled. Returns true if system allows passphrase caching and the user has selected to cache their passphrase Otherwise returns false.

  • return: true if caching is enabled, false if not
boolean gpg_is_passphrase_cacheable ()
gpg_is_passphrase_cached (line 558)

This function checks all the options to see if a cached passphrase should be retrieved. Returns true if system allows passphrase caching and the user has selected to cache their passphrase, and there is a cached passphrase Otherwise returns false.

  • return: true if passphrase is cached, false if not
boolean gpg_is_passphrase_cached ()
gpg_page_title (line 1215)

Creates page title tags

Called by the module pages to display the optional title header.

Function was modified in 2.1.nsm. It returns html tags instead of echoing them

  • author: Brian Peterson
string gpg_page_title (string $title)
  • string $title: Localized page title
gpg_parse_output (line 665)

This will parse the string that gpg returns for info, warnings, errors and return them in arrays. This function also returns any other output seperately

FIXME: dupe. See GnuPG::parse_output

  • return: ['errors'],['warnings'],['info'] contain gpg messages ['output'] contains the rest of the output
array gpg_parse_output (string $gpg_output)
  • string $gpg_output: text output from gpg
gpg_secure_unlink (line 278)

Securely delete a temporary file

Should be redundant, as the deleteat shutdown functions should work but just to be sure, and to minimize the time the file is in existence

Function was renamed in 2.1.nsm in order to avoid name collisions.

  • since: 2.1.nsm
boolean gpg_secure_unlink (string $filename)
  • string $filename
gpg_setglobal (line 117)

This function will set a global variable that we want to be available to NaSMail in a fassion that is usable by all of the NaSMail sqgetGlobalVar or other get functions. Place the variable in _SESSION, _POST, and _GET

void gpg_setglobal (string $name, string $value)
  • string $name: The name of the global variable
  • string $value: The value to set it to.
gpg_set_cached_passphrase (line 444)

Sets the Cached Passphrase, storing it in secure storage

boolean gpg_set_cached_passphrase (string $passphrase)
  • string $passphrase: passphrase
gpg_show_encrypt_errors (line 1096)

Prints all error messages generated during signing and encrypting process

  • since: 2.1.nsm
void gpg_show_encrypt_errors (array $errors)
  • array $errors: array with 'errors', 'warnings', 'skipped_keys' and 'info' keys. array values store other indexed arrays with error messages
gpg_stripstr (line 633)

function to strip a gpg: from the beginning of a string, if it exists

  • return: of output with gpg: stripped off
string gpg_stripstr (string $inline, [ $stripstr = 'gpg:'])
  • string $inline: line of output from gpg
  • $stripstr
gpg_update_trustdb (line 648)

This function will update the gpg trustdb for the current user including a scan of the system keyring if enabled

void gpg_update_trustdb ()
gpg_verify_passphrase (line 573)

Checks if the passphrase for the given key is valid

  • return: boolean string true if valid, false if not valid
$return['verified'] gpg_verify_passphrase ($passphrase $passphrase, [$key_id $key_id = ''])
  • $passphrase $passphrase: is the passphrase to verify
  • $key_id $key_id: is the secret key ID to check the passphrase on
initGnuPG (line 72)

This function is used to inialize and return a configured GnuPG object

  • return: object to run gpg commands
object GnuPG initGnuPG ()

Documentation generated on Sun, 22 Nov 2009 17:36:36 +0200 by phpDocumentor 1.4.3