NAME

Win32::SPGP - A simple programmer interface to the SPGP API.


REQUIREMENTS

PGP 5.5.x to 6.x for Windows. (Available at http://www.pgp.com)


SYNOPSIS

        use Win32::SPGP;

        $pgp = new Win32::SPGP;
        $pgp->KeyID($hexid);
        $pgp->PassPhrase($string);
        $pgp->Armour($bool);
        $pgp->TextMode($bool);
        $pgp->ClearSign($bool);
        $pgp->Comment($string);
        $pgp->BufferSize($size);

        $cipher = $pgp->encrypt(Text => $string, Keys => \@keys);
        $cipher = $pgp->encrypt_and_sign(Text => $string, Keys => \@keys);
        $cipher = $pgp->sign(Text => $string);

        ($text, $sig) = $pgp->decrypt(Cipher => $cipher);

        $pgp->fencrypt(InFile => $file, Keys => \@keys);
        $pgp->fencrypt_and_sign(InFile => $file, Keys => \@keys);
        $pgp->fsign(InFile => $file);

        ($file, $sig) = $pgp->fdecrypt(InFile => $file);

        $pgp->fsign_detached(InFile => $file);
        $sig = $pgp->fverify_detached(InFile => $file);


DESCRIPTION

Win32::SPGP provides a simplified programmers interface to the Win32::SPGP::API library. It allows the user to perform the following basic functions with PGP for Windows:

        Encrypting & decrypting strings and files
        Creating & verifying digital signatures
        Examining the properties of keys and signatures


CONSTANTS

        PGP_SIGNED_GOOD
        PGP_SIGNED_NOT
        PGP_SIGNED_BAD
        PGP_SIGNED_NO_KEY


METHODS

Unless otherwise specified, all of the functions return undef if they fail. You can call Win32::SPGP::error() to get more error information.

new([OPTIONS])

OPTIONS are passed in a hash like fashion using key and value pairs. Available options are:

KeyID - Hex ID or Email address of the default private key used for signing and decrypting.

PassPhrase - Passphrase for the private key.

Armour - ASCII Armour any encrypted output.

TextMode - Treat input as text. If true, input data will be converted to ``canonical text'' (CRLF at the end of each line) before encryption/signing.

ClearSign - Digitally signed output will be ASCII Armoured.

Comment - A comment string will be added below the ``Version: '' string in digitally signed text.

BufferSize - Set the output buffer size in bytes. The default is 500,000 bytes.

encrypt(Text=>$string,Keys=>[$key|\@keys],[OPTIONS])

Encrypts a text string. Returns the encrypted string.

Text - Text to be encrypted.

Keys - Public keys to be encrypted by. Keys can be passed as either a string containing a single key, or a reference to an array of keys. The keys can consist of either their Hex ID's or email addresses.

OPTIONS can be any of the options defined in new().

encrypt_and_sign(Text=>$string,Keys=>[$key|\@keys],[OPTIONS])

Encrypts and signs a text string. Returns the encrypted/signed string.

Text - Text to be encrypted and signed.

Keys - Keys - Public keys to be encrypted by. Keys can be passed as either a string containing a single key, or a reference to an array of keys. The keys can consist of either their Hex ID's or email addresses.

OPTIONS can be any of the options defined in new(). KeyID and PassPhrase must be set in order to sign the text.

sign(Text=>$string,[OPTIONS])

Signs a text string. Returns the signed string.

Text - Text to be encrypted and signed.

OPTIONS can be any of the options defined in new(). KeyID and PassPhrase must be set in order to sign the text.

fencrypt(InFile=>$in,Keys=>[$key|\@keys],[OutFile=>$out],[OPTIONS])

Encrypts a file. A true return value indicates success.

InFile - Full path and filename of file to encrypt.

Keys - Keys - Public keys to be encrypted by. Keys can be passed as either a string containing a single key, or a reference to an array of keys. The keys can consist of either their Hex ID's or email addresses.

OutFile - (Optional) Full path and filename to write the encrypted file to. The default is the name of the file with the added extension of .pgp or .asc.

OPTIONS can be any of the options defined in new().

fencrypt_and_sign(InFile=>$in,Keys=>[$key|\@keys],[OutFile=>$out],[OPTIONS])

Encrypts and signs a file. A true return value indicates success.

InFile - Full path and filename of file to encrypt.

Keys - Keys - Public keys to be encrypted by. Keys can be passed as either a string containing a single key, or a reference to an array of keys. The keys can consist of either their Hex ID's or email addresses.

OutFile - (Optional) Full path and filename to write the encrypted file to. The default is the name of the file with the added extension of .pgp or .asc.

OPTIONS can be any of the options defined in new(). KeyID and PassPhrase must be set in order to sign the text.

fsign(InFile=>$in,[OutFile=>$out],[OPTIONS])

Signs a file. A true return value indicates success.

InFile - Full path and filename of file to encrypt.

OutFile - (Optional) Full path and filename to write the encrypted file to. The default is the name of the file with the added extension of .pgp or .asc.

OPTIONS can be any of the options defined in new(). KeyID and PassPhrase must be set in order to sign the text.

decrypt(Cipher=>$cipher,[OPTIONS])

Decrypts an encrypted text string and/or verifies its signature. In a scalar context, returns the decrypted plaintext. In a list context returns both the decrypted plaintext, and a hash reference containing the properties of the signing key if present.

Cipher - Encrypted ciphertext.

OPTIONS can be any of the options defined in new(). PassPhrase must be set in order to decrypt the ciphertext.

The hash reference returned will contain the following properties of the signing key, (if indeed the ciphertext was signed).

Status - Indicates the status of the signing key. It can be one of the following constants, (PGP_SIGNED_GOOD - a good signature, PGP_SIGNED_NOT - no signature present, PGP_SIGNED_BAD - a bad signature, PGP_SIGNED_NO_KEY - No public key for the signature is on the keyring.)

UserID - UserID of the signing key. This will be of the form ``name <email@address.com>

KeyID - Hex ID of the signing key. This will be of the form ``0xFDD1C507''.

Date - Date of the signature in ctime format ``Thu Oct 01 20:42:41 1998''.

Epoch - Date of signature in epoch seconds.

Checked - A boolean value (1 or 0) indicating whether the signing key is available and the message is formatted properly.

Verified - A boolean value (1 or 0) indicating whether the signed data is unchanged. Both Checked and Verified must be true for the signature to be valid.

Validity - The signing key's current level of validity; a number corresponding to one of the following constants: Unknown = 0, Invalid = 1, Marginal = 2, Complete = 3.

Revoked - A boolean value (1 or 0) indicating whether the signing key is revoked.

Disabled - A boolean value (1 or 0) indicating whether the signing key is disabled.

Expired - A boolean value (1 or 0) indicating whether the signing key has expired.

fdecrypt(InFile=>$in,[OutFile=>$out],[OPTIONS])

Decrypts a file and/or verifies its signature. In a scalar context, returns the decrypted filename. In a list context returns both the decrypted filename, and a hash reference containing the properties of the signing key if present.

InFile - Full path and filename of encrypted file to decrypt.

OutFile - (Optional) Full path and filename to write the unencrypted file to. The default is the name of the encrypted file with the extension of .pgp or .asc removed.

OPTIONS can be any of the options defined in new(). PassPhrase must be set in order to decrypt the file.

The hash reference returned will contain the properties of the signing key, (if indeed the ciphertext was signed). The properties returned are described in decrypt().

fsign_detached(InFile=>$in,[SigFile=>$sig],[OPTIONS])

Creates a detached signature file for a given file. A true return value indicates success.

InFile - Full path and filename of file to be signed.

SigFile - (Optional) Full path and filename of detached signature to be created. Default is the name of the signed file with the extension .sig added.

OPTIONS can be any of the options defined in new(). KeyID and PassPhrase must be set in order to sign the file.

fverify_detached(InFile=>$in,[SigFile=>$sig],[OPTIONS])

Verifies a detached signature file for a given file. Returns a hash reference containing the properties of the signing key.

InFile - Full path and filename of file to be verified against its signature.

SigFile - (Optional) Full path and filename of the detached signature to be verified. Default is the name of the signed file with the extension .sig added.

OPTIONS can be any of the options defined in new().

error()

Returns either the error code or error string of the last error that occurred.

A list of error codes can be found at http://www.oz.net/~srheller/spgp/funcref/errorcodes.html for those errors that do not return a message string.


Unimplemented

This module only implements a few of the most commonly used features of the SPGP library. More functionality can be accessed directly through the raw interface provided by the Win32::SPGP::API module.


VERSION

        SPGP.pm  Version 2.00     January 21, 2001.
        SPGP.dll Version 2.5.6.0  October 21, 2000.


AUTHORS

        Module Author:  Grant Hopwood mailto:hopwoodg@valero.com
        Library Author: S.R.Heller    mailto:srheller@oz.net


COPYRIGHT

You can do whatever you like with the Win32::SPGP.pm module.

SPGP.DLL copyright 2000 S.R.Heller. http://www.oz.net/~srheller/spgp/