Mercurial > pidgin.yaz
annotate libpurple/cipher.c @ 29977:47cda4fb5d5d
These files were removed.
And there was much rejoicing.
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 10 Mar 2010 17:38:24 +0000 |
parents | 279c6cfe6966 |
children | 8a15b164ef30 |
rev | line source |
---|---|
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
15823 | 2 * purple |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
15823 | 4 * Purple is the legal property of its developers, whose names are too numerous |
15374
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 |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19653
diff
changeset
|
51 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15374
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 "internal.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 #include "cipher.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 #include "dbus-maybe.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 #include "signals.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 #include "value.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 |
27390
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
60 #if GLIB_CHECK_VERSION(2,16,0) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
61 static void |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
62 purple_g_checksum_init(PurpleCipherContext *context, GChecksumType type) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
63 { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
64 GChecksum *checksum; |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
65 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
66 checksum = g_checksum_new(type); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
67 purple_cipher_context_set_data(context, checksum); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
68 } |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
69 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
70 static void |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
71 purple_g_checksum_reset(PurpleCipherContext *context, GChecksumType type) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
72 { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
73 GChecksum *checksum; |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
74 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
75 checksum = purple_cipher_context_get_data(context); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
76 g_return_if_fail(checksum != NULL); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
77 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
78 #if GLIB_CHECK_VERSION(2,18,0) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
79 g_checksum_reset(checksum); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
80 #else |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
81 g_checksum_free(checksum); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
82 checksum = g_checksum_new(type); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
83 purple_cipher_context_set_data(context, checksum); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
84 #endif |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
85 } |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
86 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
87 static void |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
88 purple_g_checksum_uninit(PurpleCipherContext *context) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
89 { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
90 GChecksum *checksum; |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
91 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
92 checksum = purple_cipher_context_get_data(context); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
93 g_return_if_fail(checksum != NULL); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
94 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
95 g_checksum_free(checksum); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
96 } |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
97 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
98 static void |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
99 purple_g_checksum_append(PurpleCipherContext *context, const guchar *data, |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
100 gsize len) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
101 { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
102 GChecksum *checksum; |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
103 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
104 checksum = purple_cipher_context_get_data(context); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
105 g_return_if_fail(checksum != NULL); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
106 |
27392
304fef974f28
Elliott's code looks nicer.
Paul Aurich <paul@darkrain42.org>
parents:
27390
diff
changeset
|
107 while (len >= G_MAXSSIZE) { |
304fef974f28
Elliott's code looks nicer.
Paul Aurich <paul@darkrain42.org>
parents:
27390
diff
changeset
|
108 g_checksum_update(checksum, data, G_MAXSSIZE); |
304fef974f28
Elliott's code looks nicer.
Paul Aurich <paul@darkrain42.org>
parents:
27390
diff
changeset
|
109 len -= G_MAXSSIZE; |
304fef974f28
Elliott's code looks nicer.
Paul Aurich <paul@darkrain42.org>
parents:
27390
diff
changeset
|
110 data += G_MAXSSIZE; |
304fef974f28
Elliott's code looks nicer.
Paul Aurich <paul@darkrain42.org>
parents:
27390
diff
changeset
|
111 } |
304fef974f28
Elliott's code looks nicer.
Paul Aurich <paul@darkrain42.org>
parents:
27390
diff
changeset
|
112 |
304fef974f28
Elliott's code looks nicer.
Paul Aurich <paul@darkrain42.org>
parents:
27390
diff
changeset
|
113 if (len) |
27390
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
114 g_checksum_update(checksum, data, len); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
115 } |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
116 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
117 static gboolean |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
118 purple_g_checksum_digest(PurpleCipherContext *context, GChecksumType type, |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
119 gsize len, guchar *digest, gsize *out_len) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
120 { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
121 GChecksum *checksum; |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
122 const gssize required_length = g_checksum_type_get_length(type); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
123 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
124 checksum = purple_cipher_context_get_data(context); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
125 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
126 g_return_val_if_fail(len >= required_length, FALSE); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
127 g_return_val_if_fail(checksum != NULL, FALSE); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
128 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
129 g_checksum_get_digest(checksum, digest, &len); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
130 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
131 purple_cipher_context_reset(context, NULL); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
132 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
133 if (out_len) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
134 *out_len = len; |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
135 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
136 return TRUE; |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
137 } |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
138 #endif |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
139 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
140 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
141 /******************************************************************************* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 * MD5 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
143 ******************************************************************************/ |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
144 #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
|
145 |
27390
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
146 static size_t |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
147 md5_get_block_size(PurpleCipherContext *context) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
148 { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
149 /* This does not change (in this case) */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
150 return MD5_HMAC_BLOCK_SIZE; |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
151 } |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
152 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
153 #if GLIB_CHECK_VERSION(2,16,0) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
154 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
155 static void |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
156 md5_init(PurpleCipherContext *context, void *extra) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
157 { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
158 purple_g_checksum_init(context, G_CHECKSUM_MD5); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
159 } |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
160 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
161 static void |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
162 md5_reset(PurpleCipherContext *context, void *extra) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
163 { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
164 purple_g_checksum_reset(context, G_CHECKSUM_MD5); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
165 } |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
166 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
167 static gboolean |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
168 md5_digest(PurpleCipherContext *context, gsize in_len, guchar digest[16], |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
169 size_t *out_len) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
170 { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
171 return purple_g_checksum_digest(context, G_CHECKSUM_MD5, in_len, |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
172 digest, out_len); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
173 } |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
174 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
175 static PurpleCipherOps MD5Ops = { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
176 NULL, /* Set Option */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
177 NULL, /* Get Option */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
178 md5_init, /* init */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
179 md5_reset, /* reset */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
180 purple_g_checksum_uninit, /* uninit */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
181 NULL, /* set iv */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
182 purple_g_checksum_append, /* append */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
183 md5_digest, /* digest */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
184 NULL, /* encrypt */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
185 NULL, /* decrypt */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
186 NULL, /* set salt */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
187 NULL, /* get salt size */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
188 NULL, /* set key */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
189 NULL, /* get key size */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
190 NULL, /* set batch mode */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
191 NULL, /* get batch mode */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
192 md5_get_block_size, /* get block size */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
193 NULL /* set key with len */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
194 }; |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
195 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
196 #else /* GLIB_CHECK_VERSION(2,16,0) */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
197 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
198 struct MD5Context { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
199 guint32 total[2]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 guint32 state[4]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
201 guchar buffer[64]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
202 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
203 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
204 #define MD5_GET_GUINT32(n,b,i) { \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
205 (n) = ((guint32)(b) [(i) ] ) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
206 | ((guint32)(b) [(i) + 1] << 8) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
207 | ((guint32)(b) [(i) + 2] << 16) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
208 | ((guint32)(b) [(i) + 3] << 24); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
209 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 #define MD5_PUT_GUINT32(n,b,i) { \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
211 (b)[(i) ] = (guchar)((n) ); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
212 (b)[(i) + 1] = (guchar)((n) >> 8); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
213 (b)[(i) + 2] = (guchar)((n) >> 16); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
214 (b)[(i) + 3] = (guchar)((n) >> 24); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
215 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
217 static void |
15823 | 218 md5_init(PurpleCipherContext *context, gpointer extra) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
219 struct MD5Context *md5_context; |
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 md5_context = g_new0(struct MD5Context, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
222 |
15823 | 223 purple_cipher_context_set_data(context, md5_context); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
224 |
15823 | 225 purple_cipher_context_reset(context, extra); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
226 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
227 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
228 static void |
15823 | 229 md5_reset(PurpleCipherContext *context, gpointer extra) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
230 struct MD5Context *md5_context; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
231 |
15823 | 232 md5_context = purple_cipher_context_get_data(context); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
233 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
234 md5_context->total[0] = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
235 md5_context->total[1] = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
236 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 md5_context->state[0] = 0x67452301; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 md5_context->state[1] = 0xEFCDAB89; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 md5_context->state[2] = 0x98BADCFE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 md5_context->state[3] = 0x10325476; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
241 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
242 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
|
243 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
244 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 static void |
15823 | 246 md5_uninit(PurpleCipherContext *context) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
247 struct MD5Context *md5_context; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
248 |
15823 | 249 purple_cipher_context_reset(context, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 |
15823 | 251 md5_context = purple_cipher_context_get_data(context); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
252 memset(md5_context, 0, sizeof(md5_context)); |
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_free(md5_context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
255 md5_context = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
256 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
258 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
259 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
|
260 guint32 X[16], A, B, C, D; |
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 A = md5_context->state[0]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
263 B = md5_context->state[1]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 C = md5_context->state[2]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
265 D = md5_context->state[3]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
267 MD5_GET_GUINT32(X[ 0], data, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
268 MD5_GET_GUINT32(X[ 1], data, 4); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
269 MD5_GET_GUINT32(X[ 2], data, 8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 MD5_GET_GUINT32(X[ 3], data, 12); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
271 MD5_GET_GUINT32(X[ 4], data, 16); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
272 MD5_GET_GUINT32(X[ 5], data, 20); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
273 MD5_GET_GUINT32(X[ 6], data, 24); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
274 MD5_GET_GUINT32(X[ 7], data, 28); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
275 MD5_GET_GUINT32(X[ 8], data, 32); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 MD5_GET_GUINT32(X[ 9], data, 36); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
277 MD5_GET_GUINT32(X[10], data, 40); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
278 MD5_GET_GUINT32(X[11], data, 44); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
279 MD5_GET_GUINT32(X[12], data, 48); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 MD5_GET_GUINT32(X[13], data, 52); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
281 MD5_GET_GUINT32(X[14], data, 56); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
282 MD5_GET_GUINT32(X[15], data, 60); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
283 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
284 #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
|
285 #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
|
286 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
|
287 a = S(a,s) + b; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
288 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
289 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
290 /* first pass */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
291 #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
|
292 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
|
293 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
|
294 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
|
295 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
|
296 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
|
297 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
|
298 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
|
299 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
|
300 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
|
301 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
|
302 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
|
303 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
|
304 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
|
305 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
|
306 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
|
307 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
|
308 #undef F |
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 /* second pass */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
311 #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
|
312 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
|
313 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
|
314 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
|
315 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
|
316 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
|
317 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
|
318 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
|
319 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
|
320 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
|
321 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
|
322 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
|
323 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
|
324 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
|
325 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
|
326 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
|
327 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
|
328 #undef F |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
329 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
330 /* third pass */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
331 #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
|
332 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
|
333 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
|
334 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
|
335 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
|
336 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
|
337 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
|
338 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
|
339 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
|
340 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
|
341 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
|
342 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
|
343 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
|
344 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
|
345 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
|
346 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
|
347 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
|
348 #undef F |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
349 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
350 /* forth pass */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
351 #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
|
352 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
|
353 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
|
354 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
|
355 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
|
356 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
|
357 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
|
358 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
|
359 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
|
360 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
|
361 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
|
362 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
|
363 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
|
364 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
|
365 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
|
366 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
|
367 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
|
368 #undef F |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
369 #undef P |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
370 #undef S |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
371 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
372 md5_context->state[0] += A; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
373 md5_context->state[1] += B; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
374 md5_context->state[2] += C; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
375 md5_context->state[3] += D; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
376 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
377 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
378 static void |
15823 | 379 md5_append(PurpleCipherContext *context, const guchar *data, size_t len) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
380 struct MD5Context *md5_context = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
381 guint32 left = 0, fill = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
382 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 g_return_if_fail(context != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
384 |
15823 | 385 md5_context = purple_cipher_context_get_data(context); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
386 g_return_if_fail(md5_context != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
387 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
388 left = md5_context->total[0] & 0x3F; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
389 fill = 64 - left; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
390 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
391 md5_context->total[0] += len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
392 md5_context->total[0] &= 0xFFFFFFFF; |
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 if(md5_context->total[0] < len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
395 md5_context->total[1]++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
396 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
397 if(left && len >= fill) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
398 memcpy((md5_context->buffer + left), data, fill); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
399 md5_process(md5_context, md5_context->buffer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
400 len -= fill; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
401 data += fill; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
402 left = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
403 } |
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 while(len >= 64) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
406 md5_process(md5_context, data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
407 len -= 64; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
408 data += 64; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
409 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
410 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
411 if(len) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 memcpy((md5_context->buffer + left), data, len); |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
416 static gboolean |
15823 | 417 md5_digest(PurpleCipherContext *context, size_t in_len, guchar digest[16], |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
418 size_t *out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
419 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 struct MD5Context *md5_context = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
421 guint32 last, pad; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
422 guint32 high, low; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
423 guchar message[8]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
424 guchar padding[64] = { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
425 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
|
426 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
|
427 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
|
428 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
|
429 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
430 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
431 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
|
432 |
15823 | 433 md5_context = purple_cipher_context_get_data(context); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
434 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
435 high = (md5_context->total[0] >> 29) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
436 | (md5_context->total[1] << 3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
437 low = (md5_context->total[0] << 3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
438 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
439 MD5_PUT_GUINT32(low, message, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
440 MD5_PUT_GUINT32(high, message, 4); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
441 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
442 last = md5_context->total[0] & 0x3F; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
443 pad = (last < 56) ? (56 - last) : (120 - last); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
444 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
445 md5_append(context, padding, pad); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
446 md5_append(context, message, 8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
447 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
448 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
|
449 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
|
450 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
|
451 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
|
452 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
453 if(out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
454 *out_len = 16; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
455 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
456 return TRUE; |
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 |
15823 | 459 static PurpleCipherOps MD5Ops = { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
460 NULL, /* Set option */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
461 NULL, /* Get option */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
462 md5_init, /* init */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
463 md5_reset, /* reset */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
464 md5_uninit, /* uninit */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
465 NULL, /* set iv */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
466 md5_append, /* append */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
467 md5_digest, /* digest */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
468 NULL, /* encrypt */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
469 NULL, /* decrypt */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
470 NULL, /* set salt */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
471 NULL, /* get salt size */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
472 NULL, /* set key */ |
16676
07cf49a0f404
I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents:
15823
diff
changeset
|
473 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
|
474 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
|
475 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
|
476 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
|
477 NULL /* set key with len */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
478 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
479 |
27390
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
480 #endif /* GLIB_CHECK_VERSION(2,16,0) */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
481 |
15374
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 * MD4 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
484 ******************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
485 #define MD4_DIGEST_SIZE 16 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
486 #define MD4_HMAC_BLOCK_SIZE 64 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
487 #define MD4_BLOCK_WORDS 16 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
488 #define MD4_HASH_WORDS 4 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
489 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
490 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
491 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
492 struct MD4_Context { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
493 guint32 hash[MD4_HASH_WORDS]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
494 guint32 block[MD4_BLOCK_WORDS]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
495 guint64 byte_count; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
496 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
497 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
498 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
|
499 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
500 x &= 0xFFFFFFFF; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
501 return ((x << s) & 0xFFFFFFFF) | (x >> (32 - s)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
502 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
503 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
504 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
|
505 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
506 return (x & y) | ((~x) & z); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
507 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
508 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
509 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
|
510 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
511 return (x & y) | (x & z) | (y & z); |
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 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
|
515 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
516 return x ^ y ^ z; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
517 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
518 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
519 #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
|
520 #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
|
521 #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
|
522 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
523 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
|
524 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
525 while (words--) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
526 *buf=GUINT_FROM_LE(*buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
527 buf++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
528 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
529 } |
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 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
|
532 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
533 while (words--) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
534 *buf=GUINT_TO_LE(*buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
535 buf++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
536 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
537 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
538 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
539 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
|
540 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
541 guint32 a, b, c, d; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
542 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
543 a = hash[0]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
544 b = hash[1]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
545 c = hash[2]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
546 d = hash[3]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
547 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
548 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
|
549 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
|
550 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
|
551 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
|
552 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
|
553 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
|
554 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
|
555 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
|
556 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
|
557 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
|
558 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
|
559 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
|
560 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
|
561 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
|
562 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
|
563 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
|
564 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
565 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
|
566 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
|
567 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
|
568 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
|
569 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
|
570 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
|
571 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
|
572 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
|
573 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
|
574 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
|
575 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
|
576 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
|
577 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
|
578 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
|
579 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
|
580 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
|
581 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
582 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
|
583 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
|
584 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
|
585 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
|
586 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
|
587 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
|
588 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
|
589 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
|
590 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
|
591 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
|
592 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
|
593 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
|
594 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
|
595 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
|
596 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
|
597 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
|
598 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
599 hash[0] += a; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
600 hash[1] += b; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
601 hash[2] += c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
602 hash[3] += d; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
603 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
604 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
605 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
|
606 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
607 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
|
608 md4_transform(ctx->hash, ctx->block); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
609 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
610 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
611 static void |
15823 | 612 md4_init(PurpleCipherContext *context, gpointer extra) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
613 struct MD4_Context *mctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
614 mctx = g_new0(struct MD4_Context, 1); |
15823 | 615 purple_cipher_context_set_data(context, mctx); |
616 purple_cipher_context_reset(context, extra); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
617 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
618 mctx->hash[0] = 0x67452301; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
619 mctx->hash[1] = 0xefcdab89; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
620 mctx->hash[2] = 0x98badcfe; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
621 mctx->hash[3] = 0x10325476; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
622 mctx->byte_count = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
623 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
624 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
625 static void |
15823 | 626 md4_reset(PurpleCipherContext *context, gpointer extra) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
627 struct MD4_Context *mctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
628 |
15823 | 629 mctx = purple_cipher_context_get_data(context); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
630 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
631 mctx->hash[0] = 0x67452301; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
632 mctx->hash[1] = 0xefcdab89; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
633 mctx->hash[2] = 0x98badcfe; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
634 mctx->hash[3] = 0x10325476; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
635 mctx->byte_count = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
636 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
637 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
638 static void |
25415
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25385
diff
changeset
|
639 md4_append(PurpleCipherContext *context, const guchar *data, size_t len) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
640 { |
15823 | 641 struct MD4_Context *mctx = purple_cipher_context_get_data(context); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
642 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
|
643 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
644 mctx->byte_count += len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
645 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
646 if (avail > len) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
647 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
|
648 data, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
649 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
650 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
651 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
652 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
|
653 data, avail); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
654 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
655 md4_transform_helper(mctx); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
656 data += avail; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
657 len -= avail; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
658 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
659 while (len >= sizeof(mctx->block)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
660 memcpy(mctx->block, data, sizeof(mctx->block)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
661 md4_transform_helper(mctx); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
662 data += sizeof(mctx->block); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
663 len -= sizeof(mctx->block); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
664 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
665 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
666 memcpy(mctx->block, data, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
667 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
668 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
669 static gboolean |
15823 | 670 md4_digest(PurpleCipherContext *context, size_t in_len, guchar *out, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
671 size_t *out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
672 { |
15823 | 673 struct MD4_Context *mctx = purple_cipher_context_get_data(context); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
674 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
|
675 char *p = (char *)mctx->block + offset; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
676 int padding = 56 - (offset + 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
677 |
25415
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25385
diff
changeset
|
678 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
679 if(in_len<16) return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
680 if(out_len) *out_len = 16; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
681 *p++ = 0x80; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
682 if (padding < 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
683 memset(p, 0x00, padding + sizeof (guint64)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
684 md4_transform_helper(mctx); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
685 p = (char *)mctx->block; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
686 padding = 56; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
687 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
688 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
689 memset(p, 0, padding); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
690 mctx->block[14] = mctx->byte_count << 3; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
691 mctx->block[15] = mctx->byte_count >> 29; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
692 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
|
693 sizeof(guint64)) / sizeof(guint32)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
694 md4_transform(mctx->hash, mctx->block); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
695 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
|
696 memcpy(out, mctx->hash, sizeof(mctx->hash)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
697 memset(mctx, 0, sizeof(*mctx)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
698 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
699 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
700 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
701 static void |
15823 | 702 md4_uninit(PurpleCipherContext *context) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
703 struct MD4_Context *md4_context; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
704 |
15823 | 705 purple_cipher_context_reset(context, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
706 |
15823 | 707 md4_context = purple_cipher_context_get_data(context); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
708 memset(md4_context, 0, sizeof(md4_context)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
709 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
710 g_free(md4_context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
711 md4_context = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
712 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
713 |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
714 static size_t |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
715 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
|
716 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
717 /* 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
|
718 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
|
719 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
720 |
15823 | 721 static PurpleCipherOps MD4Ops = { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
722 NULL, /* Set option */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
723 NULL, /* Get option */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
724 md4_init, /* init */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
725 md4_reset, /* reset */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
726 md4_uninit, /* uninit */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
727 NULL, /* set iv */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
728 md4_append, /* append */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
729 md4_digest, /* digest */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
730 NULL, /* encrypt */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
731 NULL, /* decrypt */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
732 NULL, /* set salt */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
733 NULL, /* get salt size */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
734 NULL, /* set key */ |
16676
07cf49a0f404
I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents:
15823
diff
changeset
|
735 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
|
736 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
|
737 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
|
738 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
|
739 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
|
740 }; |
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 /******************************************************************************* |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
743 * HMAC |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
744 ******************************************************************************/ |
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 struct HMAC_Context { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
747 PurpleCipherContext *hash; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
748 char *name; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
749 int blocksize; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
750 guchar *opad; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
751 }; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
752 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
753 static void |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
754 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
|
755 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
756 struct HMAC_Context *hctx; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
757 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
|
758 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
|
759 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
|
760 } |
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 static void |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
763 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
|
764 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
765 struct HMAC_Context *hctx; |
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 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
|
768 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
769 g_free(hctx->name); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
770 hctx->name = NULL; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
771 if (hctx->hash) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
772 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
|
773 hctx->hash = NULL; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
774 hctx->blocksize = 0; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
775 g_free(hctx->opad); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
776 hctx->opad = NULL; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
777 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
778 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
779 static void |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
780 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
|
781 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
782 struct HMAC_Context *hctx; |
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 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 |
25385
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:
23600
diff
changeset
|
786 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
|
787 g_free(hctx->name); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
788 if (hctx->hash) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
789 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
|
790 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
|
791 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
|
792 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
|
793 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
794 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
795 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
796 static void * |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
797 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
|
798 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
799 struct HMAC_Context *hctx; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
800 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
801 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
|
802 |
25385
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:
23600
diff
changeset
|
803 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
|
804 return hctx->name; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
805 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
806 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
807 return NULL; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
808 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
809 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
810 static void |
25415
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25385
diff
changeset
|
811 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
|
812 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
813 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
|
814 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
815 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
|
816 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
817 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
|
818 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
819 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
820 static gboolean |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
821 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
|
822 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
823 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
|
824 PurpleCipherContext *hash = hctx->hash; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
825 guchar *inner_hash; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
826 size_t hash_len; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
827 gboolean result; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
828 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
829 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
|
830 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
831 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
|
832 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
|
833 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
834 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
|
835 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
836 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
|
837 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
|
838 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
839 g_free(inner_hash); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
840 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
841 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
|
842 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
843 return result; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
844 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
845 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
846 static void |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
847 hmac_uninit(PurpleCipherContext *context) |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
848 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
849 struct HMAC_Context *hctx; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
850 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
851 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
|
852 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
853 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
|
854 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
855 g_free(hctx); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
856 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
857 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
858 static void |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
859 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
|
860 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
861 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
|
862 int blocksize, i; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
863 guchar *ipad; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
864 guchar *full_key; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
865 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
866 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
|
867 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
868 g_free(hctx->opad); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
869 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
870 blocksize = hctx->blocksize; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
871 ipad = g_malloc(blocksize); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
872 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
|
873 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
874 if (key_len > blocksize) { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
875 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
|
876 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
|
877 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
|
878 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
|
879 } else |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
880 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
|
881 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
882 if (key_len < blocksize) { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
883 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
|
884 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
|
885 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
886 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
887 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
|
888 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
|
889 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
|
890 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
891 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
892 g_free(full_key); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
893 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
894 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
|
895 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
|
896 g_free(ipad); |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
897 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
898 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
899 static void |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
900 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
|
901 { |
22011
76e0463db3aa
Squash some compiler warnings, some from my -Wstrict-prototypes fixing.
Richard Laager <rlaager@wiktel.com>
parents:
21908
diff
changeset
|
902 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
|
903 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
904 |
25415
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25385
diff
changeset
|
905 static size_t |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
906 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
|
907 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
908 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
|
909 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
910 return hctx->blocksize; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
911 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
912 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
913 static PurpleCipherOps HMACOps = { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
914 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
|
915 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
|
916 hmac_init, /* init */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
917 hmac_reset, /* reset */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
918 hmac_uninit, /* uninit */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
919 NULL, /* set iv */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
920 hmac_append, /* append */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
921 hmac_digest, /* digest */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
922 NULL, /* encrypt */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
923 NULL, /* decrypt */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
924 NULL, /* set salt */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
925 NULL, /* get salt size */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
926 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
|
927 NULL, /* get key size */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
928 NULL, /* set batch mode */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
929 NULL, /* get batch mode */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
930 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
|
931 hmac_set_key_with_len /* set key with len */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
932 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
933 |
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 * DES |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
936 *****************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
937 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
938 typedef struct _des_ctx |
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 guint32 encrypt_subkeys[32]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
941 guint32 decrypt_subkeys[32]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
942 } des_ctx[1]; |
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 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
945 * 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
|
946 */ |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19680
diff
changeset
|
947 static const guint32 sbox1[64] = |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
948 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
949 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
|
950 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
|
951 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
|
952 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
|
953 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
|
954 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
|
955 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
|
956 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
|
957 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
958 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19680
diff
changeset
|
959 static const guint32 sbox2[64] = |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
960 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
961 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
|
962 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
|
963 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
|
964 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
|
965 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
|
966 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
|
967 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
|
968 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
|
969 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
970 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19680
diff
changeset
|
971 static const guint32 sbox3[64] = |
15374
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 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
|
974 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
|
975 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
|
976 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
|
977 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
|
978 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
|
979 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
|
980 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
|
981 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
982 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19680
diff
changeset
|
983 static const guint32 sbox4[64] = |
15374
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 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
|
986 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
|
987 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
|
988 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
|
989 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
|
990 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
|
991 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
|
992 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
|
993 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
994 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19680
diff
changeset
|
995 static const guint32 sbox5[64] = |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
996 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
997 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
|
998 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
|
999 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
|
1000 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
|
1001 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
|
1002 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
|
1003 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
|
1004 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
|
1005 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1006 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19680
diff
changeset
|
1007 static const guint32 sbox6[64] = |
15374
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 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
|
1010 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
|
1011 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
|
1012 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
|
1013 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
|
1014 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
|
1015 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
|
1016 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
|
1017 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1018 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19680
diff
changeset
|
1019 static const guint32 sbox7[64] = |
15374
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 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
|
1022 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
|
1023 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
|
1024 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
|
1025 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
|
1026 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
|
1027 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
|
1028 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
|
1029 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1030 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19680
diff
changeset
|
1031 static const guint32 sbox8[64] = |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1032 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1033 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
|
1034 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
|
1035 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
|
1036 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
|
1037 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
|
1038 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
|
1039 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
|
1040 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
|
1041 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1042 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1043 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1044 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1045 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1046 * * 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
|
1047 * * 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
|
1048 * */ |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19680
diff
changeset
|
1049 static const guint32 leftkey_swap[16] = |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1050 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1051 0x00000000, 0x00000001, 0x00000100, 0x00000101, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1052 0x00010000, 0x00010001, 0x00010100, 0x00010101, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1053 0x01000000, 0x01000001, 0x01000100, 0x01000101, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1054 0x01010000, 0x01010001, 0x01010100, 0x01010101 |
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 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19680
diff
changeset
|
1057 static const guint32 rightkey_swap[16] = |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1058 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1059 0x00000000, 0x01000000, 0x00010000, 0x01010000, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1060 0x00000100, 0x01000100, 0x00010100, 0x01010100, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1061 0x00000001, 0x01000001, 0x00010001, 0x01010001, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1062 0x00000101, 0x01000101, 0x00010101, 0x01010101, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1063 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1064 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1065 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1066 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1067 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1068 * 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
|
1069 * 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
|
1070 * 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
|
1071 * subkey schedule. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1072 */ |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
19680
diff
changeset
|
1073 static const guint8 encrypt_rotate_tab[16] = |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1074 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1075 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
|
1076 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1077 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1078 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1079 * Macro to swap bits across two words |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1080 **/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1081 #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
|
1082 temp = ((a>>offset) ^ b) & mask; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1083 b ^= temp; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1084 a ^= temp<<offset; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1085 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1086 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1087 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1088 * 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
|
1089 **/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1090 #define INITIAL_PERMUTATION(left, temp, right) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1091 DO_PERMUTATION(left, temp, right, 4, 0x0f0f0f0f) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1092 DO_PERMUTATION(left, temp, right, 16, 0x0000ffff) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1093 DO_PERMUTATION(right, temp, left, 2, 0x33333333) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1094 DO_PERMUTATION(right, temp, left, 8, 0x00ff00ff) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1095 DO_PERMUTATION(left, temp, right, 1, 0x55555555) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1096 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1097 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1098 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1099 * The 'inverse initial permutation' |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1100 **/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1101 #define FINAL_PERMUTATION(left, temp, right) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1102 DO_PERMUTATION(left, temp, right, 1, 0x55555555) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1103 DO_PERMUTATION(right, temp, left, 8, 0x00ff00ff) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1104 DO_PERMUTATION(right, temp, left, 2, 0x33333333) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1105 DO_PERMUTATION(left, temp, right, 16, 0x0000ffff) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1106 DO_PERMUTATION(left, temp, right, 4, 0x0f0f0f0f) |
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 * 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
|
1111 * 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
|
1112 **/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1113 #define DES_ROUND(from, to, work, subkey) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1114 work = ((from<<1) | (from>>31)) ^ *subkey++; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1115 to ^= sbox8[ work & 0x3f ]; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1116 to ^= sbox6[ (work>>8) & 0x3f ]; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1117 to ^= sbox4[ (work>>16) & 0x3f ]; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1118 to ^= sbox2[ (work>>24) & 0x3f ]; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1119 work = ((from>>3) | (from<<29)) ^ *subkey++; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1120 to ^= sbox7[ work & 0x3f ]; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1121 to ^= sbox5[ (work>>8) & 0x3f ]; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1122 to ^= sbox3[ (work>>16) & 0x3f ]; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1123 to ^= sbox1[ (work>>24) & 0x3f ]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1124 |
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 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1127 * 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
|
1128 **/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1129 #define READ_64BIT_DATA(data, left, right) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1130 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
|
1131 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
|
1132 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1133 #define WRITE_64BIT_DATA(data, left, right) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1134 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
|
1135 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
|
1136 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
|
1137 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
|
1138 |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1141 |
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 |
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 * 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
|
1146 * 16 encryption rounds. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1147 * To calculate subkeys for decryption the caller |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1148 * have to reorder the generated subkeys. |
25415
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25385
diff
changeset
|
1149 * |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1150 * rawkey: 8 Bytes of key data |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1151 * 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
|
1152 * with calculated subkeys. |
25415
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25385
diff
changeset
|
1153 * |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1154 **/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1155 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1156 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
|
1157 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1158 guint32 left, right, work; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1159 int round; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1160 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1161 READ_64BIT_DATA (rawkey, left, right) |
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 DO_PERMUTATION (right, work, left, 4, 0x0f0f0f0f) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1164 DO_PERMUTATION (right, work, left, 0, 0x10101010) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1165 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1166 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
|
1167 | (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
|
1168 | (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
|
1169 | (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
|
1170 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1171 left &= 0x0fffffff; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1172 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1173 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
|
1174 | (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
|
1175 | (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
|
1176 | (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
|
1177 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1178 right &= 0x0fffffff; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1179 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1180 for (round = 0; round < 16; ++round) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1181 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1182 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
|
1183 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
|
1184 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1185 *subkey++ = ((left << 4) & 0x24000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1186 | ((left << 28) & 0x10000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1187 | ((left << 14) & 0x08000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1188 | ((left << 18) & 0x02080000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1189 | ((left << 6) & 0x01000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1190 | ((left << 9) & 0x00200000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1191 | ((left >> 1) & 0x00100000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1192 | ((left << 10) & 0x00040000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1193 | ((left << 2) & 0x00020000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1194 | ((left >> 10) & 0x00010000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1195 | ((right >> 13) & 0x00002000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1196 | ((right >> 4) & 0x00001000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1197 | ((right << 6) & 0x00000800) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1198 | ((right >> 1) & 0x00000400) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1199 | ((right >> 14) & 0x00000200) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1200 | (right & 0x00000100) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1201 | ((right >> 5) & 0x00000020) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1202 | ((right >> 10) & 0x00000010) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1203 | ((right >> 3) & 0x00000008) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1204 | ((right >> 18) & 0x00000004) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1205 | ((right >> 26) & 0x00000002) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1206 | ((right >> 24) & 0x00000001); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1207 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1208 *subkey++ = ((left << 15) & 0x20000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1209 | ((left << 17) & 0x10000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1210 | ((left << 10) & 0x08000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1211 | ((left << 22) & 0x04000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1212 | ((left >> 2) & 0x02000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1213 | ((left << 1) & 0x01000000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1214 | ((left << 16) & 0x00200000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1215 | ((left << 11) & 0x00100000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1216 | ((left << 3) & 0x00080000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1217 | ((left >> 6) & 0x00040000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1218 | ((left << 15) & 0x00020000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1219 | ((left >> 4) & 0x00010000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1220 | ((right >> 2) & 0x00002000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1221 | ((right << 8) & 0x00001000) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1222 | ((right >> 14) & 0x00000808) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1223 | ((right >> 9) & 0x00000400) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1224 | ((right) & 0x00000200) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1225 | ((right << 7) & 0x00000100) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1226 | ((right >> 7) & 0x00000020) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1227 | ((right >> 3) & 0x00000011) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1228 | ((right << 2) & 0x00000004) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1229 | ((right >> 21) & 0x00000002); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1230 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1231 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1232 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1233 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1234 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1235 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1236 * 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
|
1237 * 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
|
1238 * Does not check for weak keys. |
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 static void |
15823 | 1241 des_set_key (PurpleCipherContext *context, const guchar * key) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1242 { |
15823 | 1243 struct _des_ctx *ctx = purple_cipher_context_get_data(context); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1244 int i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1245 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1246 des_key_schedule (key, ctx->encrypt_subkeys); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1247 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1248 for(i=0; i<32; i+=2) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1249 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1250 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
|
1251 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
|
1252 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1253 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1254 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1255 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1256 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1257 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1258 * 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
|
1259 * to 'mode'. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1260 **/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1261 static int |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1262 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
|
1263 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1264 guint32 left, right, work; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1265 guint32 *keys; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1266 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1267 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
|
1268 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1269 READ_64BIT_DATA (from, left, right) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1270 INITIAL_PERMUTATION (left, work, right) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1271 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1272 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
|
1273 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
|
1274 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
|
1275 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
|
1276 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
|
1277 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
|
1278 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
|
1279 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
|
1280 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1281 FINAL_PERMUTATION (right, work, left) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1282 WRITE_64BIT_DATA (to, right, left) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1283 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1284 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1285 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1286 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1287 static gint |
15823 | 1288 des_encrypt(PurpleCipherContext *context, const guchar data[], |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1289 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
|
1290 int offset = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1291 int i = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1292 int tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1293 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
|
1294 while(offset+8<=len) { |
15823 | 1295 des_ecb_crypt(purple_cipher_context_get_data(context), |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1296 data+offset, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1297 output+offset, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1298 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1299 offset+=8; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1300 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1301 *outlen = len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1302 if(offset<len) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1303 *outlen += len - offset; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1304 tmp = offset; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1305 while(tmp<len) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1306 buf[i++] = data[tmp]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1307 tmp++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1308 } |
15823 | 1309 des_ecb_crypt(purple_cipher_context_get_data(context), |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1310 buf, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1311 output+offset, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1312 0); |
25415
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25385
diff
changeset
|
1313 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1314 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1315 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1316 |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1317 static gint |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1318 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
|
1319 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
|
1320 int offset = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1321 int i = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1322 int tmp; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1323 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
|
1324 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
|
1325 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
|
1326 data+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1327 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1328 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1329 offset+=8; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1330 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1331 *outlen = len; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1332 if(offset<len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1333 *outlen += len - offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1334 tmp = offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1335 while(tmp<len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1336 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
|
1337 tmp++; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1338 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1339 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
|
1340 buf, |
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 1); |
25415
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25385
diff
changeset
|
1343 } |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1344 return 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1345 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1346 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1347 static void |
15823 | 1348 des_init(PurpleCipherContext *context, gpointer extra) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1349 struct _des_ctx *mctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1350 mctx = g_new0(struct _des_ctx, 1); |
15823 | 1351 purple_cipher_context_set_data(context, mctx); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1352 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1353 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1354 static void |
15823 | 1355 des_uninit(PurpleCipherContext *context) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1356 struct _des_ctx *des_context; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1357 |
15823 | 1358 des_context = purple_cipher_context_get_data(context); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1359 memset(des_context, 0, sizeof(des_context)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1360 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1361 g_free(des_context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1362 des_context = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1363 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1364 |
15823 | 1365 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
|
1366 NULL, /* Set option */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1367 NULL, /* Get option */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1368 des_init, /* init */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1369 NULL, /* reset */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1370 des_uninit, /* uninit */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1371 NULL, /* set iv */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1372 NULL, /* append */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1373 NULL, /* digest */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1374 des_encrypt, /* encrypt */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1375 des_decrypt, /* decrypt */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1376 NULL, /* set salt */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1377 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
|
1378 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
|
1379 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
|
1380 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
|
1381 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
|
1382 NULL, /* get block size */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
1383 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
|
1384 }; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1385 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1386 /****************************************************************************** |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1387 * Triple-DES |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1388 *****************************************************************************/ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1389 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1390 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
|
1391 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1392 PurpleCipherBatchMode mode; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1393 guchar iv[8]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1394 /* 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
|
1395 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
|
1396 /* 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
|
1397 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
|
1398 /* 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
|
1399 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
|
1400 } des3_ctx[1]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1401 |
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 * 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
|
1404 * 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
|
1405 * 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
|
1406 **/ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1407 static void |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1408 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
|
1409 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1410 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
|
1411 int i; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1412 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1413 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
|
1414 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
|
1415 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
|
1416 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1417 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
|
1418 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1419 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
|
1420 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
|
1421 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
|
1422 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
|
1423 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
|
1424 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
|
1425 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1426 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1427 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1428 static gint |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1429 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
|
1430 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
|
1431 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1432 int offset = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1433 int i = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1434 int tmp; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1435 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
|
1436 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
|
1437 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
|
1438 data+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1439 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1440 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1441 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
|
1442 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1443 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1444 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1445 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
|
1446 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1447 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1448 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1449 offset += 8; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1450 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1451 *outlen = len; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1452 if (offset < len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1453 *outlen += len - offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1454 tmp = offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1455 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
|
1456 while (tmp < len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1457 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
|
1458 tmp++; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1459 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1460 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
|
1461 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1462 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1463 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1464 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
|
1465 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1466 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1467 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1468 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
|
1469 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1470 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1471 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1472 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1473 return 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1474 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1475 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1476 static gint |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1477 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
|
1478 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
|
1479 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1480 int offset = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1481 int i = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1482 int tmp; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1483 guint8 buf[8]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1484 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
|
1485 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
|
1486 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
|
1487 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
|
1488 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
|
1489 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1490 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1491 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1492 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
|
1493 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1494 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1495 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1496 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
|
1497 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1498 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1499 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1500 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
|
1501 offset += 8; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1502 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1503 *outlen = len; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1504 if (offset < len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1505 *outlen += len - offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1506 tmp = offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1507 i = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1508 while (tmp < len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1509 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
|
1510 tmp++; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1511 } |
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->key1, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1513 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1514 output+offset, |
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->key2, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1517 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1518 buf, |
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 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
|
1521 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1522 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1523 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 return 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1526 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1527 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1528 static gint |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1529 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
|
1530 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
|
1531 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1532 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
|
1533 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1534 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
|
1535 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
|
1536 } 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
|
1537 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
|
1538 } else { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1539 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
|
1540 } |
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 return 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1543 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1544 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1545 static gint |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1546 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
|
1547 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
|
1548 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1549 int offset = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1550 int i = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1551 int tmp; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1552 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
|
1553 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
|
1554 /* 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
|
1555 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
|
1556 data+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1557 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1558 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1559 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
|
1560 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1561 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1562 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1563 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
|
1564 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1565 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1566 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1567 offset+=8; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1568 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1569 *outlen = len; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1570 if (offset < len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1571 *outlen += len - offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1572 tmp = offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1573 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
|
1574 while (tmp < len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1575 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
|
1576 tmp++; |
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 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
|
1579 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1580 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1581 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1582 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
|
1583 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1584 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1585 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1586 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
|
1587 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1588 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1589 1); |
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 return 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1592 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1593 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1594 static gint |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1595 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
|
1596 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
|
1597 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1598 int offset = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1599 int i = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1600 int tmp; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1601 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
|
1602 guint8 link[8]; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1603 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
|
1604 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
|
1605 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
|
1606 data+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1607 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1608 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1609 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
|
1610 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1611 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1612 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1613 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
|
1614 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1615 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1616 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1617 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
|
1618 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
|
1619 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
|
1620 offset+=8; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1621 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1622 *outlen = len; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1623 if(offset<len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1624 *outlen += len - offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1625 tmp = offset; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1626 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
|
1627 i = 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1628 while(tmp<len) { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1629 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
|
1630 tmp++; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1631 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1632 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
|
1633 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1634 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1635 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1636 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
|
1637 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1638 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1639 0); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1640 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
|
1641 buf, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1642 output+offset, |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1643 1); |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1644 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
|
1645 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
|
1646 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1647 return 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1648 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1649 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1650 static gint |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1651 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
|
1652 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
|
1653 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1654 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
|
1655 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1656 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
|
1657 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
|
1658 } 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
|
1659 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
|
1660 } else { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1661 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
|
1662 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1663 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1664 return 0; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1665 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1666 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1667 static void |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1668 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
|
1669 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1670 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
|
1671 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1672 ctx->mode = mode; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1673 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1674 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1675 static PurpleCipherBatchMode |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1676 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
|
1677 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1678 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
|
1679 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1680 return ctx->mode; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1681 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1682 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1683 static void |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1684 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
|
1685 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1686 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
|
1687 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1688 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
|
1689 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1690 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
|
1691 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1692 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
|
1693 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1694 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1695 static void |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1696 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
|
1697 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1698 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
|
1699 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
|
1700 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
|
1701 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1702 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1703 static void |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1704 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
|
1705 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1706 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
|
1707 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1708 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
|
1709 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
|
1710 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1711 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
|
1712 des3_context = NULL; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1713 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1714 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1715 static PurpleCipherOps DES3Ops = { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1716 NULL, /* Set option */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1717 NULL, /* Get option */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1718 des3_init, /* init */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1719 NULL, /* reset */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1720 des3_uninit, /* uninit */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1721 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
|
1722 NULL, /* append */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1723 NULL, /* digest */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1724 des3_encrypt, /* encrypt */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1725 des3_decrypt, /* decrypt */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1726 NULL, /* set salt */ |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
1727 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
|
1728 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
|
1729 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
|
1730 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
|
1731 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
|
1732 NULL, /* get block size */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
1733 NULL /* set key with len */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1734 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1735 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1736 /******************************************************************************* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1737 * SHA-1 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1738 ******************************************************************************/ |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
1739 #define SHA1_HMAC_BLOCK_SIZE 64 |
27390
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1740 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1741 static size_t |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1742 sha1_get_block_size(PurpleCipherContext *context) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1743 { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1744 /* This does not change (in this case) */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1745 return SHA1_HMAC_BLOCK_SIZE; |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1746 } |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1747 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1748 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1749 #if GLIB_CHECK_VERSION(2,16,0) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1750 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1751 static void |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1752 sha1_init(PurpleCipherContext *context, void *extra) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1753 { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1754 purple_g_checksum_init(context, G_CHECKSUM_SHA1); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1755 } |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1756 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1757 static void |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1758 sha1_reset(PurpleCipherContext *context, void *extra) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1759 { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1760 purple_g_checksum_reset(context, G_CHECKSUM_SHA1); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1761 } |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1762 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1763 static gboolean |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1764 sha1_digest(PurpleCipherContext *context, gsize in_len, guchar digest[20], |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1765 gsize *out_len) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1766 { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1767 return purple_g_checksum_digest(context, G_CHECKSUM_SHA1, in_len, |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1768 digest, out_len); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1769 } |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1770 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1771 static PurpleCipherOps SHA1Ops = { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1772 NULL, /* Set Option */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1773 NULL, /* Get Option */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1774 sha1_init, /* init */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1775 sha1_reset, /* reset */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1776 purple_g_checksum_uninit, /* uninit */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1777 NULL, /* set iv */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1778 purple_g_checksum_append, /* append */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1779 sha1_digest, /* digest */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1780 NULL, /* encrypt */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1781 NULL, /* decrypt */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1782 NULL, /* set salt */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1783 NULL, /* get salt size */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1784 NULL, /* set key */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1785 NULL, /* get key size */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1786 NULL, /* set batch mode */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1787 NULL, /* get batch mode */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1788 sha1_get_block_size, /* get block size */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1789 NULL /* set key with len */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1790 }; |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1791 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1792 #else /* GLIB_CHECK_VERSION(2,16,0) */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1793 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1794 #define SHA1_HMAC_BLOCK_SIZE 64 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1795 #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
|
1796 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1797 struct SHA1Context { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1798 guint32 H[5]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1799 guint32 W[80]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1800 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1801 gint lenW; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1802 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1803 guint32 sizeHi; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1804 guint32 sizeLo; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1807 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1808 sha1_hash_block(struct SHA1Context *sha1_ctx) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1809 gint i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1810 guint32 A, B, C, D, E, T; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1811 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1812 for(i = 16; i < 80; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1813 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
|
1814 sha1_ctx->W[i - 8] ^ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1815 sha1_ctx->W[i - 14] ^ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1816 sha1_ctx->W[i - 16], 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1817 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1818 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1819 A = sha1_ctx->H[0]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1820 B = sha1_ctx->H[1]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1821 C = sha1_ctx->H[2]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1822 D = sha1_ctx->H[3]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1823 E = sha1_ctx->H[4]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1824 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1825 for(i = 0; i < 20; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1826 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
|
1827 E = D; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1828 D = C; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1829 C = SHA1_ROTL(B, 30); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1830 B = A; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1831 A = T; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1834 for(i = 20; i < 40; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1835 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
|
1836 E = D; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1837 D = C; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1838 C = SHA1_ROTL(B, 30); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1839 B = A; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1840 A = T; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1841 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1842 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1843 for(i = 40; i < 60; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1844 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
|
1845 E = D; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1846 D = C; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1847 C = SHA1_ROTL(B, 30); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1848 B = A; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1849 A = T; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1850 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1851 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1852 for(i = 60; i < 80; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1853 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
|
1854 E = D; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1855 D = C; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1856 C = SHA1_ROTL(B, 30); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1857 B = A; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1858 A = T; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1859 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1860 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1861 sha1_ctx->H[0] += A; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1862 sha1_ctx->H[1] += B; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1863 sha1_ctx->H[2] += C; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1864 sha1_ctx->H[3] += D; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1865 sha1_ctx->H[4] += E; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1866 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1867 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1868 static void |
15823 | 1869 sha1_set_opt(PurpleCipherContext *context, const gchar *name, void *value) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1870 struct SHA1Context *ctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1871 |
15823 | 1872 ctx = purple_cipher_context_get_data(context); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1873 |
25385
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:
23600
diff
changeset
|
1874 if(purple_strequal(name, "sizeHi")) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1875 ctx->sizeHi = GPOINTER_TO_INT(value); |
25385
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:
23600
diff
changeset
|
1876 } else if(purple_strequal(name, "sizeLo")) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1877 ctx->sizeLo = GPOINTER_TO_INT(value); |
25385
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:
23600
diff
changeset
|
1878 } else if(purple_strequal(name, "lenW")) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1879 ctx->lenW = GPOINTER_TO_INT(value); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1880 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1881 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1882 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1883 static void * |
15823 | 1884 sha1_get_opt(PurpleCipherContext *context, const gchar *name) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1885 struct SHA1Context *ctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1886 |
15823 | 1887 ctx = purple_cipher_context_get_data(context); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1888 |
25385
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:
23600
diff
changeset
|
1889 if(purple_strequal(name, "sizeHi")) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1890 return GINT_TO_POINTER(ctx->sizeHi); |
25385
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:
23600
diff
changeset
|
1891 } else if(purple_strequal(name, "sizeLo")) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1892 return GINT_TO_POINTER(ctx->sizeLo); |
25385
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:
23600
diff
changeset
|
1893 } else if(purple_strequal(name, "lenW")) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1894 return GINT_TO_POINTER(ctx->lenW); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1895 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1896 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1897 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1898 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1899 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1900 static void |
15823 | 1901 sha1_init(PurpleCipherContext *context, void *extra) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1902 struct SHA1Context *sha1_ctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1903 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1904 sha1_ctx = g_new0(struct SHA1Context, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1905 |
15823 | 1906 purple_cipher_context_set_data(context, sha1_ctx); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1907 |
15823 | 1908 purple_cipher_context_reset(context, extra); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1909 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1910 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1911 static void |
15823 | 1912 sha1_reset(PurpleCipherContext *context, void *extra) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1913 struct SHA1Context *sha1_ctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1914 gint i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1915 |
15823 | 1916 sha1_ctx = purple_cipher_context_get_data(context); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1917 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1918 g_return_if_fail(sha1_ctx); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1919 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1920 sha1_ctx->lenW = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1921 sha1_ctx->sizeHi = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1922 sha1_ctx->sizeLo = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1923 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1924 sha1_ctx->H[0] = 0x67452301; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1925 sha1_ctx->H[1] = 0xEFCDAB89; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1926 sha1_ctx->H[2] = 0x98BADCFE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1927 sha1_ctx->H[3] = 0x10325476; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1928 sha1_ctx->H[4] = 0xC3D2E1F0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1929 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1930 for(i = 0; i < 80; i++) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1931 sha1_ctx->W[i] = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1932 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1933 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1934 static void |
15823 | 1935 sha1_uninit(PurpleCipherContext *context) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1936 struct SHA1Context *sha1_ctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1937 |
15823 | 1938 purple_cipher_context_reset(context, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1939 |
15823 | 1940 sha1_ctx = purple_cipher_context_get_data(context); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1941 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1942 memset(sha1_ctx, 0, sizeof(struct SHA1Context)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1943 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1944 g_free(sha1_ctx); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1945 sha1_ctx = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1946 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1947 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1948 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1949 static void |
15823 | 1950 sha1_append(PurpleCipherContext *context, const guchar *data, size_t len) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1951 struct SHA1Context *sha1_ctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1952 gint i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1953 |
15823 | 1954 sha1_ctx = purple_cipher_context_get_data(context); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1955 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1956 g_return_if_fail(sha1_ctx); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1957 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1958 for(i = 0; i < len; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1959 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
|
1960 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
|
1961 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1962 if((++sha1_ctx->lenW) % 64 == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1963 sha1_hash_block(sha1_ctx); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1964 sha1_ctx->lenW = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1965 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1966 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1967 sha1_ctx->sizeLo += 8; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1968 sha1_ctx->sizeHi += (sha1_ctx->sizeLo < 8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1969 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1970 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1971 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1972 static gboolean |
15823 | 1973 sha1_digest(PurpleCipherContext *context, size_t in_len, guchar digest[20], |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1974 size_t *out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1975 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1976 struct SHA1Context *sha1_ctx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1977 guchar pad0x80 = 0x80, pad0x00 = 0x00; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1978 guchar padlen[8]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1979 gint i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1980 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1981 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
|
1982 |
15823 | 1983 sha1_ctx = purple_cipher_context_get_data(context); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1984 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1985 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
|
1986 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1987 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
|
1988 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
|
1989 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
|
1990 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
|
1991 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
|
1992 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
|
1993 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
|
1994 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
|
1995 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1996 /* pad with a 1, then zeroes, then length */ |
15823 | 1997 purple_cipher_context_append(context, &pad0x80, 1); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1998 while(sha1_ctx->lenW != 56) |
15823 | 1999 purple_cipher_context_append(context, &pad0x00, 1); |
2000 purple_cipher_context_append(context, padlen, 8); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2001 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2002 for(i = 0; i < 20; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2003 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
|
2004 sha1_ctx->H[i / 4] <<= 8; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2005 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2006 |
15823 | 2007 purple_cipher_context_reset(context, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2008 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2009 if(out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2010 *out_len = 20; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2011 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2012 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2013 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2014 |
15823 | 2015 static PurpleCipherOps SHA1Ops = { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2016 sha1_set_opt, /* Set Option */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2017 sha1_get_opt, /* Get Option */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2018 sha1_init, /* init */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2019 sha1_reset, /* reset */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2020 sha1_uninit, /* uninit */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2021 NULL, /* set iv */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2022 sha1_append, /* append */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2023 sha1_digest, /* digest */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2024 NULL, /* encrypt */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2025 NULL, /* decrypt */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2026 NULL, /* set salt */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2027 NULL, /* get salt size */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2028 NULL, /* set key */ |
16676
07cf49a0f404
I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents:
15823
diff
changeset
|
2029 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
|
2030 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
|
2031 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
|
2032 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
|
2033 NULL /* set key with len */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2034 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2035 |
27390
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2036 #endif /* GLIB_CHECK_VERSION(2,16,0) */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2037 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2038 /******************************************************************************* |
27241
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2039 * SHA-256 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2040 ******************************************************************************/ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2041 #define SHA256_HMAC_BLOCK_SIZE 64 |
27390
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2042 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2043 static size_t |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2044 sha256_get_block_size(PurpleCipherContext *context) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2045 { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2046 /* This does not change (in this case) */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2047 return SHA256_HMAC_BLOCK_SIZE; |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2048 } |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2049 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2050 #if GLIB_CHECK_VERSION(2,16,0) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2051 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2052 static void |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2053 sha256_init(PurpleCipherContext *context, void *extra) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2054 { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2055 purple_g_checksum_init(context, G_CHECKSUM_SHA256); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2056 } |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2057 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2058 static void |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2059 sha256_reset(PurpleCipherContext *context, void *extra) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2060 { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2061 purple_g_checksum_reset(context, G_CHECKSUM_SHA256); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2062 } |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2063 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2064 static gboolean |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2065 sha256_digest(PurpleCipherContext *context, gsize in_len, guchar digest[20], |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2066 gsize *out_len) |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2067 { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2068 return purple_g_checksum_digest(context, G_CHECKSUM_SHA256, in_len, |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2069 digest, out_len); |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2070 } |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2071 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2072 static PurpleCipherOps SHA256Ops = { |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2073 NULL, /* Set Option */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2074 NULL, /* Get Option */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2075 sha256_init, /* init */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2076 sha256_reset, /* reset */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2077 purple_g_checksum_uninit, /* uninit */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2078 NULL, /* set iv */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2079 purple_g_checksum_append, /* append */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2080 sha256_digest, /* digest */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2081 NULL, /* encrypt */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2082 NULL, /* decrypt */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2083 NULL, /* set salt */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2084 NULL, /* get salt size */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2085 NULL, /* set key */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2086 NULL, /* get key size */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2087 NULL, /* set batch mode */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2088 NULL, /* get batch mode */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2089 sha256_get_block_size, /* get block size */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2090 NULL /* set key with len */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2091 }; |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2092 |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2093 #else /* GLIB_CHECK_VERSION(2,16,0) */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2094 |
27241
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2095 #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:
25415
diff
changeset
|
2096 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2097 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:
25415
diff
changeset
|
2098 { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2099 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:
25415
diff
changeset
|
2100 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:
25415
diff
changeset
|
2101 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:
25415
diff
changeset
|
2102 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:
25415
diff
changeset
|
2103 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:
25415
diff
changeset
|
2104 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:
25415
diff
changeset
|
2105 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:
25415
diff
changeset
|
2106 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:
25415
diff
changeset
|
2107 }; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2108 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2109 struct SHA256Context { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2110 guint32 H[8]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2111 guint32 W[64]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2112 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2113 gint lenW; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2114 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2115 guint32 sizeHi; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2116 guint32 sizeLo; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2117 }; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2118 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2119 static void |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2120 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:
25415
diff
changeset
|
2121 gint i; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2122 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:
25415
diff
changeset
|
2123 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2124 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:
25415
diff
changeset
|
2125 sha256_ctx->W[i] = |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2126 (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:
25415
diff
changeset
|
2127 + sha256_ctx->W[i-7] |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2128 + (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:
25415
diff
changeset
|
2129 + sha256_ctx->W[i-16]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2130 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2131 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2132 A = sha256_ctx->H[0]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2133 B = sha256_ctx->H[1]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2134 C = sha256_ctx->H[2]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2135 D = sha256_ctx->H[3]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2136 E = sha256_ctx->H[4]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2137 F = sha256_ctx->H[5]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2138 G = sha256_ctx->H[6]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2139 H = sha256_ctx->H[7]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2140 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2141 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:
25415
diff
changeset
|
2142 T1 = H |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2143 + (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:
25415
diff
changeset
|
2144 + ((E & F) ^ ((~E) & G)) |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2145 + 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:
25415
diff
changeset
|
2146 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:
25415
diff
changeset
|
2147 + ((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:
25415
diff
changeset
|
2148 H = G; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2149 G = F; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2150 F = E; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2151 E = D + T1; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2152 D = C; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2153 C = B; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2154 B = A; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2155 A = T1 + T2; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2156 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2157 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2158 sha256_ctx->H[0] += A; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2159 sha256_ctx->H[1] += B; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2160 sha256_ctx->H[2] += C; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2161 sha256_ctx->H[3] += D; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2162 sha256_ctx->H[4] += E; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2163 sha256_ctx->H[5] += F; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2164 sha256_ctx->H[6] += G; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2165 sha256_ctx->H[7] += H; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2166 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2167 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2168 static void |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2169 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:
25415
diff
changeset
|
2170 struct SHA256Context *ctx; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2171 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2172 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:
25415
diff
changeset
|
2173 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2174 if(!strcmp(name, "sizeHi")) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2175 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:
25415
diff
changeset
|
2176 } else if(!strcmp(name, "sizeLo")) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2177 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:
25415
diff
changeset
|
2178 } else if(!strcmp(name, "lenW")) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2179 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:
25415
diff
changeset
|
2180 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2181 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2182 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2183 static void * |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2184 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:
25415
diff
changeset
|
2185 struct SHA256Context *ctx; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2186 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2187 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:
25415
diff
changeset
|
2188 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2189 if(!strcmp(name, "sizeHi")) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2190 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:
25415
diff
changeset
|
2191 } else if(!strcmp(name, "sizeLo")) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2192 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:
25415
diff
changeset
|
2193 } else if(!strcmp(name, "lenW")) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2194 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:
25415
diff
changeset
|
2195 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2196 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2197 return NULL; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2198 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2199 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2200 static void |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2201 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:
25415
diff
changeset
|
2202 struct SHA256Context *sha256_ctx; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2203 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2204 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:
25415
diff
changeset
|
2205 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2206 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:
25415
diff
changeset
|
2207 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2208 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:
25415
diff
changeset
|
2209 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2210 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2211 static void |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2212 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:
25415
diff
changeset
|
2213 struct SHA256Context *sha256_ctx; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2214 gint i; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2215 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2216 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:
25415
diff
changeset
|
2217 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2218 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:
25415
diff
changeset
|
2219 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2220 sha256_ctx->lenW = 0; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2221 sha256_ctx->sizeHi = 0; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2222 sha256_ctx->sizeLo = 0; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2223 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2224 sha256_ctx->H[0] = 0x6a09e667; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2225 sha256_ctx->H[1] = 0xbb67ae85; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2226 sha256_ctx->H[2] = 0x3c6ef372; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2227 sha256_ctx->H[3] = 0xa54ff53a; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2228 sha256_ctx->H[4] = 0x510e527f; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2229 sha256_ctx->H[5] = 0x9b05688c; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2230 sha256_ctx->H[6] = 0x1f83d9ab; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2231 sha256_ctx->H[7] = 0x5be0cd19; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2232 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2233 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:
25415
diff
changeset
|
2234 sha256_ctx->W[i] = 0; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2235 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2236 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2237 static void |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2238 sha256_uninit(PurpleCipherContext *context) { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2239 struct SHA256Context *sha256_ctx; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2240 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2241 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:
25415
diff
changeset
|
2242 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2243 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:
25415
diff
changeset
|
2244 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2245 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:
25415
diff
changeset
|
2246 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2247 g_free(sha256_ctx); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2248 sha256_ctx = NULL; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2249 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2250 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2251 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2252 static void |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2253 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:
25415
diff
changeset
|
2254 struct SHA256Context *sha256_ctx; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2255 gint i; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2256 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2257 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:
25415
diff
changeset
|
2258 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2259 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:
25415
diff
changeset
|
2260 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2261 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:
25415
diff
changeset
|
2262 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:
25415
diff
changeset
|
2263 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:
25415
diff
changeset
|
2264 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2265 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:
25415
diff
changeset
|
2266 sha256_hash_block(sha256_ctx); |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2267 sha256_ctx->lenW = 0; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2268 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2269 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2270 sha256_ctx->sizeLo += 8; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2271 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:
25415
diff
changeset
|
2272 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2273 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2274 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2275 static gboolean |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2276 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:
25415
diff
changeset
|
2277 size_t *out_len) |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2278 { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2279 struct SHA256Context *sha256_ctx; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2280 guchar pad0x80 = 0x80, pad0x00 = 0x00; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2281 guchar padlen[8]; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2282 gint i; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2283 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2284 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:
25415
diff
changeset
|
2285 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2286 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:
25415
diff
changeset
|
2287 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2288 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:
25415
diff
changeset
|
2289 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2290 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:
25415
diff
changeset
|
2291 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:
25415
diff
changeset
|
2292 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:
25415
diff
changeset
|
2293 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:
25415
diff
changeset
|
2294 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:
25415
diff
changeset
|
2295 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:
25415
diff
changeset
|
2296 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:
25415
diff
changeset
|
2297 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:
25415
diff
changeset
|
2298 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2299 /* 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:
25415
diff
changeset
|
2300 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:
25415
diff
changeset
|
2301 while(sha256_ctx->lenW != 56) |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2302 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:
25415
diff
changeset
|
2303 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:
25415
diff
changeset
|
2304 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2305 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:
25415
diff
changeset
|
2306 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:
25415
diff
changeset
|
2307 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:
25415
diff
changeset
|
2308 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2309 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2310 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:
25415
diff
changeset
|
2311 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2312 if(out_len) |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2313 *out_len = 32; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2314 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2315 return TRUE; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2316 } |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2317 |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2318 static PurpleCipherOps SHA256Ops = { |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2319 sha256_set_opt, /* Set Option */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2320 sha256_get_opt, /* Get Option */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2321 sha256_init, /* init */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2322 sha256_reset, /* reset */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2323 sha256_uninit, /* uninit */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2324 NULL, /* set iv */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2325 sha256_append, /* append */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2326 sha256_digest, /* digest */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2327 NULL, /* encrypt */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2328 NULL, /* decrypt */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2329 NULL, /* set salt */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2330 NULL, /* get salt size */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2331 NULL, /* set key */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2332 NULL, /* get key size */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2333 NULL, /* set batch mode */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2334 NULL, /* get batch mode */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2335 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:
25415
diff
changeset
|
2336 NULL /* set key with len */ |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2337 }; |
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2338 |
27390
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2339 #endif /* GLIB_CHECK_VERSION(2,16,0) */ |
fc5508709e74
Use glib's SHA1, SHA256, and MD5 implementations when available (glib 2.16)
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
2340 |
27241
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2341 /******************************************************************************* |
17008
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2342 * RC4 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2343 ******************************************************************************/ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2344 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2345 struct RC4Context { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2346 guchar state[256]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2347 guchar x; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2348 guchar y; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2349 gint key_len; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2350 }; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2351 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2352 static void |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2353 rc4_init(PurpleCipherContext *context, void *extra) { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2354 struct RC4Context *rc4_ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2355 rc4_ctx = g_new0(struct RC4Context, 1); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2356 purple_cipher_context_set_data(context, rc4_ctx); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2357 purple_cipher_context_reset(context, extra); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2358 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2359 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2360 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2361 static void |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2362 rc4_reset(PurpleCipherContext *context, void *extra) { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2363 struct RC4Context *rc4_ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2364 guint i; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2365 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2366 rc4_ctx = purple_cipher_context_get_data(context); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2367 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2368 g_return_if_fail(rc4_ctx); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2369 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2370 for(i = 0; i < 256; i++) |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2371 rc4_ctx->state[i] = i; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2372 rc4_ctx->x = 0; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2373 rc4_ctx->y = 0; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2374 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2375 /* default is 5 bytes (40bit key) */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2376 rc4_ctx->key_len = 5; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2377 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2378 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2379 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2380 static void |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2381 rc4_uninit(PurpleCipherContext *context) { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2382 struct RC4Context *rc4_ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2383 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2384 rc4_ctx = purple_cipher_context_get_data(context); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2385 memset(rc4_ctx, 0, sizeof(rc4_ctx)); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2386 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2387 g_free(rc4_ctx); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2388 rc4_ctx = NULL; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2389 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2390 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2391 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2392 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2393 static void |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2394 rc4_set_key (PurpleCipherContext *context, const guchar * key) { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2395 struct RC4Context *ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2396 guchar *state; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2397 guchar temp_swap; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2398 guchar x, y; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2399 guint i; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2400 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2401 ctx = purple_cipher_context_get_data(context); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2402 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2403 x = 0; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2404 y = 0; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2405 state = &ctx->state[0]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2406 for(i = 0; i < 256; i++) |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2407 { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2408 y = (key[x] + state[i] + y) % 256; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2409 temp_swap = state[i]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2410 state[i] = state[y]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2411 state[y] = temp_swap; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2412 x = (x + 1) % ctx->key_len; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2413 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2414 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2415 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2416 static void |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2417 rc4_set_opt(PurpleCipherContext *context, const gchar *name, void *value) { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2418 struct RC4Context *ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2419 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2420 ctx = purple_cipher_context_get_data(context); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2421 |
25385
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:
23600
diff
changeset
|
2422 if(purple_strequal(name, "key_len")) { |
17008
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2423 ctx->key_len = GPOINTER_TO_INT(value); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2424 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2425 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2426 |
25415
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25385
diff
changeset
|
2427 static size_t |
17008
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2428 rc4_get_key_size (PurpleCipherContext *context) |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2429 { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2430 struct RC4Context *ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2431 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2432 g_return_val_if_fail(context, -1); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2433 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2434 ctx = purple_cipher_context_get_data(context); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2435 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2436 g_return_val_if_fail(ctx, -1); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2437 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2438 return ctx->key_len; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2439 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2440 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2441 static void * |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2442 rc4_get_opt(PurpleCipherContext *context, const gchar *name) { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2443 struct RC4Context *ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2444 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2445 ctx = purple_cipher_context_get_data(context); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2446 |
25385
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:
23600
diff
changeset
|
2447 if(purple_strequal(name, "key_len")) { |
17008
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2448 return GINT_TO_POINTER(ctx->key_len); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2449 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2450 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2451 return NULL; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2452 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2453 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2454 static gint |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2455 rc4_encrypt(PurpleCipherContext *context, const guchar data[], |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2456 size_t len, guchar output[], size_t *outlen) { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2457 struct RC4Context *ctx; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2458 guchar temp_swap; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2459 guchar x, y, z; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2460 guchar *state; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2461 guint i; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2462 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2463 ctx = purple_cipher_context_get_data(context); |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2464 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2465 x = ctx->x; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2466 y = ctx->y; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2467 state = &ctx->state[0]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2468 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2469 for(i = 0; i < len; i++) |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2470 { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2471 x = (x + 1) % 256; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2472 y = (state[x] + y) % 256; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2473 temp_swap = state[x]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2474 state[x] = state[y]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2475 state[y] = temp_swap; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2476 z = state[x] + (state[y]) % 256; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2477 output[i] = data[i] ^ state[z]; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2478 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2479 ctx->x = x; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2480 ctx->y = y; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2481 if(outlen) |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2482 *outlen = len; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2483 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2484 return 0; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2485 } |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2486 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2487 static PurpleCipherOps RC4Ops = { |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2488 rc4_set_opt, /* Set Option */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2489 rc4_get_opt, /* Get Option */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2490 rc4_init, /* init */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2491 rc4_reset, /* reset */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2492 rc4_uninit, /* uninit */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2493 NULL, /* set iv */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2494 NULL, /* append */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2495 NULL, /* digest */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2496 rc4_encrypt, /* encrypt */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2497 NULL, /* decrypt */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2498 NULL, /* set salt */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2499 NULL, /* get salt size */ |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2500 rc4_set_key, /* set key */ |
17027
ba8de77ec9b8
Add padding to the RC4Ops struct to fix a compiler warning.
Richard Laager <rlaager@wiktel.com>
parents:
17008
diff
changeset
|
2501 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
|
2502 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
|
2503 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
|
2504 NULL, /* get block size */ |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
2505 NULL /* set key with len */ |
17008
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2506 }; |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2507 |
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2508 /******************************************************************************* |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2509 * Structs |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2510 ******************************************************************************/ |
15823 | 2511 struct _PurpleCipher { |
17465
103a37dd9398
applied changes from b0f6005b1330af13bce0bcb189a2c887036b5ea3
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17095
diff
changeset
|
2512 gchar *name; /**< Internal name - used for searching */ |
103a37dd9398
applied changes from b0f6005b1330af13bce0bcb189a2c887036b5ea3
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17095
diff
changeset
|
2513 PurpleCipherOps *ops; /**< Operations supported by this cipher */ |
103a37dd9398
applied changes from b0f6005b1330af13bce0bcb189a2c887036b5ea3
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17095
diff
changeset
|
2514 guint ref; /**< Reference count */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2515 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2516 |
15823 | 2517 struct _PurpleCipherContext { |
17465
103a37dd9398
applied changes from b0f6005b1330af13bce0bcb189a2c887036b5ea3
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17095
diff
changeset
|
2518 PurpleCipher *cipher; /**< Cipher this context is under */ |
103a37dd9398
applied changes from b0f6005b1330af13bce0bcb189a2c887036b5ea3
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17095
diff
changeset
|
2519 gpointer data; /**< Internal cipher state data */ |
15374
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2522 /****************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2523 * Globals |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2524 *****************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2525 static GList *ciphers = NULL; |
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 /****************************************************************************** |
15823 | 2528 * PurpleCipher API |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2529 *****************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2530 const gchar * |
15823 | 2531 purple_cipher_get_name(PurpleCipher *cipher) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2532 g_return_val_if_fail(cipher, NULL); |
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 return cipher->name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2535 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2536 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2537 guint |
15823 | 2538 purple_cipher_get_capabilities(PurpleCipher *cipher) { |
2539 PurpleCipherOps *ops = NULL; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2540 guint caps = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2541 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2542 g_return_val_if_fail(cipher, 0); |
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 ops = cipher->ops; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2545 g_return_val_if_fail(ops, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2546 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2547 if(ops->set_option) |
15823 | 2548 caps |= PURPLE_CIPHER_CAPS_SET_OPT; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2549 if(ops->get_option) |
15823 | 2550 caps |= PURPLE_CIPHER_CAPS_GET_OPT; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2551 if(ops->init) |
15823 | 2552 caps |= PURPLE_CIPHER_CAPS_INIT; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2553 if(ops->reset) |
15823 | 2554 caps |= PURPLE_CIPHER_CAPS_RESET; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2555 if(ops->uninit) |
15823 | 2556 caps |= PURPLE_CIPHER_CAPS_UNINIT; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2557 if(ops->set_iv) |
15823 | 2558 caps |= PURPLE_CIPHER_CAPS_SET_IV; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2559 if(ops->append) |
15823 | 2560 caps |= PURPLE_CIPHER_CAPS_APPEND; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2561 if(ops->digest) |
15823 | 2562 caps |= PURPLE_CIPHER_CAPS_DIGEST; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2563 if(ops->encrypt) |
15823 | 2564 caps |= PURPLE_CIPHER_CAPS_ENCRYPT; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2565 if(ops->decrypt) |
15823 | 2566 caps |= PURPLE_CIPHER_CAPS_DECRYPT; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2567 if(ops->set_salt) |
15823 | 2568 caps |= PURPLE_CIPHER_CAPS_SET_SALT; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2569 if(ops->get_salt_size) |
15823 | 2570 caps |= PURPLE_CIPHER_CAPS_GET_SALT_SIZE; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2571 if(ops->set_key) |
15823 | 2572 caps |= PURPLE_CIPHER_CAPS_SET_KEY; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2573 if(ops->get_key_size) |
15823 | 2574 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
|
2575 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
|
2576 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
|
2577 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
|
2578 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
|
2579 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
|
2580 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
|
2581 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
|
2582 caps |= PURPLE_CIPHER_CAPS_SET_KEY_WITH_LEN; |
15374
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 return caps; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2585 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2586 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2587 gboolean |
15823 | 2588 purple_cipher_digest_region(const gchar *name, const guchar *data, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2589 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
|
2590 guchar digest[], size_t *out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2591 { |
15823 | 2592 PurpleCipher *cipher; |
2593 PurpleCipherContext *context; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2594 gboolean ret = FALSE; |
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 g_return_val_if_fail(name, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2597 g_return_val_if_fail(data, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2598 |
15823 | 2599 cipher = purple_ciphers_find_cipher(name); |
15374
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_val_if_fail(cipher, FALSE); |
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 if(!cipher->ops->append || !cipher->ops->digest) { |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
27241
diff
changeset
|
2604 purple_debug_warning("cipher", "purple_cipher_region failed: " |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2605 "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
|
2606 "digesting.", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2607 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2608 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2609 |
15823 | 2610 context = purple_cipher_context_new(cipher, NULL); |
2611 purple_cipher_context_append(context, data, data_len); | |
2612 ret = purple_cipher_context_digest(context, in_len, digest, out_len); | |
2613 purple_cipher_context_destroy(context); | |
15374
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 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2616 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2617 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2618 /****************************************************************************** |
15823 | 2619 * PurpleCiphers API |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2620 *****************************************************************************/ |
15823 | 2621 PurpleCipher * |
2622 purple_ciphers_find_cipher(const gchar *name) { | |
2623 PurpleCipher *cipher; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2624 GList *l; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2625 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2626 g_return_val_if_fail(name, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2627 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2628 for(l = ciphers; l; l = l->next) { |
15823 | 2629 cipher = PURPLE_CIPHER(l->data); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2630 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2631 if(!g_ascii_strcasecmp(cipher->name, name)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2632 return cipher; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2635 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2636 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2637 |
15823 | 2638 PurpleCipher * |
2639 purple_ciphers_register_cipher(const gchar *name, PurpleCipherOps *ops) { | |
2640 PurpleCipher *cipher = NULL; | |
15374
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 g_return_val_if_fail(name, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2643 g_return_val_if_fail(ops, NULL); |
15823 | 2644 g_return_val_if_fail(!purple_ciphers_find_cipher(name), NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2645 |
15823 | 2646 cipher = g_new0(PurpleCipher, 1); |
2647 PURPLE_DBUS_REGISTER_POINTER(cipher, PurpleCipher); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2648 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2649 cipher->name = g_strdup(name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2650 cipher->ops = ops; |
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 ciphers = g_list_append(ciphers, cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2653 |
15823 | 2654 purple_signal_emit(purple_ciphers_get_handle(), "cipher-added", cipher); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2655 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2656 return cipher; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2659 gboolean |
15823 | 2660 purple_ciphers_unregister_cipher(PurpleCipher *cipher) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2661 g_return_val_if_fail(cipher, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2662 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
|
2663 |
15823 | 2664 purple_signal_emit(purple_ciphers_get_handle(), "cipher-removed", cipher); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2665 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2666 ciphers = g_list_remove(ciphers, cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2667 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2668 g_free(cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2669 |
15823 | 2670 PURPLE_DBUS_UNREGISTER_POINTER(cipher); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2671 g_free(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2672 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2673 return TRUE; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2676 GList * |
15823 | 2677 purple_ciphers_get_ciphers() { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2678 return ciphers; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2681 /****************************************************************************** |
15823 | 2682 * PurpleCipher Subsystem API |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2683 *****************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2684 gpointer |
15823 | 2685 purple_ciphers_get_handle() { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2686 static gint handle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2687 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2688 return &handle; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2691 void |
15823 | 2692 purple_ciphers_init() { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2693 gpointer handle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2694 |
15823 | 2695 handle = purple_ciphers_get_handle(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2696 |
15823 | 2697 purple_signal_register(handle, "cipher-added", |
2698 purple_marshal_VOID__POINTER, NULL, 1, | |
2699 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
2700 PURPLE_SUBTYPE_CIPHER)); | |
2701 purple_signal_register(handle, "cipher-removed", | |
2702 purple_marshal_VOID__POINTER, NULL, 1, | |
2703 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
2704 PURPLE_SUBTYPE_CIPHER)); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2705 |
15823 | 2706 purple_ciphers_register_cipher("md5", &MD5Ops); |
2707 purple_ciphers_register_cipher("sha1", &SHA1Ops); | |
27241
8487bf2c306e
An implementation of SHA-256. Created by copying libpurple's SHA-1
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
2708 purple_ciphers_register_cipher("sha256", &SHA256Ops); |
15823 | 2709 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
|
2710 purple_ciphers_register_cipher("hmac", &HMACOps); |
15823 | 2711 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
|
2712 purple_ciphers_register_cipher("des3", &DES3Ops); |
17008
34d9037a228c
RC4 support to libpurple's cipher.c.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16676
diff
changeset
|
2713 purple_ciphers_register_cipher("rc4", &RC4Ops); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2714 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2715 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2716 void |
15823 | 2717 purple_ciphers_uninit() { |
2718 PurpleCipher *cipher; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2719 GList *l, *ll; |
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 for(l = ciphers; l; l = ll) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2722 ll = l->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2723 |
15823 | 2724 cipher = PURPLE_CIPHER(l->data); |
2725 purple_ciphers_unregister_cipher(cipher); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2726 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2727 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2728 g_list_free(ciphers); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2729 |
15823 | 2730 purple_signals_unregister_by_instance(purple_ciphers_get_handle()); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2731 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2732 /****************************************************************************** |
15823 | 2733 * PurpleCipherContext API |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2734 *****************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2735 void |
15823 | 2736 purple_cipher_context_set_option(PurpleCipherContext *context, const gchar *name, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2737 gpointer value) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2738 { |
15823 | 2739 PurpleCipher *cipher = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2740 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2741 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2742 g_return_if_fail(name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2743 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2744 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2745 g_return_if_fail(cipher); |
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 if(cipher->ops && cipher->ops->set_option) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2748 cipher->ops->set_option(context, name, value); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2749 else |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
27241
diff
changeset
|
2750 purple_debug_warning("cipher", "the %s cipher does not support the " |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2751 "set_option operation\n", cipher->name); |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2754 gpointer |
15823 | 2755 purple_cipher_context_get_option(PurpleCipherContext *context, const gchar *name) { |
2756 PurpleCipher *cipher = NULL; | |
15374
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 g_return_val_if_fail(context, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2759 g_return_val_if_fail(name, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2760 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2761 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2762 g_return_val_if_fail(cipher, NULL); |
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 if(cipher->ops && cipher->ops->get_option) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2765 return cipher->ops->get_option(context, name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2766 else { |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
27241
diff
changeset
|
2767 purple_debug_warning("cipher", "the %s cipher does not support the " |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2768 "get_option operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2769 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2770 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2771 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2772 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2773 |
15823 | 2774 PurpleCipherContext * |
2775 purple_cipher_context_new(PurpleCipher *cipher, void *extra) { | |
2776 PurpleCipherContext *context = NULL; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2777 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2778 g_return_val_if_fail(cipher, NULL); |
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 cipher->ref++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2781 |
15823 | 2782 context = g_new0(PurpleCipherContext, 1); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2783 context->cipher = cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2784 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2785 if(cipher->ops->init) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2786 cipher->ops->init(context, extra); |
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 return 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 |
15823 | 2791 PurpleCipherContext * |
2792 purple_cipher_context_new_by_name(const gchar *name, void *extra) { | |
2793 PurpleCipher *cipher; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2794 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2795 g_return_val_if_fail(name, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2796 |
15823 | 2797 cipher = purple_ciphers_find_cipher(name); |
15374
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 g_return_val_if_fail(cipher, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2800 |
15823 | 2801 return purple_cipher_context_new(cipher, extra); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2802 } |
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 void |
15823 | 2805 purple_cipher_context_reset(PurpleCipherContext *context, void *extra) { |
2806 PurpleCipher *cipher = NULL; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2807 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2808 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2809 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2810 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2811 g_return_if_fail(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2812 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2813 if(cipher->ops && cipher->ops->reset) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2814 context->cipher->ops->reset(context, extra); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2815 } |
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 void |
15823 | 2818 purple_cipher_context_destroy(PurpleCipherContext *context) { |
2819 PurpleCipher *cipher = NULL; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2820 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2821 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2822 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2823 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2824 g_return_if_fail(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2825 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2826 cipher->ref--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2827 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2828 if(cipher->ops && cipher->ops->uninit) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2829 cipher->ops->uninit(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2830 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2831 memset(context, 0, sizeof(context)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2832 g_free(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2833 context = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2834 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2835 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2836 void |
15823 | 2837 purple_cipher_context_set_iv(PurpleCipherContext *context, guchar *iv, size_t len) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2838 { |
15823 | 2839 PurpleCipher *cipher = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2840 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2841 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2842 g_return_if_fail(iv); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2843 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2844 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2845 g_return_if_fail(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2846 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2847 if(cipher->ops && cipher->ops->set_iv) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2848 cipher->ops->set_iv(context, iv, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2849 else |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
27241
diff
changeset
|
2850 purple_debug_warning("cipher", "the %s cipher does not support the set" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2851 "initialization vector operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2852 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2853 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2854 void |
15823 | 2855 purple_cipher_context_append(PurpleCipherContext *context, const guchar *data, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2856 size_t len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2857 { |
15823 | 2858 PurpleCipher *cipher = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2859 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2860 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2861 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2862 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2863 g_return_if_fail(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2864 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2865 if(cipher->ops && cipher->ops->append) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2866 cipher->ops->append(context, data, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2867 else |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
27241
diff
changeset
|
2868 purple_debug_warning("cipher", "the %s cipher does not support the append " |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2869 "operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2870 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2871 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2872 gboolean |
15823 | 2873 purple_cipher_context_digest(PurpleCipherContext *context, size_t in_len, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2874 guchar digest[], size_t *out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2875 { |
15823 | 2876 PurpleCipher *cipher = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2877 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2878 g_return_val_if_fail(context, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2879 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2880 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2881 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2882 if(cipher->ops && cipher->ops->digest) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2883 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
|
2884 else { |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
27241
diff
changeset
|
2885 purple_debug_warning("cipher", "the %s cipher does not support the digest " |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2886 "operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2887 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2888 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2889 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2890 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2891 gboolean |
15823 | 2892 purple_cipher_context_digest_to_str(PurpleCipherContext *context, size_t in_len, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2893 gchar digest_s[], size_t *out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2894 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2895 /* 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
|
2896 guchar digest[BUF_LEN * 4]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2897 gint n = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2898 size_t dlen = 0; |
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 g_return_val_if_fail(context, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2901 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
|
2902 |
15823 | 2903 if(!purple_cipher_context_digest(context, sizeof(digest), digest, &dlen)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2904 return FALSE; |
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 /* 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
|
2907 if(in_len <= dlen * 2) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2908 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2909 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2910 for(n = 0; n < dlen; n++) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2911 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
|
2912 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2913 digest_s[n * 2] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2914 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2915 if(out_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2916 *out_len = dlen * 2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2917 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2918 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2919 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2920 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2921 gint |
15823 | 2922 purple_cipher_context_encrypt(PurpleCipherContext *context, const guchar data[], |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2923 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
|
2924 { |
15823 | 2925 PurpleCipher *cipher = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2926 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2927 g_return_val_if_fail(context, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2928 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2929 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2930 g_return_val_if_fail(cipher, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2931 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2932 if(cipher->ops && cipher->ops->encrypt) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2933 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
|
2934 else { |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
27241
diff
changeset
|
2935 purple_debug_warning("cipher", "the %s cipher does not support the encrypt" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2936 "operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2937 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2938 if(outlen) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2939 *outlen = -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2940 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2941 return -1; |
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 } |
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 gint |
15823 | 2946 purple_cipher_context_decrypt(PurpleCipherContext *context, const guchar data[], |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2947 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
|
2948 { |
15823 | 2949 PurpleCipher *cipher = NULL; |
15374
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 g_return_val_if_fail(context, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2952 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2953 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2954 g_return_val_if_fail(cipher, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2955 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2956 if(cipher->ops && cipher->ops->decrypt) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2957 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
|
2958 else { |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
27241
diff
changeset
|
2959 purple_debug_warning("cipher", "the %s cipher does not support the decrypt" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2960 "operation\n", cipher->name); |
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 if(outlen) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2963 *outlen = -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2964 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2965 return -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2966 } |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2969 void |
15823 | 2970 purple_cipher_context_set_salt(PurpleCipherContext *context, guchar *salt) { |
2971 PurpleCipher *cipher = NULL; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2972 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2973 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2974 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2975 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2976 g_return_if_fail(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2977 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2978 if(cipher->ops && cipher->ops->set_salt) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2979 cipher->ops->set_salt(context, salt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2980 else |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
27241
diff
changeset
|
2981 purple_debug_warning("cipher", "the %s cipher does not support the " |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2982 "set_salt operation\n", cipher->name); |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2985 size_t |
15823 | 2986 purple_cipher_context_get_salt_size(PurpleCipherContext *context) { |
2987 PurpleCipher *cipher = NULL; | |
15374
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 g_return_val_if_fail(context, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2990 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2991 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2992 g_return_val_if_fail(cipher, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2993 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2994 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
|
2995 return cipher->ops->get_salt_size(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2996 else { |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
27241
diff
changeset
|
2997 purple_debug_warning("cipher", "the %s cipher does not support the " |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2998 "get_salt_size operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2999 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3000 return -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3001 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3002 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3003 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3004 void |
15823 | 3005 purple_cipher_context_set_key(PurpleCipherContext *context, const guchar *key) { |
3006 PurpleCipher *cipher = NULL; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3007 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3008 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3009 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3010 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3011 g_return_if_fail(cipher); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3012 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3013 if(cipher->ops && cipher->ops->set_key) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3014 cipher->ops->set_key(context, key); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3015 else |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
27241
diff
changeset
|
3016 purple_debug_warning("cipher", "the %s cipher does not support the " |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3017 "set_key operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3018 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3019 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3020 size_t |
15823 | 3021 purple_cipher_context_get_key_size(PurpleCipherContext *context) { |
3022 PurpleCipher *cipher = NULL; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3023 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3024 g_return_val_if_fail(context, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3025 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3026 cipher = context->cipher; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3027 g_return_val_if_fail(cipher, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3028 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3029 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
|
3030 return cipher->ops->get_key_size(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3031 else { |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
27241
diff
changeset
|
3032 purple_debug_warning("cipher", "the %s cipher does not support the " |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3033 "get_key_size operation\n", cipher->name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3034 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3035 return -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3036 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3037 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3038 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3039 void |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3040 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
|
3041 PurpleCipherBatchMode mode) |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3042 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3043 PurpleCipher *cipher = NULL; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3044 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3045 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
|
3046 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3047 cipher = context->cipher; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3048 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
|
3049 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3050 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
|
3051 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
|
3052 else |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
27241
diff
changeset
|
3053 purple_debug_warning("cipher", "The %s cipher does not support the " |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3054 "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
|
3055 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3056 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3057 PurpleCipherBatchMode |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3058 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
|
3059 { |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3060 PurpleCipher *cipher = NULL; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3061 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3062 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
|
3063 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3064 cipher = context->cipher; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3065 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
|
3066 |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3067 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
|
3068 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
|
3069 else { |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
27241
diff
changeset
|
3070 purple_debug_warning("cipher", "The %s cipher does not support the " |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3071 "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
|
3072 return -1; |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3073 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3074 } |
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3075 |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3076 size_t |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3077 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
|
3078 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3079 PurpleCipher *cipher = NULL; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3080 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3081 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
|
3082 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3083 cipher = context->cipher; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3084 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
|
3085 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3086 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
|
3087 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
|
3088 else { |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
27241
diff
changeset
|
3089 purple_debug_warning("cipher", "The %s cipher does not support the " |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3090 "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
|
3091 return -1; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3092 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3093 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3094 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3095 void |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3096 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
|
3097 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
|
3098 { |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3099 PurpleCipher *cipher = NULL; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3100 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3101 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
|
3102 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3103 cipher = context->cipher; |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3104 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
|
3105 |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3106 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
|
3107 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
|
3108 else |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
27241
diff
changeset
|
3109 purple_debug_warning("cipher", "The %s cipher does not support the " |
21908
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3110 "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
|
3111 } |
f786e478e08b
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21907
diff
changeset
|
3112 |
21907
03463c52b9d7
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
21015
diff
changeset
|
3113 void |
15823 | 3114 purple_cipher_context_set_data(PurpleCipherContext *context, gpointer data) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3115 g_return_if_fail(context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3116 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3117 context->data = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3118 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3119 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3120 gpointer |
15823 | 3121 purple_cipher_context_get_data(PurpleCipherContext *context) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3122 g_return_val_if_fail(context, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3123 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3124 return context->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3125 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3126 |
15823 | 3127 gchar *purple_cipher_http_digest_calculate_session_key( |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3128 const gchar *algorithm, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3129 const gchar *username, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3130 const gchar *realm, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3131 const gchar *password, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3132 const gchar *nonce, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3133 const gchar *client_nonce) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3134 { |
15823 | 3135 PurpleCipher *cipher; |
3136 PurpleCipherContext *context; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3137 gchar hash[33]; /* We only support MD5. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3138 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3139 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
|
3140 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
|
3141 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
|
3142 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
|
3143 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3144 /* Check for a supported algorithm. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3145 g_return_val_if_fail(algorithm == NULL || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3146 *algorithm == '\0' || |
17095
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17027
diff
changeset
|
3147 g_ascii_strcasecmp(algorithm, "MD5") || |
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17027
diff
changeset
|
3148 g_ascii_strcasecmp(algorithm, "MD5-sess"), NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3149 |
15823 | 3150 cipher = purple_ciphers_find_cipher("md5"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3151 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
|
3152 |
15823 | 3153 context = purple_cipher_context_new(cipher, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3154 |
15823 | 3155 purple_cipher_context_append(context, (guchar *)username, strlen(username)); |
3156 purple_cipher_context_append(context, (guchar *)":", 1); | |
3157 purple_cipher_context_append(context, (guchar *)realm, strlen(realm)); | |
3158 purple_cipher_context_append(context, (guchar *)":", 1); | |
3159 purple_cipher_context_append(context, (guchar *)password, strlen(password)); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3160 |
17095
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17027
diff
changeset
|
3161 if (algorithm != NULL && !g_ascii_strcasecmp(algorithm, "MD5-sess")) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3162 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3163 guchar digest[16]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3164 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3165 if (client_nonce == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3166 { |
15823 | 3167 purple_cipher_context_destroy(context); |
19653
941965d6fd88
Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17465
diff
changeset
|
3168 purple_debug_error("cipher", "Required client_nonce missing for MD5-sess digest calculation.\n"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3169 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3170 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3171 |
15823 | 3172 purple_cipher_context_digest(context, sizeof(digest), digest, NULL); |
3173 purple_cipher_context_destroy(context); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3174 |
15823 | 3175 context = purple_cipher_context_new(cipher, NULL); |
3176 purple_cipher_context_append(context, digest, sizeof(digest)); | |
3177 purple_cipher_context_append(context, (guchar *)":", 1); | |
3178 purple_cipher_context_append(context, (guchar *)nonce, strlen(nonce)); | |
3179 purple_cipher_context_append(context, (guchar *)":", 1); | |
3180 purple_cipher_context_append(context, (guchar *)client_nonce, strlen(client_nonce)); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3181 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3182 |
15823 | 3183 purple_cipher_context_digest_to_str(context, sizeof(hash), hash, NULL); |
3184 purple_cipher_context_destroy(context); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3185 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3186 return g_strdup(hash); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3187 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3188 |
15823 | 3189 gchar *purple_cipher_http_digest_calculate_response( |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3190 const gchar *algorithm, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3191 const gchar *method, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3192 const gchar *digest_uri, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3193 const gchar *qop, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3194 const gchar *entity, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3195 const gchar *nonce, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3196 const gchar *nonce_count, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3197 const gchar *client_nonce, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3198 const gchar *session_key) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3199 { |
15823 | 3200 PurpleCipher *cipher; |
3201 PurpleCipherContext *context; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3202 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
|
3203 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3204 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
|
3205 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
|
3206 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
|
3207 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
|
3208 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3209 /* Check for a supported algorithm. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3210 g_return_val_if_fail(algorithm == NULL || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3211 *algorithm == '\0' || |
17095
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17027
diff
changeset
|
3212 g_ascii_strcasecmp(algorithm, "MD5") || |
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17027
diff
changeset
|
3213 g_ascii_strcasecmp(algorithm, "MD5-sess"), NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3214 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3215 /* Check for a supported "quality of protection". */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3216 g_return_val_if_fail(qop == NULL || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3217 *qop == '\0' || |
17095
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17027
diff
changeset
|
3218 g_ascii_strcasecmp(qop, "auth") || |
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17027
diff
changeset
|
3219 g_ascii_strcasecmp(qop, "auth-int"), NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3220 |
15823 | 3221 cipher = purple_ciphers_find_cipher("md5"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3222 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
|
3223 |
15823 | 3224 context = purple_cipher_context_new(cipher, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3225 |
15823 | 3226 purple_cipher_context_append(context, (guchar *)method, strlen(method)); |
3227 purple_cipher_context_append(context, (guchar *)":", 1); | |
3228 purple_cipher_context_append(context, (guchar *)digest_uri, strlen(digest_uri)); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3229 |
17095
7ade887fd3f6
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents:
17027
diff
changeset
|
3230 if (qop != NULL && !g_ascii_strcasecmp(qop, "auth-int")) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3231 { |
15823 | 3232 PurpleCipherContext *context2; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3233 gchar entity_hash[33]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3234 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3235 if (entity == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3236 { |
15823 | 3237 purple_cipher_context_destroy(context); |
19653
941965d6fd88
Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17465
diff
changeset
|
3238 purple_debug_error("cipher", "Required entity missing for auth-int digest calculation.\n"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3239 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3240 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3241 |
15823 | 3242 context2 = purple_cipher_context_new(cipher, NULL); |
3243 purple_cipher_context_append(context2, (guchar *)entity, strlen(entity)); | |
3244 purple_cipher_context_digest_to_str(context2, sizeof(entity_hash), entity_hash, NULL); | |
3245 purple_cipher_context_destroy(context2); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3246 |
15823 | 3247 purple_cipher_context_append(context, (guchar *)":", 1); |
3248 purple_cipher_context_append(context, (guchar *)entity_hash, strlen(entity_hash)); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3249 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3250 |
15823 | 3251 purple_cipher_context_digest_to_str(context, sizeof(hash2), hash2, NULL); |
3252 purple_cipher_context_destroy(context); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3253 |
15823 | 3254 context = purple_cipher_context_new(cipher, NULL); |
3255 purple_cipher_context_append(context, (guchar *)session_key, strlen(session_key)); | |
3256 purple_cipher_context_append(context, (guchar *)":", 1); | |
3257 purple_cipher_context_append(context, (guchar *)nonce, strlen(nonce)); | |
3258 purple_cipher_context_append(context, (guchar *)":", 1); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3259 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3260 if (qop != NULL && *qop != '\0') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3261 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3262 if (nonce_count == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3263 { |
15823 | 3264 purple_cipher_context_destroy(context); |
19653
941965d6fd88
Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17465
diff
changeset
|
3265 purple_debug_error("cipher", "Required nonce_count missing for digest calculation.\n"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3266 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3267 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3268 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3269 if (client_nonce == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3270 { |
15823 | 3271 purple_cipher_context_destroy(context); |
19653
941965d6fd88
Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17465
diff
changeset
|
3272 purple_debug_error("cipher", "Required client_nonce missing for digest calculation.\n"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3273 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3274 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3275 |
15823 | 3276 purple_cipher_context_append(context, (guchar *)nonce_count, strlen(nonce_count)); |
3277 purple_cipher_context_append(context, (guchar *)":", 1); | |
3278 purple_cipher_context_append(context, (guchar *)client_nonce, strlen(client_nonce)); | |
3279 purple_cipher_context_append(context, (guchar *)":", 1); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3280 |
15823 | 3281 purple_cipher_context_append(context, (guchar *)qop, strlen(qop)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3282 |
15823 | 3283 purple_cipher_context_append(context, (guchar *)":", 1); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3284 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3285 |
15823 | 3286 purple_cipher_context_append(context, (guchar *)hash2, strlen(hash2)); |
3287 purple_cipher_context_digest_to_str(context, sizeof(hash2), hash2, NULL); | |
3288 purple_cipher_context_destroy(context); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3289 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3290 return g_strdup(hash2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3291 } |