[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] OpenSSL BigNum library



Here is a first attempt at assembly language optimization of the OpenSSL
0.9.6c crypto/bn_asm.c file for Motorola 68020-60. Some of it is written
completely by me, some of it is gcc-output that has been slightly tweaked by
me. It's still a bit rough, there are a few areas that obviously need to be
cleaned up. But it's at least 4 times faster than the original C code for
RSA private/public key stuff, which will make life with SSL much easier. I
will continue to hack on this a bit more, but I wanted to get it out quickly
so you guys can look thru it as well.

The code passed the bntest program, but it appears to have some errors still
in the DSA algorithm. Not quite sure what's going on yet.

Here's also a diff for bn_div.c along similar lines...

viola:/home/software/openssl-0.9.6c/crypto/bn> diff -u bn_div.c{.O,}
--- bn_div.c.O  Sun Feb 17 09:24:14 2002
+++ bn_div.c    Sun Feb 17 04:42:27 2002
@@ -139,7 +139,7 @@
     *
     *                                  <appro@fy.chalmers.se>
     */
-#  define bn_div_words(n0,n1,d0)               \
+#   define bn_div_words(n0,n1,d0)              \
        ({  asm volatile (                      \
                "divl   %4"                     \
                : "=a"(q), "=d"(rem)            \
@@ -147,7 +147,22 @@
                : "cc");                        \
            q;                                  \
        })
-#  define REMAINDER_IS_ALREADY_CALCULATED
+#   define REMAINDER_IS_ALREADY_CALCULATED
+#  elif defined(__mc68020__)
+   /* Same rationale as for i386. On the 68020-60/CPU32 the divu
+    * instruction will take a 64 bit dividend in a register pair
+    * and overwrite that pair with the remainder:quotient.
+    *                                  <hyc@highlandsun.com>
+    */
+#   define bn_div_words(n0,n1,d0)              \
+       ({ asm volatile (                       \
+               "divu.l %4,%2:%3"               \
+               : "=d"(rem), "=d"(q)            \
+               : "0"(n0), "1"(n1), "d"(d0)     \
+               : "cc");                        \
+           q;                                  \
+       })
+#   define REMAINDER_IS_ALREADY_CALCULATED
 #  endif /* __<cpu> */
 # endif /* __GNUC__ */
 #endif /* NO_ASM */

  -- Howard Chu
  Chief Architect, Symas Corp.       Director, Highland Sun
  http://www.symas.com               http://highlandsun.com/hyc
  Symas: Premier OpenSource Development and Support

Attachment: bn_m68k.s
Description: Binary data