$message = new PGP $pgppath;
Create the PGP encapsulation object. The standard location for the PGP executable is /usr/local/bin/pgp.
Execute the PGP command and attach the $in
, $out
, $err
file handles.
This should be fine for the moment, but need to look into making
sure that data is not written to a temporary file anywhere.
The $args variable can have several substituted strings:
The file handle variables--$in
, $out
and $err
--are send as
normal filehandle names, but they reside in the PGP package. For
example, the following procedure call is made:
Even though the file handles were specified as FIN
, FOUT
and
FERR
; they must be referred to as PGP::FIN
, PGP::FOUT
and
PGP::FERR
in the orignal procedure that made the call.
The Sign
procedure will take a file or data and sign with a PGP
secret key. The default behavior is to sign the data with the last
secret key added to the keyring, but that can be overridden with the
Key argument. This method always returns the signed document.
The %args
consist of a series of keys and values. Since there are
several variations in the way data can be signed, not all the
following options must be specified. This approach also makes it much
easier to scale to new versions of PGP with more options.
The only absolute argument that is always required is the Password
.
Examples
This would return a signed copy of the /etc/motd file. In this case, we use a file as the input, but the output is returned at the method's termination. The orignal file remains in the clear, and the signature is ASCII armored (Base64).
This is sort of the reverse of the first example. It takes what is in
the Text
field and signs it. It then puts the result in the file
signed.asc and returns it to the caller. In this case, the entire
message is ASCII armored including the orignal text (i.e. Text
).
We also specify another secret key to produce the signature. For more
information on the the key objects, please see ``PGP::Key'' section.
The Encrypt
method produces an encrypted document with the given
public keys specified by Key
. The Encrypt
method follow the
same conventions as the Sign
method. The data to be encrypted can
be sent to the method or can reside in a file. The resulting
encrypted data can also reside in a file or be sent back to the caller.
In addition to encrypting a document, the document can also be signed
by using the Sign
key in the %args
array. If the document is to
be signed by the default secret key (last key added to the secret
keyring), then Sign
can be left undefined or contain something
other than a reference to a key object. Otherwise the Sign
key
should contain a reference to a specific key object (see
``PGP::Key'').
Decrypt
will use a PGP secret key to decrypt a message. The secret
key must reside on the secret keyring. The Decrypt
method follows
the same conventions for data transfer that Sign
and Encrypt
follow. The resulting associative array that is sent back contains
three fields:
The following are the accepted arguments:
The Password
argument is required to perform the decryption of the
document. The Keyring
argument is also required if any document
information is to be returned.
Document_Info
returns an associative array or a reference to an
associative array to the caller. This returned structure contains
information about the document that is sent to the Document_Info
method. The returned structure is fairly straight forward:
The Document_Info
method currently accepts the following arguments:
Add a signature to the keyring. At this point, there is no error checking or verification that the key has been added.
Remove a signature from a keyring.
Extract a key from the specified keyring. A real simple dirty way of extracting the key.
Generate a new secret and public key set. This routine will not be present in the first rev of code. It is also subject to change.
Produce a revocation certificate for the given key. Revocation is
actually a two step process. We must first mark the key as revoked.
This is the same as the Remove_Key
method. After flaging the key,
the key must be extracted to produce a revocation certificate.
List the keys on a given keyring. This routine simply captures the output
of the command pgp -kc $keyring
and does a quick parse on it. It
takes the lines that it parses, and constructs
PGP::Key
objects.
In the near future, this function will also pass the trust factors to the
PGP::Key object. We got it in the output, so why not use it.
Function to locate a single key.
Future revisions will provide actual methods to do key comparison for the trust and validity factors. These methods will provide a standardized way to determine which keys can be trusted and which keys should not be used at all.
This is the constructor for the
PGP::Key
object. This is primarily
used by the
PGP::Keyring
methods. The
PGP::Keyring
methods keep
track of the keys and maintain the Trust and Validity components.
About the only useful method is the PGP::Key::Fingerprint
, which
will return a string that is the finger print of the given key.
The Add_ID
method will add identification information to the owner
and email portions of the given
PGP::Key
object. This is to support
keys that multiple identification packets associated with them.
What this means is that this program may be copied freely given that there is no payment in exchange for this program, and that all the source is left intact with all comments and documentation. If you wish to modify this program to correct bugs or to extend it's usefullness, please coordinate such actions with the author.