get in sync with fishlim upstream

This commit is contained in:
Berke Viktor 2011-11-25 10:24:33 +01:00
parent 3067b7b267
commit 81ed389e71
8 changed files with 72 additions and 30 deletions

View File

@ -4,17 +4,17 @@ OURCFLAGS = -Wall -Wextra -Wno-unused-parameter -std=c99 -pedantic `pkg-config -
OURLINKFLAGS = `pkg-config --libs glib-2.0 libcrypto` $(CFLAGS) $(LDFLAGS)
BASE_OBJECTS = irc.o fish.o keystore.o misc.o
PLUGIN_OBJECTS = $(BASE_OBJECTS) xchat_plugin.o
PLUGIN_OBJECTS = $(BASE_OBJECTS) plugin_xchat.o
TEST_OBJECTS = $(BASE_OBJECTS) test.o
all: fishlim.so test
fish.o: fish.h keystore.h misc.h
irc.o: irc.h
keystore.o: keystore.h irc.h fish.h misc.h
keystore.o: keystore.h irc.h fish.h misc.h plugin_xchat.h
misc.o: misc.h
test.o: fish.h
xchat_plugin.o: fish.h irc.h keystore.h
plugin_xchat.o: fish.h irc.h keystore.h plugin_xchat.h
.c.o:
$(CC) $(OURCFLAGS) -c $< -o $@

View File

@ -2,7 +2,7 @@
FiSHLiM
http://fishlim.slbdata.se/
http://fishlim.kodafritt.se/
FiSHLiM is an XChat plugin for FiSH IRC encryption. It's my attempt at making

View File

@ -58,14 +58,14 @@ static const signed char fish_unbase64[256] = {
char *fish_encrypt(const char *key, size_t keylen, const char *message) {
BF_KEY bfkey;
size_t messagelen;
size_t i;
int j;
char *encrypted;
char *end;
unsigned char bit;
unsigned char word;
unsigned char d;
size_t messagelen;
size_t i;
int j;
char *encrypted;
char *end;
unsigned char bit;
unsigned char word;
unsigned char d;
BF_set_key(&bfkey, keylen, (const unsigned char*)key);
messagelen = strlen(message);
@ -111,12 +111,12 @@ char *fish_encrypt(const char *key, size_t keylen, const char *message) {
char *fish_decrypt(const char *key, size_t keylen, const char *data) {
BF_KEY bfkey;
size_t i;
char *decrypted;
char *end;
unsigned char bit;
unsigned char word;
unsigned char d;
size_t i;
char *decrypted;
char *end;
unsigned char bit;
unsigned char word;
unsigned char d;
BF_set_key(&bfkey, keylen, (const unsigned char*)key);
decrypted = malloc(strlen(data)+1);

View File

@ -29,7 +29,7 @@
#include "fish.h"
#include "misc.h"
#include "keystore.h"
#include "xchat_plugin.h"
#include "plugin_xchat.h"
static char *keystore_password = NULL;

View File

@ -33,7 +33,7 @@
#include <stddef.h>
char *keystore_get_key(const char *nick);
int keystore_store_key(const char *nick, const char *key);
bool keystore_store_key(const char *nick, const char *key);
bool keystore_delete_nick(const char *nick);
void keystore_secure_free(void *ptr, size_t size);

View File

@ -27,7 +27,11 @@
#include <string.h>
// #pragma GCC visibility push(default)
#ifdef _MSC_VER
#include "xchat-plugin.h"
#else
#include <xchat/xchat-plugin.h>
#endif
#define XCHAT_MAX_WORDS 32
// #pragma GCC visibility pop
@ -40,7 +44,7 @@
static const char plugin_name[] = "FiSHLiM";
static const char plugin_desc[] = "Encryption plugin for the FiSH protocol. Less is More!";
static const char plugin_version[] = "0.0.13";
static const char plugin_version[] = "0.0.14";
static const char usage_setkey[] = "Usage: SETKEY [<nick or #channel>] <password>, sets the key for a channel or nick";
static const char usage_delkey[] = "Usage: DELKEY <nick or #channel>, deletes the key for a channel or nick";
@ -112,7 +116,7 @@ static int handle_incoming(char *word[], char *word_eol[], void *userdata) {
const char *recipient;
const char *encrypted;
const char *peice;
char *sender_nick;
char *sender_nick;
char *decrypted;
char *message;
size_t w;
@ -127,7 +131,6 @@ static int handle_incoming(char *word[], char *word_eol[], void *userdata) {
if (!strcmp(command, "332")) w++;
// Look for encrypted data
ew;
for (ew = w+1; ew < XCHAT_MAX_WORDS-1; ew++) {
const char *s = (ew == w+1 ? word[ew]+1 : word[ew]);
if (strcmp(s, "+OK") == 0) goto has_encrypted_data;
@ -242,7 +245,7 @@ static int handle_delkey(char *word[], char *word_eol[], void *userdata) {
* Returns the plugin name version information.
*/
void xchat_plugin_get_info(const char **name, const char **desc,
const char **version, void **reserved) {
const char **version, void **reserved) {
*name = plugin_name;
*desc = plugin_desc;
*version = plugin_version;
@ -252,10 +255,10 @@ void xchat_plugin_get_info(const char **name, const char **desc,
* Plugin entry point.
*/
int xchat_plugin_init(xchat_plugin *plugin_handle,
const char **name,
const char **desc,
const char **version,
char *arg) {
const char **name,
const char **desc,
const char **version,
char *arg) {
ph = plugin_handle;
/* Send our info to XChat */
@ -275,12 +278,13 @@ int xchat_plugin_init(xchat_plugin *plugin_handle,
xchat_hook_server(ph, "TOPIC", XCHAT_PRI_NORM, handle_incoming, NULL);
xchat_hook_server(ph, "332", XCHAT_PRI_NORM, handle_incoming, NULL);
xchat_printf (ph, "%s plugin loaded\n", plugin_name);
xchat_printf(ph, "%s plugin loaded\n", plugin_name);
/* Return success */
return 1;
}
int xchat_plugin_deinit(void) {
xchat_printf (ph, "%s plugin unloaded\n", plugin_name);
xchat_printf(ph, "%s plugin unloaded\n", plugin_name);
return 1;
}

View File

@ -1 +1,31 @@
/*
Copyright (c) 2010 Samuel Lidén Borell <samuel@slbdata.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef XCHAT_PLUGIN_H
#define XCHAT_PLUGIN_H
gchar *get_config_filename();
#endif

View File

@ -22,10 +22,18 @@
*/
#include <glib.h>
#include <stdio.h>
#include <string.h>
#include "fish.h"
// We can't use the XChat plugin API from here...
gchar *get_config_filename() {
const gchar *homedir = g_get_home_dir();
return g_build_filename(homedir, ".xchat2", "blow.ini", NULL);
}
static int decrypt(int nick_count, char *nicks[]) {
char encrypted[8192];
while (fgets(encrypted, sizeof(encrypted), stdin)) {