I had an issue with channels not decrypting for all messages. It took me a while to figure out that certain users/bots were using different channel names for the encrypted channel that we were using.
For example ...
The channel is registered as "#Test", so you "/join #Test" and you "/blowkey #Test myprivatekey". This works for most things, however, we had some bots who were set to send to "#TEST" and these messages were not being decrypted. I finally realized that I needed to "/blowkey #TEST myprivatekey" as well to get those to properly decrypt.
My suggestion would be to handle all hash keys in the %channels hash as lowercase hash-keys (not the encryption keys). The simple fix (theoretically) should be replacing all calls to the key hash from
to
I can't think of a reason where you'd need the channel/nick identifier to be case-sensitive, but it saves you from needing to have duplicate entries just to catch all the cases.
My other suggestion would be to not have the blowssi script handle the pasting decrypted messages directly to the window and directly sending the encrypted messages to the server. Instead, just catch the events and alter the contained message and forward it on, allowing Irssi to naturally handle the messages.
For example, if I want other scripts to be able to interact with the recieved/sent encrypted messages, your script in its current form would prevent that from happening, since you're using add_signal_first. If I wanted a script that prevented me from typing certain words into the irc window (like if I were to blacklist my passwords from accidentally being pasted into the input box), I'd need my checker script to process the input before the blowssi script would encrypt the input and forward it to the server.
Example:
sub handleMessagePublic {
my ($server, $msg, $nick, $address, $target) = @_;
$msg = decrypt_msg($target, $msg);
Irssi::signal_continue($server, $msg, $nick, $address, $target);
}
sub handleMessageOwnPublic {
my ($server, $msg, $target) = @_;
$msg = encrypt_msg($target, $msg);
Irssi::signal_continue($server, $msg, $target);
}
Irssi::signal_add_first('message public', \&handleMessagePublic);
Irssi::signal_add_last('message own_public', \&handleMessageOwnPublic);
(Obviously your Blowssi script is set-up differently than how this example works, but I hope the gist is clear.)
If you considered this route, you'd want the incoming encrypted messages to be processed first, and the outgoing encrypted messages to be processed last.
Note: I don't use the keyx/dh1080 stuff, so I'm not sure if any of that would be affected by my suggestions, just thought this might be of some use to the cause. Nice useful script though, so thanks for the hard work you've put into it.
Also, I had an issue with handling keys that have the '%' sign in them. They don't output correctly and might need to be escaped. Not a big deal though.