1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
/*
* Off-the-Record Messaging (OTR) modules for IRC
*
* Copyright (C) 2008 - Uli Meis <a.sporto+bee@gmail.com>
* 2012 - David Goulet <dgoulet@ev0ke.net>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301,USA
*/
#ifndef IRSSI_OTR_OTR_H
#define IRSSI_OTR_OTR_H
/* Libotr */
#include <libotr/proto.h>
#include <libotr/message.h>
#include <libotr/context.h>
#include <libotr/privkey.h>
#include "common.h"
#include "servers.h"
/* irssi module name */
#define MODULE_NAME "otr/core"
/*
* XXX: Maybe this should be configurable?
*/
#define OTR_MAX_MSG_SIZE 400
/* OTR protocol id */
#define OTR_PROTOCOL_ID "IRC"
#define OTR_DIR "otr"
#define OTR_KEYFILE OTR_DIR "/otr.key"
#define OTR_FINGERPRINTS_FILE OTR_DIR "/otr.fp"
#define OTR_INSTAG_FILE OTR_DIR "/otr.instag"
/*
* Specified in OTR protocol version 3. See:
* http://www.cypherpunks.ca/otr/Protocol-v3-4.0.0.html
*/
#define OTR_MSG_BEGIN_TAG "?OTR:"
#define OTR_MSG_END_TAG '.'
/* IRC /me command marker and len. */
#define OTR_IRC_MARKER_ME "/me "
#define OTR_IRC_MARKER_ME_LEN sizeof(OTR_IRC_MARKER_ME) - 1
/* Irssi otr user state */
struct otr_user_state {
OtrlUserState otr_state;
};
/*
* Peer OTR internal context.
*/
struct otr_peer_context {
/* The SMP event status. Used for the Irssi status bar. */
OtrlSMPEvent smp_event;
/* Did the SMP secret was asked so are we in a responder state? */
unsigned int ask_secret;
/*
* The fingerprint of the private message OTR session. This is useful for
* the forget command for which we can recover the fingerprint
* automatically.
*/
Fingerprint *active_fingerprint;
/*
* If needed, used to reconstruct the full message from fragmentation.
* Bitlbee for instance does that where we receive a *long* OTR message
* split in multiple PRIVMSG so we need to reconstruct it.
*/
char *full_msg;
/* Size of full_msg. Note this is the allocated memory size. */
size_t msg_size;
/* Len of the actual string in full_msg NOT counting the NULL byte. */
size_t msg_len;
};
/* given to otr_status_change */
enum otr_status_event {
OTR_STATUS_FINISHED,
OTR_STATUS_TRUST_MANUAL,
OTR_STATUS_TRUST_SMP,
OTR_STATUS_SMP_ABORT,
OTR_STATUS_SMP_STARTED,
OTR_STATUS_SMP_RESPONDED,
OTR_STATUS_SMP_INCOMING,
OTR_STATUS_SMP_FINALIZE,
OTR_STATUS_SMP_ABORTED,
OTR_STATUS_PEER_FINISHED,
OTR_STATUS_SMP_FAILED,
OTR_STATUS_SMP_SUCCESS,
OTR_STATUS_GONE_SECURE,
OTR_STATUS_GONE_INSECURE,
OTR_STATUS_CTX_UPDATE
};
enum otr_msg_status {
OTR_MSG_ORIGINAL = 1,
OTR_MSG_WAIT_MORE = 2,
OTR_MSG_USE_QUEUE = 3,
OTR_MSG_ERROR = 4,
};
/* there can be only one */
extern struct otr_user_state *user_state_global;
/* Libotr ops functions */
extern OtrlMessageAppOps otr_ops;
int otr_debug_get(void);
void otr_debug_toggle(void);
void otr_send_message(SERVER_REC *irssi, const char *recipient,
const char *message);
void otr_status_change(SERVER_REC *irssi, const char *nick,
enum otr_status_event event);
/* init stuff */
struct otr_user_state *otr_init_user_state(void);
void otr_free_user_state(struct otr_user_state *ustate);
void otr_lib_init();
void otr_lib_uninit();
void otr_control_timer(unsigned int interval, void *opdata);
/* Message transport. */
int otr_send(SERVER_REC *irssi, const char *msg, const char *to,
char **otr_msg);
int otr_receive(SERVER_REC *irssi, const char *msg,
const char *from, char **new_msg);
/* User interaction */
void otr_finish(SERVER_REC *irssi, const char *nick);
void otr_auth(SERVER_REC *irssi, const char *nick, const char *question,
const char *secret);
void otr_auth_abort(SERVER_REC *irssi, const char *nick);
void otr_contexts(struct otr_user_state *ustate);
void otr_finishall(struct otr_user_state *ustate);
void otr_forget(SERVER_REC *irssi, const char *nick, char *str_fp,
struct otr_user_state *ustate);
void otr_distrust(SERVER_REC *irssi, const char *nick, char *str_fp,
struct otr_user_state *ustate);
void otr_trust(SERVER_REC *irssi, const char *nick, char *str_fp,
struct otr_user_state *ustate);
enum otr_status_format otr_get_status_format(SERVER_REC *irssi,
const char *nick);
struct otr_peer_context *otr_create_peer_context(void);
ConnContext *otr_find_context(SERVER_REC *irssi, const char *nick, int create);
Fingerprint *otr_find_hash_fingerprint_from_human(const char *human_fp,
struct otr_user_state *ustate);
#endif /* IRSSI_OTR_OTR_H */
|