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