md32_common.h update and accompanying MD5 update.
[openssl.git] / crypto / md32_common.h
index dc464ea..5e62d40 100644 (file)
@@ -94,6 +94,8 @@
  *     in original (data) byte order, implemented externally (it
  *     actually is optional if data and host are of the same
  *     "endianess").
+ * HASH_MAKE_STRING
+ *     macro convering context variables to an ASCII hash string.
  *
  * Optional macros:
  *
 #undef ROTATE
 #ifndef PEDANTIC
 # if defined(_MSC_VER)
-#  define ROTATE(a,n)     _lrotl(a,n)
-# elif defined(__GNUC__) && __GNUC__>=2
+#  define ROTATE(a,n)  _lrotl(a,n)
+# elif defined(__MWERKS__)
+#  define ROTATE(a,n)  __rol(a,n)
+# elif defined(__GNUC__) && __GNUC__>=2 && !defined(NO_ASM)
   /*
    * Some GNU C inline assembler templates. Note that these are
    * rotates by *constant* number of bits! But that's exactly
  * Engage compiler specific "fetch in reverse byte order"
  * intrinsic function if available.
  */
-# if defined(__GNUC__) && __GNUC__>=2
+# if defined(__GNUC__) && __GNUC__>=2 && !defined(NO_ASM)
   /* some GNU C inline assembler templates by <appro@fy.chalmers.se> */
 #  if defined(__i386) && !defined(I386_ONLY)
 #   define BE_FETCH32(a)       ({ register unsigned int l=(a);\
 #  endif
 #endif
 
-#if !defined(HASH_BLOCK_DATA_ORDER_ALIGNED) && HASH_BLOCK_DATA_ORDER_ALIGNED!=1
+#if !defined(HASH_BLOCK_DATA_ORDER_ALIGNED)
 #ifndef HASH_BLOCK_DATA_ORDER
 #error "HASH_BLOCK_DATA_ORDER must be defined!"
 #endif
@@ -461,13 +465,14 @@ void HASH_UPDATE (HASH_CTX *c, const unsigned char *data, unsigned long len)
        sw=len/HASH_CBLOCK;
        if (sw > 0)
                {
-#if defined(HASH_BLOCK_DATA_ORDER_ALIGNED) && HASH_BLOCK_DATA_ORDER_ALIGNED!=1
+#if defined(HASH_BLOCK_DATA_ORDER_ALIGNED)
                /*
                 * Note that HASH_BLOCK_DATA_ORDER_ALIGNED gets defined
                 * only if sizeof(HASH_LONG)==4.
                 */
                if ((((unsigned long)data)%4) == 0)
                        {
+                       /* data is properly aligned so that we can cast it: */
                        HASH_BLOCK_DATA_ORDER_ALIGNED (c,(HASH_LONG *)data,sw);
                        sw*=HASH_CBLOCK;
                        data+=sw;
@@ -510,10 +515,11 @@ void HASH_UPDATE (HASH_CTX *c, const unsigned char *data, unsigned long len)
        }
 
 
-void HASH_TRANSFORM (HASH_CTX *c, unsigned char *data)
+void HASH_TRANSFORM (HASH_CTX *c, const unsigned char *data)
        {
-#if defined(HASH_BLOCK_DATA_ORDER_ALIGNED) && HASH_BLOCK_DATA_ORDER_ALIGNED!=1
+#if defined(HASH_BLOCK_DATA_ORDER_ALIGNED)
        if ((((unsigned long)data)%4) == 0)
+               /* data is properly aligned so that we can cast it: */
                HASH_BLOCK_DATA_ORDER_ALIGNED (c,(HASH_LONG *)data,1);
        else
 #if !defined(HASH_BLOCK_DATA_ORDER)
@@ -579,10 +585,11 @@ void HASH_FINAL (unsigned char *md, HASH_CTX *c)
 #endif
        HASH_BLOCK_HOST_ORDER (c,p,1);
 
-       l=c->A; HOST_l2c(l,md);
-       l=c->B; HOST_l2c(l,md);
-       l=c->C; HOST_l2c(l,md);
-       l=c->D; HOST_l2c(l,md);
+#ifndef HASH_MAKE_STRING
+#error "HASH_MAKE_STRING must be defined!"
+#else
+       HASH_MAKE_STRING(c,md);
+#endif
 
        c->num=0;
        /* clear stuff, HASH_BLOCK may be leaving some stuff on the stack