/* -*-Asm-*- */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see .
*/
#include
unsigned
cs (unsigned a, unsigned b)
{
return (a<>(32-b));
}
#define grub_cputole32(x) (x)
int
main ()
{
char buf[512];
unsigned w[80];
int i;
unsigned h0 = 0x67452301;
unsigned h1 = 0xefcdab89;
unsigned h2 = 0x98badcfe;
unsigned h3 = 0x10325476;
unsigned h4 = 0xc3d2e1f0;
unsigned a,b,c,d,e,f,k,t;
while (fread (buf,1,64,stdin) == 64)
{
for (i = 0; i < 16; i++)
{
w[i] = grub_cputole32 (((unsigned *)buf)[i]);
// printf ("%08x, ", w[i]);
}
// printf ("\n\n");
for (;i<80;i++)
{
w[i] = cs(w[i-3]^w[i-8]^w[i-14]^w[i-16],1);
// printf ("%08x, ", w[i]);
}
// printf ("\n\n");
a = h0;
b = h1;
c = h2;
d = h3;
e = h4;
for (i=0;i<80;i++)
{
if (0 <= i && i<=19)
{
f = (b&c)|(~b & d);
k = 0x5a827999;
}
if (20 <= i && i<=39)
{
f = b^c^d;
k = 0x6ed9eba1;
}
if (40 <= i && i<=59)
{
f = (b & c) | (b & d) | (c & d);
k = 0x8f1bbcdc;
}
if (60 <= i && i<=79)
{
f = b^c^d;
k = 0xca62c1d6;
}
t = cs(a,5)+f+e+k+w[i];
e=d;
d=c;
c=cs(b,30);
b=a;
a=t;
}
h0 += a;
h1 += b;
h2 += c;
h3 += d;
h4 += e;
}
printf ("%08x,%08x,%08x,%08x,%08x\n", h1, h2, h3, h4, h0);
return 0;
}