~ubuntu-branches/ubuntu/trusty/jack-audio-connection-kit/trusty

« back to all changes in this revision

Viewing changes to jackd/md5_loc.h

  • Committer: Bazaar Package Importer
  • Author(s): Luca Falavigna
  • Date: 2008-12-06 11:05:15 UTC
  • mfrom: (4.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20081206110515-xa9v9pajr9jqvfvg
Tags: 0.115.6-1ubuntu1
* Merge from Debian unstable, remaining Ubuntu changes:
  - Redirect stderr in bash completion (Debian #504488).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Local defines for the md5 functions.
 
3
 *
 
4
 */
 
5
 
 
6
/*
 
7
 * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
 
8
 * rights reserved.
 
9
 *
 
10
 * License to copy and use this software is granted provided that it is
 
11
 * identified as the "RSA Data Security, Inc. MD5 Message-Digest
 
12
 * Algorithm" in all material mentioning or referencing this software
 
13
 * or this function.
 
14
 *
 
15
 * License is also granted to make and use derivative works provided that
 
16
 * such works are identified as "derived from the RSA Data Security,
 
17
 * Inc. MD5 Message-Digest Algorithm" in all material mentioning or
 
18
 * referencing the derived work.
 
19
 *
 
20
 * RSA Data Security, Inc. makes no representations concerning either the
 
21
 * merchantability of this software or the suitability of this
 
22
 * software for any particular purpose. It is provided "as is" without
 
23
 * express or implied warranty of any kind.
 
24
 *
 
25
 * These notices must be retained in any copies of any part of this
 
26
 * documentation and/or software.
 
27
 */
 
28
 
 
29
#ifndef __MD5_LOC_H__
 
30
#define __MD5_LOC_H__
 
31
 
 
32
#define HEX_STRING      "0123456789abcdef"      /* to convert to hex */
 
33
#define BLOCK_SIZE_MASK (MD5_BLOCK_SIZE - 1)
 
34
 
 
35
 
 
36
#include <config.h>
 
37
 
 
38
/*
 
39
 * Define my endian-ness.  Could not do in a portable manner using the
 
40
 * include files -- grumble.
 
41
 */
 
42
#ifdef WORDS_BIGENDIAN
 
43
/*
 
44
 * big endian - big is better
 
45
 */
 
46
#define SWAP(n) \
 
47
    (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
 
48
#else
 
49
/*
 
50
        + * little endian
 
51
        + */
 
52
#define SWAP(n)    (n)
 
53
#endif
 
54
 
 
55
/*
 
56
 * These are the four functions used in the four steps of the MD5
 
57
 * algorithm and defined in the RFC 1321.  The first function is a
 
58
 * little bit optimized (as found in Colin Plumbs public domain
 
59
 * implementation).
 
60
 */
 
61
/* #define FF(b, c, d) ((b & c) | (~b & d)) */
 
62
#define FF(b, c, d)     (d ^ (b & (c ^ d)))
 
63
#define FG(b, c, d)     FF(d, b, c)
 
64
#define FH(b, c, d)     (b ^ c ^ d)
 
65
#define FI(b, c, d)     (c ^ (b | ~d))
 
66
 
 
67
/*
 
68
 * It is unfortunate that C does not provide an operator for cyclic
 
69
 * rotation.  Hope the C compiler is smart enough.  -- Modified to
 
70
 * remove the w = at the front - Gray 2/97
 
71
 */
 
72
#define CYCLIC(w, s)    ((w << s) | (w >> (32 - s)))
 
73
 
 
74
/*
 
75
 * First Round: using the given function, the context and a constant
 
76
 * the next context is computed.  Because the algorithms processing
 
77
 * unit is a 32-bit word and it is determined to work on words in
 
78
 * little endian byte order we perhaps have to change the byte order
 
79
 * before the computation.  To reduce the work for the next steps we
 
80
 * store the swapped words in the array CORRECT_WORDS. -- Modified to
 
81
 * fix the handling of unaligned buffer spaces - Gray 7/97
 
82
 */
 
83
#define OP1(a, b, c, d, b_p, c_p, s, T)                         \
 
84
     do {                                                       \
 
85
       memcpy(c_p, b_p, sizeof(md5_uint32));                    \
 
86
       *c_p = SWAP(*c_p);                                       \
 
87
       a += FF (b, c, d) + *c_p + T;                            \
 
88
       a = CYCLIC (a, s);                                       \
 
89
       a += b;                                                  \
 
90
       b_p = (char *)b_p + sizeof(md5_uint32);                  \
 
91
       c_p++;                                                   \
 
92
    } while (0)
 
93
 
 
94
/*
 
95
 * Second to Fourth Round: we have the possibly swapped words in
 
96
 * CORRECT_WORDS.  Redefine the macro to take an additional first
 
97
 * argument specifying the function to use.
 
98
 */
 
99
#define OP234(FUNC, a, b, c, d, k, s, T)                \
 
100
    do {                                                \
 
101
      a += FUNC (b, c, d) + k + T;                      \
 
102
      a = CYCLIC (a, s);                                \
 
103
      a += b;                                           \
 
104
    } while (0)
 
105
 
 
106
#endif /* ! __MD5_LOC_H__ */