~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to crypto/sha512_generic.c

  • Committer: Package Import Robot
  • Author(s): Ben Hutchings, Bastian Blank, Ben Hutchings, Uwe Kleine-König
  • Date: 2012-03-04 15:32:20 UTC
  • mfrom: (43.1.29 sid)
  • Revision ID: package-import@ubuntu.com-20120304153220-r171jd27k3dd3639
Tags: 3.2.9-1
* New upstream stable update:
  http://www.kernel.org/pub/linux/kernel/v3.x/ChangeLog-3.2.8
  - [i386] i387: move TS_USEDFPU flag from thread_info to task_struct
  - [x86] additional refactoring of FPU/SSE state save and restore
  http://www.kernel.org/pub/linux/kernel/v3.x/ChangeLog-3.2.9
  - vfs: fix d_inode_lookup() dentry ref leak
  - target: Allow control CDBs with data > 1 page
  - epoll: introduce POLLFREE to flush ->signalfd_wqh before kfree()
  - epoll: ep_unregister_pollwait() can use the freed pwq->whead
  - epoll: limit paths (CVE-2011-1083)
  - cdrom: use copy_to_user() without the underscores

[ Bastian Blank ]
* [mips,mipsel] Also remove ext4 modules from installer.

[ Ben Hutchings ]
* Update debconf template translations:
  - Update Dutch (Willem Kuyn) (Closes: #658736)
  - Add Polish (Michał Kułach) (Closes: #658912)
* Bump ABI to 2
* fs: Introduce and enable security restrictions on links:
  - Do not follow symlinks in /tmp that are owned by other users
    (sysctl: fs.protected_symlinks)
  - Do not allow unprivileged users to create hard links to sensitive files
    (sysctl: fs.protected_hardlinks) (Closes: #609455)
    + This breaks the 'at' package in stable, which will be fixed shortly
      (see #597130)
  The precise restrictions are specified in Documentation/sysctl/fs.txt in
  the linux-doc-3.2 and linux-source-3.2 packages.
* iwlwifi: fix key removal (Closes: #651199)
* cgroups: Set CGROUP_PERF
* hid: Enable HID_HOLTEK, HID_PRIMAX, HID_SPEEDLINK, HID_WIIMOTE as modules,
  HID_ACRUX_FF
* media/rc: Enable RC_ATI_REMOTE as module
* gspca: Enable USB_GSPCA_TOPRO as module
* dvb-usb: Enable DVB_USB_PCTV452E, DVB_USB_MXL111SF as modules

[ Uwe Kleine-König ]
* [x86] Update rt featureset to 3.2.9-rt15

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
        return (x & y) | (z & (x | y));
32
32
}
33
33
 
34
 
static inline u64 RORu64(u64 x, u64 y)
35
 
{
36
 
        return (x >> y) | (x << (64 - y));
37
 
}
38
 
 
39
34
static const u64 sha512_K[80] = {
40
35
        0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL,
41
36
        0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL,
66
61
        0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL,
67
62
};
68
63
 
69
 
#define e0(x)       (RORu64(x,28) ^ RORu64(x,34) ^ RORu64(x,39))
70
 
#define e1(x)       (RORu64(x,14) ^ RORu64(x,18) ^ RORu64(x,41))
71
 
#define s0(x)       (RORu64(x, 1) ^ RORu64(x, 8) ^ (x >> 7))
72
 
#define s1(x)       (RORu64(x,19) ^ RORu64(x,61) ^ (x >> 6))
 
64
#define e0(x)       (ror64(x,28) ^ ror64(x,34) ^ ror64(x,39))
 
65
#define e1(x)       (ror64(x,14) ^ ror64(x,18) ^ ror64(x,41))
 
66
#define s0(x)       (ror64(x, 1) ^ ror64(x, 8) ^ (x >> 7))
 
67
#define s1(x)       (ror64(x,19) ^ ror64(x,61) ^ (x >> 6))
73
68
 
74
69
static inline void LOAD_OP(int I, u64 *W, const u8 *input)
75
70
{
78
73
 
79
74
static inline void BLEND_OP(int I, u64 *W)
80
75
{
81
 
        W[I % 16] += s1(W[(I-2) % 16]) + W[(I-7) % 16] + s0(W[(I-15) % 16]);
 
76
        W[I & 15] += s1(W[(I-2) & 15]) + W[(I-7) & 15] + s0(W[(I-15) & 15]);
82
77
}
83
78
 
84
79
static void
89
84
        int i;
90
85
        u64 W[16];
91
86
 
92
 
        /* load the input */
93
 
        for (i = 0; i < 16; i++)
94
 
                LOAD_OP(i, W, input);
95
 
 
96
87
        /* load the state into our registers */
97
88
        a=state[0];   b=state[1];   c=state[2];   d=state[3];
98
89
        e=state[4];   f=state[5];   g=state[6];   h=state[7];
99
90
 
100
 
#define SHA512_0_15(i, a, b, c, d, e, f, g, h)                  \
101
 
        t1 = h + e1(e) + Ch(e, f, g) + sha512_K[i] + W[i];      \
102
 
        t2 = e0(a) + Maj(a, b, c);                              \
103
 
        d += t1;                                                \
104
 
        h = t1 + t2
105
 
 
106
 
#define SHA512_16_79(i, a, b, c, d, e, f, g, h)                 \
107
 
        BLEND_OP(i, W);                                         \
108
 
        t1 = h + e1(e) + Ch(e, f, g) + sha512_K[i] + W[(i)%16]; \
109
 
        t2 = e0(a) + Maj(a, b, c);                              \
110
 
        d += t1;                                                \
111
 
        h = t1 + t2
112
 
 
113
 
        for (i = 0; i < 16; i += 8) {
114
 
                SHA512_0_15(i, a, b, c, d, e, f, g, h);
115
 
                SHA512_0_15(i + 1, h, a, b, c, d, e, f, g);
116
 
                SHA512_0_15(i + 2, g, h, a, b, c, d, e, f);
117
 
                SHA512_0_15(i + 3, f, g, h, a, b, c, d, e);
118
 
                SHA512_0_15(i + 4, e, f, g, h, a, b, c, d);
119
 
                SHA512_0_15(i + 5, d, e, f, g, h, a, b, c);
120
 
                SHA512_0_15(i + 6, c, d, e, f, g, h, a, b);
121
 
                SHA512_0_15(i + 7, b, c, d, e, f, g, h, a);
122
 
        }
123
 
        for (i = 16; i < 80; i += 8) {
124
 
                SHA512_16_79(i, a, b, c, d, e, f, g, h);
125
 
                SHA512_16_79(i + 1, h, a, b, c, d, e, f, g);
126
 
                SHA512_16_79(i + 2, g, h, a, b, c, d, e, f);
127
 
                SHA512_16_79(i + 3, f, g, h, a, b, c, d, e);
128
 
                SHA512_16_79(i + 4, e, f, g, h, a, b, c, d);
129
 
                SHA512_16_79(i + 5, d, e, f, g, h, a, b, c);
130
 
                SHA512_16_79(i + 6, c, d, e, f, g, h, a, b);
131
 
                SHA512_16_79(i + 7, b, c, d, e, f, g, h, a);
 
91
        /* now iterate */
 
92
        for (i=0; i<80; i+=8) {
 
93
                if (!(i & 8)) {
 
94
                        int j;
 
95
 
 
96
                        if (i < 16) {
 
97
                                /* load the input */
 
98
                                for (j = 0; j < 16; j++)
 
99
                                        LOAD_OP(i + j, W, input);
 
100
                        } else {
 
101
                                for (j = 0; j < 16; j++) {
 
102
                                        BLEND_OP(i + j, W);
 
103
                                }
 
104
                        }
 
105
                }
 
106
 
 
107
                t1 = h + e1(e) + Ch(e,f,g) + sha512_K[i  ] + W[(i & 15)];
 
108
                t2 = e0(a) + Maj(a,b,c);    d+=t1;    h=t1+t2;
 
109
                t1 = g + e1(d) + Ch(d,e,f) + sha512_K[i+1] + W[(i & 15) + 1];
 
110
                t2 = e0(h) + Maj(h,a,b);    c+=t1;    g=t1+t2;
 
111
                t1 = f + e1(c) + Ch(c,d,e) + sha512_K[i+2] + W[(i & 15) + 2];
 
112
                t2 = e0(g) + Maj(g,h,a);    b+=t1;    f=t1+t2;
 
113
                t1 = e + e1(b) + Ch(b,c,d) + sha512_K[i+3] + W[(i & 15) + 3];
 
114
                t2 = e0(f) + Maj(f,g,h);    a+=t1;    e=t1+t2;
 
115
                t1 = d + e1(a) + Ch(a,b,c) + sha512_K[i+4] + W[(i & 15) + 4];
 
116
                t2 = e0(e) + Maj(e,f,g);    h+=t1;    d=t1+t2;
 
117
                t1 = c + e1(h) + Ch(h,a,b) + sha512_K[i+5] + W[(i & 15) + 5];
 
118
                t2 = e0(d) + Maj(d,e,f);    g+=t1;    c=t1+t2;
 
119
                t1 = b + e1(g) + Ch(g,h,a) + sha512_K[i+6] + W[(i & 15) + 6];
 
120
                t2 = e0(c) + Maj(c,d,e);    f+=t1;    b=t1+t2;
 
121
                t1 = a + e1(f) + Ch(f,g,h) + sha512_K[i+7] + W[(i & 15) + 7];
 
122
                t2 = e0(b) + Maj(b,c,d);    e+=t1;    a=t1+t2;
132
123
        }
133
124
 
134
125
        state[0] += a; state[1] += b; state[2] += c; state[3] += d;