Mercurial > pidgin
annotate libpurple/cipher.c @ 25987:035ba9355361
IBB is now in im.pidgin.pidgin
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sat, 07 Mar 2009 02:23:14 +0000 |
parents | 584063555949 |
children | 8487bf2c306e |
rev | line source |
---|---|
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
15822 | 2 * purple |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
15822 | 4 * Purple is the legal property of its developers, whose names are too numerous |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
6 * source distribution. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * Original md5 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * Copyright (C) 2001-2003 Christophe Devine <c.devine@cr0.net> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * Original md4 taken from linux kernel |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * MD4 Message Digest Algorithm (RFC1320). |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * Implementation derived from Andrew Tridgell and Steve French's |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * CIFS MD4 implementation, and the cryptoapi implementation |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * originally based on the public domain implementation written |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * by Colin Plumb in 1993. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * Copyright (c) Andrew Tridgell 1997-1998. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 * Modified by Steve French (sfrench@us.ibm.com) 2002 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * Copyright (c) Cryptoapi developers. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 * Copyright (c) 2002 David S. Miller (davem@redhat.com) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 * Original des taken from gpg |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 * des.c - DES and Triple-DES encryption/decryption Algorithm |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 * Copyright (C) 1998 Free Software Foundation, Inc. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 * Please see below for more legal information! |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 * According to the definition of DES in FIPS PUB 46-2 from December 1993. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 * For a description of triple encryption, see: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 * Bruce Schneier: Applied Cryptography. Second Edition. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 * John Wiley & Sons, 1996. ISBN 0-471-12845-7. Pages 358 ff. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
37 * This file is part of GnuPG. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
49 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 * along with this program; if not, write to the Free Software |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19654
diff
changeset
|
51 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 #include <glib.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 #include <string.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 #include <stdio.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 #include "internal.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 #include "cipher.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 #include "dbus-maybe.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 #include "signals.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 #include "value.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 /******************************************************************************* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 * MD5 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 ******************************************************************************/ |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
67 #define MD5_HMAC_BLOCK_SIZE 64 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
68 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 struct MD5Context { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
70 guint32 total[2]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 guint32 state[4]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 guchar buffer[64]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 #define MD5_GET_GUINT32(n,b,i) { \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 (n) = ((guint32)(b) [(i) ] ) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
77 | ((guint32)(b) [(i) + 1] << 8) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
78 | ((guint32)(b) [(i) + 2] << 16) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
79 | ((guint32)(b) [(i) + 3] << 24); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
80 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 #define MD5_PUT_GUINT32(n,b,i) { \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
82 (b)[(i) ] = (guchar)((n) ); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 (b)[(i) + 1] = (guchar)((n) >> 8); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 (b)[(i) + 2] = (guchar)((n) >> 16); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 (b)[(i) + 3] = (guchar)((n) >> 24); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
87 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 static void |
15822 | 89 md5_init(PurpleCipherContext *context, gpointer extra) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 struct MD5Context *md5_context; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
92 md5_context = g_new0(struct MD5Context, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
93 |
15822 | 94 purple_cipher_context_set_data(context, md5_context); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
95 |
15822 | 96 purple_cipher_context_reset(context, extra); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
97 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
98 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
99 static void |
15822 | 100 md5_reset(PurpleCipherContext *context, gpointer extra) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
101 struct MD5Context *md5_context; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
102 |
15822 | 103 md5_context = purple_cipher_context_get_data(context); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
104 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
105 md5_context->total[0] = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
106 md5_context->total[1] = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
108 md5_context->state[0] = 0x67452301; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
109 md5_context->state[1] = 0xEFCDAB89; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
110 md5_context->state[2] = 0x98BADCFE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 md5_context->state[3] = 0x10325476; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
113 memset(md5_context->buffer, 0, sizeof(md5_context->buffer)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
114 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
115 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
116 static void |
15822 | 117 md5_uninit(PurpleCipherContext *context) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 struct MD5Context *md5_context; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
119 |
15822 | 120 purple_cipher_context_reset(context, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
121 |
15822 | 122 md5_context = purple_cipher_context_get_data(context); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 memset(md5_context, 0, sizeof(md5_context)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 g_free(md5_context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 md5_context = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 md5_process(struct MD5Context *md5_context, const guchar data[64]) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 guint32 X[16], A, B, C, D; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
133 A = md5_context->state[0]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
134 B = md5_context->state[1]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
135 C = md5_context->state[2]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 D = md5_context->state[3]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
137 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 MD5_GET_GUINT32(X[ 0], data, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
139 MD5_GET_GUINT32(X[ 1], data, 4); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
140 MD5_GET_GUINT32(X[ 2], data, 8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
141 MD5_GET_GUINT32(X[ 3], data, 12); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 MD5_GET_GUINT32(X[ 4], data, 16); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
143 MD5_GET_GUINT32(X[ 5], data, 20); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
144 MD5_GET_GUINT32(X[ 6], data, 24); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
145 MD5_GET_GUINT32(X[ 7], data, 28); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
146 MD5_GET_GUINT32(X[ 8], data, 32); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
147 MD5_GET_GUINT32(X[ 9], data, 36); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
148 MD5_GET_GUINT32(X[10], data, 40); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
149 MD5_GET_GUINT32(X[11], data, 44); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 MD5_GET_GUINT32(X[12], data, 48); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
151 MD5_GET_GUINT32(X[13], data, 52); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 MD5_GET_GUINT32(X[14], data, 56); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 MD5_GET_GUINT32(X[15], data, 60); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
155 #define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
156 #define P(a,b,c,d,k,s,t) { \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
157 a += F(b,c,d) + X[k] + t; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
158 a = S(a,s) + b; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
159 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
160 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
161 /* first pass */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
162 #define F(x,y,z) (z ^ (x & (y ^ z))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
163 P(A, B, C, D, 0, 7, 0xD76AA478); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 P(D, A, B, C, 1, 12, 0xE8C7B756); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
165 P(C, D, A, B, 2, 17, 0x242070DB); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
166 P(B, C, D, A, 3, 22, 0xC1BDCEEE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
167 P(A, B, C, D, 4, 7, 0xF57C0FAF); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
168 P(D, A, B, C, 5, 12, 0x4787C62A); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 P(C, D, A, B, 6, 17, 0xA8304613); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 P(B, C, D, A, 7, 22, 0xFD469501); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
171 P(A, B, C, D, 8, 7, 0x698098D8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 P(D, A, B, C, 9, 12, 0x8B44F7AF); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 P(C, D, A, B, 10, 17, 0xFFFF5BB1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 P(B, C, D, A, 11, 22, 0x895CD7BE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 P(A, B, C, D, 12, 7, 0x6B901122); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 P(D, A, B, C, 13, 12, 0xFD987193); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
177 P(C, D, A, B, 14, 17, 0xA679438E); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
178 P(B, C, D, A, 15, 22, 0x49B40821); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
179 #undef F |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
180 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
181 /* second pass */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
182 #define F(x,y,z) (y ^ (z & (x ^ y))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
183 P(A, B, C, D, 1, 5, 0xF61E2562); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
184 P(D, A, B, C, 6, 9, 0xC040B340); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
185 P(C, D, A, B, 11, 14, 0x265E5A51); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
186 P(B, C, D, A, 0, 20, 0xE9B6C7AA); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
187 P(A, B, C, D, 5, 5, 0xD62F105D); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
188 P(D, A, B, C, 10, 9, 0x02441453); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
189 P(C, D, A, B, 15, 14, 0xD8A1E681); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
190 P(B, C, D, A, 4, 20, 0xE7D3FBC8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
191 P(A, B, C, D, 9, 5, 0x21E1CDE6); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
192 P(D, A, B, C, 14, 9, 0xC33707D6); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
193 P(C, D, A, B, 3, 14, 0xF4D50D87); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
194 P(B, C, D, A, 8, 20, 0x455A14ED); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
195 P(A, B, C, D, 13, 5, 0xA9E3E905); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
196 P(D, A, B, C, 2, 9, 0xFCEFA3F8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 P(C, D, A, B, 7, 14, 0x676F02D9); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
198 P(B, C, D, A, 12, 20, 0x8D2A4C8A); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
199 #undef F |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
201 /* third pass */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
202 #define F(x,y,z) (x ^ y ^ z) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
203 P(A, B, C, D, 5, 4, 0xFFFA3942); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
204 P(D, A, B, C, 8, 11, 0x8771F681); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
205 P(C, D, A, B, 11, 16, 0x6D9D6122); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
206 P(B, C, D, A, 14, 23, 0xFDE5380C); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
207 P(A, B, C, D, 1, 4, 0xA4BEEA44); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
208 P(D, A, B, C, 4, 11, 0x4BDECFA9); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
209 P(C, D, A, B, 7, 16, 0xF6BB4B60); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 P(B, C, D, A, 10, 23, 0xBEBFBC70); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
211 P(A, B, C, D, 13, 4, 0x289B7EC6); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
212 P(D, A, B, C, 0, 11, 0xEAA127FA); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
213 P(C, D, A, B, 3, 16, 0xD4EF3085); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
214 P(B, C, D, A, 6, 23, 0x04881D05); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
215 P(A, B, C, D, 9, 4, 0xD9D4D039); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 P(D, A, B, C, 12, 11, 0xE6DB99E5); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
217 P(C, D, A, B, 15, 16, 0x1FA27CF8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
218 P(B, C, D, A, 2, 23, 0xC4AC5665); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
219 #undef F |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
220 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
221 /* forth pass */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
222 #define F(x,y,z) (y ^ (x | ~z)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
223 P(A, B, C, D, 0, 6, 0xF4292244); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
224 P(D, A, B, C, 7, 10, 0x432AFF97); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
225 P(C, D, A, B, 14, 15, 0xAB9423A7); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
226 P(B, C, D, A, 5, 21, 0xFC93A039); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
227 P(A, B, C, D, 12, 6, 0x655B59C3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
228 P(D, A, B, C, 3, 10, 0x8F0CCC92); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
229 P(C, D, A, B, 10, 15, 0xFFEFF47D); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
230 P(B, C, D, A, 1, 21, 0x85845DD1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
231 P(A, B, C, D, 8, 6, 0x6FA87E4F); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
232 P(D, A, B, C, 15, 10, 0xFE2CE6E0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
233 P(C, D, A, B, 6, 15, 0xA3014314); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
234 P(B, C, D, A, 13, 21, 0x4E0811A1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
235 P(A, B, C, D, 4, 6, 0xF7537E82); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
236 P(D, A, B, C, 11, 10, 0xBD3AF235); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 P(C, D, A, B, 2, 15, 0x2AD7D2BB); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 P(B, C, D, A, 9, 21, 0xEB86D391); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 #undef F |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 #undef P |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
241 #undef S |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
242 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
243 md5_context->state[0] += A; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
244 md5_context->state[1] += B; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 md5_context->state[2] += C; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
246 md5_context->state[3] += D; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
247 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
248 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
249 static void |
15822 | 250 md5_append(PurpleCipherContext *context, const guchar *data, size_t len) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
251 struct MD5Context *md5_context = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
252 guint32 left = 0, fill = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
253 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
254 g_return_if_fail(context != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
255 |
15822 | 256 md5_context = purple_cipher_context_get_data(context); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 g_return_if_fail(md5_context != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
258 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
259 left = md5_context->total[0] & 0x3F; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
260 fill = 64 - left; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
261 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
262 md5_context->total[0] += len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
263 md5_context->total[0] &= 0xFFFFFFFF; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
265 if(md5_context->total[0] < len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 md5_context->total[1]++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
267 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
268 if(left && len >= fill) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
269 memcpy((md5_context->buffer + left), data, fill); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 md5_process(md5_context, md5_context->buffer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
271 len -= fill; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
272 data += fill; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
273 left = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
274 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
275 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 while(len >= 64) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
277 md5_process(md5_context, data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
278 len -= 64; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
279 data += 64; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
281 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
282 if(len) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
283 memcpy((md5_context->buffer + left), data, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
284 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
285 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
286 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
287 static gboolean |
15822 | 288 md5_digest(PurpleCipherContext *context, size_t in_len, guchar digest[16], |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
289 size_t *out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
290 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
291 struct MD5Context *md5_context = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
292 guint32 last, pad; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
293 guint32 high, low; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
294 guchar message[8]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
295 guchar padding[64] = { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
296 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
297 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
298 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
299 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
300 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
301 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
302 g_return_val_if_fail(in_len >= 16, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
303 |
15822 | 304 md5_context = purple_cipher_context_get_data(context); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
305 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
306 high = (md5_context->total[0] >> 29) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
307 | (md5_context->total[1] << 3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
308 low = (md5_context->total[0] << 3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
309 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
310 MD5_PUT_GUINT32(low, message, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
311 MD5_PUT_GUINT32(high, message, 4); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
312 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
313 last = md5_context->total[0] & 0x3F; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
314 pad = (last < 56) ? (56 - last) : (120 - last); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
315 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
316 md5_append(context, padding, pad); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
317 md5_append(context, message, 8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
318 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
319 MD5_PUT_GUINT32(md5_context->state[0], digest, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
320 MD5_PUT_GUINT32(md5_context->state[1], digest, 4); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
321 MD5_PUT_GUINT32(md5_context->state[2], digest, 8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
322 MD5_PUT_GUINT32(md5_context->state[3], digest, 12); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
323 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
324 if(out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
325 *out_len = 16; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
326 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
327 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
328 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
329 |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
330 static size_t |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
331 md5_get_block_size(PurpleCipherContext *context) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
332 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
333 /* This does not change (in this case) */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
334 return MD5_HMAC_BLOCK_SIZE; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
335 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
336 |
15822 | 337 static PurpleCipherOps MD5Ops = { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
338 NULL, /* Set option */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
339 NULL, /* Get option */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
340 md5_init, /* init */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
341 md5_reset, /* reset */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
342 md5_uninit, /* uninit */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
343 NULL, /* set iv */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
344 md5_append, /* append */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
345 md5_digest, /* digest */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
346 NULL, /* encrypt */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
347 NULL, /* decrypt */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
348 NULL, /* set salt */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
349 NULL, /* get salt size */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
350 NULL, /* set key */ |
16668
07cf49a0f404
I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
351 NULL, /* get key size */ |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
352 NULL, /* set batch mode */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
353 NULL, /* get batch mode */ |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
354 md5_get_block_size, /* get block size */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
355 NULL /* set key with len */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
356 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
357 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
358 /******************************************************************************* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
359 * MD4 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
360 ******************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
361 #define MD4_DIGEST_SIZE 16 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
362 #define MD4_HMAC_BLOCK_SIZE 64 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
363 #define MD4_BLOCK_WORDS 16 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
364 #define MD4_HASH_WORDS 4 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
365 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
366 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
367 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
368 struct MD4_Context { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
369 guint32 hash[MD4_HASH_WORDS]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
370 guint32 block[MD4_BLOCK_WORDS]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
371 guint64 byte_count; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
372 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
373 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
374 static inline guint32 lshift(guint32 x, unsigned int s) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
375 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
376 x &= 0xFFFFFFFF; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
377 return ((x << s) & 0xFFFFFFFF) | (x >> (32 - s)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
378 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
379 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
380 static inline guint32 F(guint32 x, guint32 y, guint32 z) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
381 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
382 return (x & y) | ((~x) & z); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
384 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
385 static inline guint32 G(guint32 x, guint32 y, guint32 z) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
386 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
387 return (x & y) | (x & z) | (y & z); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
388 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
389 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
390 static inline guint32 H(guint32 x, guint32 y, guint32 z) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
391 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
392 return x ^ y ^ z; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
393 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
394 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
395 #define ROUND1(a,b,c,d,k,s) (a = lshift(a + F(b,c,d) + k, s)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
396 #define ROUND2(a,b,c,d,k,s) (a = lshift(a + G(b,c,d) + k + (guint32)0x5A827999,s)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
397 #define ROUND3(a,b,c,d,k,s) (a = lshift(a + H(b,c,d) + k + (guint32)0x6ED9EBA1,s)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
398 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
399 static inline void le32_to_cpu_array(guint32 *buf, unsigned int words) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
400 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
401 while (words--) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
402 *buf=GUINT_FROM_LE(*buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
403 buf++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
404 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
405 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
406 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
407 static inline void cpu_to_le32_array(guint32 *buf, unsigned int words) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
408 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
409 while (words--) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
410 *buf=GUINT_TO_LE(*buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
411 buf++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
413 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
414 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
415 static void md4_transform(guint32 *hash, guint32 const *in) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
416 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
417 guint32 a, b, c, d; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
418 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
419 a = hash[0]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 b = hash[1]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
421 c = hash[2]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
422 d = hash[3]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
423 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
424 ROUND1(a, b, c, d, in[0], 3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
425 ROUND1(d, a, b, c, in[1], 7); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
426 ROUND1(c, d, a, b, in[2], 11); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
427 ROUND1(b, c, d, a, in[3], 19); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
428 ROUND1(a, b, c, d, in[4], 3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
429 ROUND1(d, a, b, c, in[5], 7); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
430 ROUND1(c, d, a, b, in[6], 11); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
431 ROUND1(b, c, d, a, in[7], 19); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
432 ROUND1(a, b, c, d, in[8], 3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
433 ROUND1(d, a, b, c, in[9], 7); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
434 ROUND1(c, d, a, b, in[10], 11); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
435 ROUND1(b, c, d, a, in[11], 19); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
436 ROUND1(a, b, c, d, in[12], 3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
437 ROUND1(d, a, b, c, in[13], 7); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
438 ROUND1(c, d, a, b, in[14], 11); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
439 ROUND1(b, c, d, a, in[15], 19); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
440 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
441 ROUND2(a, b, c, d,in[ 0], 3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
442 ROUND2(d, a, b, c, in[4], 5); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
443 ROUND2(c, d, a, b, in[8], 9); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
444 ROUND2(b, c, d, a, in[12], 13); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
445 ROUND2(a, b, c, d, in[1], 3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
446 ROUND2(d, a, b, c, in[5], 5); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
447 ROUND2(c, d, a, b, in[9], 9); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
448 ROUND2(b, c, d, a, in[13], 13); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
449 ROUND2(a, b, c, d, in[2], 3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
450 ROUND2(d, a, b, c, in[6], 5); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
451 ROUND2(c, d, a, b, in[10], 9); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
452 ROUND2(b, c, d, a, in[14], 13); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
453 ROUND2(a, b, c, d, in[3], 3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
454 ROUND2(d, a, b, c, in[7], 5); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
455 ROUND2(c, d, a, b, in[11], 9); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
456 ROUND2(b, c, d, a, in[15], 13); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
457 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
458 ROUND3(a, b, c, d,in[ 0], 3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
459 ROUND3(d, a, b, c, in[8], 9); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
460 ROUND3(c, d, a, b, in[4], 11); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
461 ROUND3(b, c, d, a, in[12], 15); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
462 ROUND3(a, b, c, d, in[2], 3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
463 ROUND3(d, a, b, c, in[10], 9); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
464 ROUND3(c, d, a, b, in[6], 11); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
465 ROUND3(b, c, d, a, in[14], 15); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
466 ROUND3(a, b, c, d, in[1], 3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
467 ROUND3(d, a, b, c, in[9], 9); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
468 ROUND3(c, d, a, b, in[5], 11); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
469 ROUND3(b, c, d, a, in[13], 15); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
470 ROUND3(a, b, c, d, in[3], 3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
471 ROUND3(d, a, b, c, in[11], 9); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
472 ROUND3(c, d, a, b, in[7], 11); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
473 ROUND3(b, c, d, a, in[15], 15); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
474 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
475 hash[0] += a; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
476 hash[1] += b; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
477 hash[2] += c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
478 hash[3] += d; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
479 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
480 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
481 static inline void md4_transform_helper(struct MD4_Context *ctx) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
482 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
483 le32_to_cpu_array(ctx->block, sizeof(ctx->block) / sizeof(guint32)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
484 md4_transform(ctx->hash, ctx->block); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
485 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
486 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
487 static void |
15822 | 488 md4_init(PurpleCipherContext *context, gpointer extra) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
489 struct MD4_Context *mctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
490 mctx = g_new0(struct MD4_Context, 1); |
15822 | 491 purple_cipher_context_set_data(context, mctx); |
492 purple_cipher_context_reset(context, extra); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
493 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
494 mctx->hash[0] = 0x67452301; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
495 mctx->hash[1] = 0xefcdab89; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
496 mctx->hash[2] = 0x98badcfe; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
497 mctx->hash[3] = 0x10325476; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
498 mctx->byte_count = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
499 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
500 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
501 static void |
15822 | 502 md4_reset(PurpleCipherContext *context, gpointer extra) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
503 struct MD4_Context *mctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
504 |
15822 | 505 mctx = purple_cipher_context_get_data(context); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
506 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
507 mctx->hash[0] = 0x67452301; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
508 mctx->hash[1] = 0xefcdab89; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
509 mctx->hash[2] = 0x98badcfe; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
510 mctx->hash[3] = 0x10325476; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
511 mctx->byte_count = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
512 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
513 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
514 static void |
25924
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25894
diff
changeset
|
515 md4_append(PurpleCipherContext *context, const guchar *data, size_t len) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
516 { |
15822 | 517 struct MD4_Context *mctx = purple_cipher_context_get_data(context); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
518 const guint32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
519 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
520 mctx->byte_count += len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
521 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
522 if (avail > len) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
523 memcpy((char *)mctx->block + (sizeof(mctx->block) - avail), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
524 data, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
525 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
526 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
527 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
528 memcpy((char *)mctx->block + (sizeof(mctx->block) - avail), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
529 data, avail); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
530 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
531 md4_transform_helper(mctx); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
532 data += avail; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
533 len -= avail; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
534 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
535 while (len >= sizeof(mctx->block)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
536 memcpy(mctx->block, data, sizeof(mctx->block)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
537 md4_transform_helper(mctx); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
538 data += sizeof(mctx->block); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
539 len -= sizeof(mctx->block); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
540 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
541 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
542 memcpy(mctx->block, data, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
543 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
544 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
545 static gboolean |
15822 | 546 md4_digest(PurpleCipherContext *context, size_t in_len, guchar *out, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
547 size_t *out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
548 { |
15822 | 549 struct MD4_Context *mctx = purple_cipher_context_get_data(context); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
550 const unsigned int offset = mctx->byte_count & 0x3f; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
551 char *p = (char *)mctx->block + offset; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
552 int padding = 56 - (offset + 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
553 |
25924
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25894
diff
changeset
|
554 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
555 if(in_len<16) return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
556 if(out_len) *out_len = 16; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
557 *p++ = 0x80; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
558 if (padding < 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
559 memset(p, 0x00, padding + sizeof (guint64)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
560 md4_transform_helper(mctx); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
561 p = (char *)mctx->block; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
562 padding = 56; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
563 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
564 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
565 memset(p, 0, padding); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
566 mctx->block[14] = mctx->byte_count << 3; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
567 mctx->block[15] = mctx->byte_count >> 29; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
568 le32_to_cpu_array(mctx->block, (sizeof(mctx->block) - |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
569 sizeof(guint64)) / sizeof(guint32)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
570 md4_transform(mctx->hash, mctx->block); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
571 cpu_to_le32_array(mctx->hash, sizeof(mctx->hash) / sizeof(guint32)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
572 memcpy(out, mctx->hash, sizeof(mctx->hash)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
573 memset(mctx, 0, sizeof(*mctx)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
574 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
575 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
576 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
577 static void |
15822 | 578 md4_uninit(PurpleCipherContext *context) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
579 struct MD4_Context *md4_context; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
580 |
15822 | 581 purple_cipher_context_reset(context, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
582 |
15822 | 583 md4_context = purple_cipher_context_get_data(context); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
584 memset(md4_context, 0, sizeof(md4_context)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
585 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
586 g_free(md4_context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
587 md4_context = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
588 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
589 |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
590 static size_t |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
591 md4_get_block_size(PurpleCipherContext *context) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
592 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
593 /* This does not change (in this case) */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
594 return MD4_HMAC_BLOCK_SIZE; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
595 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
596 |
15822 | 597 static PurpleCipherOps MD4Ops = { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
598 NULL, /* Set option */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
599 NULL, /* Get option */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
600 md4_init, /* init */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
601 md4_reset, /* reset */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
602 md4_uninit, /* uninit */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
603 NULL, /* set iv */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
604 md4_append, /* append */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
605 md4_digest, /* digest */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
606 NULL, /* encrypt */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
607 NULL, /* decrypt */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
608 NULL, /* set salt */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
609 NULL, /* get salt size */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
610 NULL, /* set key */ |
16668
07cf49a0f404
I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
611 NULL, /* get key size */ |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
612 NULL, /* set batch mode */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
613 NULL, /* get batch mode */ |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
614 md4_get_block_size, /* get block size */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
615 NULL /* set key with len */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
616 }; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
617 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
618 /******************************************************************************* |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
619 * HMAC |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
620 ******************************************************************************/ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
621 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
622 struct HMAC_Context { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
623 PurpleCipherContext *hash; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
624 char *name; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
625 int blocksize; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
626 guchar *opad; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
627 }; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
628 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
629 static void |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
630 hmac_init(PurpleCipherContext *context, gpointer extra) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
631 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
632 struct HMAC_Context *hctx; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
633 hctx = g_new0(struct HMAC_Context, 1); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
634 purple_cipher_context_set_data(context, hctx); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
635 purple_cipher_context_reset(context, extra); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
636 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
637 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
638 static void |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
639 hmac_reset(PurpleCipherContext *context, gpointer extra) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
640 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
641 struct HMAC_Context *hctx; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
642 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
643 hctx = purple_cipher_context_get_data(context); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
644 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
645 g_free(hctx->name); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
646 hctx->name = NULL; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
647 if (hctx->hash) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
648 purple_cipher_context_destroy(hctx->hash); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
649 hctx->hash = NULL; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
650 hctx->blocksize = 0; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
651 g_free(hctx->opad); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
652 hctx->opad = NULL; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
653 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
654 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
655 static void |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
656 hmac_set_opt(PurpleCipherContext *context, const gchar *name, void *value) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
657 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
658 struct HMAC_Context *hctx; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
659 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
660 hctx = purple_cipher_context_get_data(context); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
661 |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
23555
diff
changeset
|
662 if (purple_strequal(name, "hash")) { |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
663 g_free(hctx->name); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
664 if (hctx->hash) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
665 purple_cipher_context_destroy(hctx->hash); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
666 hctx->name = g_strdup((char*)value); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
667 hctx->hash = purple_cipher_context_new_by_name((char *)value, NULL); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
668 hctx->blocksize = purple_cipher_context_get_block_size(hctx->hash); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
669 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
670 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
671 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
672 static void * |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
673 hmac_get_opt(PurpleCipherContext *context, const gchar *name) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
674 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
675 struct HMAC_Context *hctx; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
676 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
677 hctx = purple_cipher_context_get_data(context); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
678 |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
23555
diff
changeset
|
679 if (purple_strequal(name, "hash")) { |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
680 return hctx->name; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
681 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
682 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
683 return NULL; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
684 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
685 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
686 static void |
25924
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25894
diff
changeset
|
687 hmac_append(PurpleCipherContext *context, const guchar *data, size_t len) |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
688 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
689 struct HMAC_Context *hctx = purple_cipher_context_get_data(context); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
690 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
691 g_return_if_fail(hctx->hash != NULL); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
692 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
693 purple_cipher_context_append(hctx->hash, data, len); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
694 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
695 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
696 static gboolean |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
697 hmac_digest(PurpleCipherContext *context, size_t in_len, guchar *out, size_t *out_len) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
698 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
699 struct HMAC_Context *hctx = purple_cipher_context_get_data(context); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
700 PurpleCipherContext *hash = hctx->hash; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
701 guchar *inner_hash; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
702 size_t hash_len; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
703 gboolean result; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
704 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
705 g_return_val_if_fail(hash != NULL, FALSE); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
706 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
707 inner_hash = g_malloc(100); /* TODO: Should be enough for now... */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
708 result = purple_cipher_context_digest(hash, 100, inner_hash, &hash_len); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
709 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
710 purple_cipher_context_reset(hash, NULL); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
711 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
712 purple_cipher_context_append(hash, hctx->opad, hctx->blocksize); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
713 purple_cipher_context_append(hash, inner_hash, hash_len); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
714 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
715 g_free(inner_hash); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
716 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
717 result = result && purple_cipher_context_digest(hash, in_len, out, out_len); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
718 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
719 return result; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
720 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
721 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
722 static void |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
723 hmac_uninit(PurpleCipherContext *context) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
724 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
725 struct HMAC_Context *hctx; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
726 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
727 purple_cipher_context_reset(context, NULL); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
728 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
729 hctx = purple_cipher_context_get_data(context); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
730 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
731 g_free(hctx); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
732 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
733 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
734 static void |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
735 hmac_set_key_with_len(PurpleCipherContext *context, const guchar * key, size_t key_len) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
736 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
737 struct HMAC_Context *hctx = purple_cipher_context_get_data(context); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
738 int blocksize, i; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
739 guchar *ipad; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
740 guchar *full_key; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
741 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
742 g_return_if_fail(hctx->hash != NULL); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
743 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
744 g_free(hctx->opad); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
745 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
746 blocksize = hctx->blocksize; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
747 ipad = g_malloc(blocksize); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
748 hctx->opad = g_malloc(blocksize); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
749 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
750 if (key_len > blocksize) { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
751 purple_cipher_context_reset(hctx->hash, NULL); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
752 purple_cipher_context_append(hctx->hash, key, key_len); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
753 full_key = g_malloc(100); /* TODO: Should be enough for now... */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
754 purple_cipher_context_digest(hctx->hash, 100, full_key, &key_len); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
755 } else |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
756 full_key = g_memdup(key, key_len); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
757 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
758 if (key_len < blocksize) { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
759 full_key = g_realloc(full_key, blocksize); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
760 memset(full_key + key_len, 0, blocksize - key_len); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
761 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
762 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
763 for(i = 0; i < blocksize; i++) { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
764 ipad[i] = 0x36 ^ full_key[i]; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
765 hctx->opad[i] = 0x5c ^ full_key[i]; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
766 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
767 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
768 g_free(full_key); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
769 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
770 purple_cipher_context_reset(hctx->hash, NULL); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
771 purple_cipher_context_append(hctx->hash, ipad, blocksize); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
772 g_free(ipad); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
773 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
774 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
775 static void |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
776 hmac_set_key(PurpleCipherContext *context, const guchar * key) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
777 { |
22011
76e0463db3aa
Squash some compiler warnings, some from my -Wstrict-prototypes fixing.
Richard Laager <rlaager@wiktel.com>
parents:
21908
diff
changeset
|
778 hmac_set_key_with_len(context, key, strlen((char *)key)); |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
779 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
780 |
25924
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25894
diff
changeset
|
781 static size_t |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
782 hmac_get_block_size(PurpleCipherContext *context) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
783 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
784 struct HMAC_Context *hctx = purple_cipher_context_get_data(context); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
785 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
786 return hctx->blocksize; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
787 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
788 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
789 static PurpleCipherOps HMACOps = { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
790 hmac_set_opt, /* Set option */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
791 hmac_get_opt, /* Get option */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
792 hmac_init, /* init */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
793 hmac_reset, /* reset */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
794 hmac_uninit, /* uninit */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
795 NULL, /* set iv */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
796 hmac_append, /* append */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
797 hmac_digest, /* digest */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
798 NULL, /* encrypt */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
799 NULL, /* decrypt */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
800 NULL, /* set salt */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
801 NULL, /* get salt size */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
802 hmac_set_key, /* set key */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
803 NULL, /* get key size */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
804 NULL, /* set batch mode */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
805 NULL, /* get batch mode */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
806 hmac_get_block_size, /* get block size */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
807 hmac_set_key_with_len /* set key with len */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
808 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
809 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
810 /****************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
811 * DES |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
812 *****************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
813 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
814 typedef struct _des_ctx |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
815 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
816 guint32 encrypt_subkeys[32]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
817 guint32 decrypt_subkeys[32]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
818 } des_ctx[1]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
819 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
820 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
821 * The s-box values are permuted according to the 'primitive function P' |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
822 */ |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19681
diff
changeset
|
823 static const guint32 sbox1[64] = |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
824 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
825 0x00808200, 0x00000000, 0x00008000, 0x00808202, 0x00808002, 0x00008202, 0x00000002, 0x00008000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
826 0x00000200, 0x00808200, 0x00808202, 0x00000200, 0x00800202, 0x00808002, 0x00800000, 0x00000002, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
827 0x00000202, 0x00800200, 0x00800200, 0x00008200, 0x00008200, 0x00808000, 0x00808000, 0x00800202, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
828 0x00008002, 0x00800002, 0x00800002, 0x00008002, 0x00000000, 0x00000202, 0x00008202, 0x00800000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
829 0x00008000, 0x00808202, 0x00000002, 0x00808000, 0x00808200, 0x00800000, 0x00800000, 0x00000200, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
830 0x00808002, 0x00008000, 0x00008200, 0x00800002, 0x00000200, 0x00000002, 0x00800202, 0x00008202, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
831 0x00808202, 0x00008002, 0x00808000, 0x00800202, 0x00800002, 0x00000202, 0x00008202, 0x00808200, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
832 0x00000202, 0x00800200, 0x00800200, 0x00000000, 0x00008002, 0x00008200, 0x00000000, 0x00808002 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
833 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
834 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19681
diff
changeset
|
835 static const guint32 sbox2[64] = |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
836 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
837 0x40084010, 0x40004000, 0x00004000, 0x00084010, 0x00080000, 0x00000010, 0x40080010, 0x40004010, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
838 0x40000010, 0x40084010, 0x40084000, 0x40000000, 0x40004000, 0x00080000, 0x00000010, 0x40080010, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
839 0x00084000, 0x00080010, 0x40004010, 0x00000000, 0x40000000, 0x00004000, 0x00084010, 0x40080000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
840 0x00080010, 0x40000010, 0x00000000, 0x00084000, 0x00004010, 0x40084000, 0x40080000, 0x00004010, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
841 0x00000000, 0x00084010, 0x40080010, 0x00080000, 0x40004010, 0x40080000, 0x40084000, 0x00004000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
842 0x40080000, 0x40004000, 0x00000010, 0x40084010, 0x00084010, 0x00000010, 0x00004000, 0x40000000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
843 0x00004010, 0x40084000, 0x00080000, 0x40000010, 0x00080010, 0x40004010, 0x40000010, 0x00080010, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
844 0x00084000, 0x00000000, 0x40004000, 0x00004010, 0x40000000, 0x40080010, 0x40084010, 0x00084000 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
845 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
846 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19681
diff
changeset
|
847 static const guint32 sbox3[64] = |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
848 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
849 0x00000104, 0x04010100, 0x00000000, 0x04010004, 0x04000100, 0x00000000, 0x00010104, 0x04000100, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
850 0x00010004, 0x04000004, 0x04000004, 0x00010000, 0x04010104, 0x00010004, 0x04010000, 0x00000104, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
851 0x04000000, 0x00000004, 0x04010100, 0x00000100, 0x00010100, 0x04010000, 0x04010004, 0x00010104, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
852 0x04000104, 0x00010100, 0x00010000, 0x04000104, 0x00000004, 0x04010104, 0x00000100, 0x04000000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
853 0x04010100, 0x04000000, 0x00010004, 0x00000104, 0x00010000, 0x04010100, 0x04000100, 0x00000000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
854 0x00000100, 0x00010004, 0x04010104, 0x04000100, 0x04000004, 0x00000100, 0x00000000, 0x04010004, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
855 0x04000104, 0x00010000, 0x04000000, 0x04010104, 0x00000004, 0x00010104, 0x00010100, 0x04000004, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
856 0x04010000, 0x04000104, 0x00000104, 0x04010000, 0x00010104, 0x00000004, 0x04010004, 0x00010100 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
857 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
858 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19681
diff
changeset
|
859 static const guint32 sbox4[64] = |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
860 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
861 0x80401000, 0x80001040, 0x80001040, 0x00000040, 0x00401040, 0x80400040, 0x80400000, 0x80001000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
862 0x00000000, 0x00401000, 0x00401000, 0x80401040, 0x80000040, 0x00000000, 0x00400040, 0x80400000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
863 0x80000000, 0x00001000, 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x80001000, 0x00001040, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
864 0x80400040, 0x80000000, 0x00001040, 0x00400040, 0x00001000, 0x00401040, 0x80401040, 0x80000040, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
865 0x00400040, 0x80400000, 0x00401000, 0x80401040, 0x80000040, 0x00000000, 0x00000000, 0x00401000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
866 0x00001040, 0x00400040, 0x80400040, 0x80000000, 0x80401000, 0x80001040, 0x80001040, 0x00000040, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
867 0x80401040, 0x80000040, 0x80000000, 0x00001000, 0x80400000, 0x80001000, 0x00401040, 0x80400040, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
868 0x80001000, 0x00001040, 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x00001000, 0x00401040 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
869 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
870 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19681
diff
changeset
|
871 static const guint32 sbox5[64] = |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
872 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
873 0x00000080, 0x01040080, 0x01040000, 0x21000080, 0x00040000, 0x00000080, 0x20000000, 0x01040000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
874 0x20040080, 0x00040000, 0x01000080, 0x20040080, 0x21000080, 0x21040000, 0x00040080, 0x20000000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
875 0x01000000, 0x20040000, 0x20040000, 0x00000000, 0x20000080, 0x21040080, 0x21040080, 0x01000080, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
876 0x21040000, 0x20000080, 0x00000000, 0x21000000, 0x01040080, 0x01000000, 0x21000000, 0x00040080, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
877 0x00040000, 0x21000080, 0x00000080, 0x01000000, 0x20000000, 0x01040000, 0x21000080, 0x20040080, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
878 0x01000080, 0x20000000, 0x21040000, 0x01040080, 0x20040080, 0x00000080, 0x01000000, 0x21040000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
879 0x21040080, 0x00040080, 0x21000000, 0x21040080, 0x01040000, 0x00000000, 0x20040000, 0x21000000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
880 0x00040080, 0x01000080, 0x20000080, 0x00040000, 0x00000000, 0x20040000, 0x01040080, 0x20000080 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
881 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
882 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19681
diff
changeset
|
883 static const guint32 sbox6[64] = |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
884 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
885 0x10000008, 0x10200000, 0x00002000, 0x10202008, 0x10200000, 0x00000008, 0x10202008, 0x00200000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
886 0x10002000, 0x00202008, 0x00200000, 0x10000008, 0x00200008, 0x10002000, 0x10000000, 0x00002008, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
887 0x00000000, 0x00200008, 0x10002008, 0x00002000, 0x00202000, 0x10002008, 0x00000008, 0x10200008, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
888 0x10200008, 0x00000000, 0x00202008, 0x10202000, 0x00002008, 0x00202000, 0x10202000, 0x10000000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
889 0x10002000, 0x00000008, 0x10200008, 0x00202000, 0x10202008, 0x00200000, 0x00002008, 0x10000008, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
890 0x00200000, 0x10002000, 0x10000000, 0x00002008, 0x10000008, 0x10202008, 0x00202000, 0x10200000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
891 0x00202008, 0x10202000, 0x00000000, 0x10200008, 0x00000008, 0x00002000, 0x10200000, 0x00202008, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
892 0x00002000, 0x00200008, 0x10002008, 0x00000000, 0x10202000, 0x10000000, 0x00200008, 0x10002008 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
893 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
894 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19681
diff
changeset
|
895 static const guint32 sbox7[64] = |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
896 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
897 0x00100000, 0x02100001, 0x02000401, 0x00000000, 0x00000400, 0x02000401, 0x00100401, 0x02100400, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
898 0x02100401, 0x00100000, 0x00000000, 0x02000001, 0x00000001, 0x02000000, 0x02100001, 0x00000401, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
899 0x02000400, 0x00100401, 0x00100001, 0x02000400, 0x02000001, 0x02100000, 0x02100400, 0x00100001, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
900 0x02100000, 0x00000400, 0x00000401, 0x02100401, 0x00100400, 0x00000001, 0x02000000, 0x00100400, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
901 0x02000000, 0x00100400, 0x00100000, 0x02000401, 0x02000401, 0x02100001, 0x02100001, 0x00000001, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
902 0x00100001, 0x02000000, 0x02000400, 0x00100000, 0x02100400, 0x00000401, 0x00100401, 0x02100400, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
903 0x00000401, 0x02000001, 0x02100401, 0x02100000, 0x00100400, 0x00000000, 0x00000001, 0x02100401, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
904 0x00000000, 0x00100401, 0x02100000, 0x00000400, 0x02000001, 0x02000400, 0x00000400, 0x00100001 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
905 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
906 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19681
diff
changeset
|
907 static const guint32 sbox8[64] = |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
908 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
909 0x08000820, 0x00000800, 0x00020000, 0x08020820, 0x08000000, 0x08000820, 0x00000020, 0x08000000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
910 0x00020020, 0x08020000, 0x08020820, 0x00020800, 0x08020800, 0x00020820, 0x00000800, 0x00000020, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
911 0x08020000, 0x08000020, 0x08000800, 0x00000820, 0x00020800, 0x00020020, 0x08020020, 0x08020800, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
912 0x00000820, 0x00000000, 0x00000000, 0x08020020, 0x08000020, 0x08000800, 0x00020820, 0x00020000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
913 0x00020820, 0x00020000, 0x08020800, 0x00000800, 0x00000020, 0x08020020, 0x00000800, 0x00020820, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
914 0x08000800, 0x00000020, 0x08000020, 0x08020000, 0x08020020, 0x08000000, 0x00020000, 0x08000820, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
915 0x00000000, 0x08020820, 0x00020020, 0x08000020, 0x08020000, 0x08000800, 0x08000820, 0x00000000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
916 0x08020820, 0x00020800, 0x00020800, 0x00000820, 0x00000820, 0x00020020, 0x08000000, 0x08020800 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
917 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
918 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
919 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
920 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
921 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
922 * * These two tables are part of the 'permuted choice 1' function. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
923 * * In this implementation several speed improvements are done. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
924 * */ |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19681
diff
changeset
|
925 static const guint32 leftkey_swap[16] = |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
926 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
927 0x00000000, 0x00000001, 0x00000100, 0x00000101, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
928 0x00010000, 0x00010001, 0x00010100, 0x00010101, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
929 0x01000000, 0x01000001, 0x01000100, 0x01000101, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
930 0x01010000, 0x01010001, 0x01010100, 0x01010101 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
931 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
932 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19681
diff
changeset
|
933 static const guint32 rightkey_swap[16] = |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
934 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
935 0x00000000, 0x01000000, 0x00010000, 0x01010000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
936 0x00000100, 0x01000100, 0x00010100, 0x01010100, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
937 0x00000001, 0x01000001, 0x00010001, 0x01010001, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
938 0x00000101, 0x01000101, 0x00010101, 0x01010101, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
939 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
940 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
941 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
942 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
943 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
944 * Numbers of left shifts per round for encryption subkey schedule |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
945 * To calculate the decryption key scheduling we just reverse the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
946 * ordering of the subkeys so we can omit the table for decryption |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
947 * subkey schedule. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
948 */ |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19681
diff
changeset
|
949 static const guint8 encrypt_rotate_tab[16] = |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
950 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
951 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
952 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
953 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
954 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
955 * Macro to swap bits across two words |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
956 **/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
957 #define DO_PERMUTATION(a, temp, b, offset, mask) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
958 temp = ((a>>offset) ^ b) & mask; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
959 b ^= temp; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
960 a ^= temp<<offset; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
961 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
962 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
963 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
964 * This performs the 'initial permutation' for the data to be encrypted or decrypted |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
965 **/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
966 #define INITIAL_PERMUTATION(left, temp, right) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
967 DO_PERMUTATION(left, temp, right, 4, 0x0f0f0f0f) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
968 DO_PERMUTATION(left, temp, right, 16, 0x0000ffff) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
969 DO_PERMUTATION(right, temp, left, 2, 0x33333333) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
970 DO_PERMUTATION(right, temp, left, 8, 0x00ff00ff) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
971 DO_PERMUTATION(left, temp, right, 1, 0x55555555) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
972 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
973 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
974 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
975 * The 'inverse initial permutation' |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
976 **/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
977 #define FINAL_PERMUTATION(left, temp, right) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
978 DO_PERMUTATION(left, temp, right, 1, 0x55555555) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
979 DO_PERMUTATION(right, temp, left, 8, 0x00ff00ff) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
980 DO_PERMUTATION(right, temp, left, 2, 0x33333333) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
981 DO_PERMUTATION(left, temp, right, 16, 0x0000ffff) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
982 DO_PERMUTATION(left, temp, right, 4, 0x0f0f0f0f) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
983 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
984 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
985 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
986 * A full DES round including 'expansion function', 'sbox substitution' |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
987 * and 'primitive function P' but without swapping the left and right word. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
988 **/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
989 #define DES_ROUND(from, to, work, subkey) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
990 work = ((from<<1) | (from>>31)) ^ *subkey++; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
991 to ^= sbox8[ work & 0x3f ]; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
992 to ^= sbox6[ (work>>8) & 0x3f ]; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
993 to ^= sbox4[ (work>>16) & 0x3f ]; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
994 to ^= sbox2[ (work>>24) & 0x3f ]; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
995 work = ((from>>3) | (from<<29)) ^ *subkey++; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
996 to ^= sbox7[ work & 0x3f ]; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
997 to ^= sbox5[ (work>>8) & 0x3f ]; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
998 to ^= sbox3[ (work>>16) & 0x3f ]; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
999 to ^= sbox1[ (work>>24) & 0x3f ]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1000 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1001 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1002 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1003 * Macros to convert 8 bytes from/to 32bit words |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1004 **/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1005 #define READ_64BIT_DATA(data, left, right) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1006 left = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1007 right = (data[4] << 24) | (data[5] << 16) | (data[6] << 8) | data[7]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1008 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1009 #define WRITE_64BIT_DATA(data, left, right) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1010 data[0] = (left >> 24) &0xff; data[1] = (left >> 16) &0xff; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1011 data[2] = (left >> 8) &0xff; data[3] = left &0xff; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1012 data[4] = (right >> 24) &0xff; data[5] = (right >> 16) &0xff; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1013 data[6] = (right >> 8) &0xff; data[7] = right &0xff; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1014 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1015 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1016 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1017 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1018 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1019 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1020 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1021 * des_key_schedule(): Calculate 16 subkeys pairs (even/odd) for |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1022 * 16 encryption rounds. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1023 * To calculate subkeys for decryption the caller |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1024 * have to reorder the generated subkeys. |
25924
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25894
diff
changeset
|
1025 * |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1026 * rawkey: 8 Bytes of key data |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1027 * subkey: Array of at least 32 guint32s. Will be filled |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1028 * with calculated subkeys. |
25924
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25894
diff
changeset
|
1029 * |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1030 **/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1031 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1032 des_key_schedule (const guint8 * rawkey, guint32 * subkey) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1033 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1034 guint32 left, right, work; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1035 int round; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1036 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1037 READ_64BIT_DATA (rawkey, left, right) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1038 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1039 DO_PERMUTATION (right, work, left, 4, 0x0f0f0f0f) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1040 DO_PERMUTATION (right, work, left, 0, 0x10101010) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1041 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1042 left = (leftkey_swap[(left >> 0) & 0xf] << 3) | (leftkey_swap[(left >> 8) & 0xf] << 2) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1043 | (leftkey_swap[(left >> 16) & 0xf] << 1) | (leftkey_swap[(left >> 24) & 0xf]) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1044 | (leftkey_swap[(left >> 5) & 0xf] << 7) | (leftkey_swap[(left >> 13) & 0xf] << 6) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1045 | (leftkey_swap[(left >> 21) & 0xf] << 5) | (leftkey_swap[(left >> 29) & 0xf] << 4); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1046 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1047 left &= 0x0fffffff; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1048 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1049 right = (rightkey_swap[(right >> 1) & 0xf] << 3) | (rightkey_swap[(right >> 9) & 0xf] << 2) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1050 | (rightkey_swap[(right >> 17) & 0xf] << 1) | (rightkey_swap[(right >> 25) & 0xf]) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1051 | (rightkey_swap[(right >> 4) & 0xf] << 7) | (rightkey_swap[(right >> 12) & 0xf] << 6) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1052 | (rightkey_swap[(right >> 20) & 0xf] << 5) | (rightkey_swap[(right >> 28) & 0xf] << 4); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1053 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1054 right &= 0x0fffffff; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1055 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1056 for (round = 0; round < 16; ++round) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1057 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1058 left = ((left << encrypt_rotate_tab[round]) | (left >> (28 - encrypt_rotate_tab[round]))) & 0x0fffffff; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1059 right = ((right << encrypt_rotate_tab[round]) | (right >> (28 - encrypt_rotate_tab[round]))) & 0x0fffffff; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1060 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1061 *subkey++ = ((left << 4) & 0x24000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1062 | ((left << 28) & 0x10000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1063 | ((left << 14) & 0x08000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1064 | ((left << 18) & 0x02080000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1065 | ((left << 6) & 0x01000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1066 | ((left << 9) & 0x00200000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1067 | ((left >> 1) & 0x00100000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1068 | ((left << 10) & 0x00040000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1069 | ((left << 2) & 0x00020000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1070 | ((left >> 10) & 0x00010000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1071 | ((right >> 13) & 0x00002000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1072 | ((right >> 4) & 0x00001000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1073 | ((right << 6) & 0x00000800) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1074 | ((right >> 1) & 0x00000400) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1075 | ((right >> 14) & 0x00000200) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1076 | (right & 0x00000100) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1077 | ((right >> 5) & 0x00000020) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1078 | ((right >> 10) & 0x00000010) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1079 | ((right >> 3) & 0x00000008) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1080 | ((right >> 18) & 0x00000004) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1081 | ((right >> 26) & 0x00000002) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1082 | ((right >> 24) & 0x00000001); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1083 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1084 *subkey++ = ((left << 15) & 0x20000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1085 | ((left << 17) & 0x10000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1086 | ((left << 10) & 0x08000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1087 | ((left << 22) & 0x04000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1088 | ((left >> 2) & 0x02000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1089 | ((left << 1) & 0x01000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1090 | ((left << 16) & 0x00200000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1091 | ((left << 11) & 0x00100000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1092 | ((left << 3) & 0x00080000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1093 | ((left >> 6) & 0x00040000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1094 | ((left << 15) & 0x00020000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1095 | ((left >> 4) & 0x00010000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1096 | ((right >> 2) & 0x00002000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1097 | ((right << 8) & 0x00001000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1098 | ((right >> 14) & 0x00000808) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1099 | ((right >> 9) & 0x00000400) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1100 | ((right) & 0x00000200) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1101 | ((right << 7) & 0x00000100) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1102 | ((right >> 7) & 0x00000020) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1103 | ((right >> 3) & 0x00000011) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1104 | ((right << 2) & 0x00000004) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1105 | ((right >> 21) & 0x00000002); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1106 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1107 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1108 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1109 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1110 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1111 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1112 * Fill a DES context with subkeys calculated from a 64bit key. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1113 * Does not check parity bits, but simply ignore them. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1114 * Does not check for weak keys. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1115 **/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1116 static void |
15822 | 1117 des_set_key (PurpleCipherContext *context, const guchar * key) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1118 { |
15822 | 1119 struct _des_ctx *ctx = purple_cipher_context_get_data(context); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1120 int i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1121 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1122 des_key_schedule (key, ctx->encrypt_subkeys); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1123 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1124 for(i=0; i<32; i+=2) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1125 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1126 ctx->decrypt_subkeys[i] = ctx->encrypt_subkeys[30-i]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1127 ctx->decrypt_subkeys[i+1] = ctx->encrypt_subkeys[31-i]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1128 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1129 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1130 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1131 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1132 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1133 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1134 * Electronic Codebook Mode DES encryption/decryption of data according |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1135 * to 'mode'. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1136 **/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1137 static int |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1138 des_ecb_crypt (struct _des_ctx *ctx, const guint8 * from, guint8 * to, int mode) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1139 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1140 guint32 left, right, work; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1141 guint32 *keys; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1142 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1143 keys = mode ? ctx->decrypt_subkeys : ctx->encrypt_subkeys; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1144 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1145 READ_64BIT_DATA (from, left, right) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1146 INITIAL_PERMUTATION (left, work, right) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1147 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1148 DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1149 DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1150 DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1151 DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1152 DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1153 DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1154 DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1155 DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1156 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1157 FINAL_PERMUTATION (right, work, left) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1158 WRITE_64BIT_DATA (to, right, left) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1159 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1160 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1161 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1162 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1163 static gint |
15822 | 1164 des_encrypt(PurpleCipherContext *context, const guchar data[], |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1165 size_t len, guchar output[], size_t *outlen) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1166 int offset = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1167 int i = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1168 int tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1169 guint8 buf[8] = {0,0,0,0,0,0,0,0}; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1170 while(offset+8<=len) { |
15822 | 1171 des_ecb_crypt(purple_cipher_context_get_data(context), |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1172 data+offset, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1173 output+offset, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1174 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1175 offset+=8; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1176 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1177 *outlen = len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1178 if(offset<len) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1179 *outlen += len - offset; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1180 tmp = offset; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1181 while(tmp<len) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1182 buf[i++] = data[tmp]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1183 tmp++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1184 } |
15822 | 1185 des_ecb_crypt(purple_cipher_context_get_data(context), |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1186 buf, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1187 output+offset, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1188 0); |
25924
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25894
diff
changeset
|
1189 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1190 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1191 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1192 |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1193 static gint |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1194 des_decrypt(PurpleCipherContext *context, const guchar data[], |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1195 size_t len, guchar output[], size_t *outlen) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1196 int offset = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1197 int i = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1198 int tmp; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1199 guint8 buf[8] = {0,0,0,0,0,0,0,0}; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1200 while(offset+8<=len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1201 des_ecb_crypt(purple_cipher_context_get_data(context), |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1202 data+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1203 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1204 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1205 offset+=8; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1206 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1207 *outlen = len; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1208 if(offset<len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1209 *outlen += len - offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1210 tmp = offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1211 while(tmp<len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1212 buf[i++] = data[tmp]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1213 tmp++; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1214 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1215 des_ecb_crypt(purple_cipher_context_get_data(context), |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1216 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1217 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1218 1); |
25924
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25894
diff
changeset
|
1219 } |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1220 return 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1221 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1222 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1223 static void |
15822 | 1224 des_init(PurpleCipherContext *context, gpointer extra) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1225 struct _des_ctx *mctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1226 mctx = g_new0(struct _des_ctx, 1); |
15822 | 1227 purple_cipher_context_set_data(context, mctx); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1228 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1229 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1230 static void |
15822 | 1231 des_uninit(PurpleCipherContext *context) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1232 struct _des_ctx *des_context; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1233 |
15822 | 1234 des_context = purple_cipher_context_get_data(context); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1235 memset(des_context, 0, sizeof(des_context)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1236 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1237 g_free(des_context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1238 des_context = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1239 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1240 |
15822 | 1241 static PurpleCipherOps DESOps = { |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1242 NULL, /* Set option */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1243 NULL, /* Get option */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1244 des_init, /* init */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1245 NULL, /* reset */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1246 des_uninit, /* uninit */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1247 NULL, /* set iv */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1248 NULL, /* append */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1249 NULL, /* digest */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1250 des_encrypt, /* encrypt */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1251 des_decrypt, /* decrypt */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1252 NULL, /* set salt */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1253 NULL, /* get salt size */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1254 des_set_key, /* set key */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1255 NULL, /* get key size */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1256 NULL, /* set batch mode */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1257 NULL, /* get batch mode */ |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
1258 NULL, /* get block size */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
1259 NULL /* set key with len */ |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1260 }; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1261 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1262 /****************************************************************************** |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1263 * Triple-DES |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1264 *****************************************************************************/ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1265 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1266 typedef struct _des3_ctx |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1267 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1268 PurpleCipherBatchMode mode; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1269 guchar iv[8]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1270 /* First key for encryption */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1271 struct _des_ctx key1; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1272 /* Second key for decryption */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1273 struct _des_ctx key2; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1274 /* Third key for encryption */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1275 struct _des_ctx key3; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1276 } des3_ctx[1]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1277 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1278 /* |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1279 * Fill a DES3 context with subkeys calculated from 3 64bit key. |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1280 * Does not check parity bits, but simply ignore them. |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1281 * Does not check for weak keys. |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1282 **/ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1283 static void |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1284 des3_set_key(PurpleCipherContext *context, const guchar * key) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1285 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1286 struct _des3_ctx *ctx = purple_cipher_context_get_data(context); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1287 int i; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1288 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1289 des_key_schedule (key + 0, ctx->key1.encrypt_subkeys); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1290 des_key_schedule (key + 8, ctx->key2.encrypt_subkeys); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1291 des_key_schedule (key + 16, ctx->key3.encrypt_subkeys); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1292 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1293 for (i = 0; i < 32; i += 2) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1294 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1295 ctx->key1.decrypt_subkeys[i] = ctx->key1.encrypt_subkeys[30-i]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1296 ctx->key1.decrypt_subkeys[i+1] = ctx->key1.encrypt_subkeys[31-i]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1297 ctx->key2.decrypt_subkeys[i] = ctx->key2.encrypt_subkeys[30-i]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1298 ctx->key2.decrypt_subkeys[i+1] = ctx->key2.encrypt_subkeys[31-i]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1299 ctx->key3.decrypt_subkeys[i] = ctx->key3.encrypt_subkeys[30-i]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1300 ctx->key3.decrypt_subkeys[i+1] = ctx->key3.encrypt_subkeys[31-i]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1301 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1302 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1303 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1304 static gint |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1305 des3_ecb_encrypt(struct _des3_ctx *ctx, const guchar data[], |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1306 size_t len, guchar output[], size_t *outlen) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1307 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1308 int offset = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1309 int i = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1310 int tmp; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1311 guint8 buf[8] = {0,0,0,0,0,0,0,0}; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1312 while (offset + 8 <= len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1313 des_ecb_crypt(&ctx->key1, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1314 data+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1315 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1316 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1317 des_ecb_crypt(&ctx->key2, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1318 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1319 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1320 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1321 des_ecb_crypt(&ctx->key3, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1322 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1323 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1324 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1325 offset += 8; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1326 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1327 *outlen = len; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1328 if (offset < len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1329 *outlen += len - offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1330 tmp = offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1331 memset(buf, 0, 8); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1332 while (tmp < len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1333 buf[i++] = data[tmp]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1334 tmp++; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1335 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1336 des_ecb_crypt(&ctx->key1, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1337 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1338 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1339 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1340 des_ecb_crypt(&ctx->key2, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1341 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1342 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1343 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1344 des_ecb_crypt(&ctx->key3, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1345 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1346 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1347 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1348 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1349 return 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1350 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1351 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1352 static gint |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1353 des3_cbc_encrypt(struct _des3_ctx *ctx, const guchar data[], |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1354 size_t len, guchar output[], size_t *outlen) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1355 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1356 int offset = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1357 int i = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1358 int tmp; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1359 guint8 buf[8]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1360 memcpy(buf, ctx->iv, 8); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1361 while (offset + 8 <= len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1362 for (i = 0; i < 8; i++) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1363 buf[i] ^= data[offset + i]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1364 des_ecb_crypt(&ctx->key1, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1365 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1366 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1367 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1368 des_ecb_crypt(&ctx->key2, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1369 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1370 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1371 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1372 des_ecb_crypt(&ctx->key3, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1373 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1374 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1375 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1376 memcpy(buf, output+offset, 8); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1377 offset += 8; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1378 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1379 *outlen = len; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1380 if (offset < len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1381 *outlen += len - offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1382 tmp = offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1383 i = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1384 while (tmp < len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1385 buf[i++] ^= data[tmp]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1386 tmp++; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1387 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1388 des_ecb_crypt(&ctx->key1, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1389 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1390 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1391 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1392 des_ecb_crypt(&ctx->key2, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1393 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1394 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1395 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1396 des_ecb_crypt(&ctx->key3, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1397 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1398 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1399 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1400 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1401 return 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1402 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1403 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1404 static gint |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1405 des3_encrypt(PurpleCipherContext *context, const guchar data[], |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1406 size_t len, guchar output[], size_t *outlen) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1407 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1408 struct _des3_ctx *ctx = purple_cipher_context_get_data(context); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1409 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1410 if (ctx->mode == PURPLE_CIPHER_BATCH_MODE_ECB) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1411 return des3_ecb_encrypt(ctx, data, len, output, outlen); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1412 } else if (ctx->mode == PURPLE_CIPHER_BATCH_MODE_CBC) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1413 return des3_cbc_encrypt(ctx, data, len, output, outlen); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1414 } else { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1415 g_return_val_if_reached(0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1416 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1417 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1418 return 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1419 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1420 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1421 static gint |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1422 des3_ecb_decrypt(struct _des3_ctx *ctx, const guchar data[], |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1423 size_t len, guchar output[], size_t *outlen) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1424 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1425 int offset = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1426 int i = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1427 int tmp; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1428 guint8 buf[8] = {0,0,0,0,0,0,0,0}; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1429 while (offset + 8 <= len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1430 /* NOTE: Apply key in reverse */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1431 des_ecb_crypt(&ctx->key3, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1432 data+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1433 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1434 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1435 des_ecb_crypt(&ctx->key2, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1436 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1437 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1438 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1439 des_ecb_crypt(&ctx->key1, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1440 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1441 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1442 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1443 offset+=8; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1444 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1445 *outlen = len; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1446 if (offset < len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1447 *outlen += len - offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1448 tmp = offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1449 memset(buf, 0, 8); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1450 while (tmp < len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1451 buf[i++] = data[tmp]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1452 tmp++; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1453 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1454 des_ecb_crypt(&ctx->key3, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1455 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1456 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1457 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1458 des_ecb_crypt(&ctx->key2, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1459 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1460 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1461 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1462 des_ecb_crypt(&ctx->key1, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1463 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1464 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1465 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1466 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1467 return 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1468 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1469 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1470 static gint |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1471 des3_cbc_decrypt(struct _des3_ctx *ctx, const guchar data[], |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1472 size_t len, guchar output[], size_t *outlen) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1473 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1474 int offset = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1475 int i = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1476 int tmp; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1477 guint8 buf[8] = {0,0,0,0,0,0,0,0}; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1478 guint8 link[8]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1479 memcpy(link, ctx->iv, 8); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1480 while (offset + 8 <= len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1481 des_ecb_crypt(&ctx->key3, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1482 data+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1483 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1484 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1485 des_ecb_crypt(&ctx->key2, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1486 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1487 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1488 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1489 des_ecb_crypt(&ctx->key1, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1490 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1491 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1492 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1493 for (i = 0; i < 8; i++) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1494 output[offset + i] ^= link[i]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1495 memcpy(link, data + offset, 8); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1496 offset+=8; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1497 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1498 *outlen = len; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1499 if(offset<len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1500 *outlen += len - offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1501 tmp = offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1502 memset(buf, 0, 8); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1503 i = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1504 while(tmp<len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1505 buf[i++] = data[tmp]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1506 tmp++; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1507 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1508 des_ecb_crypt(&ctx->key3, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1509 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1510 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1511 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1512 des_ecb_crypt(&ctx->key2, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1513 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1514 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1515 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1516 des_ecb_crypt(&ctx->key1, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1517 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1518 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1519 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1520 for (i = 0; i < 8; i++) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1521 output[offset + i] ^= link[i]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1522 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1523 return 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1524 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1525 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1526 static gint |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1527 des3_decrypt(PurpleCipherContext *context, const guchar data[], |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1528 size_t len, guchar output[], size_t *outlen) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1529 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1530 struct _des3_ctx *ctx = purple_cipher_context_get_data(context); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1531 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1532 if (ctx->mode == PURPLE_CIPHER_BATCH_MODE_ECB) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1533 return des3_ecb_decrypt(ctx, data, len, output, outlen); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1534 } else if (ctx->mode == PURPLE_CIPHER_BATCH_MODE_CBC) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1535 return des3_cbc_decrypt(ctx, data, len, output, outlen); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1536 } else { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1537 g_return_val_if_reached(0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1538 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1539 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1540 return 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1541 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1542 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1543 static void |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1544 des3_set_batch(PurpleCipherContext *context, PurpleCipherBatchMode mode) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1545 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1546 struct _des3_ctx *ctx = purple_cipher_context_get_data(context); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1547 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1548 ctx->mode = mode; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1549 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1550 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1551 static PurpleCipherBatchMode |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1552 des3_get_batch(PurpleCipherContext *context) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1553 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1554 struct _des3_ctx *ctx = purple_cipher_context_get_data(context); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1555 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1556 return ctx->mode; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1557 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1558 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1559 static void |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1560 des3_set_iv(PurpleCipherContext *context, guchar *iv, size_t len) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1561 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1562 struct _des3_ctx *ctx; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1563 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1564 g_return_if_fail(len == 8); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1565 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1566 ctx = purple_cipher_context_get_data(context); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1567 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1568 memcpy(ctx->iv, iv, len); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1569 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1570 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1571 static void |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1572 des3_init(PurpleCipherContext *context, gpointer extra) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1573 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1574 struct _des3_ctx *mctx; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1575 mctx = g_new0(struct _des3_ctx, 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1576 purple_cipher_context_set_data(context, mctx); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1577 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1578 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1579 static void |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1580 des3_uninit(PurpleCipherContext *context) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1581 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1582 struct _des3_ctx *des3_context; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1583 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1584 des3_context = purple_cipher_context_get_data(context); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1585 memset(des3_context, 0, sizeof(des3_context)); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1586 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1587 g_free(des3_context); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1588 des3_context = NULL; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1589 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1590 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1591 static PurpleCipherOps DES3Ops = { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1592 NULL, /* Set option */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1593 NULL, /* Get option */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1594 des3_init, /* init */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1595 NULL, /* reset */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1596 des3_uninit, /* uninit */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1597 des3_set_iv, /* set iv */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1598 NULL, /* append */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1599 NULL, /* digest */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1600 des3_encrypt, /* encrypt */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1601 des3_decrypt, /* decrypt */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1602 NULL, /* set salt */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1603 NULL, /* get salt size */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1604 des3_set_key, /* set key */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1605 NULL, /* get key size */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1606 des3_set_batch, /* set batch mode */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1607 des3_get_batch, /* get batch mode */ |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
1608 NULL, /* get block size */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
1609 NULL /* set key with len */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1610 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1611 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1612 /******************************************************************************* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1613 * SHA-1 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1614 ******************************************************************************/ |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
1615 #define SHA1_HMAC_BLOCK_SIZE 64 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1616 #define SHA1_ROTL(X,n) ((((X) << (n)) | ((X) >> (32-(n)))) & 0xFFFFFFFF) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1617 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1618 struct SHA1Context { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1619 guint32 H[5]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1620 guint32 W[80]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1621 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1622 gint lenW; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1623 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1624 guint32 sizeHi; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1625 guint32 sizeLo; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1626 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1627 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1628 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1629 sha1_hash_block(struct SHA1Context *sha1_ctx) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1630 gint i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1631 guint32 A, B, C, D, E, T; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1632 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1633 for(i = 16; i < 80; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1634 sha1_ctx->W[i] = SHA1_ROTL(sha1_ctx->W[i - 3] ^ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1635 sha1_ctx->W[i - 8] ^ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1636 sha1_ctx->W[i - 14] ^ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1637 sha1_ctx->W[i - 16], 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1638 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1639 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1640 A = sha1_ctx->H[0]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1641 B = sha1_ctx->H[1]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1642 C = sha1_ctx->H[2]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1643 D = sha1_ctx->H[3]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1644 E = sha1_ctx->H[4]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1645 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1646 for(i = 0; i < 20; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1647 T = (SHA1_ROTL(A, 5) + (((C ^ D) & B) ^ D) + E + sha1_ctx->W[i] + 0x5A827999) & 0xFFFFFFFF; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1648 E = D; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1649 D = C; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1650 C = SHA1_ROTL(B, 30); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1651 B = A; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1652 A = T; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1653 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1654 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1655 for(i = 20; i < 40; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1656 T = (SHA1_ROTL(A, 5) + (B ^ C ^ D) + E + sha1_ctx->W[i] + 0x6ED9EBA1) & 0xFFFFFFFF; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1657 E = D; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1658 D = C; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1659 C = SHA1_ROTL(B, 30); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1660 B = A; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1661 A = T; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1662 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1663 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1664 for(i = 40; i < 60; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1665 T = (SHA1_ROTL(A, 5) + ((B & C) | (D & (B | C))) + E + sha1_ctx->W[i] + 0x8F1BBCDC) & 0xFFFFFFFF; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1666 E = D; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1667 D = C; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1668 C = SHA1_ROTL(B, 30); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1669 B = A; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1670 A = T; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1671 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1672 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1673 for(i = 60; i < 80; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1674 T = (SHA1_ROTL(A, 5) + (B ^ C ^ D) + E + sha1_ctx->W[i] + 0xCA62C1D6) & 0xFFFFFFFF; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1675 E = D; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1676 D = C; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1677 C = SHA1_ROTL(B, 30); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1678 B = A; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1679 A = T; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1680 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1681 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1682 sha1_ctx->H[0] += A; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1683 sha1_ctx->H[1] += B; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1684 sha1_ctx->H[2] += C; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1685 sha1_ctx->H[3] += D; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1686 sha1_ctx->H[4] += E; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1687 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1688 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1689 static void |
15822 | 1690 sha1_set_opt(PurpleCipherContext *context, const gchar *name, void *value) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1691 struct SHA1Context *ctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1692 |
15822 | 1693 ctx = purple_cipher_context_get_data(context); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1694 |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
23555
diff
changeset
|
1695 if(purple_strequal(name, "sizeHi")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1696 ctx->sizeHi = GPOINTER_TO_INT(value); |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
23555
diff
changeset
|
1697 } else if(purple_strequal(name, "sizeLo")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1698 ctx->sizeLo = GPOINTER_TO_INT(value); |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
23555
diff
changeset
|
1699 } else if(purple_strequal(name, "lenW")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1700 ctx->lenW = GPOINTER_TO_INT(value); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1701 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1702 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1703 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1704 static void * |
15822 | 1705 sha1_get_opt(PurpleCipherContext *context, const gchar *name) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1706 struct SHA1Context *ctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1707 |
15822 | 1708 ctx = purple_cipher_context_get_data(context); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1709 |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
23555
diff
changeset
|
1710 if(purple_strequal(name, "sizeHi")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1711 return GINT_TO_POINTER(ctx->sizeHi); |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
23555
diff
changeset
|
1712 } else if(purple_strequal(name, "sizeLo")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1713 return GINT_TO_POINTER(ctx->sizeLo); |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
23555
diff
changeset
|
1714 } else if(purple_strequal(name, "lenW")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1715 return GINT_TO_POINTER(ctx->lenW); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1716 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1717 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1718 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1719 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1720 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1721 static void |
15822 | 1722 sha1_init(PurpleCipherContext *context, void *extra) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1723 struct SHA1Context *sha1_ctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1724 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1725 sha1_ctx = g_new0(struct SHA1Context, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1726 |
15822 | 1727 purple_cipher_context_set_data(context, sha1_ctx); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1728 |
15822 | 1729 purple_cipher_context_reset(context, extra); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1730 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1731 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1732 static void |
15822 | 1733 sha1_reset(PurpleCipherContext *context, void *extra) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1734 struct SHA1Context *sha1_ctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1735 gint i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1736 |
15822 | 1737 sha1_ctx = purple_cipher_context_get_data(context); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1738 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1739 g_return_if_fail(sha1_ctx); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1740 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1741 sha1_ctx->lenW = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1742 sha1_ctx->sizeHi = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1743 sha1_ctx->sizeLo = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1744 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1745 sha1_ctx->H[0] = 0x67452301; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1746 sha1_ctx->H[1] = 0xEFCDAB89; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1747 sha1_ctx->H[2] = 0x98BADCFE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1748 sha1_ctx->H[3] = 0x10325476; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1749 sha1_ctx->H[4] = 0xC3D2E1F0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1750 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1751 for(i = 0; i < 80; i++) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1752 sha1_ctx->W[i] = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1753 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1754 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1755 static void |
15822 | 1756 sha1_uninit(PurpleCipherContext *context) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1757 struct SHA1Context *sha1_ctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1758 |
15822 | 1759 purple_cipher_context_reset(context, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1760 |
15822 | 1761 sha1_ctx = purple_cipher_context_get_data(context); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1762 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1763 memset(sha1_ctx, 0, sizeof(struct SHA1Context)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1764 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1765 g_free(sha1_ctx); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1766 sha1_ctx = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1767 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1768 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1769 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1770 static void |
15822 | 1771 sha1_append(PurpleCipherContext *context, const guchar *data, size_t len) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1772 struct SHA1Context *sha1_ctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1773 gint i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1774 |
15822 | 1775 sha1_ctx = purple_cipher_context_get_data(context); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1776 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1777 g_return_if_fail(sha1_ctx); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1778 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1779 for(i = 0; i < len; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1780 sha1_ctx->W[sha1_ctx->lenW / 4] <<= 8; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1781 sha1_ctx->W[sha1_ctx->lenW / 4] |= data[i]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1782 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1783 if((++sha1_ctx->lenW) % 64 == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1784 sha1_hash_block(sha1_ctx); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1785 sha1_ctx->lenW = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1786 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1787 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1788 sha1_ctx->sizeLo += 8; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1789 sha1_ctx->sizeHi += (sha1_ctx->sizeLo < 8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1790 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1791 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1792 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1793 static gboolean |
15822 | 1794 sha1_digest(PurpleCipherContext *context, size_t in_len, guchar digest[20], |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1795 size_t *out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1796 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1797 struct SHA1Context *sha1_ctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1798 guchar pad0x80 = 0x80, pad0x00 = 0x00; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1799 guchar padlen[8]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1800 gint i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1801 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1802 g_return_val_if_fail(in_len >= 20, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1803 |
15822 | 1804 sha1_ctx = purple_cipher_context_get_data(context); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1805 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1806 g_return_val_if_fail(sha1_ctx, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1807 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1808 padlen[0] = (guchar)((sha1_ctx->sizeHi >> 24) & 255); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1809 padlen[1] = (guchar)((sha1_ctx->sizeHi >> 16) & 255); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1810 padlen[2] = (guchar)((sha1_ctx->sizeHi >> 8) & 255); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1811 padlen[3] = (guchar)((sha1_ctx->sizeHi >> 0) & 255); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1812 padlen[4] = (guchar)((sha1_ctx->sizeLo >> 24) & 255); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1813 padlen[5] = (guchar)((sha1_ctx->sizeLo >> 16) & 255); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1814 padlen[6] = (guchar)((sha1_ctx->sizeLo >> 8) & 255); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1815 padlen[7] = (guchar)((sha1_ctx->sizeLo >> 0) & 255); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1816 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1817 /* pad with a 1, then zeroes, then length */ |
15822 | 1818 purple_cipher_context_append(context, &pad0x80, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1819 while(sha1_ctx->lenW != 56) |
15822 | 1820 purple_cipher_context_append(context, &pad0x00, 1); |
1821 purple_cipher_context_append(context, padlen, 8); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1822 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1823 for(i = 0; i < 20; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1824 digest[i] = (guchar)(sha1_ctx->H[i / 4] >> 24); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1825 sha1_ctx->H[i / 4] <<= 8; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1826 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1827 |
15822 | 1828 purple_cipher_context_reset(context, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1829 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1830 if(out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1831 *out_len = 20; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1832 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1833 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1834 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1835 |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
1836 static size_t |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
1837 sha1_get_block_size(PurpleCipherContext *context) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
1838 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
1839 /* This does not change (in this case) */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
1840 return SHA1_HMAC_BLOCK_SIZE; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
1841 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
1842 |
15822 | 1843 static PurpleCipherOps SHA1Ops = { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1844 sha1_set_opt, /* Set Option */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1845 sha1_get_opt, /* Get Option */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1846 sha1_init, /* init */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1847 sha1_reset, /* reset */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1848 sha1_uninit, /* uninit */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1849 NULL, /* set iv */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1850 sha1_append, /* append */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1851 sha1_digest, /* digest */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1852 NULL, /* encrypt */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1853 NULL, /* decrypt */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1854 NULL, /* set salt */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1855 NULL, /* get salt size */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1856 NULL, /* set key */ |
16668
07cf49a0f404
I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents:
15822
diff
changeset
|
1857 NULL, /* get key size */ |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1858 NULL, /* set batch mode */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1859 NULL, /* get batch mode */ |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
1860 sha1_get_block_size, /* get block size */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
1861 NULL /* set key with len */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1862 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1863 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1864 /******************************************************************************* |
16997
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1865 * RC4 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1866 ******************************************************************************/ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1867 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1868 struct RC4Context { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1869 guchar state[256]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1870 guchar x; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1871 guchar y; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1872 gint key_len; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1873 }; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1874 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1875 static void |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1876 rc4_init(PurpleCipherContext *context, void *extra) { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1877 struct RC4Context *rc4_ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1878 rc4_ctx = g_new0(struct RC4Context, 1); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1879 purple_cipher_context_set_data(context, rc4_ctx); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1880 purple_cipher_context_reset(context, extra); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1881 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1882 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1883 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1884 static void |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1885 rc4_reset(PurpleCipherContext *context, void *extra) { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1886 struct RC4Context *rc4_ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1887 guint i; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1888 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1889 rc4_ctx = purple_cipher_context_get_data(context); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1890 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1891 g_return_if_fail(rc4_ctx); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1892 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1893 for(i = 0; i < 256; i++) |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1894 rc4_ctx->state[i] = i; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1895 rc4_ctx->x = 0; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1896 rc4_ctx->y = 0; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1897 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1898 /* default is 5 bytes (40bit key) */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1899 rc4_ctx->key_len = 5; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1900 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1901 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1902 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1903 static void |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1904 rc4_uninit(PurpleCipherContext *context) { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1905 struct RC4Context *rc4_ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1906 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1907 rc4_ctx = purple_cipher_context_get_data(context); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1908 memset(rc4_ctx, 0, sizeof(rc4_ctx)); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1909 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1910 g_free(rc4_ctx); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1911 rc4_ctx = NULL; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1912 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1913 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1914 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1915 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1916 static void |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1917 rc4_set_key (PurpleCipherContext *context, const guchar * key) { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1918 struct RC4Context *ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1919 guchar *state; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1920 guchar temp_swap; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1921 guchar x, y; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1922 guint i; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1923 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1924 ctx = purple_cipher_context_get_data(context); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1925 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1926 x = 0; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1927 y = 0; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1928 state = &ctx->state[0]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1929 for(i = 0; i < 256; i++) |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1930 { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1931 y = (key[x] + state[i] + y) % 256; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1932 temp_swap = state[i]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1933 state[i] = state[y]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1934 state[y] = temp_swap; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1935 x = (x + 1) % ctx->key_len; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1936 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1937 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1938 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1939 static void |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1940 rc4_set_opt(PurpleCipherContext *context, const gchar *name, void *value) { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1941 struct RC4Context *ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1942 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1943 ctx = purple_cipher_context_get_data(context); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1944 |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
23555
diff
changeset
|
1945 if(purple_strequal(name, "key_len")) { |
16997
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1946 ctx->key_len = GPOINTER_TO_INT(value); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1947 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1948 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1949 |
25924
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25894
diff
changeset
|
1950 static size_t |
16997
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1951 rc4_get_key_size (PurpleCipherContext *context) |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1952 { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1953 struct RC4Context *ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1954 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1955 g_return_val_if_fail(context, -1); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1956 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1957 ctx = purple_cipher_context_get_data(context); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1958 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1959 g_return_val_if_fail(ctx, -1); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1960 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1961 return ctx->key_len; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1962 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1963 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1964 static void * |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1965 rc4_get_opt(PurpleCipherContext *context, const gchar *name) { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1966 struct RC4Context *ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1967 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1968 ctx = purple_cipher_context_get_data(context); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1969 |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
23555
diff
changeset
|
1970 if(purple_strequal(name, "key_len")) { |
16997
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1971 return GINT_TO_POINTER(ctx->key_len); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1972 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1973 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1974 return NULL; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1975 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1976 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1977 static gint |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1978 rc4_encrypt(PurpleCipherContext *context, const guchar data[], |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1979 size_t len, guchar output[], size_t *outlen) { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1980 struct RC4Context *ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1981 guchar temp_swap; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1982 guchar x, y, z; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1983 guchar *state; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1984 guint i; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1985 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1986 ctx = purple_cipher_context_get_data(context); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1987 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1988 x = ctx->x; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1989 y = ctx->y; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1990 state = &ctx->state[0]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1991 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1992 for(i = 0; i < len; i++) |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1993 { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1994 x = (x + 1) % 256; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1995 y = (state[x] + y) % 256; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1996 temp_swap = state[x]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1997 state[x] = state[y]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1998 state[y] = temp_swap; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
1999 z = state[x] + (state[y]) % 256; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2000 output[i] = data[i] ^ state[z]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2001 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2002 ctx->x = x; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2003 ctx->y = y; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2004 if(outlen) |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2005 *outlen = len; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2006 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2007 return 0; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2008 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2009 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2010 static PurpleCipherOps RC4Ops = { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2011 rc4_set_opt, /* Set Option */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2012 rc4_get_opt, /* Get Option */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2013 rc4_init, /* init */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2014 rc4_reset, /* reset */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2015 rc4_uninit, /* uninit */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2016 NULL, /* set iv */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2017 NULL, /* append */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2018 NULL, /* digest */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2019 rc4_encrypt, /* encrypt */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2020 NULL, /* decrypt */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2021 NULL, /* set salt */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2022 NULL, /* get salt size */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2023 rc4_set_key, /* set key */ |
17016
ba8de77ec9b8
Add padding to the RC4Ops struct to fix a compiler warning.
Richard Laager <rlaager@wiktel.com>
parents:
16997
diff
changeset
|
2024 rc4_get_key_size, /* get key size */ |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2025 NULL, /* set batch mode */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2026 NULL, /* get batch mode */ |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2027 NULL, /* get block size */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2028 NULL /* set key with len */ |
16997
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2029 }; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2030 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2031 /******************************************************************************* |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2032 * Structs |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2033 ******************************************************************************/ |
15822 | 2034 struct _PurpleCipher { |
17385
103a37dd9398
applied changes from b0f6005b1330af13bce0bcb189a2c887036b5ea3
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17082
diff
changeset
|
2035 gchar *name; /**< Internal name - used for searching */ |
103a37dd9398
applied changes from b0f6005b1330af13bce0bcb189a2c887036b5ea3
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17082
diff
changeset
|
2036 PurpleCipherOps *ops; /**< Operations supported by this cipher */ |
103a37dd9398
applied changes from b0f6005b1330af13bce0bcb189a2c887036b5ea3
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17082
diff
changeset
|
2037 guint ref; /**< Reference count */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2038 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2039 |
15822 | 2040 struct _PurpleCipherContext { |
17385
103a37dd9398
applied changes from b0f6005b1330af13bce0bcb189a2c887036b5ea3
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17082
diff
changeset
|
2041 PurpleCipher *cipher; /**< Cipher this context is under */ |
103a37dd9398
applied changes from b0f6005b1330af13bce0bcb189a2c887036b5ea3
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17082
diff
changeset
|
2042 gpointer data; /**< Internal cipher state data */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2043 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2044 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2045 /****************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2046 * Globals |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2047 *****************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2048 static GList *ciphers = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2049 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2050 /****************************************************************************** |
15822 | 2051 * PurpleCipher API |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2052 *****************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2053 const gchar * |
15822 | 2054 purple_cipher_get_name(PurpleCipher *cipher) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2055 g_return_val_if_fail(cipher, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2056 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2057 return cipher->name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2058 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2059 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2060 guint |
15822 | 2061 purple_cipher_get_capabilities(PurpleCipher *cipher) { |
2062 PurpleCipherOps *ops = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2063 guint caps = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2064 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2065 g_return_val_if_fail(cipher, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2066 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2067 ops = cipher->ops; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2068 g_return_val_if_fail(ops, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2069 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2070 if(ops->set_option) |
15822 | 2071 caps |= PURPLE_CIPHER_CAPS_SET_OPT; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2072 if(ops->get_option) |
15822 | 2073 caps |= PURPLE_CIPHER_CAPS_GET_OPT; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2074 if(ops->init) |
15822 | 2075 caps |= PURPLE_CIPHER_CAPS_INIT; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2076 if(ops->reset) |
15822 | 2077 caps |= PURPLE_CIPHER_CAPS_RESET; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2078 if(ops->uninit) |
15822 | 2079 caps |= PURPLE_CIPHER_CAPS_UNINIT; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2080 if(ops->set_iv) |
15822 | 2081 caps |= PURPLE_CIPHER_CAPS_SET_IV; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2082 if(ops->append) |
15822 | 2083 caps |= PURPLE_CIPHER_CAPS_APPEND; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2084 if(ops->digest) |
15822 | 2085 caps |= PURPLE_CIPHER_CAPS_DIGEST; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2086 if(ops->encrypt) |
15822 | 2087 caps |= PURPLE_CIPHER_CAPS_ENCRYPT; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2088 if(ops->decrypt) |
15822 | 2089 caps |= PURPLE_CIPHER_CAPS_DECRYPT; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2090 if(ops->set_salt) |
15822 | 2091 caps |= PURPLE_CIPHER_CAPS_SET_SALT; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2092 if(ops->get_salt_size) |
15822 | 2093 caps |= PURPLE_CIPHER_CAPS_GET_SALT_SIZE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2094 if(ops->set_key) |
15822 | 2095 caps |= PURPLE_CIPHER_CAPS_SET_KEY; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2096 if(ops->get_key_size) |
15822 | 2097 caps |= PURPLE_CIPHER_CAPS_GET_KEY_SIZE; |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2098 if(ops->set_batch_mode) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2099 caps |= PURPLE_CIPHER_CAPS_SET_BATCH_MODE; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2100 if(ops->get_batch_mode) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2101 caps |= PURPLE_CIPHER_CAPS_GET_BATCH_MODE; |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2102 if(ops->get_block_size) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2103 caps |= PURPLE_CIPHER_CAPS_GET_BLOCK_SIZE; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2104 if(ops->set_key_with_len) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2105 caps |= PURPLE_CIPHER_CAPS_SET_KEY_WITH_LEN; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2106 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2107 return caps; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2108 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2109 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2110 gboolean |
15822 | 2111 purple_cipher_digest_region(const gchar *name, const guchar *data, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2112 size_t data_len, size_t in_len, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2113 guchar digest[], size_t *out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2114 { |
15822 | 2115 PurpleCipher *cipher; |
2116 PurpleCipherContext *context; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2117 gboolean ret = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2118 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2119 g_return_val_if_fail(name, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2120 g_return_val_if_fail(data, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2121 |
15822 | 2122 cipher = purple_ciphers_find_cipher(name); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2123 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2124 g_return_val_if_fail(cipher, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2125 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2126 if(!cipher->ops->append || !cipher->ops->digest) { |
15822 | 2127 purple_debug_info("cipher", "purple_cipher_region failed: " |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2128 "the %s cipher does not support appending and or " |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2129 "digesting.", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2130 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2131 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2132 |
15822 | 2133 context = purple_cipher_context_new(cipher, NULL); |
2134 purple_cipher_context_append(context, data, data_len); | |
2135 ret = purple_cipher_context_digest(context, in_len, digest, out_len); | |
2136 purple_cipher_context_destroy(context); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2137 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2138 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2139 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2140 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2141 /****************************************************************************** |
15822 | 2142 * PurpleCiphers API |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2143 *****************************************************************************/ |
15822 | 2144 PurpleCipher * |
2145 purple_ciphers_find_cipher(const gchar *name) { | |
2146 PurpleCipher *cipher; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2147 GList *l; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2148 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2149 g_return_val_if_fail(name, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2150 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2151 for(l = ciphers; l; l = l->next) { |
15822 | 2152 cipher = PURPLE_CIPHER(l->data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2153 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2154 if(!g_ascii_strcasecmp(cipher->name, name)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2155 return cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2156 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2157 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2158 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2159 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2160 |
15822 | 2161 PurpleCipher * |
2162 purple_ciphers_register_cipher(const gchar *name, PurpleCipherOps *ops) { | |
2163 PurpleCipher *cipher = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2164 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2165 g_return_val_if_fail(name, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2166 g_return_val_if_fail(ops, NULL); |
15822 | 2167 g_return_val_if_fail(!purple_ciphers_find_cipher(name), NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2168 |
15822 | 2169 cipher = g_new0(PurpleCipher, 1); |
2170 PURPLE_DBUS_REGISTER_POINTER(cipher, PurpleCipher); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2171 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2172 cipher->name = g_strdup(name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2173 cipher->ops = ops; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2174 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2175 ciphers = g_list_append(ciphers, cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2176 |
15822 | 2177 purple_signal_emit(purple_ciphers_get_handle(), "cipher-added", cipher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2178 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2179 return cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2180 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2181 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2182 gboolean |
15822 | 2183 purple_ciphers_unregister_cipher(PurpleCipher *cipher) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2184 g_return_val_if_fail(cipher, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2185 g_return_val_if_fail(cipher->ref == 0, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2186 |
15822 | 2187 purple_signal_emit(purple_ciphers_get_handle(), "cipher-removed", cipher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2188 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2189 ciphers = g_list_remove(ciphers, cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2190 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2191 g_free(cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2192 |
15822 | 2193 PURPLE_DBUS_UNREGISTER_POINTER(cipher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2194 g_free(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2195 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2196 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2197 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2198 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2199 GList * |
15822 | 2200 purple_ciphers_get_ciphers() { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2201 return ciphers; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2202 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2203 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2204 /****************************************************************************** |
15822 | 2205 * PurpleCipher Subsystem API |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2206 *****************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2207 gpointer |
15822 | 2208 purple_ciphers_get_handle() { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2209 static gint handle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2210 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2211 return &handle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2212 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2213 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2214 void |
15822 | 2215 purple_ciphers_init() { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2216 gpointer handle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2217 |
15822 | 2218 handle = purple_ciphers_get_handle(); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2219 |
15822 | 2220 purple_signal_register(handle, "cipher-added", |
2221 purple_marshal_VOID__POINTER, NULL, 1, | |
2222 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
2223 PURPLE_SUBTYPE_CIPHER)); | |
2224 purple_signal_register(handle, "cipher-removed", | |
2225 purple_marshal_VOID__POINTER, NULL, 1, | |
2226 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
2227 PURPLE_SUBTYPE_CIPHER)); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2228 |
15822 | 2229 purple_ciphers_register_cipher("md5", &MD5Ops); |
2230 purple_ciphers_register_cipher("sha1", &SHA1Ops); | |
2231 purple_ciphers_register_cipher("md4", &MD4Ops); | |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2232 purple_ciphers_register_cipher("hmac", &HMACOps); |
15822 | 2233 purple_ciphers_register_cipher("des", &DESOps); |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2234 purple_ciphers_register_cipher("des3", &DES3Ops); |
16997
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2235 purple_ciphers_register_cipher("rc4", &RC4Ops); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2236 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2237 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2238 void |
15822 | 2239 purple_ciphers_uninit() { |
2240 PurpleCipher *cipher; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2241 GList *l, *ll; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2242 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2243 for(l = ciphers; l; l = ll) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2244 ll = l->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2245 |
15822 | 2246 cipher = PURPLE_CIPHER(l->data); |
2247 purple_ciphers_unregister_cipher(cipher); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2248 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2249 ciphers = g_list_remove(ciphers, cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2250 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2251 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2252 g_list_free(ciphers); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2253 |
15822 | 2254 purple_signals_unregister_by_instance(purple_ciphers_get_handle()); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2255 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2256 /****************************************************************************** |
15822 | 2257 * PurpleCipherContext API |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2258 *****************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2259 void |
15822 | 2260 purple_cipher_context_set_option(PurpleCipherContext *context, const gchar *name, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2261 gpointer value) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2262 { |
15822 | 2263 PurpleCipher *cipher = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2264 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2265 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2266 g_return_if_fail(name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2267 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2268 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2269 g_return_if_fail(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2270 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2271 if(cipher->ops && cipher->ops->set_option) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2272 cipher->ops->set_option(context, name, value); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2273 else |
15822 | 2274 purple_debug_info("cipher", "the %s cipher does not support the " |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2275 "set_option operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2276 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2277 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2278 gpointer |
15822 | 2279 purple_cipher_context_get_option(PurpleCipherContext *context, const gchar *name) { |
2280 PurpleCipher *cipher = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2281 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2282 g_return_val_if_fail(context, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2283 g_return_val_if_fail(name, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2284 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2285 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2286 g_return_val_if_fail(cipher, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2287 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2288 if(cipher->ops && cipher->ops->get_option) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2289 return cipher->ops->get_option(context, name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2290 else { |
15822 | 2291 purple_debug_info("cipher", "the %s cipher does not support the " |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2292 "get_option operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2293 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2294 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2295 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2296 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2297 |
15822 | 2298 PurpleCipherContext * |
2299 purple_cipher_context_new(PurpleCipher *cipher, void *extra) { | |
2300 PurpleCipherContext *context = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2301 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2302 g_return_val_if_fail(cipher, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2303 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2304 cipher->ref++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2305 |
15822 | 2306 context = g_new0(PurpleCipherContext, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2307 context->cipher = cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2308 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2309 if(cipher->ops->init) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2310 cipher->ops->init(context, extra); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2311 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2312 return context; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2313 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2314 |
15822 | 2315 PurpleCipherContext * |
2316 purple_cipher_context_new_by_name(const gchar *name, void *extra) { | |
2317 PurpleCipher *cipher; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2318 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2319 g_return_val_if_fail(name, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2320 |
15822 | 2321 cipher = purple_ciphers_find_cipher(name); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2322 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2323 g_return_val_if_fail(cipher, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2324 |
15822 | 2325 return purple_cipher_context_new(cipher, extra); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2326 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2327 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2328 void |
15822 | 2329 purple_cipher_context_reset(PurpleCipherContext *context, void *extra) { |
2330 PurpleCipher *cipher = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2331 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2332 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2333 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2334 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2335 g_return_if_fail(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2336 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2337 if(cipher->ops && cipher->ops->reset) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2338 context->cipher->ops->reset(context, extra); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2339 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2340 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2341 void |
15822 | 2342 purple_cipher_context_destroy(PurpleCipherContext *context) { |
2343 PurpleCipher *cipher = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2344 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2345 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2346 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2347 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2348 g_return_if_fail(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2349 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2350 cipher->ref--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2351 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2352 if(cipher->ops && cipher->ops->uninit) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2353 cipher->ops->uninit(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2354 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2355 memset(context, 0, sizeof(context)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2356 g_free(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2357 context = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2358 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2359 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2360 void |
15822 | 2361 purple_cipher_context_set_iv(PurpleCipherContext *context, guchar *iv, size_t len) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2362 { |
15822 | 2363 PurpleCipher *cipher = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2364 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2365 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2366 g_return_if_fail(iv); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2367 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2368 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2369 g_return_if_fail(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2370 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2371 if(cipher->ops && cipher->ops->set_iv) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2372 cipher->ops->set_iv(context, iv, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2373 else |
15822 | 2374 purple_debug_info("cipher", "the %s cipher does not support the set" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2375 "initialization vector operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2376 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2377 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2378 void |
15822 | 2379 purple_cipher_context_append(PurpleCipherContext *context, const guchar *data, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2380 size_t len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2381 { |
15822 | 2382 PurpleCipher *cipher = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2383 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2384 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2385 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2386 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2387 g_return_if_fail(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2388 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2389 if(cipher->ops && cipher->ops->append) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2390 cipher->ops->append(context, data, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2391 else |
15822 | 2392 purple_debug_info("cipher", "the %s cipher does not support the append " |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2393 "operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2394 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2395 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2396 gboolean |
15822 | 2397 purple_cipher_context_digest(PurpleCipherContext *context, size_t in_len, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2398 guchar digest[], size_t *out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2399 { |
15822 | 2400 PurpleCipher *cipher = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2401 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2402 g_return_val_if_fail(context, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2403 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2404 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2405 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2406 if(cipher->ops && cipher->ops->digest) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2407 return cipher->ops->digest(context, in_len, digest, out_len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2408 else { |
15822 | 2409 purple_debug_info("cipher", "the %s cipher does not support the digest " |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2410 "operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2411 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2412 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2413 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2414 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2415 gboolean |
15822 | 2416 purple_cipher_context_digest_to_str(PurpleCipherContext *context, size_t in_len, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2417 gchar digest_s[], size_t *out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2418 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2419 /* 8k is a bit excessive, will tweak later. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2420 guchar digest[BUF_LEN * 4]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2421 gint n = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2422 size_t dlen = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2423 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2424 g_return_val_if_fail(context, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2425 g_return_val_if_fail(digest_s, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2426 |
15822 | 2427 if(!purple_cipher_context_digest(context, sizeof(digest), digest, &dlen)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2428 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2429 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2430 /* in_len must be greater than dlen * 2 so we have room for the NUL. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2431 if(in_len <= dlen * 2) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2432 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2433 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2434 for(n = 0; n < dlen; n++) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2435 sprintf(digest_s + (n * 2), "%02x", digest[n]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2436 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2437 digest_s[n * 2] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2438 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2439 if(out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2440 *out_len = dlen * 2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2441 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2442 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2443 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2444 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2445 gint |
15822 | 2446 purple_cipher_context_encrypt(PurpleCipherContext *context, const guchar data[], |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2447 size_t len, guchar output[], size_t *outlen) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2448 { |
15822 | 2449 PurpleCipher *cipher = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2450 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2451 g_return_val_if_fail(context, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2452 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2453 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2454 g_return_val_if_fail(cipher, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2455 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2456 if(cipher->ops && cipher->ops->encrypt) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2457 return cipher->ops->encrypt(context, data, len, output, outlen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2458 else { |
15822 | 2459 purple_debug_info("cipher", "the %s cipher does not support the encrypt" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2460 "operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2461 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2462 if(outlen) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2463 *outlen = -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2464 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2465 return -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2466 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2467 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2468 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2469 gint |
15822 | 2470 purple_cipher_context_decrypt(PurpleCipherContext *context, const guchar data[], |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2471 size_t len, guchar output[], size_t *outlen) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2472 { |
15822 | 2473 PurpleCipher *cipher = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2474 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2475 g_return_val_if_fail(context, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2476 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2477 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2478 g_return_val_if_fail(cipher, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2479 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2480 if(cipher->ops && cipher->ops->decrypt) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2481 return cipher->ops->decrypt(context, data, len, output, outlen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2482 else { |
15822 | 2483 purple_debug_info("cipher", "the %s cipher does not support the decrypt" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2484 "operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2485 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2486 if(outlen) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2487 *outlen = -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2488 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2489 return -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2490 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2491 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2492 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2493 void |
15822 | 2494 purple_cipher_context_set_salt(PurpleCipherContext *context, guchar *salt) { |
2495 PurpleCipher *cipher = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2496 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2497 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2498 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2499 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2500 g_return_if_fail(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2501 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2502 if(cipher->ops && cipher->ops->set_salt) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2503 cipher->ops->set_salt(context, salt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2504 else |
15822 | 2505 purple_debug_info("cipher", "the %s cipher does not support the " |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2506 "set_salt operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2507 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2508 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2509 size_t |
15822 | 2510 purple_cipher_context_get_salt_size(PurpleCipherContext *context) { |
2511 PurpleCipher *cipher = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2512 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2513 g_return_val_if_fail(context, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2514 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2515 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2516 g_return_val_if_fail(cipher, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2517 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2518 if(cipher->ops && cipher->ops->get_salt_size) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2519 return cipher->ops->get_salt_size(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2520 else { |
15822 | 2521 purple_debug_info("cipher", "the %s cipher does not support the " |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2522 "get_salt_size operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2523 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2524 return -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2525 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2526 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2527 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2528 void |
15822 | 2529 purple_cipher_context_set_key(PurpleCipherContext *context, const guchar *key) { |
2530 PurpleCipher *cipher = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2531 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2532 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2533 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2534 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2535 g_return_if_fail(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2536 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2537 if(cipher->ops && cipher->ops->set_key) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2538 cipher->ops->set_key(context, key); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2539 else |
15822 | 2540 purple_debug_info("cipher", "the %s cipher does not support the " |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2541 "set_key operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2542 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2543 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2544 size_t |
15822 | 2545 purple_cipher_context_get_key_size(PurpleCipherContext *context) { |
2546 PurpleCipher *cipher = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2547 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2548 g_return_val_if_fail(context, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2549 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2550 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2551 g_return_val_if_fail(cipher, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2552 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2553 if(cipher->ops && cipher->ops->get_key_size) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2554 return cipher->ops->get_key_size(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2555 else { |
15822 | 2556 purple_debug_info("cipher", "the %s cipher does not support the " |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2557 "get_key_size operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2558 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2559 return -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2560 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2561 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2562 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2563 void |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2564 purple_cipher_context_set_batch_mode(PurpleCipherContext *context, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2565 PurpleCipherBatchMode mode) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2566 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2567 PurpleCipher *cipher = NULL; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2568 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2569 g_return_if_fail(context); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2570 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2571 cipher = context->cipher; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2572 g_return_if_fail(cipher); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2573 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2574 if(cipher->ops && cipher->ops->set_batch_mode) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2575 cipher->ops->set_batch_mode(context, mode); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2576 else |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2577 purple_debug_info("cipher", "The %s cipher does not support the " |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2578 "set_batch_mode operation\n", cipher->name); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2579 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2580 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2581 PurpleCipherBatchMode |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2582 purple_cipher_context_get_batch_mode(PurpleCipherContext *context) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2583 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2584 PurpleCipher *cipher = NULL; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2585 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2586 g_return_val_if_fail(context, -1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2587 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2588 cipher = context->cipher; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2589 g_return_val_if_fail(cipher, -1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2590 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2591 if(cipher->ops && cipher->ops->get_batch_mode) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2592 return cipher->ops->get_batch_mode(context); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2593 else { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2594 purple_debug_info("cipher", "The %s cipher does not support the " |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2595 "get_batch_mode operation\n", cipher->name); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2596 return -1; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2597 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2598 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2599 |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2600 size_t |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2601 purple_cipher_context_get_block_size(PurpleCipherContext *context) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2602 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2603 PurpleCipher *cipher = NULL; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2604 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2605 g_return_val_if_fail(context, -1); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2606 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2607 cipher = context->cipher; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2608 g_return_val_if_fail(cipher, -1); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2609 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2610 if(cipher->ops && cipher->ops->get_block_size) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2611 return cipher->ops->get_block_size(context); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2612 else { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2613 purple_debug_info("cipher", "The %s cipher does not support the " |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2614 "get_block_size operation\n", cipher->name); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2615 return -1; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2616 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2617 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2618 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2619 void |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2620 purple_cipher_context_set_key_with_len(PurpleCipherContext *context, |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2621 const guchar *key, size_t len) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2622 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2623 PurpleCipher *cipher = NULL; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2624 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2625 g_return_if_fail(context); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2626 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2627 cipher = context->cipher; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2628 g_return_if_fail(cipher); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2629 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2630 if(cipher->ops && cipher->ops->set_key_with_len) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2631 cipher->ops->set_key_with_len(context, key, len); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2632 else |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2633 purple_debug_info("cipher", "The %s cipher does not support the " |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2634 "set_key_with_len operation\n", cipher->name); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2635 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2636 |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2637 void |
15822 | 2638 purple_cipher_context_set_data(PurpleCipherContext *context, gpointer data) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2639 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2640 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2641 context->data = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2642 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2643 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2644 gpointer |
15822 | 2645 purple_cipher_context_get_data(PurpleCipherContext *context) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2646 g_return_val_if_fail(context, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2647 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2648 return context->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2649 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2650 |
15822 | 2651 gchar *purple_cipher_http_digest_calculate_session_key( |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2652 const gchar *algorithm, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2653 const gchar *username, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2654 const gchar *realm, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2655 const gchar *password, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2656 const gchar *nonce, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2657 const gchar *client_nonce) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2658 { |
15822 | 2659 PurpleCipher *cipher; |
2660 PurpleCipherContext *context; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2661 gchar hash[33]; /* We only support MD5. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2662 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2663 g_return_val_if_fail(username != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2664 g_return_val_if_fail(realm != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2665 g_return_val_if_fail(password != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2666 g_return_val_if_fail(nonce != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2667 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2668 /* Check for a supported algorithm. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2669 g_return_val_if_fail(algorithm == NULL || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2670 *algorithm == '\0' || |
17082
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17016
diff
changeset
|
2671 g_ascii_strcasecmp(algorithm, "MD5") || |
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17016
diff
changeset
|
2672 g_ascii_strcasecmp(algorithm, "MD5-sess"), NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2673 |
15822 | 2674 cipher = purple_ciphers_find_cipher("md5"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2675 g_return_val_if_fail(cipher != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2676 |
15822 | 2677 context = purple_cipher_context_new(cipher, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2678 |
15822 | 2679 purple_cipher_context_append(context, (guchar *)username, strlen(username)); |
2680 purple_cipher_context_append(context, (guchar *)":", 1); | |
2681 purple_cipher_context_append(context, (guchar *)realm, strlen(realm)); | |
2682 purple_cipher_context_append(context, (guchar *)":", 1); | |
2683 purple_cipher_context_append(context, (guchar *)password, strlen(password)); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2684 |
17082
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17016
diff
changeset
|
2685 if (algorithm != NULL && !g_ascii_strcasecmp(algorithm, "MD5-sess")) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2686 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2687 guchar digest[16]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2688 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2689 if (client_nonce == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2690 { |
15822 | 2691 purple_cipher_context_destroy(context); |
19654
941965d6fd88
Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17385
diff
changeset
|
2692 purple_debug_error("cipher", "Required client_nonce missing for MD5-sess digest calculation.\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2693 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2694 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2695 |
15822 | 2696 purple_cipher_context_digest(context, sizeof(digest), digest, NULL); |
2697 purple_cipher_context_destroy(context); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2698 |
15822 | 2699 context = purple_cipher_context_new(cipher, NULL); |
2700 purple_cipher_context_append(context, digest, sizeof(digest)); | |
2701 purple_cipher_context_append(context, (guchar *)":", 1); | |
2702 purple_cipher_context_append(context, (guchar *)nonce, strlen(nonce)); | |
2703 purple_cipher_context_append(context, (guchar *)":", 1); | |
2704 purple_cipher_context_append(context, (guchar *)client_nonce, strlen(client_nonce)); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2705 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2706 |
15822 | 2707 purple_cipher_context_digest_to_str(context, sizeof(hash), hash, NULL); |
2708 purple_cipher_context_destroy(context); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2709 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2710 return g_strdup(hash); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2711 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2712 |
15822 | 2713 gchar *purple_cipher_http_digest_calculate_response( |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2714 const gchar *algorithm, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2715 const gchar *method, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2716 const gchar *digest_uri, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2717 const gchar *qop, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2718 const gchar *entity, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2719 const gchar *nonce, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2720 const gchar *nonce_count, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2721 const gchar *client_nonce, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2722 const gchar *session_key) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2723 { |
15822 | 2724 PurpleCipher *cipher; |
2725 PurpleCipherContext *context; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2726 static gchar hash2[33]; /* We only support MD5. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2727 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2728 g_return_val_if_fail(method != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2729 g_return_val_if_fail(digest_uri != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2730 g_return_val_if_fail(nonce != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2731 g_return_val_if_fail(session_key != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2732 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2733 /* Check for a supported algorithm. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2734 g_return_val_if_fail(algorithm == NULL || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2735 *algorithm == '\0' || |
17082
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17016
diff
changeset
|
2736 g_ascii_strcasecmp(algorithm, "MD5") || |
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17016
diff
changeset
|
2737 g_ascii_strcasecmp(algorithm, "MD5-sess"), NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2738 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2739 /* Check for a supported "quality of protection". */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2740 g_return_val_if_fail(qop == NULL || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2741 *qop == '\0' || |
17082
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17016
diff
changeset
|
2742 g_ascii_strcasecmp(qop, "auth") || |
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17016
diff
changeset
|
2743 g_ascii_strcasecmp(qop, "auth-int"), NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2744 |
15822 | 2745 cipher = purple_ciphers_find_cipher("md5"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2746 g_return_val_if_fail(cipher != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2747 |
15822 | 2748 context = purple_cipher_context_new(cipher, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2749 |
15822 | 2750 purple_cipher_context_append(context, (guchar *)method, strlen(method)); |
2751 purple_cipher_context_append(context, (guchar *)":", 1); | |
2752 purple_cipher_context_append(context, (guchar *)digest_uri, strlen(digest_uri)); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2753 |
17082
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17016
diff
changeset
|
2754 if (qop != NULL && !g_ascii_strcasecmp(qop, "auth-int")) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2755 { |
15822 | 2756 PurpleCipherContext *context2; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2757 gchar entity_hash[33]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2758 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2759 if (entity == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2760 { |
15822 | 2761 purple_cipher_context_destroy(context); |
19654
941965d6fd88
Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17385
diff
changeset
|
2762 purple_debug_error("cipher", "Required entity missing for auth-int digest calculation.\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2763 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2764 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2765 |
15822 | 2766 context2 = purple_cipher_context_new(cipher, NULL); |
2767 purple_cipher_context_append(context2, (guchar *)entity, strlen(entity)); | |
2768 purple_cipher_context_digest_to_str(context2, sizeof(entity_hash), entity_hash, NULL); | |
2769 purple_cipher_context_destroy(context2); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2770 |
15822 | 2771 purple_cipher_context_append(context, (guchar *)":", 1); |
2772 purple_cipher_context_append(context, (guchar *)entity_hash, strlen(entity_hash)); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2773 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2774 |
15822 | 2775 purple_cipher_context_digest_to_str(context, sizeof(hash2), hash2, NULL); |
2776 purple_cipher_context_destroy(context); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2777 |
15822 | 2778 context = purple_cipher_context_new(cipher, NULL); |
2779 purple_cipher_context_append(context, (guchar *)session_key, strlen(session_key)); | |
2780 purple_cipher_context_append(context, (guchar *)":", 1); | |
2781 purple_cipher_context_append(context, (guchar *)nonce, strlen(nonce)); | |
2782 purple_cipher_context_append(context, (guchar *)":", 1); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2783 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2784 if (qop != NULL && *qop != '\0') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2785 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2786 if (nonce_count == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2787 { |
15822 | 2788 purple_cipher_context_destroy(context); |
19654
941965d6fd88
Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17385
diff
changeset
|
2789 purple_debug_error("cipher", "Required nonce_count missing for digest calculation.\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2790 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2791 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2792 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2793 if (client_nonce == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2794 { |
15822 | 2795 purple_cipher_context_destroy(context); |
19654
941965d6fd88
Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17385
diff
changeset
|
2796 purple_debug_error("cipher", "Required client_nonce missing for digest calculation.\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2797 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2798 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2799 |
15822 | 2800 purple_cipher_context_append(context, (guchar *)nonce_count, strlen(nonce_count)); |
2801 purple_cipher_context_append(context, (guchar *)":", 1); | |
2802 purple_cipher_context_append(context, (guchar *)client_nonce, strlen(client_nonce)); | |
2803 purple_cipher_context_append(context, (guchar *)":", 1); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2804 |
15822 | 2805 purple_cipher_context_append(context, (guchar *)qop, strlen(qop)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2806 |
15822 | 2807 purple_cipher_context_append(context, (guchar *)":", 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2808 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2809 |
15822 | 2810 purple_cipher_context_append(context, (guchar *)hash2, strlen(hash2)); |
2811 purple_cipher_context_digest_to_str(context, sizeof(hash2), hash2, NULL); | |
2812 purple_cipher_context_destroy(context); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2813 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2814 return g_strdup(hash2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2815 } |