Sun, 05 May 2013 13:15:07 +0200
ciphers cleanup: passing keys with length by default
| 10684 | 1 | /* |
| 15884 | 2 | * purple |
| 10684 | 3 | * |
| 15884 | 4 | * Purple is the legal property of its developers, whose names are too numerous |
| 10684 | 5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 6 | * source distribution. | |
| 7 | * | |
|
11335
8e8d266179bb
[gaim-migrate @ 13548]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11333
diff
changeset
|
8 | * Original des taken from gpg |
|
8e8d266179bb
[gaim-migrate @ 13548]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11333
diff
changeset
|
9 | * |
|
8e8d266179bb
[gaim-migrate @ 13548]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11333
diff
changeset
|
10 | * des.c - DES and Triple-DES encryption/decryption Algorithm |
|
8e8d266179bb
[gaim-migrate @ 13548]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11333
diff
changeset
|
11 | * Copyright (C) 1998 Free Software Foundation, Inc. |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13760
diff
changeset
|
12 | * |
|
11335
8e8d266179bb
[gaim-migrate @ 13548]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11333
diff
changeset
|
13 | * Please see below for more legal information! |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13760
diff
changeset
|
14 | * |
|
11335
8e8d266179bb
[gaim-migrate @ 13548]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11333
diff
changeset
|
15 | * According to the definition of DES in FIPS PUB 46-2 from December 1993. |
|
8e8d266179bb
[gaim-migrate @ 13548]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11333
diff
changeset
|
16 | * For a description of triple encryption, see: |
|
8e8d266179bb
[gaim-migrate @ 13548]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11333
diff
changeset
|
17 | * Bruce Schneier: Applied Cryptography. Second Edition. |
|
8e8d266179bb
[gaim-migrate @ 13548]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11333
diff
changeset
|
18 | * John Wiley & Sons, 1996. ISBN 0-471-12845-7. Pages 358 ff. |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13760
diff
changeset
|
19 | * |
|
11335
8e8d266179bb
[gaim-migrate @ 13548]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11333
diff
changeset
|
20 | * This file is part of GnuPG. |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13760
diff
changeset
|
21 | * |
| 10684 | 22 | * This program is free software; you can redistribute it and/or modify |
| 23 | * it under the terms of the GNU General Public License as published by | |
| 24 | * the Free Software Foundation; either version 2 of the License, or | |
| 25 | * (at your option) any later version. | |
| 26 | * | |
| 27 | * This program is distributed in the hope that it will be useful, | |
| 28 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 29 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 30 | * GNU General Public License for more details. | |
| 31 | * | |
| 32 | * You should have received a copy of the GNU General Public License | |
| 33 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19832
diff
changeset
|
34 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 10684 | 35 | */ |
| 36 | #include "internal.h" | |
| 37 | #include "cipher.h" | |
|
33881
9b112a06cbdc
Fix warnings for ciphers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
31431
diff
changeset
|
38 | #include "ciphers/ciphers.h" |
|
13760
09669e542e2f
[gaim-migrate @ 16169]
Mark Doliner <markdoliner@pidgin.im>
parents:
13699
diff
changeset
|
39 | #include "dbus-maybe.h" |
| 10684 | 40 | #include "debug.h" |
| 41 | #include "signals.h" | |
| 42 | #include "value.h" | |
| 43 | ||
|
11329
5ca3cf4e502e
[gaim-migrate @ 13541]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11183
diff
changeset
|
44 | /******************************************************************************* |
| 10684 | 45 | * Structs |
| 46 | ******************************************************************************/ | |
| 15884 | 47 | struct _PurpleCipher { |
|
17435
a42f7e095cfd
- Add documentation for the internal CipherContext struct
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17155
diff
changeset
|
48 | gchar *name; /**< Internal name - used for searching */ |
|
a42f7e095cfd
- Add documentation for the internal CipherContext struct
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17155
diff
changeset
|
49 | PurpleCipherOps *ops; /**< Operations supported by this cipher */ |
|
a42f7e095cfd
- Add documentation for the internal CipherContext struct
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17155
diff
changeset
|
50 | guint ref; /**< Reference count */ |
| 10684 | 51 | }; |
| 52 | ||
| 15884 | 53 | struct _PurpleCipherContext { |
|
17435
a42f7e095cfd
- Add documentation for the internal CipherContext struct
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17155
diff
changeset
|
54 | PurpleCipher *cipher; /**< Cipher this context is under */ |
|
a42f7e095cfd
- Add documentation for the internal CipherContext struct
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17155
diff
changeset
|
55 | gpointer data; /**< Internal cipher state data */ |
| 10684 | 56 | }; |
| 57 | ||
| 58 | /****************************************************************************** | |
| 59 | * Globals | |
| 60 | *****************************************************************************/ | |
| 61 | static GList *ciphers = NULL; | |
| 62 | ||
| 63 | /****************************************************************************** | |
| 15884 | 64 | * PurpleCipher API |
| 10684 | 65 | *****************************************************************************/ |
| 66 | const gchar * | |
| 15884 | 67 | purple_cipher_get_name(PurpleCipher *cipher) { |
| 10684 | 68 | g_return_val_if_fail(cipher, NULL); |
| 69 | ||
| 70 | return cipher->name; | |
| 71 | } | |
| 72 | ||
| 73 | guint | |
| 15884 | 74 | purple_cipher_get_capabilities(PurpleCipher *cipher) { |
| 75 | PurpleCipherOps *ops = NULL; | |
| 10684 | 76 | guint caps = 0; |
| 77 | ||
| 78 | g_return_val_if_fail(cipher, 0); | |
| 79 | ||
| 80 | ops = cipher->ops; | |
| 81 | g_return_val_if_fail(ops, 0); | |
| 82 | ||
| 83 | if(ops->set_option) | |
| 15884 | 84 | caps |= PURPLE_CIPHER_CAPS_SET_OPT; |
| 10684 | 85 | if(ops->get_option) |
| 15884 | 86 | caps |= PURPLE_CIPHER_CAPS_GET_OPT; |
| 10684 | 87 | if(ops->init) |
| 15884 | 88 | caps |= PURPLE_CIPHER_CAPS_INIT; |
| 10684 | 89 | if(ops->reset) |
| 15884 | 90 | caps |= PURPLE_CIPHER_CAPS_RESET; |
| 10684 | 91 | if(ops->uninit) |
| 15884 | 92 | caps |= PURPLE_CIPHER_CAPS_UNINIT; |
| 10684 | 93 | if(ops->set_iv) |
| 15884 | 94 | caps |= PURPLE_CIPHER_CAPS_SET_IV; |
| 10684 | 95 | if(ops->append) |
| 15884 | 96 | caps |= PURPLE_CIPHER_CAPS_APPEND; |
| 10684 | 97 | if(ops->digest) |
| 15884 | 98 | caps |= PURPLE_CIPHER_CAPS_DIGEST; |
| 10684 | 99 | if(ops->encrypt) |
| 15884 | 100 | caps |= PURPLE_CIPHER_CAPS_ENCRYPT; |
| 10684 | 101 | if(ops->decrypt) |
| 15884 | 102 | caps |= PURPLE_CIPHER_CAPS_DECRYPT; |
| 10684 | 103 | if(ops->set_salt) |
| 15884 | 104 | caps |= PURPLE_CIPHER_CAPS_SET_SALT; |
| 10684 | 105 | if(ops->get_salt_size) |
| 15884 | 106 | caps |= PURPLE_CIPHER_CAPS_GET_SALT_SIZE; |
| 10684 | 107 | if(ops->set_key) |
| 15884 | 108 | caps |= PURPLE_CIPHER_CAPS_SET_KEY; |
|
22024
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
109 | if(ops->set_batch_mode) |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
110 | caps |= PURPLE_CIPHER_CAPS_SET_BATCH_MODE; |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
111 | if(ops->get_batch_mode) |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
112 | caps |= PURPLE_CIPHER_CAPS_GET_BATCH_MODE; |
|
22025
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
113 | if(ops->get_block_size) |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
114 | caps |= PURPLE_CIPHER_CAPS_GET_BLOCK_SIZE; |
| 10684 | 115 | |
| 116 | return caps; | |
| 117 | } | |
| 118 | ||
| 10687 | 119 | gboolean |
| 15884 | 120 | purple_cipher_digest_region(const gchar *name, const guchar *data, |
| 10687 | 121 | size_t data_len, size_t in_len, |
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11143
diff
changeset
|
122 | guchar digest[], size_t *out_len) |
| 10684 | 123 | { |
| 15884 | 124 | PurpleCipher *cipher; |
| 125 | PurpleCipherContext *context; | |
| 10687 | 126 | gboolean ret = FALSE; |
| 10684 | 127 | |
| 10687 | 128 | g_return_val_if_fail(name, FALSE); |
| 129 | g_return_val_if_fail(data, FALSE); | |
| 10684 | 130 | |
| 15884 | 131 | cipher = purple_ciphers_find_cipher(name); |
| 10684 | 132 | |
| 10687 | 133 | g_return_val_if_fail(cipher, FALSE); |
| 10684 | 134 | |
| 135 | if(!cipher->ops->append || !cipher->ops->digest) { | |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
27383
diff
changeset
|
136 | purple_debug_warning("cipher", "purple_cipher_region failed: " |
| 10684 | 137 | "the %s cipher does not support appending and or " |
| 138 | "digesting.", cipher->name); | |
| 10687 | 139 | return FALSE; |
| 10684 | 140 | } |
| 141 | ||
| 15884 | 142 | context = purple_cipher_context_new(cipher, NULL); |
| 143 | purple_cipher_context_append(context, data, data_len); | |
| 144 | ret = purple_cipher_context_digest(context, in_len, digest, out_len); | |
| 145 | purple_cipher_context_destroy(context); | |
| 10687 | 146 | |
| 147 | return ret; | |
| 10684 | 148 | } |
| 149 | ||
| 150 | /****************************************************************************** | |
| 15884 | 151 | * PurpleCiphers API |
| 10684 | 152 | *****************************************************************************/ |
| 15884 | 153 | PurpleCipher * |
| 154 | purple_ciphers_find_cipher(const gchar *name) { | |
| 155 | PurpleCipher *cipher; | |
| 10684 | 156 | GList *l; |
| 157 | ||
| 158 | g_return_val_if_fail(name, NULL); | |
| 159 | ||
| 160 | for(l = ciphers; l; l = l->next) { | |
| 15884 | 161 | cipher = PURPLE_CIPHER(l->data); |
| 10684 | 162 | |
| 163 | if(!g_ascii_strcasecmp(cipher->name, name)) | |
| 164 | return cipher; | |
| 165 | } | |
| 166 | ||
| 167 | return NULL; | |
| 168 | } | |
| 169 | ||
| 15884 | 170 | PurpleCipher * |
| 171 | purple_ciphers_register_cipher(const gchar *name, PurpleCipherOps *ops) { | |
| 172 | PurpleCipher *cipher = NULL; | |
| 10684 | 173 | |
| 174 | g_return_val_if_fail(name, NULL); | |
| 175 | g_return_val_if_fail(ops, NULL); | |
| 15884 | 176 | g_return_val_if_fail(!purple_ciphers_find_cipher(name), NULL); |
| 10684 | 177 | |
| 15884 | 178 | cipher = g_new0(PurpleCipher, 1); |
| 179 | PURPLE_DBUS_REGISTER_POINTER(cipher, PurpleCipher); | |
| 10684 | 180 | |
| 181 | cipher->name = g_strdup(name); | |
| 182 | cipher->ops = ops; | |
| 183 | ||
| 184 | ciphers = g_list_append(ciphers, cipher); | |
| 185 | ||
| 15884 | 186 | purple_signal_emit(purple_ciphers_get_handle(), "cipher-added", cipher); |
| 10684 | 187 | |
| 188 | return cipher; | |
| 189 | } | |
| 190 | ||
| 191 | gboolean | |
| 15884 | 192 | purple_ciphers_unregister_cipher(PurpleCipher *cipher) { |
| 10684 | 193 | g_return_val_if_fail(cipher, FALSE); |
| 194 | g_return_val_if_fail(cipher->ref == 0, FALSE); | |
| 195 | ||
| 15884 | 196 | purple_signal_emit(purple_ciphers_get_handle(), "cipher-removed", cipher); |
| 10684 | 197 | |
| 198 | ciphers = g_list_remove(ciphers, cipher); | |
| 199 | ||
| 200 | g_free(cipher->name); | |
|
13760
09669e542e2f
[gaim-migrate @ 16169]
Mark Doliner <markdoliner@pidgin.im>
parents:
13699
diff
changeset
|
201 | |
| 15884 | 202 | PURPLE_DBUS_UNREGISTER_POINTER(cipher); |
| 10684 | 203 | g_free(cipher); |
| 204 | ||
| 205 | return TRUE; | |
| 206 | } | |
| 207 | ||
| 208 | GList * | |
| 15884 | 209 | purple_ciphers_get_ciphers() { |
| 10684 | 210 | return ciphers; |
| 211 | } | |
| 212 | ||
| 213 | /****************************************************************************** | |
| 15884 | 214 | * PurpleCipher Subsystem API |
| 10684 | 215 | *****************************************************************************/ |
| 216 | gpointer | |
| 15884 | 217 | purple_ciphers_get_handle() { |
| 10684 | 218 | static gint handle; |
| 219 | ||
| 220 | return &handle; | |
| 221 | } | |
| 222 | ||
| 223 | void | |
| 15884 | 224 | purple_ciphers_init() { |
| 10684 | 225 | gpointer handle; |
| 226 | ||
| 15884 | 227 | handle = purple_ciphers_get_handle(); |
| 10684 | 228 | |
| 15884 | 229 | purple_signal_register(handle, "cipher-added", |
| 230 | purple_marshal_VOID__POINTER, NULL, 1, | |
| 231 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 232 | PURPLE_SUBTYPE_CIPHER)); | |
| 233 | purple_signal_register(handle, "cipher-removed", | |
| 234 | purple_marshal_VOID__POINTER, NULL, 1, | |
| 235 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 236 | PURPLE_SUBTYPE_CIPHER)); | |
| 10684 | 237 | |
|
31421
713fb035d563
Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
31407
diff
changeset
|
238 | purple_ciphers_register_cipher("md5", purple_md5_cipher_get_ops()); |
| 31424 | 239 | purple_ciphers_register_cipher("sha1", purple_sha1_cipher_get_ops()); |
|
31426
290d182e7bf9
Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
31425
diff
changeset
|
240 | purple_ciphers_register_cipher("sha256", purple_sha256_cipher_get_ops()); |
|
31421
713fb035d563
Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
31407
diff
changeset
|
241 | purple_ciphers_register_cipher("md4", purple_md4_cipher_get_ops()); |
|
31423
8483c092dbc4
Broke out the hmac cipher to it's own file. Removed already transitioned info in the fileheader of cipher.c
Gary Kramlich <grim@reaperworld.com>
parents:
31421
diff
changeset
|
242 | purple_ciphers_register_cipher("hmac", purple_hmac_cipher_get_ops()); |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
31426
diff
changeset
|
243 | purple_ciphers_register_cipher("des", purple_des_cipher_get_ops()); |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
31426
diff
changeset
|
244 | purple_ciphers_register_cipher("des3", purple_des3_cipher_get_ops()); |
|
31425
e8113737ec1a
Moved rc4 to the ciphers sublibrary
Gary Kramlich <grim@reaperworld.com>
parents:
31424
diff
changeset
|
245 | purple_ciphers_register_cipher("rc4", purple_rc4_cipher_get_ops()); |
| 10684 | 246 | } |
| 247 | ||
| 248 | void | |
| 15884 | 249 | purple_ciphers_uninit() { |
| 250 | PurpleCipher *cipher; | |
| 10684 | 251 | GList *l, *ll; |
| 252 | ||
| 253 | for(l = ciphers; l; l = ll) { | |
| 254 | ll = l->next; | |
| 255 | ||
| 15884 | 256 | cipher = PURPLE_CIPHER(l->data); |
| 257 | purple_ciphers_unregister_cipher(cipher); | |
| 10684 | 258 | } |
| 259 | ||
| 260 | g_list_free(ciphers); | |
| 261 | ||
| 15884 | 262 | purple_signals_unregister_by_instance(purple_ciphers_get_handle()); |
| 10684 | 263 | } |
|
31426
290d182e7bf9
Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
31425
diff
changeset
|
264 | |
| 10684 | 265 | /****************************************************************************** |
| 15884 | 266 | * PurpleCipherContext API |
| 10684 | 267 | *****************************************************************************/ |
| 268 | void | |
| 15884 | 269 | purple_cipher_context_set_option(PurpleCipherContext *context, const gchar *name, |
| 10684 | 270 | gpointer value) |
| 271 | { | |
| 15884 | 272 | PurpleCipher *cipher = NULL; |
| 10684 | 273 | |
| 274 | g_return_if_fail(context); | |
| 275 | g_return_if_fail(name); | |
| 276 | ||
| 277 | cipher = context->cipher; | |
| 278 | g_return_if_fail(cipher); | |
| 279 | ||
| 280 | if(cipher->ops && cipher->ops->set_option) | |
| 281 | cipher->ops->set_option(context, name, value); | |
| 282 | else | |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
27383
diff
changeset
|
283 | purple_debug_warning("cipher", "the %s cipher does not support the " |
| 10684 | 284 | "set_option operation\n", cipher->name); |
| 285 | } | |
| 286 | ||
| 287 | gpointer | |
| 15884 | 288 | purple_cipher_context_get_option(PurpleCipherContext *context, const gchar *name) { |
| 289 | PurpleCipher *cipher = NULL; | |
| 10684 | 290 | |
| 291 | g_return_val_if_fail(context, NULL); | |
| 292 | g_return_val_if_fail(name, NULL); | |
| 293 | ||
| 294 | cipher = context->cipher; | |
| 295 | g_return_val_if_fail(cipher, NULL); | |
| 296 | ||
| 297 | if(cipher->ops && cipher->ops->get_option) | |
| 298 | return cipher->ops->get_option(context, name); | |
| 299 | else { | |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
27383
diff
changeset
|
300 | purple_debug_warning("cipher", "the %s cipher does not support the " |
| 10684 | 301 | "get_option operation\n", cipher->name); |
| 302 | ||
| 303 | return NULL; | |
| 304 | } | |
| 305 | } | |
| 306 | ||
| 15884 | 307 | PurpleCipherContext * |
| 308 | purple_cipher_context_new(PurpleCipher *cipher, void *extra) { | |
| 309 | PurpleCipherContext *context = NULL; | |
| 10684 | 310 | |
| 311 | g_return_val_if_fail(cipher, NULL); | |
| 312 | ||
| 313 | cipher->ref++; | |
| 314 | ||
| 15884 | 315 | context = g_new0(PurpleCipherContext, 1); |
| 10684 | 316 | context->cipher = cipher; |
| 317 | ||
| 318 | if(cipher->ops->init) | |
| 319 | cipher->ops->init(context, extra); | |
| 320 | ||
| 321 | return context; | |
| 322 | } | |
| 323 | ||
| 15884 | 324 | PurpleCipherContext * |
| 325 | purple_cipher_context_new_by_name(const gchar *name, void *extra) { | |
| 326 | PurpleCipher *cipher; | |
| 10684 | 327 | |
| 328 | g_return_val_if_fail(name, NULL); | |
| 329 | ||
| 15884 | 330 | cipher = purple_ciphers_find_cipher(name); |
| 10684 | 331 | |
| 332 | g_return_val_if_fail(cipher, NULL); | |
| 333 | ||
| 15884 | 334 | return purple_cipher_context_new(cipher, extra); |
| 10684 | 335 | } |
| 336 | ||
| 337 | void | |
| 15884 | 338 | purple_cipher_context_reset(PurpleCipherContext *context, void *extra) { |
| 339 | PurpleCipher *cipher = NULL; | |
| 10684 | 340 | |
| 341 | g_return_if_fail(context); | |
| 342 | ||
| 343 | cipher = context->cipher; | |
| 344 | g_return_if_fail(cipher); | |
| 345 | ||
| 346 | if(cipher->ops && cipher->ops->reset) | |
| 347 | context->cipher->ops->reset(context, extra); | |
| 348 | } | |
| 349 | ||
| 350 | void | |
| 15884 | 351 | purple_cipher_context_destroy(PurpleCipherContext *context) { |
| 352 | PurpleCipher *cipher = NULL; | |
| 10684 | 353 | |
| 354 | g_return_if_fail(context); | |
| 355 | ||
| 356 | cipher = context->cipher; | |
| 357 | g_return_if_fail(cipher); | |
| 358 | ||
| 359 | cipher->ref--; | |
| 360 | ||
| 361 | if(cipher->ops && cipher->ops->uninit) | |
| 362 | cipher->ops->uninit(context); | |
| 363 | ||
|
31407
8c850977cb42
Fix a potential information leak in cipher.c.
Julia Lawall <julia@diku.dk>
parents:
28762
diff
changeset
|
364 | memset(context, 0, sizeof(*context)); |
| 10684 | 365 | g_free(context); |
| 366 | context = NULL; | |
| 367 | } | |
| 368 | ||
| 369 | void | |
| 15884 | 370 | purple_cipher_context_set_iv(PurpleCipherContext *context, guchar *iv, size_t len) |
| 10684 | 371 | { |
| 15884 | 372 | PurpleCipher *cipher = NULL; |
| 10684 | 373 | |
| 374 | g_return_if_fail(context); | |
| 375 | g_return_if_fail(iv); | |
| 376 | ||
| 377 | cipher = context->cipher; | |
| 378 | g_return_if_fail(cipher); | |
| 379 | ||
| 380 | if(cipher->ops && cipher->ops->set_iv) | |
| 381 | cipher->ops->set_iv(context, iv, len); | |
| 382 | else | |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
27383
diff
changeset
|
383 | purple_debug_warning("cipher", "the %s cipher does not support the set" |
| 10684 | 384 | "initialization vector operation\n", cipher->name); |
| 385 | } | |
| 386 | ||
| 387 | void | |
| 15884 | 388 | purple_cipher_context_append(PurpleCipherContext *context, const guchar *data, |
| 10684 | 389 | size_t len) |
| 390 | { | |
| 15884 | 391 | PurpleCipher *cipher = NULL; |
| 10684 | 392 | |
| 393 | g_return_if_fail(context); | |
| 394 | ||
| 395 | cipher = context->cipher; | |
| 396 | g_return_if_fail(cipher); | |
| 397 | ||
| 398 | if(cipher->ops && cipher->ops->append) | |
| 399 | cipher->ops->append(context, data, len); | |
| 400 | else | |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
27383
diff
changeset
|
401 | purple_debug_warning("cipher", "the %s cipher does not support the append " |
| 10684 | 402 | "operation\n", cipher->name); |
| 403 | } | |
| 404 | ||
| 405 | gboolean | |
| 15884 | 406 | purple_cipher_context_digest(PurpleCipherContext *context, size_t in_len, |
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11143
diff
changeset
|
407 | guchar digest[], size_t *out_len) |
| 10684 | 408 | { |
| 15884 | 409 | PurpleCipher *cipher = NULL; |
| 10684 | 410 | |
| 411 | g_return_val_if_fail(context, FALSE); | |
| 412 | ||
| 413 | cipher = context->cipher; | |
| 414 | ||
| 415 | if(cipher->ops && cipher->ops->digest) | |
| 10687 | 416 | return cipher->ops->digest(context, in_len, digest, out_len); |
| 10684 | 417 | else { |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
27383
diff
changeset
|
418 | purple_debug_warning("cipher", "the %s cipher does not support the digest " |
| 10684 | 419 | "operation\n", cipher->name); |
| 420 | return FALSE; | |
| 421 | } | |
| 422 | } | |
| 423 | ||
| 424 | gboolean | |
| 15884 | 425 | purple_cipher_context_digest_to_str(PurpleCipherContext *context, size_t in_len, |
| 10687 | 426 | gchar digest_s[], size_t *out_len) |
| 10684 | 427 | { |
| 10687 | 428 | /* 8k is a bit excessive, will tweak later. */ |
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11143
diff
changeset
|
429 | guchar digest[BUF_LEN * 4]; |
| 10684 | 430 | gint n = 0; |
| 431 | size_t dlen = 0; | |
| 432 | ||
| 433 | g_return_val_if_fail(context, FALSE); | |
| 434 | g_return_val_if_fail(digest_s, FALSE); | |
| 435 | ||
| 15884 | 436 | if(!purple_cipher_context_digest(context, sizeof(digest), digest, &dlen)) |
| 10684 | 437 | return FALSE; |
| 438 | ||
|
12388
3a25d96abdaf
[gaim-migrate @ 14694]
Richard Laager <rlaager@pidgin.im>
parents:
12382
diff
changeset
|
439 | /* in_len must be greater than dlen * 2 so we have room for the NUL. */ |
|
3a25d96abdaf
[gaim-migrate @ 14694]
Richard Laager <rlaager@pidgin.im>
parents:
12382
diff
changeset
|
440 | if(in_len <= dlen * 2) |
| 10687 | 441 | return FALSE; |
| 10684 | 442 | |
| 443 | for(n = 0; n < dlen; n++) | |
| 444 | sprintf(digest_s + (n * 2), "%02x", digest[n]); | |
| 445 | ||
| 446 | digest_s[n * 2] = '\0'; | |
| 447 | ||
| 10687 | 448 | if(out_len) |
| 449 | *out_len = dlen * 2; | |
| 450 | ||
| 10684 | 451 | return TRUE; |
| 452 | } | |
| 453 | ||
| 454 | gint | |
| 15884 | 455 | purple_cipher_context_encrypt(PurpleCipherContext *context, const guchar data[], |
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11143
diff
changeset
|
456 | size_t len, guchar output[], size_t *outlen) |
| 10684 | 457 | { |
| 15884 | 458 | PurpleCipher *cipher = NULL; |
| 10684 | 459 | |
| 460 | g_return_val_if_fail(context, -1); | |
| 461 | ||
| 462 | cipher = context->cipher; | |
| 463 | g_return_val_if_fail(cipher, -1); | |
| 464 | ||
| 465 | if(cipher->ops && cipher->ops->encrypt) | |
| 466 | return cipher->ops->encrypt(context, data, len, output, outlen); | |
| 467 | else { | |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
27383
diff
changeset
|
468 | purple_debug_warning("cipher", "the %s cipher does not support the encrypt" |
| 10684 | 469 | "operation\n", cipher->name); |
| 470 | ||
| 471 | if(outlen) | |
| 472 | *outlen = -1; | |
| 473 | ||
| 474 | return -1; | |
| 475 | } | |
| 476 | } | |
| 477 | ||
| 478 | gint | |
| 15884 | 479 | purple_cipher_context_decrypt(PurpleCipherContext *context, const guchar data[], |
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11143
diff
changeset
|
480 | size_t len, guchar output[], size_t *outlen) |
| 10684 | 481 | { |
| 15884 | 482 | PurpleCipher *cipher = NULL; |
| 10684 | 483 | |
| 484 | g_return_val_if_fail(context, -1); | |
| 485 | ||
| 486 | cipher = context->cipher; | |
| 487 | g_return_val_if_fail(cipher, -1); | |
| 488 | ||
| 489 | if(cipher->ops && cipher->ops->decrypt) | |
| 490 | return cipher->ops->decrypt(context, data, len, output, outlen); | |
| 491 | else { | |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
27383
diff
changeset
|
492 | purple_debug_warning("cipher", "the %s cipher does not support the decrypt" |
| 10684 | 493 | "operation\n", cipher->name); |
| 494 | ||
| 495 | if(outlen) | |
| 496 | *outlen = -1; | |
| 497 | ||
| 498 | return -1; | |
| 499 | } | |
| 500 | } | |
| 501 | ||
| 502 | void | |
| 15884 | 503 | purple_cipher_context_set_salt(PurpleCipherContext *context, guchar *salt) { |
| 504 | PurpleCipher *cipher = NULL; | |
| 10684 | 505 | |
| 506 | g_return_if_fail(context); | |
| 507 | ||
| 508 | cipher = context->cipher; | |
| 509 | g_return_if_fail(cipher); | |
| 510 | ||
| 511 | if(cipher->ops && cipher->ops->set_salt) | |
| 512 | cipher->ops->set_salt(context, salt); | |
| 513 | else | |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
27383
diff
changeset
|
514 | purple_debug_warning("cipher", "the %s cipher does not support the " |
| 10684 | 515 | "set_salt operation\n", cipher->name); |
| 516 | } | |
| 517 | ||
| 518 | size_t | |
| 15884 | 519 | purple_cipher_context_get_salt_size(PurpleCipherContext *context) { |
| 520 | PurpleCipher *cipher = NULL; | |
| 10684 | 521 | |
| 522 | g_return_val_if_fail(context, -1); | |
| 523 | ||
| 524 | cipher = context->cipher; | |
| 525 | g_return_val_if_fail(cipher, -1); | |
| 526 | ||
| 527 | if(cipher->ops && cipher->ops->get_salt_size) | |
| 528 | return cipher->ops->get_salt_size(context); | |
| 529 | else { | |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
27383
diff
changeset
|
530 | purple_debug_warning("cipher", "the %s cipher does not support the " |
| 10684 | 531 | "get_salt_size operation\n", cipher->name); |
| 532 | ||
| 533 | return -1; | |
| 534 | } | |
| 535 | } | |
| 536 | ||
| 537 | void | |
|
33908
78b42fd69e02
ciphers cleanup: passing keys with length by default
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33881
diff
changeset
|
538 | purple_cipher_context_set_key(PurpleCipherContext *context, const guchar *key, size_t len) { |
| 15884 | 539 | PurpleCipher *cipher = NULL; |
| 10684 | 540 | |
| 541 | g_return_if_fail(context); | |
| 542 | ||
| 543 | cipher = context->cipher; | |
| 544 | g_return_if_fail(cipher); | |
| 545 | ||
| 546 | if(cipher->ops && cipher->ops->set_key) | |
|
33908
78b42fd69e02
ciphers cleanup: passing keys with length by default
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33881
diff
changeset
|
547 | cipher->ops->set_key(context, key, len); |
| 10684 | 548 | else |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
27383
diff
changeset
|
549 | purple_debug_warning("cipher", "the %s cipher does not support the " |
| 10684 | 550 | "set_key operation\n", cipher->name); |
| 551 | } | |
| 552 | ||
| 553 | void | |
|
22024
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
554 | purple_cipher_context_set_batch_mode(PurpleCipherContext *context, |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
555 | PurpleCipherBatchMode mode) |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
556 | { |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
557 | PurpleCipher *cipher = NULL; |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
558 | |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
559 | g_return_if_fail(context); |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
560 | |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
561 | cipher = context->cipher; |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
562 | g_return_if_fail(cipher); |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
563 | |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
564 | if(cipher->ops && cipher->ops->set_batch_mode) |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
565 | cipher->ops->set_batch_mode(context, mode); |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
566 | else |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
27383
diff
changeset
|
567 | purple_debug_warning("cipher", "The %s cipher does not support the " |
|
22024
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
568 | "set_batch_mode operation\n", cipher->name); |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
569 | } |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
570 | |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
571 | PurpleCipherBatchMode |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
572 | purple_cipher_context_get_batch_mode(PurpleCipherContext *context) |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
573 | { |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
574 | PurpleCipher *cipher = NULL; |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
575 | |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
576 | g_return_val_if_fail(context, -1); |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
577 | |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
578 | cipher = context->cipher; |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
579 | g_return_val_if_fail(cipher, -1); |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
580 | |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
581 | if(cipher->ops && cipher->ops->get_batch_mode) |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
582 | return cipher->ops->get_batch_mode(context); |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
583 | else { |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
27383
diff
changeset
|
584 | purple_debug_warning("cipher", "The %s cipher does not support the " |
|
22024
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
585 | "get_batch_mode operation\n", cipher->name); |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
586 | return -1; |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
587 | } |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
588 | } |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21091
diff
changeset
|
589 | |
|
22025
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
590 | size_t |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
591 | purple_cipher_context_get_block_size(PurpleCipherContext *context) |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
592 | { |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
593 | PurpleCipher *cipher = NULL; |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
594 | |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
595 | g_return_val_if_fail(context, -1); |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
596 | |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
597 | cipher = context->cipher; |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
598 | g_return_val_if_fail(cipher, -1); |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
599 | |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
600 | if(cipher->ops && cipher->ops->get_block_size) |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
601 | return cipher->ops->get_block_size(context); |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
602 | else { |
|
27497
2dc5a0e0c4c2
Increase the logging level of some debugging messages that seemed to be a
Mauro Brasil <mauro.brasil@tqi.com.br>
parents:
27383
diff
changeset
|
603 | purple_debug_warning("cipher", "The %s cipher does not support the " |
|
22025
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
604 | "get_block_size operation\n", cipher->name); |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
605 | return -1; |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
606 | } |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
607 | } |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
608 | |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
609 | void |
| 15884 | 610 | purple_cipher_context_set_data(PurpleCipherContext *context, gpointer data) { |
| 10684 | 611 | g_return_if_fail(context); |
| 612 | ||
| 613 | context->data = data; | |
| 614 | } | |
| 615 | ||
| 616 | gpointer | |
| 15884 | 617 | purple_cipher_context_get_data(PurpleCipherContext *context) { |
| 10684 | 618 | g_return_val_if_fail(context, NULL); |
| 619 | ||
| 620 | return context->data; | |
| 621 | } | |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
622 | |
| 15884 | 623 | gchar *purple_cipher_http_digest_calculate_session_key( |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
624 | const gchar *algorithm, |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
625 | const gchar *username, |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
626 | const gchar *realm, |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
627 | const gchar *password, |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
628 | const gchar *nonce, |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
629 | const gchar *client_nonce) |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
630 | { |
| 15884 | 631 | PurpleCipher *cipher; |
| 632 | PurpleCipherContext *context; | |
|
12388
3a25d96abdaf
[gaim-migrate @ 14694]
Richard Laager <rlaager@pidgin.im>
parents:
12382
diff
changeset
|
633 | gchar hash[33]; /* We only support MD5. */ |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
634 | |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
635 | g_return_val_if_fail(username != NULL, NULL); |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
636 | g_return_val_if_fail(realm != NULL, NULL); |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
637 | g_return_val_if_fail(password != NULL, NULL); |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
638 | g_return_val_if_fail(nonce != NULL, NULL); |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
639 | |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
640 | /* Check for a supported algorithm. */ |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
641 | g_return_val_if_fail(algorithm == NULL || |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
642 | *algorithm == '\0' || |
|
17155
143ff2796376
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@pidgin.im>
parents:
17065
diff
changeset
|
643 | g_ascii_strcasecmp(algorithm, "MD5") || |
|
143ff2796376
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@pidgin.im>
parents:
17065
diff
changeset
|
644 | g_ascii_strcasecmp(algorithm, "MD5-sess"), NULL); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
645 | |
| 15884 | 646 | cipher = purple_ciphers_find_cipher("md5"); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
647 | g_return_val_if_fail(cipher != NULL, NULL); |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
648 | |
| 15884 | 649 | context = purple_cipher_context_new(cipher, NULL); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
650 | |
| 15884 | 651 | purple_cipher_context_append(context, (guchar *)username, strlen(username)); |
| 652 | purple_cipher_context_append(context, (guchar *)":", 1); | |
| 653 | purple_cipher_context_append(context, (guchar *)realm, strlen(realm)); | |
| 654 | purple_cipher_context_append(context, (guchar *)":", 1); | |
| 655 | purple_cipher_context_append(context, (guchar *)password, strlen(password)); | |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
656 | |
|
17155
143ff2796376
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@pidgin.im>
parents:
17065
diff
changeset
|
657 | if (algorithm != NULL && !g_ascii_strcasecmp(algorithm, "MD5-sess")) |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
658 | { |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
659 | guchar digest[16]; |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
660 | |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
661 | if (client_nonce == NULL) |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
662 | { |
| 15884 | 663 | purple_cipher_context_destroy(context); |
|
19832
84b69b21672b
Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17435
diff
changeset
|
664 | purple_debug_error("cipher", "Required client_nonce missing for MD5-sess digest calculation.\n"); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
665 | return NULL; |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
666 | } |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
667 | |
| 15884 | 668 | purple_cipher_context_digest(context, sizeof(digest), digest, NULL); |
| 669 | purple_cipher_context_destroy(context); | |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
670 | |
| 15884 | 671 | context = purple_cipher_context_new(cipher, NULL); |
| 672 | purple_cipher_context_append(context, digest, sizeof(digest)); | |
| 673 | purple_cipher_context_append(context, (guchar *)":", 1); | |
| 674 | purple_cipher_context_append(context, (guchar *)nonce, strlen(nonce)); | |
| 675 | purple_cipher_context_append(context, (guchar *)":", 1); | |
| 676 | purple_cipher_context_append(context, (guchar *)client_nonce, strlen(client_nonce)); | |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
677 | } |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
678 | |
| 15884 | 679 | purple_cipher_context_digest_to_str(context, sizeof(hash), hash, NULL); |
| 680 | purple_cipher_context_destroy(context); | |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
681 | |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
682 | return g_strdup(hash); |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
683 | } |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
684 | |
| 15884 | 685 | gchar *purple_cipher_http_digest_calculate_response( |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
686 | const gchar *algorithm, |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
687 | const gchar *method, |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
688 | const gchar *digest_uri, |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
689 | const gchar *qop, |
|
12389
7196ba664097
[gaim-migrate @ 14695]
Richard Laager <rlaager@pidgin.im>
parents:
12388
diff
changeset
|
690 | const gchar *entity, |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
691 | const gchar *nonce, |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
692 | const gchar *nonce_count, |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
693 | const gchar *client_nonce, |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
694 | const gchar *session_key) |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
695 | { |
| 15884 | 696 | PurpleCipher *cipher; |
| 697 | PurpleCipherContext *context; | |
|
12388
3a25d96abdaf
[gaim-migrate @ 14694]
Richard Laager <rlaager@pidgin.im>
parents:
12382
diff
changeset
|
698 | static gchar hash2[33]; /* We only support MD5. */ |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
699 | |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
700 | g_return_val_if_fail(method != NULL, NULL); |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
701 | g_return_val_if_fail(digest_uri != NULL, NULL); |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
702 | g_return_val_if_fail(nonce != NULL, NULL); |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
703 | g_return_val_if_fail(session_key != NULL, NULL); |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
704 | |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
705 | /* Check for a supported algorithm. */ |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
706 | g_return_val_if_fail(algorithm == NULL || |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
707 | *algorithm == '\0' || |
|
17155
143ff2796376
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@pidgin.im>
parents:
17065
diff
changeset
|
708 | g_ascii_strcasecmp(algorithm, "MD5") || |
|
143ff2796376
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@pidgin.im>
parents:
17065
diff
changeset
|
709 | g_ascii_strcasecmp(algorithm, "MD5-sess"), NULL); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
710 | |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
711 | /* Check for a supported "quality of protection". */ |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
712 | g_return_val_if_fail(qop == NULL || |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
713 | *qop == '\0' || |
|
17155
143ff2796376
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@pidgin.im>
parents:
17065
diff
changeset
|
714 | g_ascii_strcasecmp(qop, "auth") || |
|
143ff2796376
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@pidgin.im>
parents:
17065
diff
changeset
|
715 | g_ascii_strcasecmp(qop, "auth-int"), NULL); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
716 | |
| 15884 | 717 | cipher = purple_ciphers_find_cipher("md5"); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
718 | g_return_val_if_fail(cipher != NULL, NULL); |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
719 | |
| 15884 | 720 | context = purple_cipher_context_new(cipher, NULL); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
721 | |
| 15884 | 722 | purple_cipher_context_append(context, (guchar *)method, strlen(method)); |
| 723 | purple_cipher_context_append(context, (guchar *)":", 1); | |
| 724 | purple_cipher_context_append(context, (guchar *)digest_uri, strlen(digest_uri)); | |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
725 | |
|
17155
143ff2796376
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@pidgin.im>
parents:
17065
diff
changeset
|
726 | if (qop != NULL && !g_ascii_strcasecmp(qop, "auth-int")) |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
727 | { |
| 15884 | 728 | PurpleCipherContext *context2; |
|
12389
7196ba664097
[gaim-migrate @ 14695]
Richard Laager <rlaager@pidgin.im>
parents:
12388
diff
changeset
|
729 | gchar entity_hash[33]; |
|
7196ba664097
[gaim-migrate @ 14695]
Richard Laager <rlaager@pidgin.im>
parents:
12388
diff
changeset
|
730 | |
|
7196ba664097
[gaim-migrate @ 14695]
Richard Laager <rlaager@pidgin.im>
parents:
12388
diff
changeset
|
731 | if (entity == NULL) |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
732 | { |
| 15884 | 733 | purple_cipher_context_destroy(context); |
|
19832
84b69b21672b
Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17435
diff
changeset
|
734 | purple_debug_error("cipher", "Required entity missing for auth-int digest calculation.\n"); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
735 | return NULL; |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
736 | } |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
737 | |
| 15884 | 738 | context2 = purple_cipher_context_new(cipher, NULL); |
| 739 | purple_cipher_context_append(context2, (guchar *)entity, strlen(entity)); | |
| 740 | purple_cipher_context_digest_to_str(context2, sizeof(entity_hash), entity_hash, NULL); | |
| 741 | purple_cipher_context_destroy(context2); | |
|
12389
7196ba664097
[gaim-migrate @ 14695]
Richard Laager <rlaager@pidgin.im>
parents:
12388
diff
changeset
|
742 | |
| 15884 | 743 | purple_cipher_context_append(context, (guchar *)":", 1); |
| 744 | purple_cipher_context_append(context, (guchar *)entity_hash, strlen(entity_hash)); | |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
745 | } |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
746 | |
| 15884 | 747 | purple_cipher_context_digest_to_str(context, sizeof(hash2), hash2, NULL); |
| 748 | purple_cipher_context_destroy(context); | |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
749 | |
| 15884 | 750 | context = purple_cipher_context_new(cipher, NULL); |
| 751 | purple_cipher_context_append(context, (guchar *)session_key, strlen(session_key)); | |
| 752 | purple_cipher_context_append(context, (guchar *)":", 1); | |
| 753 | purple_cipher_context_append(context, (guchar *)nonce, strlen(nonce)); | |
| 754 | purple_cipher_context_append(context, (guchar *)":", 1); | |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
755 | |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
756 | if (qop != NULL && *qop != '\0') |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
757 | { |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
758 | if (nonce_count == NULL) |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
759 | { |
| 15884 | 760 | purple_cipher_context_destroy(context); |
|
19832
84b69b21672b
Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17435
diff
changeset
|
761 | purple_debug_error("cipher", "Required nonce_count missing for digest calculation.\n"); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
762 | return NULL; |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
763 | } |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
764 | |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
765 | if (client_nonce == NULL) |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
766 | { |
| 15884 | 767 | purple_cipher_context_destroy(context); |
|
19832
84b69b21672b
Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17435
diff
changeset
|
768 | purple_debug_error("cipher", "Required client_nonce missing for digest calculation.\n"); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
769 | return NULL; |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
770 | } |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
771 | |
| 15884 | 772 | purple_cipher_context_append(context, (guchar *)nonce_count, strlen(nonce_count)); |
| 773 | purple_cipher_context_append(context, (guchar *)":", 1); | |
| 774 | purple_cipher_context_append(context, (guchar *)client_nonce, strlen(client_nonce)); | |
| 775 | purple_cipher_context_append(context, (guchar *)":", 1); | |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
776 | |
| 15884 | 777 | purple_cipher_context_append(context, (guchar *)qop, strlen(qop)); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
778 | |
| 15884 | 779 | purple_cipher_context_append(context, (guchar *)":", 1); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
780 | } |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
781 | |
| 15884 | 782 | purple_cipher_context_append(context, (guchar *)hash2, strlen(hash2)); |
| 783 | purple_cipher_context_digest_to_str(context, sizeof(hash2), hash2, NULL); | |
| 784 | purple_cipher_context_destroy(context); | |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
785 | |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
786 | return g_strdup(hash2); |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
787 | } |