/* -*-c-*-
*
- * $Id: hash.h,v 1.1 1999/09/03 08:41:12 mdw Exp $
+ * $Id: hash.h,v 1.2 1999/12/10 23:16:40 mdw Exp $
*
* Generic handling for message digest functions
*
/*----- Revision history --------------------------------------------------*
*
* $Log: hash.h,v $
+ * Revision 1.2 1999/12/10 23:16:40 mdw
+ * Split mode macros into interface and implementation.
+ *
* Revision 1.1 1999/09/03 08:41:12 mdw
* Initial import.
*
*/
-#ifndef HASH_H
-#define HASH_H
+#ifndef CATACOMB_HASH_H
+#define CATACOMB_HASH_H
#ifdef __cplusplus
extern "C" {
size_t _bsz = (isz); \
const octet *_bbuf = (octet *)(ibuf); \
\
- /* --- Add on the size done so far --- */ \
- \
- _bctx->count += _bsz; \
+ /* --- Add on the size done so far --- * \
+ * \
+ * Messy, because trapping overflow is difficult when you don't know \
+ * how many bits you've actually got. \
+ */ \
+ \
+ { \
+ uint32 _l = U32(_bsz), _h = (_bsz >> 16) >> 16; \
+ _bctx->nh += _h; \
+ _bctx->nl += _l; \
+ if (_bctx->nl < _l || _bctx->nl & ~MASK32) \
+ _bctx->nh++; \
+ } \
\
/* --- Handle very small contributions --- */ \
\
#define HASH_MD5STRENGTH(PRE, pre, ictx) do { \
pre##_ctx *_mctx = (ictx); \
HASH_PAD(PRE, pre, _mctx, 0x80u, 0, 8); \
- STORE32_L(_mctx->buf + PRE##_BUFSZ - 8, _mctx->count << 3); \
- STORE32_L(_mctx->buf + PRE##_BUFSZ - 4, _mctx->count >> 29); \
+ STORE32_L(_mctx->buf + PRE##_BUFSZ - 8, _mctx->nl << 3); \
+ STORE32_L(_mctx->buf + PRE##_BUFSZ - 4, \
+ (_mctx->nl >> 29) | (_mctx->nh << 3)); \
pre##_compress(_mctx, _mctx->buf); \
} while (0)