/* -*-c-*-
*
- * $Id: has160.c,v 1.1 2004/04/04 19:42:59 mdw Exp $
+ * $Id: has160.c,v 1.2 2004/04/08 01:36:15 mdw Exp $
*
* The HAS160 message digest function
*
* (c) 2004 Straylight/Edgeware
*/
-/*----- Licensing notice --------------------------------------------------*
+/*----- Licensing notice --------------------------------------------------*
*
* This file is part of Catacomb.
*
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
- *
+ *
* Catacomb 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 Library General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Library General Public
* License along with Catacomb; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
-/*----- Revision history --------------------------------------------------*
- *
- * $Log: has160.c,v $
- * Revision 1.1 2004/04/04 19:42:59 mdw
- * Add set -e.
- *
- */
-
/*----- Header files ------------------------------------------------------*/
#include <mLib/bits.h>
*/
#define ROUND(f, ss, k, \
- i0, i1, i2, i3, i4, i5, i6, i7, \
+ i0, i1, i2, i3, i4, i5, i6, i7, \
i8, i9, i10, i11, i12, i13, i14, i15) do { \
FF(f, a, b, c, d, e, buf[ i8]^buf[ i9]^buf[i10]^buf[i11], 5, ss, k); \
- FF(f, e, a, b, c, d, buf[ i0], 11, ss, k); \
- FF(f, d, e, a, b, c, buf[ i1], 7, ss, k); \
- FF(f, c, d, e, a, b, buf[ i2], 15, ss, k); \
- FF(f, b, c, d, e, a, buf[ i3], 6, ss, k); \
+ FF(f, e, a, b, c, d, buf[ i0], 11, ss, k); \
+ FF(f, d, e, a, b, c, buf[ i1], 7, ss, k); \
+ FF(f, c, d, e, a, b, buf[ i2], 15, ss, k); \
+ FF(f, b, c, d, e, a, buf[ i3], 6, ss, k); \
FF(f, a, b, c, d, e, buf[i12]^buf[i13]^buf[i14]^buf[i15], 13, ss, k); \
- FF(f, e, a, b, c, d, buf[ i4], 8, ss, k); \
- FF(f, d, e, a, b, c, buf[ i5], 14, ss, k); \
- FF(f, c, d, e, a, b, buf[ i6], 7, ss, k); \
- FF(f, b, c, d, e, a, buf[ i7], 12, ss, k); \
+ FF(f, e, a, b, c, d, buf[ i4], 8, ss, k); \
+ FF(f, d, e, a, b, c, buf[ i5], 14, ss, k); \
+ FF(f, c, d, e, a, b, buf[ i6], 7, ss, k); \
+ FF(f, b, c, d, e, a, buf[ i7], 12, ss, k); \
FF(f, a, b, c, d, e, buf[ i0]^buf[ i1]^buf[ i2]^buf[ i3], 9, ss, k); \
- FF(f, e, a, b, c, d, buf[ i8], 11, ss, k); \
- FF(f, d, e, a, b, c, buf[ i9], 8, ss, k); \
- FF(f, c, d, e, a, b, buf[i10], 15, ss, k); \
- FF(f, b, c, d, e, a, buf[i11], 6, ss, k); \
+ FF(f, e, a, b, c, d, buf[ i8], 11, ss, k); \
+ FF(f, d, e, a, b, c, buf[ i9], 8, ss, k); \
+ FF(f, c, d, e, a, b, buf[i10], 15, ss, k); \
+ FF(f, b, c, d, e, a, buf[i11], 6, ss, k); \
FF(f, a, b, c, d, e, buf[ i4]^buf[ i5]^buf[ i6]^buf[ i7], 12, ss, k); \
- FF(f, e, a, b, c, d, buf[i12], 9, ss, k); \
- FF(f, d, e, a, b, c, buf[i13], 14, ss, k); \
- FF(f, c, d, e, a, b, buf[i14], 5, ss, k); \
- FF(f, b, c, d, e, a, buf[i15], 13, ss, k); \
+ FF(f, e, a, b, c, d, buf[i12], 9, ss, k); \
+ FF(f, d, e, a, b, c, buf[i13], 14, ss, k); \
+ FF(f, c, d, e, a, b, buf[i14], 5, ss, k); \
+ FF(f, b, c, d, e, a, buf[i15], 13, ss, k); \
} while (0)
ROUND(F, 10, 0x00000000,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
ROUND(G, 17, 0x5a827999,
- 3, 6, 9, 12, 15, 2, 5, 8, 11, 14, 1, 4, 7, 10, 13, 0);
+ 3, 6, 9, 12, 15, 2, 5, 8, 11, 14, 1, 4, 7, 10, 13, 0);
ROUND(H, 25, 0x6ed9eba1,
- 12, 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3);
+ 12, 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3);
ROUND(G, 30, 0x8f1bbcdc,
- 7, 2, 13, 8, 3, 14, 9, 4, 15, 10, 5, 0, 11, 6, 1, 12);
+ 7, 2, 13, 8, 3, 14, 9, 4, 15, 10, 5, 0, 11, 6, 1, 12);
/* --- Update the chaining variables --- */
void has160_set(has160_ctx *ctx, const void *buf, unsigned long count)
{
const octet *p = buf;
- ctx->a = LOAD32_L(p + 0);
- ctx->b = LOAD32_L(p + 4);
- ctx->c = LOAD32_L(p + 8);
+ ctx->a = LOAD32_L(p + 0);
+ ctx->b = LOAD32_L(p + 4);
+ ctx->c = LOAD32_L(p + 8);
ctx->d = LOAD32_L(p + 12);
ctx->e = LOAD32_L(p + 16);
ctx->off = 0;
{
octet *p = hash;
HASH_MD5STRENGTH(HAS160, has160, ctx);
- STORE32_L(p + 0, ctx->a);
- STORE32_L(p + 4, ctx->b);
- STORE32_L(p + 8, ctx->c);
+ STORE32_L(p + 0, ctx->a);
+ STORE32_L(p + 4, ctx->b);
+ STORE32_L(p + 8, ctx->c);
STORE32_L(p + 12, ctx->d);
STORE32_L(p + 16, ctx->e);
}
unsigned long has160_state(has160_ctx *ctx, void *state)
{
octet *p = state;
- STORE32_L(p + 0, ctx->a);
- STORE32_L(p + 4, ctx->b);
- STORE32_L(p + 8, ctx->c);
+ STORE32_L(p + 0, ctx->a);
+ STORE32_L(p + 4, ctx->b);
+ STORE32_L(p + 8, ctx->c);
STORE32_L(p + 12, ctx->d);
STORE32_L(p + 16, ctx->e);
return (ctx->nl | ((ctx->nh << 16) << 16));