The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::Eduard - GnuPG email sign/encrypt testing bot

SYNOPSIS

  use App::Eduard;
  my ($status, %params) = process_message '/path/to/message';
  if ($status eq 'signencrypt') {
    say 'This message is encrypted and signed with key ', $params{keyid}, ' from ', $params{email};
    say 'Its contents are: ', $params{plaintext};
  } elsif ($status eq 'encrypt') {
    say 'This message is encrypted but not signed';
    say 'Its contents are: ', $params{plaintext};
  } elsif ($status eq 'encrypt_error') {
    say 'This message is encrypted but I was unable to decrypt it. GnuPG output: ', $params{message};
  } elsif ($status eq 'sign') {
    say 'This message is signed with key ', $params{keyid}, ' from ', $params{email};
  } elsif ($status eq 'sign_error') {
    say 'This message is signed but I was unable to verify the signature. GnuPG output: ', $params{message};
  } elsif ($status eq 'plain') {
    say 'This message is neither signed nor encrypted';
  } elsif ($status eq 'error') {
    say 'There was an error processing the message: ', $params{message};
  }

DESCRIPTION

Eduard is Ceata's reimplementation of the Edward reply bot referenced in https://emailselfdefense.fsf.org/.

EXPORTS

None by default.

import_keys($entity, $gpg)

Scan a message for PGP public keys, and import them. $entity is a MIME::Entity to scan, $gpg is a Mail::GnuPG instance.

Returns a list of fingerprints of keys found.

process_message($message)

Analyze a message, looking for PGP signatures and encryption. $message can be:

A filehandle reference, e.g. \*STDIN.
A reference to a scalar which holds the message contents.
A scalar which represents a path to a message.
A MIME::Entity object created with decode_bodies(0)

The function returns a status followed by a hash. Possible results:

plain

The message is neither signed nor encrypted.

sign_error, message => $message

The message is signed but the signature could not be verified. GnuPG output is $message.

sign, keyid => $keyid, email => $email, message => $message

The message is signed with key $keyid from $email. GnuPG output is $message.

encrypt_error, message => $message

The message is encrypted and unable to be decrypted. GnuPG output is $message.

encrypt, plaintext => $plaintext, decrypted => $decrypted, message => $message

The message is encrypted and unsigned. $plaintext is the decrypted message as plain text, while $decrypted is a MIME::Entity representing the decrypted message. GnuPG output is $message.

signencrypt, plaintext => $plaintext, decrypted => $decrypted, keyid => $keyid, email => $email, message => $message

The message is encrypted and signed with key $keyid from $email. $plaintext is the decrypted message as plain text, while $decrypted is a MIME::Entity representing the decrypted message. GnuPG output is $message.

error, message => $message

There was an error while processing the message. The error can be found in $message.

ENVIRONMENT

This module is configured via the %ENV hash. See the eduard(1) manpage for more information.

SEE ALSO

eduard(1), http://ceata.org/proiecte/eduard

AUTHOR

Marius Gavrilescu, <marius@ceata.org>

COPYRIGHT AND LICENSE

Copyright (C) 2014 by Fundația Ceata

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.18.2 or, at your option, any later version of Perl 5 you may have available.