source: branches/samba-3.2.x/source/lib/md4.c@ 715

Last change on this file since 715 was 133, checked in by Paul Smedley, 18 years ago

Update trunk to 3.2.0pre3

File size: 4.3 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3 a implementation of MD4 designed for use in the SMB authentication protocol
4 Copyright (C) Andrew Tridgell 1997-1998.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#include "includes.h"
21
22/* NOTE: This code makes no attempt to be fast!
23
24 It assumes that a int is at least 32 bits long
25*/
26
27#if 0
28static uint32 A, B, C, D;
29#else
30#define A (state[0])
31#define B (state[1])
32#define C (state[2])
33#define D (state[3])
34#endif
35
36static uint32 F(uint32 X, uint32 Y, uint32 Z)
37{
38 return (X&Y) | ((~X)&Z);
39}
40
41static uint32 G(uint32 X, uint32 Y, uint32 Z)
42{
43 return (X&Y) | (X&Z) | (Y&Z);
44}
45
46static uint32 H(uint32 X, uint32 Y, uint32 Z)
47{
48 return X^Y^Z;
49}
50
51static uint32 lshift(uint32 x, int s)
52{
53 x &= 0xFFFFFFFF;
54 return ((x<<s)&0xFFFFFFFF) | (x>>(32-s));
55}
56
57#define ROUND1(a,b,c,d,k,s) a = lshift(a + F(b,c,d) + X[k], s)