From a65d091da086680881aa0b90833d4ade81492191 Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Fri, 29 Apr 2005 05:37:33 +0000 Subject: This commit was manufactured by cvs2git to create tag 'OPENSSL_0_9_7G'. --- src/lib/libcrypto/idea/ideatest.c | 232 -------------------- src/lib/libcrypto/mdc2/mdc2test.c | 146 ------------- src/lib/libcrypto/rc4/asm/rc4-amd64.pl | 227 +++++++++++++++++++ src/lib/libcrypto/rc5/rc5_locl.h | 207 ------------------ src/lib/libcrypto/rc5/rc5s.cpp | 70 ------ src/lib/libcrypto/rc5/rc5test.c | 386 --------------------------------- 6 files changed, 227 insertions(+), 1041 deletions(-) delete mode 100644 src/lib/libcrypto/idea/ideatest.c delete mode 100644 src/lib/libcrypto/mdc2/mdc2test.c create mode 100755 src/lib/libcrypto/rc4/asm/rc4-amd64.pl delete mode 100644 src/lib/libcrypto/rc5/rc5_locl.h delete mode 100644 src/lib/libcrypto/rc5/rc5s.cpp delete mode 100644 src/lib/libcrypto/rc5/rc5test.c (limited to 'src/lib/libcrypto') diff --git a/src/lib/libcrypto/idea/ideatest.c b/src/lib/libcrypto/idea/ideatest.c deleted file mode 100644 index 98f805d72a..0000000000 --- a/src/lib/libcrypto/idea/ideatest.c +++ /dev/null @@ -1,232 +0,0 @@ -/* crypto/idea/ideatest.c */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * 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). - * - * 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)" - * 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)" - * - * 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.] - */ - -#include -#include -#include - -#include "../e_os.h" - -#ifdef OPENSSL_NO_IDEA -int main(int argc, char *argv[]) -{ - printf("No IDEA support\n"); - return(0); -} -#else -#include - -unsigned char k[16]={ - 0x00,0x01,0x00,0x02,0x00,0x03,0x00,0x04, - 0x00,0x05,0x00,0x06,0x00,0x07,0x00,0x08}; - -unsigned char in[8]={0x00,0x00,0x00,0x01,0x00,0x02,0x00,0x03}; -unsigned char c[8]={0x11,0xFB,0xED,0x2B,0x01,0x98,0x6D,0xE5}; -unsigned char out[80]; - -char *text="Hello to all people out there"; - -static unsigned char cfb_key[16]={ - 0xe1,0xf0,0xc3,0xd2,0xa5,0xb4,0x87,0x96, - 0x69,0x78,0x4b,0x5a,0x2d,0x3c,0x0f,0x1e, - }; -static unsigned char cfb_iv[80]={0x34,0x12,0x78,0x56,0xab,0x90,0xef,0xcd}; -static unsigned char cfb_buf1[40],cfb_buf2[40],cfb_tmp[8]; -#define CFB_TEST_SIZE 24 -static unsigned char plain[CFB_TEST_SIZE]= - { - 0x4e,0x6f,0x77,0x20,0x69,0x73, - 0x20,0x74,0x68,0x65,0x20,0x74, - 0x69,0x6d,0x65,0x20,0x66,0x6f, - 0x72,0x20,0x61,0x6c,0x6c,0x20 - }; -static unsigned char cfb_cipher64[CFB_TEST_SIZE]={ - 0x59,0xD8,0xE2,0x65,0x00,0x58,0x6C,0x3F, - 0x2C,0x17,0x25,0xD0,0x1A,0x38,0xB7,0x2A, - 0x39,0x61,0x37,0xDC,0x79,0xFB,0x9F,0x45 - -/* 0xF9,0x78,0x32,0xB5,0x42,0x1A,0x6B,0x38, - 0x9A,0x44,0xD6,0x04,0x19,0x43,0xC4,0xD9, - 0x3D,0x1E,0xAE,0x47,0xFC,0xCF,0x29,0x0B,*/ - }; - -static int cfb64_test(unsigned char *cfb_cipher); -static char *pt(unsigned char *p); -int main(int argc, char *argv[]) - { - int i,err=0; - IDEA_KEY_SCHEDULE key,dkey; - unsigned char iv[8]; - - idea_set_encrypt_key(k,&key); - idea_ecb_encrypt(in,out,&key); - if (memcmp(out,c,8) != 0) - { - printf("ecb idea error encrypting\n"); - printf("got :"); - for (i=0; i<8; i++) - printf("%02X ",out[i]); - printf("\n"); - printf("expected:"); - for (i=0; i<8; i++) - printf("%02X ",c[i]); - err=20; - printf("\n"); - } - - idea_set_decrypt_key(&key,&dkey); - idea_ecb_encrypt(c,out,&dkey); - if (memcmp(out,in,8) != 0) - { - printf("ecb idea error decrypting\n"); - printf("got :"); - for (i=0; i<8; i++) - printf("%02X ",out[i]); - printf("\n"); - printf("expected:"); - for (i=0; i<8; i++) - printf("%02X ",in[i]); - printf("\n"); - err=3; - } - - if (err == 0) printf("ecb idea ok\n"); - - memcpy(iv,k,8); - idea_cbc_encrypt((unsigned char *)text,out,strlen(text)+1,&key,iv,1); - memcpy(iv,k,8); - idea_cbc_encrypt(out,out,8,&dkey,iv,0); - idea_cbc_encrypt(&(out[8]),&(out[8]),strlen(text)+1-8,&dkey,iv,0); - if (memcmp(text,out,strlen(text)+1) != 0) - { - printf("cbc idea bad\n"); - err=4; - } - else - printf("cbc idea ok\n"); - - printf("cfb64 idea "); - if (cfb64_test(cfb_cipher64)) - { - printf("bad\n"); - err=5; - } - else - printf("ok\n"); - - EXIT(err); - return(err); - } - -static int cfb64_test(unsigned char *cfb_cipher) - { - IDEA_KEY_SCHEDULE eks,dks; - int err=0,i,n; - - idea_set_encrypt_key(cfb_key,&eks); - idea_set_decrypt_key(&eks,&dks); - memcpy(cfb_tmp,cfb_iv,8); - n=0; - idea_cfb64_encrypt(plain,cfb_buf1,(long)12,&eks, - cfb_tmp,&n,IDEA_ENCRYPT); - idea_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]), - (long)CFB_TEST_SIZE-12,&eks, - cfb_tmp,&n,IDEA_ENCRYPT); - if (memcmp(cfb_cipher,cfb_buf1,CFB_TEST_SIZE) != 0) - { - err=1; - printf("idea_cfb64_encrypt encrypt error\n"); - for (i=0; i>4)&0xf]; - ret[i*2+1]=f[p[i]&0xf]; - } - ret[16]='\0'; - return(ret); - } -#endif diff --git a/src/lib/libcrypto/mdc2/mdc2test.c b/src/lib/libcrypto/mdc2/mdc2test.c deleted file mode 100644 index c9abe99d92..0000000000 --- a/src/lib/libcrypto/mdc2/mdc2test.c +++ /dev/null @@ -1,146 +0,0 @@ -/* crypto/mdc2/mdc2test.c */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * 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). - * - * 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)" - * 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)" - * - * 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.] - */ - -#include -#include -#include - -#include "../e_os.h" - -#if defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_MDC2) -#define OPENSSL_NO_MDC2 -#endif - -#ifdef OPENSSL_NO_MDC2 -int main(int argc, char *argv[]) -{ - printf("No MDC2 support\n"); - return(0); -} -#else -#include -#include - -#ifdef CHARSET_EBCDIC -#include -#endif - -static unsigned char pad1[16]={ - 0x42,0xE5,0x0C,0xD2,0x24,0xBA,0xCE,0xBA, - 0x76,0x0B,0xDD,0x2B,0xD4,0x09,0x28,0x1A - }; - -static unsigned char pad2[16]={ - 0x2E,0x46,0x79,0xB5,0xAD,0xD9,0xCA,0x75, - 0x35,0xD8,0x7A,0xFE,0xAB,0x33,0xBE,0xE2 - }; - -int main(int argc, char *argv[]) - { - int ret=0; - unsigned char md[MDC2_DIGEST_LENGTH]; - int i; - EVP_MD_CTX c; - static char *text="Now is the time for all "; - -#ifdef CHARSET_EBCDIC - ebcdic2ascii(text,text,strlen(text)); -#endif - - EVP_MD_CTX_init(&c); - EVP_DigestInit_ex(&c,EVP_mdc2(), NULL); - EVP_DigestUpdate(&c,(unsigned char *)text,strlen(text)); - EVP_DigestFinal_ex(&c,&(md[0]),NULL); - - if (memcmp(md,pad1,MDC2_DIGEST_LENGTH) != 0) - { - for (i=0; ipad_type=2; - EVP_DigestUpdate(&c,(unsigned char *)text,strlen(text)); - EVP_DigestFinal_ex(&c,&(md[0]),NULL); - - if (memcmp(md,pad2,MDC2_DIGEST_LENGTH) != 0) - { - for (i=0; i for the OpenSSL +# project. Rights for redistribution and usage in source and binary +# forms are granted according to the OpenSSL license. +# ==================================================================== +# +# 2.22x RC4 tune-up:-) It should be noted though that my hand [as in +# "hand-coded assembler"] doesn't stand for the whole improvement +# coefficient. It turned out that eliminating RC4_CHAR from config +# line results in ~40% improvement (yes, even for C implementation). +# Presumably it has everything to do with AMD cache architecture and +# RAW or whatever penalties. Once again! The module *requires* config +# line *without* RC4_CHAR! As for coding "secret," I bet on partial +# register arithmetics. For example instead of 'inc %r8; and $255,%r8' +# I simply 'inc %r8b'. Even though optimization manual discourages +# to operate on partial registers, it turned out to be the best bet. +# At least for AMD... How IA32E would perform remains to be seen... + +# As was shown by Marc Bevand reordering of couple of load operations +# results in even higher performance gain of 3.3x:-) At least on +# Opteron... For reference, 1x in this case is RC4_CHAR C-code +# compiled with gcc 3.3.2, which performs at ~54MBps per 1GHz clock. +# Latter means that if you want to *estimate* what to expect from +# *your* CPU, then multiply 54 by 3.3 and clock frequency in GHz. + +# Intel P4 EM64T core was found to run the AMD64 code really slow... +# The only way to achieve comparable performance on P4 is to keep +# RC4_CHAR. Kind of ironic, huh? As it's apparently impossible to +# compose blended code, which would perform even within 30% marginal +# on either AMD and Intel platforms, I implement both cases. See +# rc4_skey.c for further details... This applies to 0.9.8 and later. +# In 0.9.7 context RC4_CHAR codepath is never engaged and ~70 bytes +# of code remain redundant. + +$output=shift; + +$win64a=1 if ($output =~ /win64a.[s|asm]/); + +open STDOUT,">$output" || die "can't open $output: $!"; + +if (defined($win64a)) { + $dat="%rcx"; # arg1 + $len="%rdx"; # arg2 + $inp="%rsi"; # r8, arg3 moves here + $out="%rdi"; # r9, arg4 moves here +} else { + $dat="%rdi"; # arg1 + $len="%rsi"; # arg2 + $inp="%rdx"; # arg3 + $out="%rcx"; # arg4 +} + +$XX="%r10"; +$TX="%r8"; +$YY="%r11"; +$TY="%r9"; + +sub PTR() { + my $ret=shift; + if (defined($win64a)) { + $ret =~ s/\[([\S]+)\+([\S]+)\]/[$2+$1]/g; # [%rN+%rM*4]->[%rM*4+%rN] + $ret =~ s/:([^\[]+)\[([^\]]+)\]/:[$2+$1]/g; # :off[ea]->:[ea+off] + } else { + $ret =~ s/[\+\*]/,/g; # [%rN+%rM*4]->[%rN,%rM,4] + $ret =~ s/\[([^\]]+)\]/($1)/g; # [%rN]->(%rN) + } + $ret; +} + +$code=<<___ if (!defined($win64a)); +.text + +.globl RC4 +.type RC4,\@function +.align 16 +RC4: or $len,$len + jne .Lentry + repret +.Lentry: +___ +$code=<<___ if (defined($win64a)); +_TEXT SEGMENT +PUBLIC RC4 +ALIGN 16 +RC4 PROC + or $len,$len + jne .Lentry + repret +.Lentry: + push %rdi + push %rsi + sub \$40,%rsp + mov %r8,$inp + mov %r9,$out +___ +$code.=<<___; + add \$8,$dat + movl `&PTR("DWORD:-8[$dat]")`,$XX#d + movl `&PTR("DWORD:-4[$dat]")`,$YY#d + cmpl \$-1,`&PTR("DWORD:256[$dat]")` + je .LRC4_CHAR + test \$-8,$len + jz .Lloop1 +.align 16 +.Lloop8: + inc $XX#b + movl `&PTR("DWORD:[$dat+$XX*4]")`,$TX#d + add $TX#b,$YY#b + movl `&PTR("DWORD:[$dat+$YY*4]")`,$TY#d + movl $TX#d,`&PTR("DWORD:[$dat+$YY*4]")` + movl $TY#d,`&PTR("DWORD:[$dat+$XX*4]")` + add $TX#b,$TY#b + inc $XX#b + movl `&PTR("DWORD:[$dat+$XX*4]")`,$TX#d + movb `&PTR("BYTE:[$dat+$TY*4]")`,%al +___ +for ($i=1;$i<=6;$i++) { +$code.=<<___; + add $TX#b,$YY#b + ror \$8,%rax + movl `&PTR("DWORD:[$dat+$YY*4]")`,$TY#d + movl $TX#d,`&PTR("DWORD:[$dat+$YY*4]")` + movl $TY#d,`&PTR("DWORD:[$dat+$XX*4]")` + add $TX#b,$TY#b + inc $XX#b + movl `&PTR("DWORD:[$dat+$XX*4]")`,$TX#d + movb `&PTR("BYTE:[$dat+$TY*4]")`,%al +___ +} +$code.=<<___; + add $TX#b,$YY#b + ror \$8,%rax + movl `&PTR("DWORD:[$dat+$YY*4]")`,$TY#d + movl $TX#d,`&PTR("DWORD:[$dat+$YY*4]")` + movl $TY#d,`&PTR("DWORD:[$dat+$XX*4]")` + sub \$8,$len + add $TY#b,$TX#b + movb `&PTR("BYTE:[$dat+$TX*4]")`,%al + ror \$8,%rax + add \$8,$inp + add \$8,$out + + xor `&PTR("QWORD:-8[$inp]")`,%rax + mov %rax,`&PTR("QWORD:-8[$out]")` + + test \$-8,$len + jnz .Lloop8 + cmp \$0,$len + jne .Lloop1 +.Lexit: + movl $XX#d,`&PTR("DWORD:-8[$dat]")` + movl $YY#d,`&PTR("DWORD:-4[$dat]")` +___ +$code.=<<___ if (defined($win64a)); + add \$40,%rsp + pop %rsi + pop %rdi +___ +$code.=<<___; + repret +.align 16 +.Lloop1: + movzb `&PTR("BYTE:[$inp]")`,%eax + inc $XX#b + movl `&PTR("DWORD:[$dat+$XX*4]")`,$TX#d + add $TX#b,$YY#b + movl `&PTR("DWORD:[$dat+$YY*4]")`,$TY#d + movl $TX#d,`&PTR("DWORD:[$dat+$YY*4]")` + movl $TY#d,`&PTR("DWORD:[$dat+$XX*4]")` + add $TY#b,$TX#b + movl `&PTR("DWORD:[$dat+$TX*4]")`,$TY#d + xor $TY,%rax + inc $inp + movb %al,`&PTR("BYTE:[$out]")` + inc $out + dec $len + jnz .Lloop1 + jmp .Lexit + +.align 16 +.LRC4_CHAR: + inc $XX#b + movzb `&PTR("BYTE:[$dat+$XX]")`,$TX#d + add $TX#b,$YY#b + movzb `&PTR("BYTE:[$dat+$YY]")`,$TY#d + movb $TX#b,`&PTR("BYTE:[$dat+$YY]")` + movb $TY#b,`&PTR("BYTE:[$dat+$XX]")` + add $TX#b,$TY#b + movzb `&PTR("BYTE:[$dat+$TY]")`,$TY#d + xorb `&PTR("BYTE:[$inp]")`,$TY#b + movb $TY#b,`&PTR("BYTE:[$out]")` + inc $inp + inc $out + dec $len + jnz .LRC4_CHAR + jmp .Lexit +___ +$code.=<<___ if (defined($win64a)); +RC4 ENDP +_TEXT ENDS +END +___ +$code.=<<___ if (!defined($win64a)); +.size RC4,.-RC4 +___ + +$code =~ s/#([bwd])/$1/gm; +$code =~ s/\`([^\`]*)\`/eval $1/gem; + +if (defined($win64a)) { + $code =~ s/\.align/ALIGN/gm; + $code =~ s/[\$%]//gm; + $code =~ s/\.L/\$L/gm; + $code =~ s/([\w]+)([\s]+)([\S]+),([\S]+)/$1$2$4,$3/gm; + $code =~ s/([QD]*WORD|BYTE):/$1 PTR/gm; + $code =~ s/mov[bwlq]/mov/gm; + $code =~ s/movzb/movzx/gm; + $code =~ s/repret/DB\t0F3h,0C3h/gm; + $code =~ s/cmpl/cmp/gm; + $code =~ s/xorb/xor/gm; +} else { + $code =~ s/([QD]*WORD|BYTE)://gm; + $code =~ s/repret/.byte\t0xF3,0xC3/gm; +} +print $code; diff --git a/src/lib/libcrypto/rc5/rc5_locl.h b/src/lib/libcrypto/rc5/rc5_locl.h deleted file mode 100644 index f4ebc23004..0000000000 --- a/src/lib/libcrypto/rc5/rc5_locl.h +++ /dev/null @@ -1,207 +0,0 @@ -/* crypto/rc5/rc5_locl.h */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * 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). - * - * 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)" - * 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)" - * - * 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.] - */ - -#include - -#undef c2l -#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ - l|=((unsigned long)(*((c)++)))<< 8L, \ - l|=((unsigned long)(*((c)++)))<<16L, \ - l|=((unsigned long)(*((c)++)))<<24L) - -/* NOTE - c is not incremented as per c2l */ -#undef c2ln -#define c2ln(c,l1,l2,n) { \ - c+=n; \ - l1=l2=0; \ - switch (n) { \ - case 8: l2 =((unsigned long)(*(--(c))))<<24L; \ - case 7: l2|=((unsigned long)(*(--(c))))<<16L; \ - case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \ - case 5: l2|=((unsigned long)(*(--(c)))); \ - case 4: l1 =((unsigned long)(*(--(c))))<<24L; \ - case 3: l1|=((unsigned long)(*(--(c))))<<16L; \ - case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \ - case 1: l1|=((unsigned long)(*(--(c)))); \ - } \ - } - -#undef l2c -#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>24L)&0xff)) - -/* NOTE - c is not incremented as per l2c */ -#undef l2cn -#define l2cn(l1,l2,c,n) { \ - c+=n; \ - switch (n) { \ - case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ - case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ - case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ - case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ - case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ - case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ - case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ - case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ - } \ - } - -/* NOTE - c is not incremented as per n2l */ -#define n2ln(c,l1,l2,n) { \ - c+=n; \ - l1=l2=0; \ - switch (n) { \ - case 8: l2 =((unsigned long)(*(--(c)))) ; \ - case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ - case 6: l2|=((unsigned long)(*(--(c))))<<16; \ - case 5: l2|=((unsigned long)(*(--(c))))<<24; \ - case 4: l1 =((unsigned long)(*(--(c)))) ; \ - case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ - case 2: l1|=((unsigned long)(*(--(c))))<<16; \ - case 1: l1|=((unsigned long)(*(--(c))))<<24; \ - } \ - } - -/* NOTE - c is not incremented as per l2n */ -#define l2nn(l1,l2,c,n) { \ - c+=n; \ - switch (n) { \ - case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ - case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ - case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ - case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ - case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ - case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ - case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ - case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ - } \ - } - -#undef n2l -#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ - l|=((unsigned long)(*((c)++)))<<16L, \ - l|=((unsigned long)(*((c)++)))<< 8L, \ - l|=((unsigned long)(*((c)++)))) - -#undef l2n -#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ - *((c)++)=(unsigned char)(((l) )&0xff)) - -#if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER) -#define ROTATE_l32(a,n) _lrotl(a,n) -#define ROTATE_r32(a,n) _lrotr(a,n) -#elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) -# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) -# define ROTATE_l32(a,n) ({ register unsigned int ret; \ - asm ("roll %%cl,%0" \ - : "=r"(ret) \ - : "c"(n),"0"(a) \ - : "cc"); \ - ret; \ - }) -# define ROTATE_r32(a,n) ({ register unsigned int ret; \ - asm ("rorl %%cl,%0" \ - : "=r"(ret) \ - : "c"(n),"0"(a) \ - : "cc"); \ - ret; \ - }) -# endif -#endif -#ifndef ROTATE_l32 -#define ROTATE_l32(a,n) (((a)<<(n&0x1f))|(((a)&0xffffffff)>>(32-(n&0x1f)))) -#endif -#ifndef ROTATE_r32 -#define ROTATE_r32(a,n) (((a)<<(32-(n&0x1f)))|(((a)&0xffffffff)>>(n&0x1f))) -#endif - -#define RC5_32_MASK 0xffffffffL - -#define RC5_16_P 0xB7E1 -#define RC5_16_Q 0x9E37 -#define RC5_32_P 0xB7E15163L -#define RC5_32_Q 0x9E3779B9L -#define RC5_64_P 0xB7E151628AED2A6BLL -#define RC5_64_Q 0x9E3779B97F4A7C15LL - -#define E_RC5_32(a,b,s,n) \ - a^=b; \ - a=ROTATE_l32(a,b); \ - a+=s[n]; \ - a&=RC5_32_MASK; \ - b^=a; \ - b=ROTATE_l32(b,a); \ - b+=s[n+1]; \ - b&=RC5_32_MASK; - -#define D_RC5_32(a,b,s,n) \ - b-=s[n+1]; \ - b&=RC5_32_MASK; \ - b=ROTATE_r32(b,a); \ - b^=a; \ - a-=s[n]; \ - a&=RC5_32_MASK; \ - a=ROTATE_r32(a,b); \ - a^=b; - - - diff --git a/src/lib/libcrypto/rc5/rc5s.cpp b/src/lib/libcrypto/rc5/rc5s.cpp deleted file mode 100644 index 1c5518bc80..0000000000 --- a/src/lib/libcrypto/rc5/rc5s.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// -// gettsc.inl -// -// gives access to the Pentium's (secret) cycle counter -// -// This software was written by Leonard Janke (janke@unixg.ubc.ca) -// in 1996-7 and is entered, by him, into the public domain. - -#if defined(__WATCOMC__) -void GetTSC(unsigned long&); -#pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax]; -#elif defined(__GNUC__) -inline -void GetTSC(unsigned long& tsc) -{ - asm volatile(".byte 15, 49\n\t" - : "=eax" (tsc) - : - : "%edx", "%eax"); -} -#elif defined(_MSC_VER) -inline -void GetTSC(unsigned long& tsc) -{ - unsigned long a; - __asm _emit 0fh - __asm _emit 31h - __asm mov a, eax; - tsc=a; -} -#endif - -#include -#include -#include - -void main(int argc,char *argv[]) - { - RC5_32_KEY key; - unsigned long s1,s2,e1,e2; - unsigned long data[2]; - int i,j; - static unsigned char d[16]={0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}; - - RC5_32_set_key(&key, 16,d,12); - - for (j=0; j<6; j++) - { - for (i=0; i<1000; i++) /**/ - { - RC5_32_encrypt(&data[0],&key); - GetTSC(s1); - RC5_32_encrypt(&data[0],&key); - RC5_32_encrypt(&data[0],&key); - RC5_32_encrypt(&data[0],&key); - GetTSC(e1); - GetTSC(s2); - RC5_32_encrypt(&data[0],&key); - RC5_32_encrypt(&data[0],&key); - RC5_32_encrypt(&data[0],&key); - RC5_32_encrypt(&data[0],&key); - GetTSC(e2); - RC5_32_encrypt(&data[0],&key); - } - - printf("cast %d %d (%d)\n", - e1-s1,e2-s2,((e2-s2)-(e1-s1))); - } - } - diff --git a/src/lib/libcrypto/rc5/rc5test.c b/src/lib/libcrypto/rc5/rc5test.c deleted file mode 100644 index ce3d0cc16f..0000000000 --- a/src/lib/libcrypto/rc5/rc5test.c +++ /dev/null @@ -1,386 +0,0 @@ -/* crypto/rc5/rc5test.c */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * 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). - * - * 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)" - * 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)" - * - * 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.] - */ - -/* This has been a quickly hacked 'ideatest.c'. When I add tests for other - * RC5 modes, more of the code will be uncommented. */ - -#include -#include -#include - -#include "../e_os.h" - -#ifdef OPENSSL_NO_RC5 -int main(int argc, char *argv[]) -{ - printf("No RC5 support\n"); - return(0); -} -#else -#include - -static unsigned char RC5key[5][16]={ - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x91,0x5f,0x46,0x19,0xbe,0x41,0xb2,0x51, - 0x63,0x55,0xa5,0x01,0x10,0xa9,0xce,0x91}, - {0x78,0x33,0x48,0xe7,0x5a,0xeb,0x0f,0x2f, - 0xd7,0xb1,0x69,0xbb,0x8d,0xc1,0x67,0x87}, - {0xdc,0x49,0xdb,0x13,0x75,0xa5,0x58,0x4f, - 0x64,0x85,0xb4,0x13,0xb5,0xf1,0x2b,0xaf}, - {0x52,0x69,0xf1,0x49,0xd4,0x1b,0xa0,0x15, - 0x24,0x97,0x57,0x4d,0x7f,0x15,0x31,0x25}, - }; - -static unsigned char RC5plain[5][8]={ - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x21,0xA5,0xDB,0xEE,0x15,0x4B,0x8F,0x6D}, - {0xF7,0xC0,0x13,0xAC,0x5B,0x2B,0x89,0x52}, - {0x2F,0x42,0xB3,0xB7,0x03,0x69,0xFC,0x92}, - {0x65,0xC1,0x78,0xB2,0x84,0xD1,0x97,0xCC}, - }; - -static unsigned char RC5cipher[5][8]={ - {0x21,0xA5,0xDB,0xEE,0x15,0x4B,0x8F,0x6D}, - {0xF7,0xC0,0x13,0xAC,0x5B,0x2B,0x89,0x52}, - {0x2F,0x42,0xB3,0xB7,0x03,0x69,0xFC,0x92}, - {0x65,0xC1,0x78,0xB2,0x84,0xD1,0x97,0xCC}, - {0xEB,0x44,0xE4,0x15,0xDA,0x31,0x98,0x24}, - }; - -#define RC5_CBC_NUM 27 -static unsigned char rc5_cbc_cipher[RC5_CBC_NUM][8]={ - {0x7a,0x7b,0xba,0x4d,0x79,0x11,0x1d,0x1e}, - {0x79,0x7b,0xba,0x4d,0x78,0x11,0x1d,0x1e}, - {0x7a,0x7b,0xba,0x4d,0x79,0x11,0x1d,0x1f}, - {0x7a,0x7b,0xba,0x4d,0x79,0x11,0x1d,0x1f}, - {0x8b,0x9d,0xed,0x91,0xce,0x77,0x94,0xa6}, - {0x2f,0x75,0x9f,0xe7,0xad,0x86,0xa3,0x78}, - {0xdc,0xa2,0x69,0x4b,0xf4,0x0e,0x07,0x88}, - {0xdc,0xa2,0x69,0x4b,0xf4,0x0e,0x07,0x88}, - {0xdc,0xfe,0x09,0x85,0x77,0xec,0xa5,0xff}, - {0x96,0x46,0xfb,0x77,0x63,0x8f,0x9c,0xa8}, - {0xb2,0xb3,0x20,0x9d,0xb6,0x59,0x4d,0xa4}, - {0x54,0x5f,0x7f,0x32,0xa5,0xfc,0x38,0x36}, - {0x82,0x85,0xe7,0xc1,0xb5,0xbc,0x74,0x02}, - {0xfc,0x58,0x6f,0x92,0xf7,0x08,0x09,0x34}, - {0xcf,0x27,0x0e,0xf9,0x71,0x7f,0xf7,0xc4}, - {0xe4,0x93,0xf1,0xc1,0xbb,0x4d,0x6e,0x8c}, - {0x5c,0x4c,0x04,0x1e,0x0f,0x21,0x7a,0xc3}, - {0x92,0x1f,0x12,0x48,0x53,0x73,0xb4,0xf7}, - {0x5b,0xa0,0xca,0x6b,0xbe,0x7f,0x5f,0xad}, - {0xc5,0x33,0x77,0x1c,0xd0,0x11,0x0e,0x63}, - {0x29,0x4d,0xdb,0x46,0xb3,0x27,0x8d,0x60}, - {0xda,0xd6,0xbd,0xa9,0xdf,0xe8,0xf7,0xe8}, - {0x97,0xe0,0x78,0x78,0x37,0xed,0x31,0x7f}, - {0x78,0x75,0xdb,0xf6,0x73,0x8c,0x64,0x78}, - {0x8f,0x34,0xc3,0xc6,0x81,0xc9,0x96,0x95}, - {0x7c,0xb3,0xf1,0xdf,0x34,0xf9,0x48,0x11}, - {0x7f,0xd1,0xa0,0x23,0xa5,0xbb,0xa2,0x17}, - }; - -static unsigned char rc5_cbc_key[RC5_CBC_NUM][17]={ - { 1,0x00}, - { 1,0x00}, - { 1,0x00}, - { 1,0x00}, - { 1,0x00}, - { 1,0x11}, - { 1,0x00}, - { 4,0x00,0x00,0x00,0x00}, - { 1,0x00}, - { 1,0x00}, - { 1,0x00}, - { 1,0x00}, - { 4,0x01,0x02,0x03,0x04}, - { 4,0x01,0x02,0x03,0x04}, - { 4,0x01,0x02,0x03,0x04}, - { 8,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08}, - { 8,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08}, - { 8,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08}, - { 8,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08}, - {16,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08, - 0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80}, - {16,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08, - 0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80}, - {16,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08, - 0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80}, - { 5,0x01,0x02,0x03,0x04,0x05}, - { 5,0x01,0x02,0x03,0x04,0x05}, - { 5,0x01,0x02,0x03,0x04,0x05}, - { 5,0x01,0x02,0x03,0x04,0x05}, - { 5,0x01,0x02,0x03,0x04,0x05}, - }; - -static unsigned char rc5_cbc_plain[RC5_CBC_NUM][8]={ - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01}, - {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80}, - {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80}, - {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80}, - {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, - {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, - {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, - {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, - {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80}, - {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80}, - {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80}, - {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80}, - {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80}, - {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80}, - {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, - {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, - {0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x01}, - }; - -static int rc5_cbc_rounds[RC5_CBC_NUM]={ - 0, 0, 0, 0, 0, 1, 2, 2, - 8, 8,12,16, 8,12,16,12, - 8,12,16, 8,12,16,12, 8, - 8, 8, 8, - }; - -static unsigned char rc5_cbc_iv[RC5_CBC_NUM][8]={ - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08}, - {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08}, - {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08}, - {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08}, - {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08}, - {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08}, - {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08}, - {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x78,0x75,0xdb,0xf6,0x73,0x8c,0x64,0x78}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x7c,0xb3,0xf1,0xdf,0x34,0xf9,0x48,0x11}, - }; - -int main(int argc, char *argv[]) - { - int i,n,err=0; - RC5_32_KEY key; - unsigned char buf[8],buf2[8],ivb[8]; - - for (n=0; n<5; n++) - { - RC5_32_set_key(&key,16,&(RC5key[n][0]),12); - - RC5_32_ecb_encrypt(&(RC5plain[n][0]),buf,&key,RC5_ENCRYPT); - if (memcmp(&(RC5cipher[n][0]),buf,8) != 0) - { - printf("ecb RC5 error encrypting (%d)\n",n+1); - printf("got :"); - for (i=0; i<8; i++) - printf("%02X ",buf[i]); - printf("\n"); - printf("expected:"); - for (i=0; i<8; i++) - printf("%02X ",RC5cipher[n][i]); - err=20; - printf("\n"); - } - - RC5_32_ecb_encrypt(buf,buf2,&key,RC5_DECRYPT); - if (memcmp(&(RC5plain[n][0]),buf2,8) != 0) - { - printf("ecb RC5 error decrypting (%d)\n",n+1); - printf("got :"); - for (i=0; i<8; i++) - printf("%02X ",buf2[i]); - printf("\n"); - printf("expected:"); - for (i=0; i<8; i++) - printf("%02X ",RC5plain[n][i]); - printf("\n"); - err=3; - } - } - if (err == 0) printf("ecb RC5 ok\n"); - - for (n=0; n>4)&0xf]; - ret[i*2+1]=f[p[i]&0xf]; - } - ret[16]='\0'; - return(ret); - } - -#endif -#endif -- cgit v1.2.3-55-g6feb