Protocol::OTR - Off-the-Record secure messaging protocol
version 0.05
use Protocol::OTR qw( :constants ); my $otr = Protocol::OTR->new( { privkeys_file => "otr.private_key", contacts_file => "otr.fingerprints", instance_tags_file => "otr.instance_tags", } ); # find or create account my $alice = $otr->account('alice@domain', 'prpl-jabber'); # find or create contact known by $alice my $bob = $alice->contact('bob@domain'); # create secure channel to Bob my $channel = $bob->channel( { policy => ..., max_message_size => ..., on_write => sub { ... }, on_read => sub { ... }, on_gone_secure => sub { ... }, on_gone_insecure => sub { ... }, on_still_secure => sub { ... }, on_unverified_fingerprint => sub { ... }, on_symkey => sub { ... }, on_timer => sub { ... }, on_smp => sub { ... }, on_error => sub { ... }, on_event => sub { ... }, on_smp_event => sub { ... }, on_before_encrypt => sub { ... }, on_after_decrypt => sub { ... }, on_is_contact_logged_in => sub { ... }, } ); # establish private chat $channel->init(); # encrypt message $channel->write("Hi Bob!"); # finish all sessions $channel->finish();
Protocol::OTR provides bindings to Off-the-Record C library allowing to manage OTR setup and to communicate in secure way.
my $otr = Protocol::OTR->new( { privkeys_file => "otr.private_key", contacts_file => "otr.fingerprints", instance_tags_file => "otr.instance_tags", } );
Returns an context object using optionally specified files. If files do not exist, they will be created when needed.
The example above shows the default filenames used.
my $account = $otr->find_account( $name, $protocol );
Returns an account object Protocol::OTR::Account if exists, otherwise undef.
undef
my $account = $otr->account( $name, $protocol );
Returns an existing matching account object Protocol::OTR::Account or creates new one.
Note: Generating new private key may take some time.
my @accounts = $otr->accounts();
Returns a list of known account objects Protocol::OTR::Account.
BEGIN { $ENV{PROTOCOL_OTR_ENABLE_QUICK_RANDOM} = 1; } use Protocol::OTR;
If exists in environment it will use much faster /dev/urandom, rather then more secure, but slow /dev/random.
/dev/urandom
/dev/random
Constants are grouped in four groups, to import them all use :constants.
:constants
See "policy" in Protocol::OTR::Channel for usage details.
Start OTR conversation whenever it detects that the correspondent supports it. Default.
Requires encrypted conversation.
See "on_error" in Protocol::OTR::Channel for usage details.
Error occured while encrypting a message.
Sent encrypted message to somebody who is not in a mutual OTR session.
Sent an unreadable encrypted message
Message sent is malformed.
See "on_event" in Protocol::OTR::Channel for usage details.
Our policy requires encryption but we are trying to send an unencrypted message out.
An error occured while encrypting a message and the message was not sent.
Message has not been sent because our buddy has ended the private conversation. We should either close the connection, or refresh it.
A private conversation could not be set up. Error message will be passed.
Received our own OTR messages.
The previous message was resent.
Received an encrypted message but cannot read it because no private connection is established yet.
Cannot read the received message.
The message received contains malformed data.
Received a heartbeat.
Sent a heartbeat.
Received a general OTR error. Error message will be passed.
Received an unencrypted message. The unencrypted message will be passed.
Cannot recognize the type of OTR message received.
Received and discarded a message intended for another instance.
See "on_smp_event" in Protocol::OTR::Channel for usage details.
The current verification has been aborted, use progress percent to update auth progress dialog.
Update the auth progress dialog with progress percent
Same as "SMPEVENT_CHEATED".
See "select_session" in Protocol::OTR::Channel for usage details.
Session that has the best conversation status, then fingerprint status (in the event of a tie), then most recent (similarly in the event of a tie). When calculating how recent an instance has been active, INSTAG_BEST is limited by a one second resolution.
INSTAG_BEST
The most recent session (either by message sent or received).
The session with the most recent message received.
The session with the most recent message sent.
https://otr.cypherpunks.ca/
Protocol::OTR::Account
Protocol::OTR::Contact
Protocol::OTR::Fingerprint
Protocol::OTR::Channel
Alex J. G. Burzyński <ajgb@cpan.org>
This software is copyright (c) 2014 by Alex J. G. Burzyński <ajgb@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Protocol::OTR, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Protocol::OTR
CPAN shell
perl -MCPAN -e shell install Protocol::OTR
For more information on module installation, please visit the detailed CPAN module installation guide.