Home | History | Annotate | Line # | Download | only in i386
bf_cbc.S revision 1.1.2.2
      1  1.1.2.2  fvdl /* $NetBSD: bf_cbc.S,v 1.1.2.2 2001/10/01 12:44:02 fvdl Exp $ */
      2  1.1.2.2  fvdl 
      3  1.1.2.2  fvdl /* Copyright (C) 1995-1998 Eric Young (eay (at) cryptsoft.com)
      4  1.1.2.2  fvdl  * All rights reserved.
      5  1.1.2.2  fvdl  *
      6  1.1.2.2  fvdl  * This package is an SSL implementation written
      7  1.1.2.2  fvdl  * by Eric Young (eay (at) cryptsoft.com).
      8  1.1.2.2  fvdl  * The implementation was written so as to conform with Netscapes SSL.
      9  1.1.2.2  fvdl  *
     10  1.1.2.2  fvdl  * This library is free for commercial and non-commercial use as long as
     11  1.1.2.2  fvdl  * the following conditions are aheared to.  The following conditions
     12  1.1.2.2  fvdl  * apply to all code found in this distribution, be it the RC4, RSA,
     13  1.1.2.2  fvdl  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
     14  1.1.2.2  fvdl  * included with this distribution is covered by the same copyright terms
     15  1.1.2.2  fvdl  * except that the holder is Tim Hudson (tjh (at) cryptsoft.com).
     16  1.1.2.2  fvdl  *
     17  1.1.2.2  fvdl  * Copyright remains Eric Young's, and as such any Copyright notices in
     18  1.1.2.2  fvdl  * the code are not to be removed.
     19  1.1.2.2  fvdl  * If this package is used in a product, Eric Young should be given attribution
     20  1.1.2.2  fvdl  * as the author of the parts of the library used.
     21  1.1.2.2  fvdl  * This can be in the form of a textual message at program startup or
     22  1.1.2.2  fvdl  * in documentation (online or textual) provided with the package.
     23  1.1.2.2  fvdl  *
     24  1.1.2.2  fvdl  * Redistribution and use in source and binary forms, with or without
     25  1.1.2.2  fvdl  * modification, are permitted provided that the following conditions
     26  1.1.2.2  fvdl  * are met:
     27  1.1.2.2  fvdl  * 1. Redistributions of source code must retain the copyright
     28  1.1.2.2  fvdl  *    notice, this list of conditions and the following disclaimer.
     29  1.1.2.2  fvdl  * 2. Redistributions in binary form must reproduce the above copyright
     30  1.1.2.2  fvdl  *    notice, this list of conditions and the following disclaimer in the
     31  1.1.2.2  fvdl  *    documentation and/or other materials provided with the distribution.
     32  1.1.2.2  fvdl  * 3. All advertising materials mentioning features or use of this software
     33  1.1.2.2  fvdl  *    must display the following acknowledgement:
     34  1.1.2.2  fvdl  *    "This product includes cryptographic software written by
     35  1.1.2.2  fvdl  *     Eric Young (eay (at) cryptsoft.com)"
     36  1.1.2.2  fvdl  *    The word 'cryptographic' can be left out if the rouines from the library
     37  1.1.2.2  fvdl  *    being used are not cryptographic related :-).
     38  1.1.2.2  fvdl  * 4. If you include any Windows specific code (or a derivative thereof) from
     39  1.1.2.2  fvdl  *    the apps directory (application code) you must include an acknowledgement:
     40  1.1.2.2  fvdl  *    "This product includes software written by Tim Hudson (tjh (at) cryptsoft.com)"
     41  1.1.2.2  fvdl  *
     42  1.1.2.2  fvdl  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
     43  1.1.2.2  fvdl  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     44  1.1.2.2  fvdl  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     45  1.1.2.2  fvdl  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     46  1.1.2.2  fvdl  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     47  1.1.2.2  fvdl  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     48  1.1.2.2  fvdl  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     49  1.1.2.2  fvdl  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     50  1.1.2.2  fvdl  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     51  1.1.2.2  fvdl  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     52  1.1.2.2  fvdl  * SUCH DAMAGE.
     53  1.1.2.2  fvdl  *
     54  1.1.2.2  fvdl  * The licence and distribution terms for any publically available version or
     55  1.1.2.2  fvdl  * derivative of this code cannot be changed.  i.e. this code cannot simply be
     56  1.1.2.2  fvdl  * copied and put under another distribution licence
     57  1.1.2.2  fvdl  * [including the GNU Public Licence.]
     58  1.1.2.2  fvdl  */
     59  1.1.2.2  fvdl 
     60  1.1.2.2  fvdl /*
     61  1.1.2.2  fvdl  * Modified from the output of `perl bf-686.pl elf' by
     62  1.1.2.2  fvdl  * Thor Lancelot Simon <tls (at) netbsd.org>
     63  1.1.2.2  fvdl  */
     64  1.1.2.2  fvdl 
     65  1.1.2.2  fvdl #include <i386/include/asm.h>
     66  1.1.2.2  fvdl 
     67  1.1.2.2  fvdl ENTRY(BF_cbc_encrypt)
     68  1.1.2.2  fvdl 
     69  1.1.2.2  fvdl 	pushl	%ebp
     70  1.1.2.2  fvdl 	pushl	%ebx
     71  1.1.2.2  fvdl 	pushl	%esi
     72  1.1.2.2  fvdl 	pushl	%edi
     73  1.1.2.2  fvdl 	movl	28(%esp),	%ebp
     74  1.1.2.2  fvdl 	# getting iv ptr from parameter 4
     75  1.1.2.2  fvdl 	movl	36(%esp),	%ebx
     76  1.1.2.2  fvdl 	movl	(%ebx),		%esi
     77  1.1.2.2  fvdl 	movl	4(%ebx),	%edi
     78  1.1.2.2  fvdl 	pushl	%edi
     79  1.1.2.2  fvdl 	pushl	%esi
     80  1.1.2.2  fvdl 	pushl	%edi
     81  1.1.2.2  fvdl 	pushl	%esi
     82  1.1.2.2  fvdl 	movl	%esp,		%ebx
     83  1.1.2.2  fvdl 	movl	36(%esp),	%esi
     84  1.1.2.2  fvdl 	movl	40(%esp),	%edi
     85  1.1.2.2  fvdl 	# getting encrypt flag from parameter 5
     86  1.1.2.2  fvdl 	movl	56(%esp),	%ecx
     87  1.1.2.2  fvdl 	# get and push parameter 3
     88  1.1.2.2  fvdl 	movl	48(%esp),	%eax
     89  1.1.2.2  fvdl 	pushl	%eax
     90  1.1.2.2  fvdl 	pushl	%ebx
     91  1.1.2.2  fvdl 	cmpl	$0,		%ecx
     92  1.1.2.2  fvdl 	jz	.L000decrypt
     93  1.1.2.2  fvdl 	andl	$4294967288,	%ebp
     94  1.1.2.2  fvdl 	movl	8(%esp),	%eax
     95  1.1.2.2  fvdl 	movl	12(%esp),	%ebx
     96  1.1.2.2  fvdl 	jz	.L001encrypt_finish
     97  1.1.2.2  fvdl .L002encrypt_loop:
     98  1.1.2.2  fvdl 	movl	(%esi),		%ecx
     99  1.1.2.2  fvdl 	movl	4(%esi),	%edx
    100  1.1.2.2  fvdl 	xorl	%ecx,		%eax
    101  1.1.2.2  fvdl 	xorl	%edx,		%ebx
    102  1.1.2.2  fvdl .byte 15
    103  1.1.2.2  fvdl .byte 200		# bswapl  %eax
    104  1.1.2.2  fvdl .byte 15
    105  1.1.2.2  fvdl .byte 203		# bswapl  %ebx
    106  1.1.2.2  fvdl 	movl	%eax,		8(%esp)
    107  1.1.2.2  fvdl 	movl	%ebx,		12(%esp)
    108  1.1.2.2  fvdl 	call	_C_LABEL(BF_encrypt)
    109  1.1.2.2  fvdl 	movl	8(%esp),	%eax
    110  1.1.2.2  fvdl 	movl	12(%esp),	%ebx
    111  1.1.2.2  fvdl .byte 15
    112  1.1.2.2  fvdl .byte 200		# bswapl  %eax
    113  1.1.2.2  fvdl .byte 15
    114  1.1.2.2  fvdl .byte 203		# bswapl  %ebx
    115  1.1.2.2  fvdl 	movl	%eax,		(%edi)
    116  1.1.2.2  fvdl 	movl	%ebx,		4(%edi)
    117  1.1.2.2  fvdl 	addl	$8,		%esi
    118  1.1.2.2  fvdl 	addl	$8,		%edi
    119  1.1.2.2  fvdl 	subl	$8,		%ebp
    120  1.1.2.2  fvdl 	jnz	.L002encrypt_loop
    121  1.1.2.2  fvdl .L001encrypt_finish:
    122  1.1.2.2  fvdl 	movl	52(%esp),	%ebp
    123  1.1.2.2  fvdl 	andl	$7,		%ebp
    124  1.1.2.2  fvdl 	jz	.L003finish
    125  1.1.2.2  fvdl 	xorl	%ecx,		%ecx
    126  1.1.2.2  fvdl 	xorl	%edx,		%edx
    127  1.1.2.2  fvdl 	movl	.L004cbc_enc_jmp_table(,%ebp,4),%ebp
    128  1.1.2.2  fvdl 	jmp	*%ebp
    129  1.1.2.2  fvdl .L005ej7:
    130  1.1.2.2  fvdl 	movb	6(%esi),	%dh
    131  1.1.2.2  fvdl 	sall	$8,		%edx
    132  1.1.2.2  fvdl .L006ej6:
    133  1.1.2.2  fvdl 	movb	5(%esi),	%dh
    134  1.1.2.2  fvdl .L007ej5:
    135  1.1.2.2  fvdl 	movb	4(%esi),	%dl
    136  1.1.2.2  fvdl .L008ej4:
    137  1.1.2.2  fvdl 	movl	(%esi),		%ecx
    138  1.1.2.2  fvdl 	jmp	.L009ejend
    139  1.1.2.2  fvdl .L010ej3:
    140  1.1.2.2  fvdl 	movb	2(%esi),	%ch
    141  1.1.2.2  fvdl 	sall	$8,		%ecx
    142  1.1.2.2  fvdl .L011ej2:
    143  1.1.2.2  fvdl 	movb	1(%esi),	%ch
    144  1.1.2.2  fvdl .L012ej1:
    145  1.1.2.2  fvdl 	movb	(%esi),		%cl
    146  1.1.2.2  fvdl .L009ejend:
    147  1.1.2.2  fvdl 	xorl	%ecx,		%eax
    148  1.1.2.2  fvdl 	xorl	%edx,		%ebx
    149  1.1.2.2  fvdl .byte 15
    150  1.1.2.2  fvdl .byte 200		# bswapl  %eax
    151  1.1.2.2  fvdl .byte 15
    152  1.1.2.2  fvdl .byte 203		# bswapl  %ebx
    153  1.1.2.2  fvdl 	movl	%eax,		8(%esp)
    154  1.1.2.2  fvdl 	movl	%ebx,		12(%esp)
    155  1.1.2.2  fvdl 	call	_C_LABEL(BF_encrypt)
    156  1.1.2.2  fvdl 	movl	8(%esp),	%eax
    157  1.1.2.2  fvdl 	movl	12(%esp),	%ebx
    158  1.1.2.2  fvdl .byte 15
    159  1.1.2.2  fvdl .byte 200		# bswapl  %eax
    160  1.1.2.2  fvdl .byte 15
    161  1.1.2.2  fvdl .byte 203		# bswapl  %ebx
    162  1.1.2.2  fvdl 	movl	%eax,		(%edi)
    163  1.1.2.2  fvdl 	movl	%ebx,		4(%edi)
    164  1.1.2.2  fvdl 	jmp	.L003finish
    165  1.1.2.2  fvdl .align 16
    166  1.1.2.2  fvdl .L000decrypt:
    167  1.1.2.2  fvdl 	andl	$4294967288,	%ebp
    168  1.1.2.2  fvdl 	movl	16(%esp),	%eax
    169  1.1.2.2  fvdl 	movl	20(%esp),	%ebx
    170  1.1.2.2  fvdl 	jz	.L013decrypt_finish
    171  1.1.2.2  fvdl .L014decrypt_loop:
    172  1.1.2.2  fvdl 	movl	(%esi),		%eax
    173  1.1.2.2  fvdl 	movl	4(%esi),	%ebx
    174  1.1.2.2  fvdl .byte 15
    175  1.1.2.2  fvdl .byte 200		# bswapl  %eax
    176  1.1.2.2  fvdl .byte 15
    177  1.1.2.2  fvdl .byte 203		# bswapl  %ebx
    178  1.1.2.2  fvdl 	movl	%eax,		8(%esp)
    179  1.1.2.2  fvdl 	movl	%ebx,		12(%esp)
    180  1.1.2.2  fvdl 	call	_C_LABEL(BF_decrypt)
    181  1.1.2.2  fvdl 	movl	8(%esp),	%eax
    182  1.1.2.2  fvdl 	movl	12(%esp),	%ebx
    183  1.1.2.2  fvdl .byte 15
    184  1.1.2.2  fvdl .byte 200		# bswapl  %eax
    185  1.1.2.2  fvdl .byte 15
    186  1.1.2.2  fvdl .byte 203		# bswapl  %ebx
    187  1.1.2.2  fvdl 	movl	16(%esp),	%ecx
    188  1.1.2.2  fvdl 	movl	20(%esp),	%edx
    189  1.1.2.2  fvdl 	xorl	%eax,		%ecx
    190  1.1.2.2  fvdl 	xorl	%ebx,		%edx
    191  1.1.2.2  fvdl 	movl	(%esi),		%eax
    192  1.1.2.2  fvdl 	movl	4(%esi),	%ebx
    193  1.1.2.2  fvdl 	movl	%ecx,		(%edi)
    194  1.1.2.2  fvdl 	movl	%edx,		4(%edi)
    195  1.1.2.2  fvdl 	movl	%eax,		16(%esp)
    196  1.1.2.2  fvdl 	movl	%ebx,		20(%esp)
    197  1.1.2.2  fvdl 	addl	$8,		%esi
    198  1.1.2.2  fvdl 	addl	$8,		%edi
    199  1.1.2.2  fvdl 	subl	$8,		%ebp
    200  1.1.2.2  fvdl 	jnz	.L014decrypt_loop
    201  1.1.2.2  fvdl .L013decrypt_finish:
    202  1.1.2.2  fvdl 	movl	52(%esp),	%ebp
    203  1.1.2.2  fvdl 	andl	$7,		%ebp
    204  1.1.2.2  fvdl 	jz	.L003finish
    205  1.1.2.2  fvdl 	movl	(%esi),		%eax
    206  1.1.2.2  fvdl 	movl	4(%esi),	%ebx
    207  1.1.2.2  fvdl .byte 15
    208  1.1.2.2  fvdl .byte 200		# bswapl  %eax
    209  1.1.2.2  fvdl .byte 15
    210  1.1.2.2  fvdl .byte 203		# bswapl  %ebx
    211  1.1.2.2  fvdl 	movl	%eax,		8(%esp)
    212  1.1.2.2  fvdl 	movl	%ebx,		12(%esp)
    213  1.1.2.2  fvdl 	call	_C_LABEL(BF_decrypt)
    214  1.1.2.2  fvdl 	movl	8(%esp),	%eax
    215  1.1.2.2  fvdl 	movl	12(%esp),	%ebx
    216  1.1.2.2  fvdl .byte 15
    217  1.1.2.2  fvdl .byte 200		# bswapl  %eax
    218  1.1.2.2  fvdl .byte 15
    219  1.1.2.2  fvdl .byte 203		# bswapl  %ebx
    220  1.1.2.2  fvdl 	movl	16(%esp),	%ecx
    221  1.1.2.2  fvdl 	movl	20(%esp),	%edx
    222  1.1.2.2  fvdl 	xorl	%eax,		%ecx
    223  1.1.2.2  fvdl 	xorl	%ebx,		%edx
    224  1.1.2.2  fvdl 	movl	(%esi),		%eax
    225  1.1.2.2  fvdl 	movl	4(%esi),	%ebx
    226  1.1.2.2  fvdl .L015dj7:
    227  1.1.2.2  fvdl 	rorl	$16,		%edx
    228  1.1.2.2  fvdl 	movb	%dl,		6(%edi)
    229  1.1.2.2  fvdl 	shrl	$16,		%edx
    230  1.1.2.2  fvdl .L016dj6:
    231  1.1.2.2  fvdl 	movb	%dh,		5(%edi)
    232  1.1.2.2  fvdl .L017dj5:
    233  1.1.2.2  fvdl 	movb	%dl,		4(%edi)
    234  1.1.2.2  fvdl .L018dj4:
    235  1.1.2.2  fvdl 	movl	%ecx,		(%edi)
    236  1.1.2.2  fvdl 	jmp	.L019djend
    237  1.1.2.2  fvdl .L020dj3:
    238  1.1.2.2  fvdl 	rorl	$16,		%ecx
    239  1.1.2.2  fvdl 	movb	%cl,		2(%edi)
    240  1.1.2.2  fvdl 	sall	$16,		%ecx
    241  1.1.2.2  fvdl .L021dj2:
    242  1.1.2.2  fvdl 	movb	%ch,		1(%esi)
    243  1.1.2.2  fvdl .L022dj1:
    244  1.1.2.2  fvdl 	movb	%cl,		(%esi)
    245  1.1.2.2  fvdl .L019djend:
    246  1.1.2.2  fvdl 	jmp	.L003finish
    247  1.1.2.2  fvdl .align 16
    248  1.1.2.2  fvdl .L003finish:
    249  1.1.2.2  fvdl 	movl	60(%esp),	%ecx
    250  1.1.2.2  fvdl 	addl	$24,		%esp
    251  1.1.2.2  fvdl 	movl	%eax,		(%ecx)
    252  1.1.2.2  fvdl 	movl	%ebx,		4(%ecx)
    253  1.1.2.2  fvdl 	popl	%edi
    254  1.1.2.2  fvdl 	popl	%esi
    255  1.1.2.2  fvdl 	popl	%ebx
    256  1.1.2.2  fvdl 	popl	%ebp
    257  1.1.2.2  fvdl 	ret
    258  1.1.2.2  fvdl .align 16
    259  1.1.2.2  fvdl .L004cbc_enc_jmp_table:
    260  1.1.2.2  fvdl 	.long 0
    261  1.1.2.2  fvdl 	.long .L012ej1
    262  1.1.2.2  fvdl 	.long .L011ej2
    263  1.1.2.2  fvdl 	.long .L010ej3
    264  1.1.2.2  fvdl 	.long .L008ej4
    265  1.1.2.2  fvdl 	.long .L007ej5
    266  1.1.2.2  fvdl 	.long .L006ej6
    267  1.1.2.2  fvdl 	.long .L005ej7
    268  1.1.2.2  fvdl .align 16
    269  1.1.2.2  fvdl .L023cbc_dec_jmp_table:
    270  1.1.2.2  fvdl 	.long 0
    271  1.1.2.2  fvdl 	.long .L022dj1
    272  1.1.2.2  fvdl 	.long .L021dj2
    273  1.1.2.2  fvdl 	.long .L020dj3
    274  1.1.2.2  fvdl 	.long .L018dj4
    275  1.1.2.2  fvdl 	.long .L017dj5
    276  1.1.2.2  fvdl 	.long .L016dj6
    277  1.1.2.2  fvdl 	.long .L015dj7
    278  1.1.2.2  fvdl .L_BF_cbc_encrypt_end:
    279  1.1.2.2  fvdl 	.size	_C_LABEL(BF_cbc_encrypt),.L_BF_cbc_encrypt_end-_C_LABEL(BF_cbc_encrypt)
    280