annotate libpurple/ciphers/md4.c @ 31802:ca94413ccd0e

Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in C mode. This is troublesome for Instantbird. This remedies the problem for the cipher code, which allows Instantbird's libpurple build to work again. committer: John Bailey <rekkanoryo@rekkanoryo.org>
author Florian Quèze <florian@instantbird.org>
date Sun, 13 Mar 2011 16:47:36 +0000
parents 2d3c1197f930
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * purple
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 *
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * source distribution.
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 *
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * Original md4 taken from linux kernel
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * MD4 Message Digest Algorithm (RFC1320).
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 *
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * Implementation derived from Andrew Tridgell and Steve French's
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * CIFS MD4 implementation, and the cryptoapi implementation
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * originally based on the public domain implementation written
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * by Colin Plumb in 1993.
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 *
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
16 * Copyright (c) Andrew Tridgell 1997-1998.
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
17 * Modified by Steve French (sfrench@us.ibm.com) 2002
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
18 * Copyright (c) Cryptoapi developers.
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
19 * Copyright (c) 2002 David S. Miller (davem@redhat.com)
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
20 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
21 *
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22 * This program is free software; you can redistribute it and/or modify
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 * it under the terms of the GNU General Public License as published by
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24 * the Free Software Foundation; either version 2 of the License, or
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 * (at your option) any later version.
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 *
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 * This program is distributed in the hope that it will be useful,
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 * GNU General Public License for more details.
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 *
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 * You should have received a copy of the GNU General Public License
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 * along with this program; if not, write to the Free Software
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 */
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 #include <cipher.h>
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 #define MD4_DIGEST_SIZE 16
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 #define MD4_HMAC_BLOCK_SIZE 64
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 #define MD4_BLOCK_WORDS 16
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 #define MD4_HASH_WORDS 4
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 struct MD4_Context {
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
44 guint32 hash[MD4_HASH_WORDS];
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
45 guint32 block[MD4_BLOCK_WORDS];
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
46 guint64 byte_count;
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 };
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 static inline guint32 lshift(guint32 x, unsigned int s)
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 {
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
51 x &= 0xFFFFFFFF;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
52 return ((x << s) & 0xFFFFFFFF) | (x >> (32 - s));
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 }
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 static inline guint32 F(guint32 x, guint32 y, guint32 z)
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 {
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
57 return (x & y) | ((~x) & z);
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 }
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 static inline guint32 G(guint32 x, guint32 y, guint32 z)
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 {
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
62 return (x & y) | (x & z) | (y & z);
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 }
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 static inline guint32 H(guint32 x, guint32 y, guint32 z)
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 {
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
67 return x ^ y ^ z;
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 }
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 #define ROUND1(a,b,c,d,k,s) (a = lshift(a + F(b,c,d) + k, s))
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 #define ROUND2(a,b,c,d,k,s) (a = lshift(a + G(b,c,d) + k + (guint32)0x5A827999,s))
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 #define ROUND3(a,b,c,d,k,s) (a = lshift(a + H(b,c,d) + k + (guint32)0x6ED9EBA1,s))
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 static inline void le32_to_cpu_array(guint32 *buf, unsigned int words)
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 {
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
76 while (words--) {
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
77 *buf=GUINT_FROM_LE(*buf);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
78 buf++;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
79 }
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 }
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 static inline void cpu_to_le32_array(guint32 *buf, unsigned int words)
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 {
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
84 while (words--) {
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
85 *buf=GUINT_TO_LE(*buf);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
86 buf++;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
87 }
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 }
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 static void md4_transform(guint32 *hash, guint32 const *in)
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 {
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
92 guint32 a, b, c, d;
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
94 a = hash[0];
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
95 b = hash[1];
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
96 c = hash[2];
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
97 d = hash[3];
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
99 ROUND1(a, b, c, d, in[0], 3);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
100 ROUND1(d, a, b, c, in[1], 7);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
101 ROUND1(c, d, a, b, in[2], 11);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
102 ROUND1(b, c, d, a, in[3], 19);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
103 ROUND1(a, b, c, d, in[4], 3);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
104 ROUND1(d, a, b, c, in[5], 7);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
105 ROUND1(c, d, a, b, in[6], 11);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
106 ROUND1(b, c, d, a, in[7], 19);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
107 ROUND1(a, b, c, d, in[8], 3);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
108 ROUND1(d, a, b, c, in[9], 7);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
109 ROUND1(c, d, a, b, in[10], 11);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
110 ROUND1(b, c, d, a, in[11], 19);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
111 ROUND1(a, b, c, d, in[12], 3);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
112 ROUND1(d, a, b, c, in[13], 7);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
113 ROUND1(c, d, a, b, in[14], 11);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
114 ROUND1(b, c, d, a, in[15], 19);
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
116 ROUND2(a, b, c, d,in[ 0], 3);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
117 ROUND2(d, a, b, c, in[4], 5);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
118 ROUND2(c, d, a, b, in[8], 9);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
119 ROUND2(b, c, d, a, in[12], 13);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
120 ROUND2(a, b, c, d, in[1], 3);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
121 ROUND2(d, a, b, c, in[5], 5);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
122 ROUND2(c, d, a, b, in[9], 9);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
123 ROUND2(b, c, d, a, in[13], 13);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
124 ROUND2(a, b, c, d, in[2], 3);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
125 ROUND2(d, a, b, c, in[6], 5);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
126 ROUND2(c, d, a, b, in[10], 9);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
127 ROUND2(b, c, d, a, in[14], 13);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
128 ROUND2(a, b, c, d, in[3], 3);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
129 ROUND2(d, a, b, c, in[7], 5);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
130 ROUND2(c, d, a, b, in[11], 9);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
131 ROUND2(b, c, d, a, in[15], 13);
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
133 ROUND3(a, b, c, d,in[ 0], 3);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
134 ROUND3(d, a, b, c, in[8], 9);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
135 ROUND3(c, d, a, b, in[4], 11);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
136 ROUND3(b, c, d, a, in[12], 15);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
137 ROUND3(a, b, c, d, in[2], 3);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
138 ROUND3(d, a, b, c, in[10], 9);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
139 ROUND3(c, d, a, b, in[6], 11);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
140 ROUND3(b, c, d, a, in[14], 15);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
141 ROUND3(a, b, c, d, in[1], 3);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
142 ROUND3(d, a, b, c, in[9], 9);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
143 ROUND3(c, d, a, b, in[5], 11);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
144 ROUND3(b, c, d, a, in[13], 15);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
145 ROUND3(a, b, c, d, in[3], 3);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
146 ROUND3(d, a, b, c, in[11], 9);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
147 ROUND3(c, d, a, b, in[7], 11);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
148 ROUND3(b, c, d, a, in[15], 15);
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
150 hash[0] += a;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
151 hash[1] += b;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
152 hash[2] += c;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
153 hash[3] += d;
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 }
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 static inline void md4_transform_helper(struct MD4_Context *ctx)
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 {
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
158 le32_to_cpu_array(ctx->block, sizeof(ctx->block) / sizeof(guint32));
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
159 md4_transform(ctx->hash, ctx->block);
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 }
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 static void
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 md4_init(PurpleCipherContext *context, gpointer extra) {
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
164 struct MD4_Context *mctx;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
165 mctx = g_new0(struct MD4_Context, 1);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
166 purple_cipher_context_set_data(context, mctx);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
167 purple_cipher_context_reset(context, extra);
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
169 mctx->hash[0] = 0x67452301;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
170 mctx->hash[1] = 0xefcdab89;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
171 mctx->hash[2] = 0x98badcfe;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
172 mctx->hash[3] = 0x10325476;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
173 mctx->byte_count = 0;
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 }
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 static void
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 md4_reset(PurpleCipherContext *context, gpointer extra) {
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
178 struct MD4_Context *mctx;
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
180 mctx = purple_cipher_context_get_data(context);
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
182 mctx->hash[0] = 0x67452301;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
183 mctx->hash[1] = 0xefcdab89;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
184 mctx->hash[2] = 0x98badcfe;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
185 mctx->hash[3] = 0x10325476;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
186 mctx->byte_count = 0;
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 }
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
189 static void
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 md4_append(PurpleCipherContext *context, const guchar *data, size_t len)
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 {
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
192 struct MD4_Context *mctx = purple_cipher_context_get_data(context);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
193 const guint32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f);
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
195 mctx->byte_count += len;
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
197 if (avail > len) {
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
198 memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
199 data, len);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
200 return;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
201 }
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
203 memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
204 data, avail);
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
206 md4_transform_helper(mctx);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
207 data += avail;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
208 len -= avail;
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
210 while (len >= sizeof(mctx->block)) {
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
211 memcpy(mctx->block, data, sizeof(mctx->block));
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
212 md4_transform_helper(mctx);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
213 data += sizeof(mctx->block);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
214 len -= sizeof(mctx->block);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
215 }
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
217 memcpy(mctx->block, data, len);
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 }
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
220 static gboolean
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 md4_digest(PurpleCipherContext *context, size_t in_len, guchar *out,
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
222 size_t *out_len)
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 {
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
224 struct MD4_Context *mctx = purple_cipher_context_get_data(context);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
225 const unsigned int offset = mctx->byte_count & 0x3f;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
226 char *p = (char *)mctx->block + offset;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
227 int padding = 56 - (offset + 1);
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
230 if(in_len<16) return FALSE;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
231 if(out_len) *out_len = 16;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
232 *p++ = 0x80;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
233 if (padding < 0) {
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
234 memset(p, 0x00, padding + sizeof (guint64));
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
235 md4_transform_helper(mctx);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
236 p = (char *)mctx->block;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
237 padding = 56;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
238 }
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
240 memset(p, 0, padding);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
241 mctx->block[14] = mctx->byte_count << 3;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
242 mctx->block[15] = mctx->byte_count >> 29;
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
243 le32_to_cpu_array(mctx->block, (sizeof(mctx->block) -
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
244 sizeof(guint64)) / sizeof(guint32));
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
245 md4_transform(mctx->hash, mctx->block);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
246 cpu_to_le32_array(mctx->hash, sizeof(mctx->hash) / sizeof(guint32));
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
247 memcpy(out, mctx->hash, sizeof(mctx->hash));
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
248 memset(mctx, 0, sizeof(*mctx));
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
249 return TRUE;
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 }
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 static void
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 md4_uninit(PurpleCipherContext *context) {
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
254 struct MD4_Context *md4_context;
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
256 purple_cipher_context_reset(context, NULL);
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
258 md4_context = purple_cipher_context_get_data(context);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
259 memset(md4_context, 0, sizeof(*md4_context));
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
261 g_free(md4_context);
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
262 md4_context = NULL;
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263 }
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
265 static size_t
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266 md4_get_block_size(PurpleCipherContext *context)
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267 {
31662
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
268 /* This does not change (in this case) */
a1a0936d10c3 Fixed indentation, forgot to do so on my first commit. Added additional info from cipher.c to the file header
Gary Kramlich <grim@reaperworld.com>
parents: 31661
diff changeset
269 return MD4_HMAC_BLOCK_SIZE;
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270 }
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 static PurpleCipherOps MD4Ops = {
31802
ca94413ccd0e Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31668
diff changeset
273 NULL, /* Set option */
ca94413ccd0e Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31668
diff changeset
274 NULL, /* Get option */
ca94413ccd0e Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31668
diff changeset
275 md4_init, /* init */
ca94413ccd0e Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31668
diff changeset
276 md4_reset, /* reset */
ca94413ccd0e Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31668
diff changeset
277 md4_uninit, /* uninit */
ca94413ccd0e Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31668
diff changeset
278 NULL, /* set iv */
ca94413ccd0e Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31668
diff changeset
279 md4_append, /* append */
ca94413ccd0e Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31668
diff changeset
280 md4_digest, /* digest */
ca94413ccd0e Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31668
diff changeset
281 NULL, /* encrypt */
ca94413ccd0e Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31668
diff changeset
282 NULL, /* decrypt */
ca94413ccd0e Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31668
diff changeset
283 NULL, /* set salt */
ca94413ccd0e Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31668
diff changeset
284 NULL, /* get salt size */
ca94413ccd0e Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31668
diff changeset
285 NULL, /* set key */
ca94413ccd0e Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31668
diff changeset
286 NULL, /* get key size */
ca94413ccd0e Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31668
diff changeset
287 NULL, /* set batch mode */
ca94413ccd0e Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31668
diff changeset
288 NULL, /* get batch mode */
ca94413ccd0e Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31668
diff changeset
289 md4_get_block_size, /* get block size */
ca94413ccd0e Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31668
diff changeset
290 NULL /* set key with len */
31661
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291 };
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
292
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 PurpleCipherOps *
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294 purple_md4_cipher_get_ops(void) {
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295 return &MD4Ops;
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 }
64587c6084e3 Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297