-
Notifications
You must be signed in to change notification settings - Fork 5
/
long_term_keys.c
91 lines (76 loc) · 3.14 KB
/
long_term_keys.c
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
/*
* Off-the-Record Messaging plugin for pidgin
* Copyright (C) 2004-2018 Ian Goldberg, Rob Smits,
* Chris Alexander, Willy Lew,
* Nikita Borisov
* The pidgin-otrng contributors
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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
*/
#include <account.h>
#include "long_term_keys.h"
#include <libotr-ng/client.h>
#include <libotr-ng/messaging.h>
#include "gtk-dialog.h"
#include "persistance.h"
#include "pidgin-helpers.h"
#include "ui.h"
extern otrng_global_state_s *otrng_state;
/* Generate a private key for the given accountname/protocol */
void long_term_keys_create_privkey_v4(otrng_client_s *client) {
PurpleAccount *account = client_id_to_purple_account(client->client_id);
if (otrng_succeeded(otrng_global_state_generate_private_key(
otrng_state, purple_account_to_client_id(account)))) {
otrng_ui_update_fingerprint();
}
}
static void load_private_key_v4(otrng_client_s *client) {
persistance_read_private_keys_v4(otrng_state);
}
static void store_private_key_v4(otrng_client_s *client) {
persistance_write_privkey_v4_FILEp(otrng_state);
}
static void create_forging_key(otrng_client_s *client) {
otrng_global_state_generate_forging_key(otrng_state, client->client_id);
}
static void load_forging_key(struct otrng_client_s *client) {
persistance_read_forging_key(otrng_state);
}
static void store_forging_key(struct otrng_client_s *client) {
persistance_write_forging_key(otrng_state);
}
void long_term_keys_create_private_key_v3(otrng_client_s *client) {
if (otrng_succeeded(otrng_global_state_generate_private_key_v3(
otrng_state, client->client_id))) {
otrng_ui_update_fingerprint();
}
}
static void load_private_key_v3(otrng_client_s *client) {
persistance_read_private_keys_v3(otrng_state);
}
static void store_private_key_v3(otrng_client_s *client) {
persistance_write_private_keys_v3(otrng_state);
}
void long_term_keys_set_callbacks(otrng_client_callbacks_s *callbacks) {
callbacks->create_privkey_v4 = long_term_keys_create_privkey_v4;
callbacks->load_privkey_v4 = load_private_key_v4;
callbacks->store_privkey_v4 = store_private_key_v4;
callbacks->create_forging_key = create_forging_key;
callbacks->load_forging_key = load_forging_key;
callbacks->store_forging_key = store_forging_key;
callbacks->create_privkey_v3 = long_term_keys_create_private_key_v3;
callbacks->store_privkey_v3 = store_private_key_v3;
callbacks->load_privkey_v3 = load_private_key_v3;
}