Source-Changes-HG archive

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

[src/trunk]: src/lib/libcrypto/arch/i386 Add support for building the assembl...



details:   https://anonhg.NetBSD.org/src/rev/befe159f2096
branches:  trunk
changeset: 495566:befe159f2096
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Jul 31 18:39:04 2000 +0000

description:
Add support for building the assembly versions of Blowfish encrypt
and decrypt from OpenSSL.  Right now we only build the 586 version,
but eventually we will be able to build the 686 version based on a
CPP flag defined as a result of using `cc -mcpu=pentiumpro'.

We don't build the assembly version of BF_cbc_encrypt(), as it would
have to be rewritten to be PIC.

Performance difference is quite noticeable.

Before:
Doing blowfish cbc for 3s on 8 size blocks: 2891026 blowfish cbc's in 2.97s
Doing blowfish cbc for 3s on 64 size blocks: 411766 blowfish cbc's in 3.10s
Doing blowfish cbc for 3s on 256 size blocks: 104721 blowfish cbc's in 3.00s
Doing blowfish cbc for 3s on 1024 size blocks: 26291 blowfish cbc's in 2.98s
Doing blowfish cbc for 3s on 8192 size blocks: 3290 blowfish cbc's in 3.10s
type              8 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes
blowfish cbc      7787.28k     8755.16k     8936.19k     9034.22k     8954.05k

After:
Doing blowfish cbc for 3s on 8 size blocks: 4573792 blowfish cbc's in 3.10s
Doing blowfish cbc for 3s on 64 size blocks: 713440 blowfish cbc's in 2.99s
Doing blowfish cbc for 3s on 256 size blocks: 183125 blowfish cbc's in 3.00s
Doing blowfish cbc for 3s on 1024 size blocks: 46221 blowfish cbc's in 3.00s
Doing blowfish cbc for 3s on 8192 size blocks: 5787 blowfish cbc's in 3.00s
type              8 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes
blowfish cbc     12156.26k    15270.96k    15626.67k    15776.77k    15802.37k

diffstat:

 lib/libcrypto/arch/i386/bf.inc       |   14 +
 lib/libcrypto/arch/i386/bf_enc_586.S |  759 +++++++++++++++++++++++++++++++++++
 lib/libcrypto/arch/i386/bf_enc_686.S |  731 +++++++++++++++++++++++++++++++++
 lib/libcrypto/arch/i386/bf_enc_x86.S |   16 +
 4 files changed, 1520 insertions(+), 0 deletions(-)

diffs (truncated from 1536 to 300 lines):

diff -r 4e37538510dd -r befe159f2096 lib/libcrypto/arch/i386/bf.inc
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libcrypto/arch/i386/bf.inc    Mon Jul 31 18:39:04 2000 +0000
@@ -0,0 +1,14 @@
+#      $NetBSD: bf.inc,v 1.1 2000/07/31 18:39:04 thorpej Exp $
+#
+#      @(#) Copyright (c) 1995 Simon J. Gerraty
+#
+#      SRCS extracted from /home/current/src/lib/libcrypto/../../crypto/dist/openssl/crypto/bf/Makefile.ssl
+#
+
+.PATH: ${OPENSSLSRC}/crypto/bf
+.PATH: ${.CURDIR}/arch/i386
+
+CPPFLAGS+=     -I${OPENSSLSRC}/crypto/bf
+CPPFLAGS+=     -I${.CURDIR}/arch/i386
+
+SRCS+=bf_skey.c bf_ecb.c bf_enc_x86.S bf_cbc.c bf_cfb64.c bf_ofb64.c
diff -r 4e37538510dd -r befe159f2096 lib/libcrypto/arch/i386/bf_enc_586.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libcrypto/arch/i386/bf_enc_586.S      Mon Jul 31 18:39:04 2000 +0000
@@ -0,0 +1,759 @@
+/*     $NetBSD: bf_enc_586.S,v 1.1 2000/07/31 18:39:05 thorpej Exp $   */
+
+/* Copyright (C) 1995-1998 Eric Young (eay%cryptsoft.com@localhost)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay%cryptsoft.com@localhost).
+ * The implementation was written so as to conform with Netscapes SSL.
+ * 
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to.  The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh%cryptsoft.com@localhost).
+ * 
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *    "This product includes cryptographic software written by
+ *     Eric Young (eay%cryptsoft.com@localhost)"
+ *    The word 'cryptographic' can be left out if the rouines from the library
+ *    being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from 
+ *    the apps directory (application code) you must include an acknowledgement:
+ *    "This product includes software written by Tim Hudson (tjh%cryptsoft.com@localhost)"
+ * 
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * 
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed.  i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+/*
+ * Modified from the output of `perl bf-586.pl elf' by
+ * Jason R. Thorpe <thorpej%zembu.com@localhost>.
+ */
+
+#include <machine/asm.h>
+
+ENTRY(BF_encrypt)
+       pushl   %ebp
+       pushl   %ebx
+       movl    12(%esp),       %ebx
+       movl    16(%esp),       %ebp
+       pushl   %esi
+       pushl   %edi
+       /* Load the 2 words */
+       movl    (%ebx),         %edi
+       movl    4(%ebx),        %esi
+       xorl    %eax,           %eax
+       movl    (%ebp),         %ebx
+       xorl    %ecx,           %ecx
+       xorl    %ebx,           %edi
+
+       /* Round 0 */
+       movl    4(%ebp),        %edx
+       movl    %edi,           %ebx
+       xorl    %edx,           %esi
+       shrl    $16,            %ebx
+       movl    %edi,           %edx
+       movb    %bh,            %al
+       andl    $255,           %ebx
+       movb    %dh,            %cl
+       andl    $255,           %edx
+       movl    72(%ebp,%eax,4),%eax
+       movl    1096(%ebp,%ebx,4),%ebx
+       addl    %eax,           %ebx
+       movl    2120(%ebp,%ecx,4),%eax
+       xorl    %eax,           %ebx
+       movl    3144(%ebp,%edx,4),%edx
+       addl    %edx,           %ebx
+       xorl    %eax,           %eax
+       xorl    %ebx,           %esi
+
+       /* Round 1 */
+       movl    8(%ebp),        %edx
+       movl    %esi,           %ebx
+       xorl    %edx,           %edi
+       shrl    $16,            %ebx
+       movl    %esi,           %edx
+       movb    %bh,            %al
+       andl    $255,           %ebx
+       movb    %dh,            %cl
+       andl    $255,           %edx
+       movl    72(%ebp,%eax,4),%eax
+       movl    1096(%ebp,%ebx,4),%ebx
+       addl    %eax,           %ebx
+       movl    2120(%ebp,%ecx,4),%eax
+       xorl    %eax,           %ebx
+       movl    3144(%ebp,%edx,4),%edx
+       addl    %edx,           %ebx
+       xorl    %eax,           %eax
+       xorl    %ebx,           %edi
+
+       /* Round 2 */
+       movl    12(%ebp),       %edx
+       movl    %edi,           %ebx
+       xorl    %edx,           %esi
+       shrl    $16,            %ebx
+       movl    %edi,           %edx
+       movb    %bh,            %al
+       andl    $255,           %ebx
+       movb    %dh,            %cl
+       andl    $255,           %edx
+       movl    72(%ebp,%eax,4),%eax
+       movl    1096(%ebp,%ebx,4),%ebx
+       addl    %eax,           %ebx
+       movl    2120(%ebp,%ecx,4),%eax
+       xorl    %eax,           %ebx
+       movl    3144(%ebp,%edx,4),%edx
+       addl    %edx,           %ebx
+       xorl    %eax,           %eax
+       xorl    %ebx,           %esi
+
+       /* Round 3 */
+       movl    16(%ebp),       %edx
+       movl    %esi,           %ebx
+       xorl    %edx,           %edi
+       shrl    $16,            %ebx
+       movl    %esi,           %edx
+       movb    %bh,            %al
+       andl    $255,           %ebx
+       movb    %dh,            %cl
+       andl    $255,           %edx
+       movl    72(%ebp,%eax,4),%eax
+       movl    1096(%ebp,%ebx,4),%ebx
+       addl    %eax,           %ebx
+       movl    2120(%ebp,%ecx,4),%eax
+       xorl    %eax,           %ebx
+       movl    3144(%ebp,%edx,4),%edx
+       addl    %edx,           %ebx
+       xorl    %eax,           %eax
+       xorl    %ebx,           %edi
+
+       /* Round 4 */
+       movl    20(%ebp),       %edx
+       movl    %edi,           %ebx
+       xorl    %edx,           %esi
+       shrl    $16,            %ebx
+       movl    %edi,           %edx
+       movb    %bh,            %al
+       andl    $255,           %ebx
+       movb    %dh,            %cl
+       andl    $255,           %edx
+       movl    72(%ebp,%eax,4),%eax
+       movl    1096(%ebp,%ebx,4),%ebx
+       addl    %eax,           %ebx
+       movl    2120(%ebp,%ecx,4),%eax
+       xorl    %eax,           %ebx
+       movl    3144(%ebp,%edx,4),%edx
+       addl    %edx,           %ebx
+       xorl    %eax,           %eax
+       xorl    %ebx,           %esi
+
+       /* Round 5 */
+       movl    24(%ebp),       %edx
+       movl    %esi,           %ebx
+       xorl    %edx,           %edi
+       shrl    $16,            %ebx
+       movl    %esi,           %edx
+       movb    %bh,            %al
+       andl    $255,           %ebx
+       movb    %dh,            %cl
+       andl    $255,           %edx
+       movl    72(%ebp,%eax,4),%eax
+       movl    1096(%ebp,%ebx,4),%ebx
+       addl    %eax,           %ebx
+       movl    2120(%ebp,%ecx,4),%eax
+       xorl    %eax,           %ebx
+       movl    3144(%ebp,%edx,4),%edx
+       addl    %edx,           %ebx
+       xorl    %eax,           %eax
+       xorl    %ebx,           %edi
+
+       /* Round 6 */
+       movl    28(%ebp),       %edx
+       movl    %edi,           %ebx
+       xorl    %edx,           %esi
+       shrl    $16,            %ebx
+       movl    %edi,           %edx
+       movb    %bh,            %al
+       andl    $255,           %ebx
+       movb    %dh,            %cl
+       andl    $255,           %edx
+       movl    72(%ebp,%eax,4),%eax
+       movl    1096(%ebp,%ebx,4),%ebx
+       addl    %eax,           %ebx
+       movl    2120(%ebp,%ecx,4),%eax
+       xorl    %eax,           %ebx
+       movl    3144(%ebp,%edx,4),%edx
+       addl    %edx,           %ebx
+       xorl    %eax,           %eax
+       xorl    %ebx,           %esi
+
+       /* Round 7 */
+       movl    32(%ebp),       %edx
+       movl    %esi,           %ebx
+       xorl    %edx,           %edi
+       shrl    $16,            %ebx
+       movl    %esi,           %edx
+       movb    %bh,            %al
+       andl    $255,           %ebx
+       movb    %dh,            %cl
+       andl    $255,           %edx
+       movl    72(%ebp,%eax,4),%eax
+       movl    1096(%ebp,%ebx,4),%ebx
+       addl    %eax,           %ebx
+       movl    2120(%ebp,%ecx,4),%eax
+       xorl    %eax,           %ebx
+       movl    3144(%ebp,%edx,4),%edx
+       addl    %edx,           %ebx
+       xorl    %eax,           %eax
+       xorl    %ebx,           %edi
+
+       /* Round 8 */
+       movl    36(%ebp),       %edx
+       movl    %edi,           %ebx
+       xorl    %edx,           %esi
+       shrl    $16,            %ebx
+       movl    %edi,           %edx
+       movb    %bh,            %al
+       andl    $255,           %ebx
+       movb    %dh,            %cl
+       andl    $255,           %edx
+       movl    72(%ebp,%eax,4),%eax
+       movl    1096(%ebp,%ebx,4),%ebx
+       addl    %eax,           %ebx
+       movl    2120(%ebp,%ecx,4),%eax
+       xorl    %eax,           %ebx
+       movl    3144(%ebp,%edx,4),%edx
+       addl    %edx,           %ebx
+       xorl    %eax,           %eax
+       xorl    %ebx,           %esi
+
+       /* Round 9 */
+       movl    40(%ebp),       %edx
+       movl    %esi,           %ebx
+       xorl    %edx,           %edi
+       shrl    $16,            %ebx
+       movl    %esi,           %edx
+       movb    %bh,            %al
+       andl    $255,           %ebx
+       movb    %dh,            %cl
+       andl    $255,           %edx
+       movl    72(%ebp,%eax,4),%eax
+       movl    1096(%ebp,%ebx,4),%ebx
+       addl    %eax,           %ebx
+       movl    2120(%ebp,%ecx,4),%eax
+       xorl    %eax,           %ebx
+       movl    3144(%ebp,%edx,4),%edx
+       addl    %edx,           %ebx



Home | Main Index | Thread Index | Old Index