Mercurial > pidgin
annotate libpurple/cipher.c @ 27242:fd45bfd89872
merge of '6b55733f733881e690313c87ac44fba18f382ce1'
and 'aa1b0003a1e5ecb2e83de16870e1dab4ee4e94cc'
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Thu, 02 Jul 2009 01:52:48 +0000 |
parents | 8487bf2c306e |
children | 627d23bfdb05 |
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 /******************************************************************************* |
27159
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1865 * SHA-256 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1866 ******************************************************************************/ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1867 #define SHA256_HMAC_BLOCK_SIZE 64 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1868 #define SHA256_ROTR(X,n) ((((X) >> (n)) | ((X) << (32-(n)))) & 0xFFFFFFFF) |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1869 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1870 static const guint32 sha256_K[64] = |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1871 { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1872 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1873 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1874 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1875 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1876 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1877 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1878 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1879 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1880 }; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1881 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1882 struct SHA256Context { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1883 guint32 H[8]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1884 guint32 W[64]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1885 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1886 gint lenW; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1887 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1888 guint32 sizeHi; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1889 guint32 sizeLo; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1890 }; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1891 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1892 static void |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1893 sha256_hash_block(struct SHA256Context *sha256_ctx) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1894 gint i; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1895 guint32 A, B, C, D, E, F, G, H, T1, T2; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1896 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1897 for(i = 16; i < 64; i++) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1898 sha256_ctx->W[i] = |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1899 (SHA256_ROTR(sha256_ctx->W[i-2], 17) ^ SHA256_ROTR(sha256_ctx->W[i-2], 19) ^ (sha256_ctx->W[i-2] >> 10)) |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1900 + sha256_ctx->W[i-7] |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1901 + (SHA256_ROTR(sha256_ctx->W[i-15], 7) ^ SHA256_ROTR(sha256_ctx->W[i-15], 18) ^ (sha256_ctx->W[i-15] >> 3)) |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1902 + sha256_ctx->W[i-16]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1903 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1904 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1905 A = sha256_ctx->H[0]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1906 B = sha256_ctx->H[1]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1907 C = sha256_ctx->H[2]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1908 D = sha256_ctx->H[3]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1909 E = sha256_ctx->H[4]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1910 F = sha256_ctx->H[5]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1911 G = sha256_ctx->H[6]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1912 H = sha256_ctx->H[7]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1913 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1914 for(i = 0; i < 64; i++) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1915 T1 = H |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1916 + (SHA256_ROTR(E, 6) ^ SHA256_ROTR(E, 11) ^ SHA256_ROTR(E, 25)) |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1917 + ((E & F) ^ ((~E) & G)) |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1918 + sha256_K[i] + sha256_ctx->W[i]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1919 T2 = (SHA256_ROTR(A, 2) ^ SHA256_ROTR(A, 13) ^ SHA256_ROTR(A, 22)) |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1920 + ((A & B) ^ (A & C) ^ (B & C)); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1921 H = G; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1922 G = F; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1923 F = E; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1924 E = D + T1; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1925 D = C; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1926 C = B; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1927 B = A; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1928 A = T1 + T2; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1929 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1930 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1931 sha256_ctx->H[0] += A; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1932 sha256_ctx->H[1] += B; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1933 sha256_ctx->H[2] += C; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1934 sha256_ctx->H[3] += D; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1935 sha256_ctx->H[4] += E; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1936 sha256_ctx->H[5] += F; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1937 sha256_ctx->H[6] += G; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1938 sha256_ctx->H[7] += H; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1939 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1940 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1941 static void |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1942 sha256_set_opt(PurpleCipherContext *context, const gchar *name, void *value) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1943 struct SHA256Context *ctx; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1944 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1945 ctx = purple_cipher_context_get_data(context); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1946 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1947 if(!strcmp(name, "sizeHi")) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1948 ctx->sizeHi = GPOINTER_TO_INT(value); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1949 } else if(!strcmp(name, "sizeLo")) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1950 ctx->sizeLo = GPOINTER_TO_INT(value); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1951 } else if(!strcmp(name, "lenW")) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1952 ctx->lenW = GPOINTER_TO_INT(value); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1953 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1954 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1955 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1956 static void * |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1957 sha256_get_opt(PurpleCipherContext *context, const gchar *name) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1958 struct SHA256Context *ctx; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1959 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1960 ctx = purple_cipher_context_get_data(context); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1961 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1962 if(!strcmp(name, "sizeHi")) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1963 return GINT_TO_POINTER(ctx->sizeHi); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1964 } else if(!strcmp(name, "sizeLo")) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1965 return GINT_TO_POINTER(ctx->sizeLo); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1966 } else if(!strcmp(name, "lenW")) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1967 return GINT_TO_POINTER(ctx->lenW); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1968 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1969 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1970 return NULL; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1971 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1972 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1973 static void |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1974 sha256_init(PurpleCipherContext *context, void *extra) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1975 struct SHA256Context *sha256_ctx; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1976 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1977 sha256_ctx = g_new0(struct SHA256Context, 1); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1978 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1979 purple_cipher_context_set_data(context, sha256_ctx); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1980 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1981 purple_cipher_context_reset(context, extra); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1982 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1983 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1984 static void |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1985 sha256_reset(PurpleCipherContext *context, void *extra) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1986 struct SHA256Context *sha256_ctx; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1987 gint i; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1988 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1989 sha256_ctx = purple_cipher_context_get_data(context); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1990 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1991 g_return_if_fail(sha256_ctx); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1992 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1993 sha256_ctx->lenW = 0; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1994 sha256_ctx->sizeHi = 0; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1995 sha256_ctx->sizeLo = 0; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1996 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1997 sha256_ctx->H[0] = 0x6a09e667; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1998 sha256_ctx->H[1] = 0xbb67ae85; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
1999 sha256_ctx->H[2] = 0x3c6ef372; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2000 sha256_ctx->H[3] = 0xa54ff53a; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2001 sha256_ctx->H[4] = 0x510e527f; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2002 sha256_ctx->H[5] = 0x9b05688c; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2003 sha256_ctx->H[6] = 0x1f83d9ab; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2004 sha256_ctx->H[7] = 0x5be0cd19; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2005 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2006 for(i = 0; i < 64; i++) |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2007 sha256_ctx->W[i] = 0; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2008 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2009 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2010 static void |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2011 sha256_uninit(PurpleCipherContext *context) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2012 struct SHA256Context *sha256_ctx; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2013 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2014 purple_cipher_context_reset(context, NULL); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2015 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2016 sha256_ctx = purple_cipher_context_get_data(context); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2017 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2018 memset(sha256_ctx, 0, sizeof(struct SHA256Context)); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2019 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2020 g_free(sha256_ctx); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2021 sha256_ctx = NULL; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2022 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2023 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2024 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2025 static void |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2026 sha256_append(PurpleCipherContext *context, const guchar *data, size_t len) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2027 struct SHA256Context *sha256_ctx; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2028 gint i; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2029 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2030 sha256_ctx = purple_cipher_context_get_data(context); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2031 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2032 g_return_if_fail(sha256_ctx); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2033 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2034 for(i = 0; i < len; i++) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2035 sha256_ctx->W[sha256_ctx->lenW / 4] <<= 8; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2036 sha256_ctx->W[sha256_ctx->lenW / 4] |= data[i]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2037 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2038 if((++sha256_ctx->lenW) % 64 == 0) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2039 sha256_hash_block(sha256_ctx); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2040 sha256_ctx->lenW = 0; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2041 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2042 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2043 sha256_ctx->sizeLo += 8; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2044 sha256_ctx->sizeHi += (sha256_ctx->sizeLo < 8); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2045 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2046 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2047 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2048 static gboolean |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2049 sha256_digest(PurpleCipherContext *context, size_t in_len, guchar digest[32], |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2050 size_t *out_len) |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2051 { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2052 struct SHA256Context *sha256_ctx; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2053 guchar pad0x80 = 0x80, pad0x00 = 0x00; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2054 guchar padlen[8]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2055 gint i; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2056 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2057 g_return_val_if_fail(in_len >= 32, FALSE); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2058 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2059 sha256_ctx = purple_cipher_context_get_data(context); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2060 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2061 g_return_val_if_fail(sha256_ctx, FALSE); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2062 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2063 padlen[0] = (guchar)((sha256_ctx->sizeHi >> 24) & 255); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2064 padlen[1] = (guchar)((sha256_ctx->sizeHi >> 16) & 255); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2065 padlen[2] = (guchar)((sha256_ctx->sizeHi >> 8) & 255); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2066 padlen[3] = (guchar)((sha256_ctx->sizeHi >> 0) & 255); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2067 padlen[4] = (guchar)((sha256_ctx->sizeLo >> 24) & 255); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2068 padlen[5] = (guchar)((sha256_ctx->sizeLo >> 16) & 255); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2069 padlen[6] = (guchar)((sha256_ctx->sizeLo >> 8) & 255); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2070 padlen[7] = (guchar)((sha256_ctx->sizeLo >> 0) & 255); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2071 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2072 /* pad with a 1, then zeroes, then length */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2073 purple_cipher_context_append(context, &pad0x80, 1); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2074 while(sha256_ctx->lenW != 56) |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2075 purple_cipher_context_append(context, &pad0x00, 1); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2076 purple_cipher_context_append(context, padlen, 8); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2077 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2078 for(i = 0; i < 32; i++) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2079 digest[i] = (guchar)(sha256_ctx->H[i / 4] >> 24); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2080 sha256_ctx->H[i / 4] <<= 8; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2081 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2082 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2083 purple_cipher_context_reset(context, NULL); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2084 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2085 if(out_len) |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2086 *out_len = 32; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2087 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2088 return TRUE; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2089 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2090 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2091 static size_t |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2092 sha256_get_block_size(PurpleCipherContext *context) |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2093 { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2094 /* This does not change (in this case) */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2095 return SHA256_HMAC_BLOCK_SIZE; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2096 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2097 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2098 static PurpleCipherOps SHA256Ops = { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2099 sha256_set_opt, /* Set Option */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2100 sha256_get_opt, /* Get Option */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2101 sha256_init, /* init */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2102 sha256_reset, /* reset */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2103 sha256_uninit, /* uninit */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2104 NULL, /* set iv */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2105 sha256_append, /* append */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2106 sha256_digest, /* digest */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2107 NULL, /* encrypt */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2108 NULL, /* decrypt */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2109 NULL, /* set salt */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2110 NULL, /* get salt size */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2111 NULL, /* set key */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2112 NULL, /* get key size */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2113 NULL, /* set batch mode */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2114 NULL, /* get batch mode */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2115 sha256_get_block_size, /* get block size */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2116 NULL /* set key with len */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2117 }; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2118 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2119 /******************************************************************************* |
16997
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2120 * RC4 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2121 ******************************************************************************/ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2122 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2123 struct RC4Context { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2124 guchar state[256]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2125 guchar x; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2126 guchar y; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2127 gint key_len; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2128 }; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2129 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2130 static void |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2131 rc4_init(PurpleCipherContext *context, void *extra) { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2132 struct RC4Context *rc4_ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2133 rc4_ctx = g_new0(struct RC4Context, 1); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2134 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
|
2135 purple_cipher_context_reset(context, extra); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2136 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2137 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2138 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2139 static void |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2140 rc4_reset(PurpleCipherContext *context, void *extra) { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2141 struct RC4Context *rc4_ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2142 guint i; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2143 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2144 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
|
2145 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2146 g_return_if_fail(rc4_ctx); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2147 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2148 for(i = 0; i < 256; i++) |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2149 rc4_ctx->state[i] = i; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2150 rc4_ctx->x = 0; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2151 rc4_ctx->y = 0; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2152 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2153 /* default is 5 bytes (40bit key) */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2154 rc4_ctx->key_len = 5; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2155 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2156 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2157 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2158 static void |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2159 rc4_uninit(PurpleCipherContext *context) { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2160 struct RC4Context *rc4_ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2161 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2162 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
|
2163 memset(rc4_ctx, 0, sizeof(rc4_ctx)); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2164 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2165 g_free(rc4_ctx); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2166 rc4_ctx = NULL; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2167 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2168 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2169 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2170 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2171 static void |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2172 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
|
2173 struct RC4Context *ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2174 guchar *state; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2175 guchar temp_swap; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2176 guchar x, y; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2177 guint i; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2178 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2179 ctx = purple_cipher_context_get_data(context); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2180 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2181 x = 0; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2182 y = 0; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2183 state = &ctx->state[0]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2184 for(i = 0; i < 256; i++) |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2185 { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2186 y = (key[x] + state[i] + y) % 256; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2187 temp_swap = state[i]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2188 state[i] = state[y]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2189 state[y] = temp_swap; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2190 x = (x + 1) % ctx->key_len; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2191 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2192 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2193 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2194 static void |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2195 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
|
2196 struct RC4Context *ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2197 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2198 ctx = purple_cipher_context_get_data(context); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2199 |
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
|
2200 if(purple_strequal(name, "key_len")) { |
16997
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2201 ctx->key_len = GPOINTER_TO_INT(value); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2202 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2203 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2204 |
25924
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25894
diff
changeset
|
2205 static size_t |
16997
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2206 rc4_get_key_size (PurpleCipherContext *context) |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2207 { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2208 struct RC4Context *ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2209 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2210 g_return_val_if_fail(context, -1); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2211 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2212 ctx = purple_cipher_context_get_data(context); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2213 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2214 g_return_val_if_fail(ctx, -1); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2215 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2216 return ctx->key_len; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2217 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2218 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2219 static void * |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2220 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
|
2221 struct RC4Context *ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2222 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2223 ctx = purple_cipher_context_get_data(context); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2224 |
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
|
2225 if(purple_strequal(name, "key_len")) { |
16997
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2226 return GINT_TO_POINTER(ctx->key_len); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2227 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2228 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2229 return NULL; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2230 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2231 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2232 static gint |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2233 rc4_encrypt(PurpleCipherContext *context, const guchar data[], |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2234 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
|
2235 struct RC4Context *ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2236 guchar temp_swap; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2237 guchar x, y, z; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2238 guchar *state; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2239 guint i; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2240 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2241 ctx = purple_cipher_context_get_data(context); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2242 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2243 x = ctx->x; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2244 y = ctx->y; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2245 state = &ctx->state[0]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2246 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2247 for(i = 0; i < len; i++) |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2248 { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2249 x = (x + 1) % 256; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2250 y = (state[x] + y) % 256; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2251 temp_swap = state[x]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2252 state[x] = state[y]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2253 state[y] = temp_swap; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2254 z = state[x] + (state[y]) % 256; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2255 output[i] = data[i] ^ state[z]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2256 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2257 ctx->x = x; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2258 ctx->y = y; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2259 if(outlen) |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2260 *outlen = len; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2261 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2262 return 0; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2263 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2264 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2265 static PurpleCipherOps RC4Ops = { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2266 rc4_set_opt, /* Set Option */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2267 rc4_get_opt, /* Get Option */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2268 rc4_init, /* init */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2269 rc4_reset, /* reset */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2270 rc4_uninit, /* uninit */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2271 NULL, /* set iv */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2272 NULL, /* append */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2273 NULL, /* digest */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2274 rc4_encrypt, /* encrypt */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2275 NULL, /* decrypt */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2276 NULL, /* set salt */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2277 NULL, /* get salt size */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2278 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
|
2279 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
|
2280 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
|
2281 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
|
2282 NULL, /* get block size */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2283 NULL /* set key with len */ |
16997
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2284 }; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2285 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2286 /******************************************************************************* |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2287 * Structs |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2288 ******************************************************************************/ |
15822 | 2289 struct _PurpleCipher { |
17385
103a37dd9398
applied changes from b0f6005b1330af13bce0bcb189a2c887036b5ea3
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17082
diff
changeset
|
2290 gchar *name; /**< Internal name - used for searching */ |
103a37dd9398
applied changes from b0f6005b1330af13bce0bcb189a2c887036b5ea3
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17082
diff
changeset
|
2291 PurpleCipherOps *ops; /**< Operations supported by this cipher */ |
103a37dd9398
applied changes from b0f6005b1330af13bce0bcb189a2c887036b5ea3
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17082
diff
changeset
|
2292 guint ref; /**< Reference count */ |
15373
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 |
15822 | 2295 struct _PurpleCipherContext { |
17385
103a37dd9398
applied changes from b0f6005b1330af13bce0bcb189a2c887036b5ea3
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17082
diff
changeset
|
2296 PurpleCipher *cipher; /**< Cipher this context is under */ |
103a37dd9398
applied changes from b0f6005b1330af13bce0bcb189a2c887036b5ea3
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17082
diff
changeset
|
2297 gpointer data; /**< Internal cipher state data */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2298 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2299 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2300 /****************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2301 * Globals |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2302 *****************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2303 static GList *ciphers = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2304 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2305 /****************************************************************************** |
15822 | 2306 * PurpleCipher API |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2307 *****************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2308 const gchar * |
15822 | 2309 purple_cipher_get_name(PurpleCipher *cipher) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2310 g_return_val_if_fail(cipher, NULL); |
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 cipher->name; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2315 guint |
15822 | 2316 purple_cipher_get_capabilities(PurpleCipher *cipher) { |
2317 PurpleCipherOps *ops = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2318 guint caps = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2319 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2320 g_return_val_if_fail(cipher, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2321 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2322 ops = cipher->ops; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2323 g_return_val_if_fail(ops, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2324 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2325 if(ops->set_option) |
15822 | 2326 caps |= PURPLE_CIPHER_CAPS_SET_OPT; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2327 if(ops->get_option) |
15822 | 2328 caps |= PURPLE_CIPHER_CAPS_GET_OPT; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2329 if(ops->init) |
15822 | 2330 caps |= PURPLE_CIPHER_CAPS_INIT; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2331 if(ops->reset) |
15822 | 2332 caps |= PURPLE_CIPHER_CAPS_RESET; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2333 if(ops->uninit) |
15822 | 2334 caps |= PURPLE_CIPHER_CAPS_UNINIT; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2335 if(ops->set_iv) |
15822 | 2336 caps |= PURPLE_CIPHER_CAPS_SET_IV; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2337 if(ops->append) |
15822 | 2338 caps |= PURPLE_CIPHER_CAPS_APPEND; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2339 if(ops->digest) |
15822 | 2340 caps |= PURPLE_CIPHER_CAPS_DIGEST; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2341 if(ops->encrypt) |
15822 | 2342 caps |= PURPLE_CIPHER_CAPS_ENCRYPT; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2343 if(ops->decrypt) |
15822 | 2344 caps |= PURPLE_CIPHER_CAPS_DECRYPT; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2345 if(ops->set_salt) |
15822 | 2346 caps |= PURPLE_CIPHER_CAPS_SET_SALT; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2347 if(ops->get_salt_size) |
15822 | 2348 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
|
2349 if(ops->set_key) |
15822 | 2350 caps |= PURPLE_CIPHER_CAPS_SET_KEY; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2351 if(ops->get_key_size) |
15822 | 2352 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
|
2353 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
|
2354 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
|
2355 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
|
2356 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
|
2357 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
|
2358 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
|
2359 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
|
2360 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
|
2361 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2362 return caps; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2363 } |
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 gboolean |
15822 | 2366 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
|
2367 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
|
2368 guchar digest[], size_t *out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2369 { |
15822 | 2370 PurpleCipher *cipher; |
2371 PurpleCipherContext *context; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2372 gboolean ret = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2373 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2374 g_return_val_if_fail(name, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2375 g_return_val_if_fail(data, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2376 |
15822 | 2377 cipher = purple_ciphers_find_cipher(name); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2378 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2379 g_return_val_if_fail(cipher, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2380 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2381 if(!cipher->ops->append || !cipher->ops->digest) { |
15822 | 2382 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
|
2383 "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
|
2384 "digesting.", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2385 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2386 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2387 |
15822 | 2388 context = purple_cipher_context_new(cipher, NULL); |
2389 purple_cipher_context_append(context, data, data_len); | |
2390 ret = purple_cipher_context_digest(context, in_len, digest, out_len); | |
2391 purple_cipher_context_destroy(context); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2392 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2393 return ret; |
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 /****************************************************************************** |
15822 | 2397 * PurpleCiphers API |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2398 *****************************************************************************/ |
15822 | 2399 PurpleCipher * |
2400 purple_ciphers_find_cipher(const gchar *name) { | |
2401 PurpleCipher *cipher; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2402 GList *l; |
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 g_return_val_if_fail(name, NULL); |
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 for(l = ciphers; l; l = l->next) { |
15822 | 2407 cipher = PURPLE_CIPHER(l->data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2408 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2409 if(!g_ascii_strcasecmp(cipher->name, name)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2410 return cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2411 } |
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 return NULL; |
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 |
15822 | 2416 PurpleCipher * |
2417 purple_ciphers_register_cipher(const gchar *name, PurpleCipherOps *ops) { | |
2418 PurpleCipher *cipher = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2419 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2420 g_return_val_if_fail(name, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2421 g_return_val_if_fail(ops, NULL); |
15822 | 2422 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
|
2423 |
15822 | 2424 cipher = g_new0(PurpleCipher, 1); |
2425 PURPLE_DBUS_REGISTER_POINTER(cipher, PurpleCipher); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2426 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2427 cipher->name = g_strdup(name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2428 cipher->ops = ops; |
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 ciphers = g_list_append(ciphers, cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2431 |
15822 | 2432 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
|
2433 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2434 return cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2435 } |
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 gboolean |
15822 | 2438 purple_ciphers_unregister_cipher(PurpleCipher *cipher) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2439 g_return_val_if_fail(cipher, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2440 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
|
2441 |
15822 | 2442 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
|
2443 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2444 ciphers = g_list_remove(ciphers, cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2445 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2446 g_free(cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2447 |
15822 | 2448 PURPLE_DBUS_UNREGISTER_POINTER(cipher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2449 g_free(cipher); |
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 return TRUE; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2454 GList * |
15822 | 2455 purple_ciphers_get_ciphers() { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2456 return ciphers; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2457 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2458 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2459 /****************************************************************************** |
15822 | 2460 * PurpleCipher Subsystem API |
15373
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 gpointer |
15822 | 2463 purple_ciphers_get_handle() { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2464 static gint handle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2465 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2466 return &handle; |
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 void |
15822 | 2470 purple_ciphers_init() { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2471 gpointer handle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2472 |
15822 | 2473 handle = purple_ciphers_get_handle(); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2474 |
15822 | 2475 purple_signal_register(handle, "cipher-added", |
2476 purple_marshal_VOID__POINTER, NULL, 1, | |
2477 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
2478 PURPLE_SUBTYPE_CIPHER)); | |
2479 purple_signal_register(handle, "cipher-removed", | |
2480 purple_marshal_VOID__POINTER, NULL, 1, | |
2481 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
2482 PURPLE_SUBTYPE_CIPHER)); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2483 |
15822 | 2484 purple_ciphers_register_cipher("md5", &MD5Ops); |
2485 purple_ciphers_register_cipher("sha1", &SHA1Ops); | |
27159
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2486 purple_ciphers_register_cipher("sha256", &SHA256Ops); |
15822 | 2487 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
|
2488 purple_ciphers_register_cipher("hmac", &HMACOps); |
15822 | 2489 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
|
2490 purple_ciphers_register_cipher("des3", &DES3Ops); |
16997
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16668
diff
changeset
|
2491 purple_ciphers_register_cipher("rc4", &RC4Ops); |
15373
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2494 void |
15822 | 2495 purple_ciphers_uninit() { |
2496 PurpleCipher *cipher; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2497 GList *l, *ll; |
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 for(l = ciphers; l; l = ll) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2500 ll = l->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2501 |
15822 | 2502 cipher = PURPLE_CIPHER(l->data); |
2503 purple_ciphers_unregister_cipher(cipher); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2504 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2505 ciphers = g_list_remove(ciphers, cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2506 } |
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 g_list_free(ciphers); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2509 |
15822 | 2510 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
|
2511 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2512 /****************************************************************************** |
15822 | 2513 * PurpleCipherContext API |
15373
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 void |
15822 | 2516 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
|
2517 gpointer value) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2518 { |
15822 | 2519 PurpleCipher *cipher = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2520 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2521 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2522 g_return_if_fail(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 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2525 g_return_if_fail(cipher); |
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 if(cipher->ops && cipher->ops->set_option) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2528 cipher->ops->set_option(context, name, value); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2529 else |
15822 | 2530 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
|
2531 "set_option operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2532 } |
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 gpointer |
15822 | 2535 purple_cipher_context_get_option(PurpleCipherContext *context, const gchar *name) { |
2536 PurpleCipher *cipher = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2537 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2538 g_return_val_if_fail(context, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2539 g_return_val_if_fail(name, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2540 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2541 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2542 g_return_val_if_fail(cipher, NULL); |
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 if(cipher->ops && cipher->ops->get_option) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2545 return cipher->ops->get_option(context, name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2546 else { |
15822 | 2547 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
|
2548 "get_option operation\n", cipher->name); |
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 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2551 } |
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 |
15822 | 2554 PurpleCipherContext * |
2555 purple_cipher_context_new(PurpleCipher *cipher, void *extra) { | |
2556 PurpleCipherContext *context = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2557 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2558 g_return_val_if_fail(cipher, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2559 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2560 cipher->ref++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2561 |
15822 | 2562 context = g_new0(PurpleCipherContext, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2563 context->cipher = cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2564 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2565 if(cipher->ops->init) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2566 cipher->ops->init(context, extra); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2567 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2568 return context; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2569 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2570 |
15822 | 2571 PurpleCipherContext * |
2572 purple_cipher_context_new_by_name(const gchar *name, void *extra) { | |
2573 PurpleCipher *cipher; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2574 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2575 g_return_val_if_fail(name, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2576 |
15822 | 2577 cipher = purple_ciphers_find_cipher(name); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2578 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2579 g_return_val_if_fail(cipher, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2580 |
15822 | 2581 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
|
2582 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2583 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2584 void |
15822 | 2585 purple_cipher_context_reset(PurpleCipherContext *context, void *extra) { |
2586 PurpleCipher *cipher = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2587 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2588 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2589 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2590 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2591 g_return_if_fail(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2592 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2593 if(cipher->ops && cipher->ops->reset) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2594 context->cipher->ops->reset(context, extra); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2595 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2596 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2597 void |
15822 | 2598 purple_cipher_context_destroy(PurpleCipherContext *context) { |
2599 PurpleCipher *cipher = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2600 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2601 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2602 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2603 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2604 g_return_if_fail(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2605 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2606 cipher->ref--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2607 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2608 if(cipher->ops && cipher->ops->uninit) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2609 cipher->ops->uninit(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2610 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2611 memset(context, 0, sizeof(context)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2612 g_free(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2613 context = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2614 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2615 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2616 void |
15822 | 2617 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
|
2618 { |
15822 | 2619 PurpleCipher *cipher = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2620 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2621 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2622 g_return_if_fail(iv); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2623 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2624 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2625 g_return_if_fail(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2626 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2627 if(cipher->ops && cipher->ops->set_iv) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2628 cipher->ops->set_iv(context, iv, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2629 else |
15822 | 2630 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
|
2631 "initialization vector operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2632 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2633 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2634 void |
15822 | 2635 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
|
2636 size_t len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2637 { |
15822 | 2638 PurpleCipher *cipher = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2639 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2640 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2641 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2642 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2643 g_return_if_fail(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2644 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2645 if(cipher->ops && cipher->ops->append) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2646 cipher->ops->append(context, data, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2647 else |
15822 | 2648 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
|
2649 "operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2650 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2651 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2652 gboolean |
15822 | 2653 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
|
2654 guchar digest[], size_t *out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2655 { |
15822 | 2656 PurpleCipher *cipher = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2657 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2658 g_return_val_if_fail(context, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2659 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2660 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2661 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2662 if(cipher->ops && cipher->ops->digest) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2663 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
|
2664 else { |
15822 | 2665 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
|
2666 "operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2667 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2668 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2669 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2670 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2671 gboolean |
15822 | 2672 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
|
2673 gchar digest_s[], size_t *out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2674 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2675 /* 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
|
2676 guchar digest[BUF_LEN * 4]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2677 gint n = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2678 size_t dlen = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2679 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2680 g_return_val_if_fail(context, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2681 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
|
2682 |
15822 | 2683 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
|
2684 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2685 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2686 /* 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
|
2687 if(in_len <= dlen * 2) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2688 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2689 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2690 for(n = 0; n < dlen; n++) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2691 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
|
2692 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2693 digest_s[n * 2] = '\0'; |
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 if(out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2696 *out_len = dlen * 2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2697 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2698 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2699 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2700 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2701 gint |
15822 | 2702 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
|
2703 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
|
2704 { |
15822 | 2705 PurpleCipher *cipher = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2706 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2707 g_return_val_if_fail(context, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2708 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2709 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2710 g_return_val_if_fail(cipher, -1); |
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 if(cipher->ops && cipher->ops->encrypt) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2713 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
|
2714 else { |
15822 | 2715 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
|
2716 "operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2717 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2718 if(outlen) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2719 *outlen = -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2720 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2721 return -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2722 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2723 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2724 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2725 gint |
15822 | 2726 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
|
2727 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
|
2728 { |
15822 | 2729 PurpleCipher *cipher = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2730 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2731 g_return_val_if_fail(context, -1); |
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 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2734 g_return_val_if_fail(cipher, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2735 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2736 if(cipher->ops && cipher->ops->decrypt) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2737 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
|
2738 else { |
15822 | 2739 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
|
2740 "operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2741 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2742 if(outlen) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2743 *outlen = -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2744 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2745 return -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2746 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2747 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2748 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2749 void |
15822 | 2750 purple_cipher_context_set_salt(PurpleCipherContext *context, guchar *salt) { |
2751 PurpleCipher *cipher = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2752 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2753 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2754 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2755 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2756 g_return_if_fail(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2757 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2758 if(cipher->ops && cipher->ops->set_salt) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2759 cipher->ops->set_salt(context, salt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2760 else |
15822 | 2761 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
|
2762 "set_salt operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2763 } |
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 size_t |
15822 | 2766 purple_cipher_context_get_salt_size(PurpleCipherContext *context) { |
2767 PurpleCipher *cipher = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2768 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2769 g_return_val_if_fail(context, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2770 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2771 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2772 g_return_val_if_fail(cipher, -1); |
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 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
|
2775 return cipher->ops->get_salt_size(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2776 else { |
15822 | 2777 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
|
2778 "get_salt_size operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2779 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2780 return -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2781 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2782 } |
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 void |
15822 | 2785 purple_cipher_context_set_key(PurpleCipherContext *context, const guchar *key) { |
2786 PurpleCipher *cipher = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2787 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2788 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2789 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2790 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2791 g_return_if_fail(cipher); |
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(cipher->ops && cipher->ops->set_key) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2794 cipher->ops->set_key(context, key); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2795 else |
15822 | 2796 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
|
2797 "set_key operation\n", cipher->name); |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2800 size_t |
15822 | 2801 purple_cipher_context_get_key_size(PurpleCipherContext *context) { |
2802 PurpleCipher *cipher = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2803 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2804 g_return_val_if_fail(context, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2805 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2806 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2807 g_return_val_if_fail(cipher, -1); |
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 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
|
2810 return cipher->ops->get_key_size(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2811 else { |
15822 | 2812 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
|
2813 "get_key_size operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2814 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2815 return -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2816 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2817 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2818 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2819 void |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2820 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
|
2821 PurpleCipherBatchMode mode) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2822 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2823 PurpleCipher *cipher = NULL; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2824 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2825 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
|
2826 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2827 cipher = context->cipher; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2828 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
|
2829 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2830 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
|
2831 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
|
2832 else |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2833 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
|
2834 "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
|
2835 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2836 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2837 PurpleCipherBatchMode |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2838 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
|
2839 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2840 PurpleCipher *cipher = NULL; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2841 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2842 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
|
2843 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2844 cipher = context->cipher; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2845 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
|
2846 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2847 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
|
2848 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
|
2849 else { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2850 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
|
2851 "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
|
2852 return -1; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2853 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2854 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2855 |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2856 size_t |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2857 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
|
2858 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2859 PurpleCipher *cipher = NULL; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2860 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2861 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
|
2862 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2863 cipher = context->cipher; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2864 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
|
2865 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2866 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
|
2867 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
|
2868 else { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2869 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
|
2870 "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
|
2871 return -1; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2872 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2873 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2874 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2875 void |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2876 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
|
2877 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
|
2878 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2879 PurpleCipher *cipher = NULL; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2880 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2881 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
|
2882 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2883 cipher = context->cipher; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2884 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
|
2885 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2886 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
|
2887 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
|
2888 else |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2889 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
|
2890 "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
|
2891 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2892 |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
2893 void |
15822 | 2894 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
|
2895 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2896 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2897 context->data = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2898 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2899 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2900 gpointer |
15822 | 2901 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
|
2902 g_return_val_if_fail(context, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2903 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2904 return context->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2905 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2906 |
15822 | 2907 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
|
2908 const gchar *algorithm, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2909 const gchar *username, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2910 const gchar *realm, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2911 const gchar *password, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2912 const gchar *nonce, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2913 const gchar *client_nonce) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2914 { |
15822 | 2915 PurpleCipher *cipher; |
2916 PurpleCipherContext *context; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2917 gchar hash[33]; /* We only support MD5. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2918 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2919 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
|
2920 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
|
2921 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
|
2922 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
|
2923 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2924 /* Check for a supported algorithm. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2925 g_return_val_if_fail(algorithm == NULL || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2926 *algorithm == '\0' || |
17082
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17016
diff
changeset
|
2927 g_ascii_strcasecmp(algorithm, "MD5") || |
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17016
diff
changeset
|
2928 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
|
2929 |
15822 | 2930 cipher = purple_ciphers_find_cipher("md5"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2931 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
|
2932 |
15822 | 2933 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
|
2934 |
15822 | 2935 purple_cipher_context_append(context, (guchar *)username, strlen(username)); |
2936 purple_cipher_context_append(context, (guchar *)":", 1); | |
2937 purple_cipher_context_append(context, (guchar *)realm, strlen(realm)); | |
2938 purple_cipher_context_append(context, (guchar *)":", 1); | |
2939 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
|
2940 |
17082
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17016
diff
changeset
|
2941 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
|
2942 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2943 guchar digest[16]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2944 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2945 if (client_nonce == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2946 { |
15822 | 2947 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
|
2948 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
|
2949 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2950 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2951 |
15822 | 2952 purple_cipher_context_digest(context, sizeof(digest), digest, NULL); |
2953 purple_cipher_context_destroy(context); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2954 |
15822 | 2955 context = purple_cipher_context_new(cipher, NULL); |
2956 purple_cipher_context_append(context, digest, sizeof(digest)); | |
2957 purple_cipher_context_append(context, (guchar *)":", 1); | |
2958 purple_cipher_context_append(context, (guchar *)nonce, strlen(nonce)); | |
2959 purple_cipher_context_append(context, (guchar *)":", 1); | |
2960 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
|
2961 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2962 |
15822 | 2963 purple_cipher_context_digest_to_str(context, sizeof(hash), hash, NULL); |
2964 purple_cipher_context_destroy(context); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2965 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2966 return g_strdup(hash); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2967 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2968 |
15822 | 2969 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
|
2970 const gchar *algorithm, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2971 const gchar *method, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2972 const gchar *digest_uri, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2973 const gchar *qop, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2974 const gchar *entity, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2975 const gchar *nonce, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2976 const gchar *nonce_count, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2977 const gchar *client_nonce, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2978 const gchar *session_key) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2979 { |
15822 | 2980 PurpleCipher *cipher; |
2981 PurpleCipherContext *context; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2982 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
|
2983 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2984 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
|
2985 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
|
2986 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
|
2987 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
|
2988 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2989 /* Check for a supported algorithm. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2990 g_return_val_if_fail(algorithm == NULL || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2991 *algorithm == '\0' || |
17082
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17016
diff
changeset
|
2992 g_ascii_strcasecmp(algorithm, "MD5") || |
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17016
diff
changeset
|
2993 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
|
2994 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2995 /* Check for a supported "quality of protection". */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2996 g_return_val_if_fail(qop == NULL || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2997 *qop == '\0' || |
17082
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17016
diff
changeset
|
2998 g_ascii_strcasecmp(qop, "auth") || |
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17016
diff
changeset
|
2999 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
|
3000 |
15822 | 3001 cipher = purple_ciphers_find_cipher("md5"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3002 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
|
3003 |
15822 | 3004 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
|
3005 |
15822 | 3006 purple_cipher_context_append(context, (guchar *)method, strlen(method)); |
3007 purple_cipher_context_append(context, (guchar *)":", 1); | |
3008 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
|
3009 |
17082
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17016
diff
changeset
|
3010 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
|
3011 { |
15822 | 3012 PurpleCipherContext *context2; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3013 gchar entity_hash[33]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3014 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3015 if (entity == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3016 { |
15822 | 3017 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
|
3018 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
|
3019 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3020 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3021 |
15822 | 3022 context2 = purple_cipher_context_new(cipher, NULL); |
3023 purple_cipher_context_append(context2, (guchar *)entity, strlen(entity)); | |
3024 purple_cipher_context_digest_to_str(context2, sizeof(entity_hash), entity_hash, NULL); | |
3025 purple_cipher_context_destroy(context2); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3026 |
15822 | 3027 purple_cipher_context_append(context, (guchar *)":", 1); |
3028 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
|
3029 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3030 |
15822 | 3031 purple_cipher_context_digest_to_str(context, sizeof(hash2), hash2, NULL); |
3032 purple_cipher_context_destroy(context); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3033 |
15822 | 3034 context = purple_cipher_context_new(cipher, NULL); |
3035 purple_cipher_context_append(context, (guchar *)session_key, strlen(session_key)); | |
3036 purple_cipher_context_append(context, (guchar *)":", 1); | |
3037 purple_cipher_context_append(context, (guchar *)nonce, strlen(nonce)); | |
3038 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
|
3039 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3040 if (qop != NULL && *qop != '\0') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3041 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3042 if (nonce_count == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3043 { |
15822 | 3044 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
|
3045 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
|
3046 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3047 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3048 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3049 if (client_nonce == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3050 { |
15822 | 3051 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
|
3052 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
|
3053 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3054 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3055 |
15822 | 3056 purple_cipher_context_append(context, (guchar *)nonce_count, strlen(nonce_count)); |
3057 purple_cipher_context_append(context, (guchar *)":", 1); | |
3058 purple_cipher_context_append(context, (guchar *)client_nonce, strlen(client_nonce)); | |
3059 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
|
3060 |
15822 | 3061 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
|
3062 |
15822 | 3063 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
|
3064 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3065 |
15822 | 3066 purple_cipher_context_append(context, (guchar *)hash2, strlen(hash2)); |
3067 purple_cipher_context_digest_to_str(context, sizeof(hash2), hash2, NULL); | |
3068 purple_cipher_context_destroy(context); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3069 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3070 return g_strdup(hash2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3071 } |