Sort openssl.ec, the configuration file for mkerr.pl.
[openssl.git] / crypto / md32_common.h
index 8c0a085369f8176a63fbfb874e15e1c89b274ced..e028376fbe49821353d16c7ef01596198bacec9b 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
+# if 0 /* defined(_MSC_VER) */
+#  define ROTATE(a,n)  _lrotl(a,n)
+# elif defined(__MWERKS__)
+#  if defined(__POWERPC__)
+#   define ROTATE(a,n) __rlwinm(a,n,0,31)
+#  elif defined(__MC68K__)
+    /* Motorola specific tweak. <appro@fy.chalmers.se> */
+#   define ROTATE(a,n) ( n<24 ? __rol(a,n) : __ror(a,32-n) )
+#  else
+#   define ROTATE(a,n) __rol(a,n)
+#  endif
+# elif defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
   /*
    * Some GNU C inline assembler templates. Note that these are
    * rotates by *constant* number of bits! But that's exactly
    */
 #  if defined(__i386)
 #   define ROTATE(a,n) ({ register unsigned int ret;   \
-                               asm volatile (          \
+                               asm (                   \
                                "roll %1,%0"            \
                                : "=r"(ret)             \
                                : "I"(n), "0"(a)        \
                                : "cc");                \
                           ret;                         \
                        })
-#  elif defined(__powerpc)
+#  elif defined(__powerpc) || defined(__ppc)
 #   define ROTATE(a,n) ({ register unsigned int ret;   \
-                               asm volatile (          \
+                               asm (                   \
                                "rlwinm %0,%1,%2,0,31"  \
                                : "=r"(ret)             \
                                : "r"(a), "I"(n));      \
  * Engage compiler specific "fetch in reverse byte order"
  * intrinsic function if available.
  */
-# if defined(__GNUC__) && __GNUC__>=2
+# if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_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);\
-                               asm volatile (          \
+                               asm (                   \
                                "bswapl %0"             \
                                : "=r"(l) : "0"(l));    \
                          l;                            \
                        })
 #  elif defined(__powerpc)
 #   define LE_FETCH32(a)       ({ register unsigned int l;     \
-                               asm volatile (          \
+                               asm (                   \
                                "lwbrx %0,0,%1"         \
                                : "=r"(l)               \
                                : "r"(a));              \
                           l;                           \
                        })
 
-#  elif defined(__sparc) && defined(ULTRASPARC)
+#  elif defined(__sparc) && defined(OPENSSL_SYS_ULTRASPARC)
 #  define LE_FETCH32(a)        ({ register unsigned int l;             \
-                               asm volatile (                  \
+                               asm (                           \
                                "lda [%1]#ASI_PRIMARY_LITTLE,%0"\
                                : "=r"(l)                       \
                                : "r"(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
  * Time for some action:-)
  */
 
-void HASH_UPDATE (HASH_CTX *c, const unsigned char *data, unsigned long len)
+void HASH_UPDATE (HASH_CTX *c, const void *data_, unsigned long len)
        {
+       const unsigned char *data=data_;
        register HASH_LONG * p;
        register unsigned long l;
        int sw,sc,ew,ec;
@@ -461,14 +473,15 @@ 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)
                        {
-                       HASH_BLOCK_DATA_ORDER_ALIGNED (c,data,sw);
+                       /* 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;
                        len-=sw;
@@ -512,9 +525,10 @@ void HASH_UPDATE (HASH_CTX *c, const unsigned char *data, unsigned long len)
 
 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)
-               HASH_BLOCK_DATA_ORDER_ALIGNED (c,data,1);
+               /* 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 +593,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