libpurple/ciphers/md4.c

Mon, 06 May 2013 12:17:16 +0200

author
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
date
Mon, 06 May 2013 12:17:16 +0200
changeset 33914
2ae6a9601d0f
parent 33913
9effc94565d8
child 34538
dbfc2ac39ed2
permissions
-rw-r--r--

ciphers cleanup: warnings

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

mercurial