mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-06-24 06:03:40 +08:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # README.md
This commit is contained in:
@@ -1,104 +0,0 @@
|
||||
#
|
||||
# OpenSSL/crypto/cast/Makefile
|
||||
#
|
||||
|
||||
DIR= cast
|
||||
TOP= ../..
|
||||
CC= cc
|
||||
CPP= $(CC) -E
|
||||
INCLUDES=
|
||||
CFLAG=-g
|
||||
MAKEFILE= Makefile
|
||||
AR= ar r
|
||||
|
||||
CAST_ENC=c_enc.o
|
||||
|
||||
CFLAGS= $(INCLUDES) $(CFLAG)
|
||||
ASFLAGS= $(INCLUDES) $(ASFLAG)
|
||||
AFLAGS= $(ASFLAGS)
|
||||
|
||||
GENERAL=Makefile
|
||||
TEST=casttest.c
|
||||
APPS=
|
||||
|
||||
LIB=$(TOP)/libcrypto.a
|
||||
LIBSRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c
|
||||
LIBOBJ=c_skey.o c_ecb.o $(CAST_ENC) c_cfb64.o c_ofb64.o
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
EXHEADER= cast.h
|
||||
HEADER= cast_s.h cast_lcl.h $(EXHEADER)
|
||||
|
||||
ALL= $(GENERAL) $(SRC) $(HEADER)
|
||||
|
||||
top:
|
||||
(cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
|
||||
|
||||
all: lib
|
||||
|
||||
lib: $(LIBOBJ)
|
||||
$(AR) $(LIB) $(LIBOBJ)
|
||||
$(RANLIB) $(LIB) || echo Never mind.
|
||||
@touch lib
|
||||
|
||||
cast-586.s: asm/cast-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
|
||||
$(PERL) asm/cast-586.pl $(PERLASM_SCHEME) $(CLAGS) $(PROCESSOR) > $@
|
||||
|
||||
files:
|
||||
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
|
||||
|
||||
links:
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
|
||||
|
||||
install:
|
||||
@[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
|
||||
@headerlist="$(EXHEADER)"; for i in $$headerlist ; \
|
||||
do \
|
||||
(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
|
||||
done;
|
||||
|
||||
tags:
|
||||
ctags $(SRC)
|
||||
|
||||
tests:
|
||||
|
||||
lint:
|
||||
lint -DLINT $(INCLUDES) $(SRC)>fluff
|
||||
|
||||
update: depend
|
||||
|
||||
depend:
|
||||
@[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
|
||||
$(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
|
||||
|
||||
dclean:
|
||||
$(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
|
||||
mv -f Makefile.new $(MAKEFILE)
|
||||
|
||||
clean:
|
||||
rm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
c_cfb64.o: ../../e_os.h ../../include/openssl/cast.h
|
||||
c_cfb64.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
|
||||
c_cfb64.o: c_cfb64.c cast_lcl.h
|
||||
c_ecb.o: ../../e_os.h ../../include/openssl/cast.h
|
||||
c_ecb.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
|
||||
c_ecb.o: ../../include/openssl/opensslv.h c_ecb.c cast_lcl.h
|
||||
c_enc.o: ../../e_os.h ../../include/openssl/cast.h
|
||||
c_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
|
||||
c_enc.o: c_enc.c cast_lcl.h
|
||||
c_ofb64.o: ../../e_os.h ../../include/openssl/cast.h
|
||||
c_ofb64.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
|
||||
c_ofb64.o: c_ofb64.c cast_lcl.h
|
||||
c_skey.o: ../../e_os.h ../../include/openssl/cast.h
|
||||
c_skey.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
c_skey.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
c_skey.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
|
||||
c_skey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
c_skey.o: c_skey.c cast_lcl.h cast_s.h
|
||||
@@ -1,104 +0,0 @@
|
||||
#
|
||||
# OpenSSL/crypto/cast/Makefile
|
||||
#
|
||||
|
||||
DIR= cast
|
||||
TOP= ../..
|
||||
CC= cc
|
||||
CPP= $(CC) -E
|
||||
INCLUDES=
|
||||
CFLAG=-g
|
||||
MAKEFILE= Makefile
|
||||
AR= ar r
|
||||
|
||||
CAST_ENC=c_enc.o
|
||||
|
||||
CFLAGS= $(INCLUDES) $(CFLAG)
|
||||
ASFLAGS= $(INCLUDES) $(ASFLAG)
|
||||
AFLAGS= $(ASFLAGS)
|
||||
|
||||
GENERAL=Makefile
|
||||
TEST=casttest.c
|
||||
APPS=
|
||||
|
||||
LIB=$(TOP)/libcrypto.a
|
||||
LIBSRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c
|
||||
LIBOBJ=c_skey.o c_ecb.o $(CAST_ENC) c_cfb64.o c_ofb64.o
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
EXHEADER= cast.h
|
||||
HEADER= cast_s.h cast_lcl.h $(EXHEADER)
|
||||
|
||||
ALL= $(GENERAL) $(SRC) $(HEADER)
|
||||
|
||||
top:
|
||||
(cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
|
||||
|
||||
all: lib
|
||||
|
||||
lib: $(LIBOBJ)
|
||||
$(AR) $(LIB) $(LIBOBJ)
|
||||
$(RANLIB) $(LIB) || echo Never mind.
|
||||
@touch lib
|
||||
|
||||
cast-586.s: asm/cast-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
|
||||
$(PERL) asm/cast-586.pl $(PERLASM_SCHEME) $(CLAGS) $(PROCESSOR) > $@
|
||||
|
||||
files:
|
||||
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
|
||||
|
||||
links:
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
|
||||
|
||||
install:
|
||||
@[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
|
||||
@headerlist="$(EXHEADER)"; for i in $$headerlist ; \
|
||||
do \
|
||||
(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
|
||||
done;
|
||||
|
||||
tags:
|
||||
ctags $(SRC)
|
||||
|
||||
tests:
|
||||
|
||||
lint:
|
||||
lint -DLINT $(INCLUDES) $(SRC)>fluff
|
||||
|
||||
update: depend
|
||||
|
||||
depend:
|
||||
@[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
|
||||
$(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
|
||||
|
||||
dclean:
|
||||
$(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
|
||||
mv -f Makefile.new $(MAKEFILE)
|
||||
|
||||
clean:
|
||||
rm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
c_cfb64.o: ../../e_os.h ../../include/openssl/cast.h
|
||||
c_cfb64.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
|
||||
c_cfb64.o: c_cfb64.c cast_lcl.h
|
||||
c_ecb.o: ../../e_os.h ../../include/openssl/cast.h
|
||||
c_ecb.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
|
||||
c_ecb.o: ../../include/openssl/opensslv.h c_ecb.c cast_lcl.h
|
||||
c_enc.o: ../../e_os.h ../../include/openssl/cast.h
|
||||
c_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
|
||||
c_enc.o: c_enc.c cast_lcl.h
|
||||
c_ofb64.o: ../../e_os.h ../../include/openssl/cast.h
|
||||
c_ofb64.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
|
||||
c_ofb64.o: c_ofb64.c cast_lcl.h
|
||||
c_skey.o: ../../e_os.h ../../include/openssl/cast.h
|
||||
c_skey.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
c_skey.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
c_skey.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
|
||||
c_skey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
c_skey.o: c_skey.c cast_lcl.h cast_s.h
|
||||
@@ -1,6 +1,16 @@
|
||||
#!/usr/local/bin/perl
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the OpenSSL license (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
# in the file LICENSE in the source distribution or at
|
||||
# https://www.openssl.org/source/license.html
|
||||
|
||||
# define for pentium pro friendly version
|
||||
|
||||
# This flag makes the inner loop one cycle longer, but generates
|
||||
# code that runs %30 faster on the pentium pro/II, 44% faster
|
||||
# of PIII, while only %7 slower on the pentium.
|
||||
# By default, this flag is on.
|
||||
$ppro=1;
|
||||
|
||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
@@ -8,6 +18,9 @@ push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "x86asm.pl";
|
||||
require "cbc.pl";
|
||||
|
||||
$output=pop;
|
||||
open STDOUT,">$output";
|
||||
|
||||
&asm_init($ARGV[0],"cast-586.pl",$ARGV[$#ARGV] eq "386");
|
||||
|
||||
$CAST_ROUNDS=16;
|
||||
@@ -33,6 +46,8 @@ $S4="CAST_S_table3";
|
||||
|
||||
&asm_finish();
|
||||
|
||||
close STDOUT;
|
||||
|
||||
sub CAST_encrypt {
|
||||
local($name,$enc)=@_;
|
||||
|
||||
@@ -140,11 +155,11 @@ sub E_CAST {
|
||||
&rotl( $tmp4, &LB($tmp1));
|
||||
|
||||
if ($ppro) {
|
||||
&mov( $tmp2, $tmp4); # B
|
||||
&xor( $tmp1, $tmp1);
|
||||
&mov( $tmp2, 0xff);
|
||||
|
||||
&movb( &LB($tmp1), &HB($tmp4)); # A
|
||||
&and( $tmp2, 0xff);
|
||||
&and( $tmp2, $tmp4);
|
||||
|
||||
&shr( $tmp4, 16); #
|
||||
&xor( $tmp3, $tmp3);
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
There is a ppro flag in cast-586 which turns on/off
|
||||
generation of pentium pro/II friendly code
|
||||
|
||||
This flag makes the inner loop one cycle longer, but generates
|
||||
code that runs %30 faster on the pentium pro/II, while only %7 slower
|
||||
on the pentium. By default, this flag is on.
|
||||
|
||||
6
crypto/cast/build.info
Normal file
6
crypto/cast/build.info
Normal file
@@ -0,0 +1,6 @@
|
||||
LIBS=../../libcrypto
|
||||
SOURCE[../../libcrypto]=\
|
||||
c_skey.c c_ecb.c {- $target{cast_asm_src} -} c_cfb64.c c_ofb64.c
|
||||
|
||||
GENERATE[cast-586.s]=asm/cast-586.pl $(PERLASM_SCHEME) $(CFLAGS) $(LIB_CFLAGS) $(PROCESSOR)
|
||||
DEPEND[cast-586.s]=../perlasm/x86asm.pl ../perlasm/cbc.pl
|
||||
@@ -1,59 +1,10 @@
|
||||
/* crypto/cast/c_cfb64.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. 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.]
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <openssl/cast.h>
|
||||
|
||||
@@ -1,67 +1,16 @@
|
||||
/* crypto/cast/c_ecb.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. 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.]
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <openssl/cast.h>
|
||||
#include "cast_lcl.h"
|
||||
#include <openssl/opensslv.h>
|
||||
|
||||
const char CAST_version[] = "CAST" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const CAST_KEY *ks, int enc)
|
||||
{
|
||||
|
||||
@@ -1,59 +1,10 @@
|
||||
/* crypto/cast/c_enc.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. 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.]
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <openssl/cast.h>
|
||||
|
||||
@@ -1,59 +1,10 @@
|
||||
/* crypto/cast/c_ofb64.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. 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.]
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <openssl/cast.h>
|
||||
|
||||
@@ -1,62 +1,12 @@
|
||||
/* crypto/cast/c_skey.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. 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.]
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/cast.h>
|
||||
#include "cast_lcl.h"
|
||||
#include "cast_s.h"
|
||||
@@ -72,15 +22,8 @@
|
||||
#define S5 CAST_S_table5
|
||||
#define S6 CAST_S_table6
|
||||
#define S7 CAST_S_table7
|
||||
void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data)
|
||||
#ifdef OPENSSL_FIPS
|
||||
{
|
||||
fips_cipher_abort(CAST);
|
||||
private_CAST_set_key(key, len, data);
|
||||
}
|
||||
|
||||
void private_CAST_set_key(CAST_KEY *key, int len, const unsigned char *data)
|
||||
#endif
|
||||
void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data)
|
||||
{
|
||||
CAST_LONG x[16];
|
||||
CAST_LONG z[16];
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
/* crypto/cast/cast.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.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_CAST_H
|
||||
# define HEADER_CAST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifdef OPENSSL_NO_CAST
|
||||
# error CAST is disabled.
|
||||
# endif
|
||||
|
||||
# define CAST_ENCRYPT 1
|
||||
# define CAST_DECRYPT 0
|
||||
|
||||
# define CAST_LONG unsigned int
|
||||
|
||||
# define CAST_BLOCK 8
|
||||
# define CAST_KEY_LENGTH 16
|
||||
|
||||
typedef struct cast_key_st {
|
||||
CAST_LONG data[32];
|
||||
int short_key; /* Use reduced rounds for short key */
|
||||
} CAST_KEY;
|
||||
|
||||
# ifdef OPENSSL_FIPS
|
||||
void private_CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);
|
||||
# endif
|
||||
void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);
|
||||
void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const CAST_KEY *key, int enc);
|
||||
void CAST_encrypt(CAST_LONG *data, const CAST_KEY *key);
|
||||
void CAST_decrypt(CAST_LONG *data, const CAST_KEY *key);
|
||||
void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, const CAST_KEY *ks, unsigned char *iv,
|
||||
int enc);
|
||||
void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, const CAST_KEY *schedule,
|
||||
unsigned char *ivec, int *num, int enc);
|
||||
void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out,
|
||||
long length, const CAST_KEY *schedule,
|
||||
unsigned char *ivec, int *num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,59 +1,10 @@
|
||||
/* crypto/cast/cast_lcl.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. 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.]
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "e_os.h"
|
||||
@@ -152,10 +103,8 @@
|
||||
|
||||
#if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER)
|
||||
# define ROTL(a,n) (_lrotl(a,n))
|
||||
#elif defined(PEDANTIC)
|
||||
# define ROTL(a,n) ((((a)<<(n))&0xffffffffL)|((a)>>((32-(n))&31)))
|
||||
#else
|
||||
# define ROTL(a,n) ((((a)<<(n))&0xffffffffL)|((a)>>(32-(n))))
|
||||
# define ROTL(a,n) ((((a)<<(n))&0xffffffffL)|((a)>>((32-(n))&31)))
|
||||
#endif
|
||||
|
||||
#define C_M 0x3fc
|
||||
|
||||
@@ -1,60 +1,12 @@
|
||||
/* crypto/cast/cast_s.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. 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.]
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
OPENSSL_GLOBAL const CAST_LONG CAST_S_table0[256] = {
|
||||
0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a,
|
||||
0x1e213f2f, 0x9c004dd3, 0x6003e540, 0xcf9fc949,
|
||||
|
||||
@@ -1,262 +0,0 @@
|
||||
/* crypto/cast/cast_spd.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.]
|
||||
*/
|
||||
|
||||
/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
|
||||
/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
|
||||
|
||||
#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
|
||||
# define TIMES
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
#include OPENSSL_UNISTD_IO
|
||||
OPENSSL_DECLARE_EXIT
|
||||
#ifndef OPENSSL_SYS_NETWARE
|
||||
# include <signal.h>
|
||||
#endif
|
||||
#ifndef _IRIX
|
||||
# include <time.h>
|
||||
#endif
|
||||
#ifdef TIMES
|
||||
# include <sys/types.h>
|
||||
# include <sys/times.h>
|
||||
#endif
|
||||
/*
|
||||
* Depending on the VMS version, the tms structure is perhaps defined.
|
||||
* The __TMS macro will show if it was. If it wasn't defined, we should
|
||||
* undefine TIMES, since that tells the rest of the program how things
|
||||
* should be handled. -- Richard Levitte
|
||||
*/
|
||||
#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
|
||||
# undef TIMES
|
||||
#endif
|
||||
#ifndef TIMES
|
||||
# include <sys/timeb.h>
|
||||
#endif
|
||||
#if defined(sun) || defined(__ultrix)
|
||||
# define _POSIX_SOURCE
|
||||
# include <limits.h>
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
#include <openssl/cast.h>
|
||||
/* The following if from times(3) man page. It may need to be changed */
|
||||
#ifndef HZ
|
||||
# ifndef CLK_TCK
|
||||
# define HZ 100.0
|
||||
# else /* CLK_TCK */
|
||||
# define HZ ((double)CLK_TCK)
|
||||
# endif
|
||||
#endif
|
||||
#define BUFSIZE ((long)1024)
|
||||
long run = 0;
|
||||
|
||||
double Time_F(int s);
|
||||
#ifdef SIGALRM
|
||||
# if defined(__STDC__) || defined(sgi) || defined(_AIX)
|
||||
# define SIGRETTYPE void
|
||||
# else
|
||||
# define SIGRETTYPE int
|
||||
# endif
|
||||
|
||||
SIGRETTYPE sig_done(int sig);
|
||||
SIGRETTYPE sig_done(int sig)
|
||||
{
|
||||
signal(SIGALRM, sig_done);
|
||||
run = 0;
|
||||
# ifdef LINT
|
||||
sig = sig;
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#define START 0
|
||||
#define STOP 1
|
||||
|
||||
double Time_F(int s)
|
||||
{
|
||||
double ret;
|
||||
#ifdef TIMES
|
||||
static struct tms tstart, tend;
|
||||
|
||||
if (s == START) {
|
||||
times(&tstart);
|
||||
return (0);
|
||||
} else {
|
||||
times(&tend);
|
||||
ret = ((double)(tend.tms_utime - tstart.tms_utime)) / HZ;
|
||||
return ((ret == 0.0) ? 1e-6 : ret);
|
||||
}
|
||||
#else /* !times() */
|
||||
static struct timeb tstart, tend;
|
||||
long i;
|
||||
|
||||
if (s == START) {
|
||||
ftime(&tstart);
|
||||
return (0);
|
||||
} else {
|
||||
ftime(&tend);
|
||||
i = (long)tend.millitm - (long)tstart.millitm;
|
||||
ret = ((double)(tend.time - tstart.time)) + ((double)i) / 1e3;
|
||||
return ((ret == 0.0) ? 1e-6 : ret);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
long count;
|
||||
static unsigned char buf[BUFSIZE];
|
||||
static unsigned char key[] = {
|
||||
0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
|
||||
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
|
||||
};
|
||||
CAST_KEY sch;
|
||||
double a, b, c, d;
|
||||
#ifndef SIGALRM
|
||||
long ca, cb, cc;
|
||||
#endif
|
||||
|
||||
#ifndef TIMES
|
||||
printf("To get the most accurate results, try to run this\n");
|
||||
printf("program when this computer is idle.\n");
|
||||
#endif
|
||||
|
||||
#ifndef SIGALRM
|
||||
printf("First we calculate the approximate speed ...\n");
|
||||
CAST_set_key(&sch, 16, key);
|
||||
count = 10;
|
||||
do {
|
||||
long i;
|
||||
CAST_LONG data[2];
|
||||
|
||||
count *= 2;
|
||||
Time_F(START);
|
||||
for (i = count; i; i--)
|
||||
CAST_encrypt(data, &sch);
|
||||
d = Time_F(STOP);
|
||||
} while (d < 3.0);
|
||||
ca = count / 512;
|
||||
cb = count;
|
||||
cc = count * 8 / BUFSIZE + 1;
|
||||
printf("Doing CAST_set_key %ld times\n", ca);
|
||||
# define COND(d) (count != (d))
|
||||
# define COUNT(d) (d)
|
||||
#else
|
||||
# define COND(c) (run)
|
||||
# define COUNT(d) (count)
|
||||
signal(SIGALRM, sig_done);
|
||||
printf("Doing CAST_set_key for 10 seconds\n");
|
||||
alarm(10);
|
||||
#endif
|
||||
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(ca); count += 4) {
|
||||
CAST_set_key(&sch, 16, key);
|
||||
CAST_set_key(&sch, 16, key);
|
||||
CAST_set_key(&sch, 16, key);
|
||||
CAST_set_key(&sch, 16, key);
|
||||
}
|
||||
d = Time_F(STOP);
|
||||
printf("%ld cast set_key's in %.2f seconds\n", count, d);
|
||||
a = ((double)COUNT(ca)) / d;
|
||||
|
||||
#ifdef SIGALRM
|
||||
printf("Doing CAST_encrypt's for 10 seconds\n");
|
||||
alarm(10);
|
||||
#else
|
||||
printf("Doing CAST_encrypt %ld times\n", cb);
|
||||
#endif
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(cb); count += 4) {
|
||||
CAST_LONG data[2];
|
||||
|
||||
CAST_encrypt(data, &sch);
|
||||
CAST_encrypt(data, &sch);
|
||||
CAST_encrypt(data, &sch);
|
||||
CAST_encrypt(data, &sch);
|
||||
}
|
||||
d = Time_F(STOP);
|
||||
printf("%ld CAST_encrypt's in %.2f second\n", count, d);
|
||||
b = ((double)COUNT(cb) * 8) / d;
|
||||
|
||||
#ifdef SIGALRM
|
||||
printf("Doing CAST_cbc_encrypt on %ld byte blocks for 10 seconds\n",
|
||||
BUFSIZE);
|
||||
alarm(10);
|
||||
#else
|
||||
printf("Doing CAST_cbc_encrypt %ld times on %ld byte blocks\n", cc,
|
||||
BUFSIZE);
|
||||
#endif
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(cc); count++)
|
||||
CAST_cbc_encrypt(buf, buf, BUFSIZE, &sch, &(key[0]), CAST_ENCRYPT);
|
||||
d = Time_F(STOP);
|
||||
printf("%ld CAST_cbc_encrypt's of %ld byte blocks in %.2f second\n",
|
||||
count, BUFSIZE, d);
|
||||
c = ((double)COUNT(cc) * BUFSIZE) / d;
|
||||
|
||||
printf("CAST set_key per sec = %12.2f (%9.3fuS)\n", a, 1.0e6 / a);
|
||||
printf("CAST raw ecb bytes per sec = %12.2f (%9.3fuS)\n", b, 8.0e6 / b);
|
||||
printf("CAST cbc bytes per sec = %12.2f (%9.3fuS)\n", c, 8.0e6 / c);
|
||||
exit(0);
|
||||
#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
|
||||
return (0);
|
||||
#endif
|
||||
}
|
||||
@@ -1,334 +0,0 @@
|
||||
/* crypto/cast/castopts.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.]
|
||||
*/
|
||||
|
||||
/*
|
||||
* define PART1, PART2, PART3 or PART4 to build only with a few of the
|
||||
* options. This is for machines with 64k code segment size restrictions.
|
||||
*/
|
||||
|
||||
#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC))
|
||||
# define TIMES
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
#include OPENSSL_UNISTD_IO
|
||||
OPENSSL_DECLARE_EXIT
|
||||
#ifndef OPENSSL_SYS_NETWARE
|
||||
# include <signal.h>
|
||||
#endif
|
||||
#ifndef _IRIX
|
||||
# include <time.h>
|
||||
#endif
|
||||
#ifdef TIMES
|
||||
# include <sys/types.h>
|
||||
# include <sys/times.h>
|
||||
#endif
|
||||
/*
|
||||
* Depending on the VMS version, the tms structure is perhaps defined.
|
||||
* The __TMS macro will show if it was. If it wasn't defined, we should
|
||||
* undefine TIMES, since that tells the rest of the program how things
|
||||
* should be handled. -- Richard Levitte
|
||||
*/
|
||||
#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
|
||||
# undef TIMES
|
||||
#endif
|
||||
#ifndef TIMES
|
||||
# include <sys/timeb.h>
|
||||
#endif
|
||||
#if defined(sun) || defined(__ultrix)
|
||||
# define _POSIX_SOURCE
|
||||
# include <limits.h>
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
#include <openssl/cast.h>
|
||||
#define CAST_DEFAULT_OPTIONS
|
||||
#undef E_CAST
|
||||
#define CAST_encrypt CAST_encrypt_normal
|
||||
#define CAST_decrypt CAST_decrypt_normal
|
||||
#define CAST_cbc_encrypt CAST_cbc_encrypt_normal
|
||||
#undef HEADER_CAST_LOCL_H
|
||||
#include "c_enc.c"
|
||||
#define CAST_PTR
|
||||
#undef CAST_PTR2
|
||||
#undef E_CAST
|
||||
#undef CAST_encrypt
|
||||
#undef CAST_decrypt
|
||||
#undef CAST_cbc_encrypt
|
||||
#define CAST_encrypt CAST_encrypt_ptr
|
||||
#define CAST_decrypt CAST_decrypt_ptr
|
||||
#define CAST_cbc_encrypt CAST_cbc_encrypt_ptr
|
||||
#undef HEADER_CAST_LOCL_H
|
||||
#include "c_enc.c"
|
||||
#undef CAST_PTR
|
||||
#define CAST_PTR2
|
||||
#undef E_CAST
|
||||
#undef CAST_encrypt
|
||||
#undef CAST_decrypt
|
||||
#undef CAST_cbc_encrypt
|
||||
#define CAST_encrypt CAST_encrypt_ptr2
|
||||
#define CAST_decrypt CAST_decrypt_ptr2
|
||||
#define CAST_cbc_encrypt CAST_cbc_encrypt_ptr2
|
||||
#undef HEADER_CAST_LOCL_H
|
||||
#include "c_enc.c"
|
||||
/* The following if from times(3) man page. It may need to be changed */
|
||||
#ifndef HZ
|
||||
# ifndef CLK_TCK
|
||||
# ifndef _BSD_CLK_TCK_ /* FreeBSD fix */
|
||||
# define HZ 100.0
|
||||
# else /* _BSD_CLK_TCK_ */
|
||||
# define HZ ((double)_BSD_CLK_TCK_)
|
||||
# endif
|
||||
# else /* CLK_TCK */
|
||||
# define HZ ((double)CLK_TCK)
|
||||
# endif
|
||||
#endif
|
||||
#define BUFSIZE ((long)1024)
|
||||
long run = 0;
|
||||
|
||||
double Time_F(int s);
|
||||
#ifdef SIGALRM
|
||||
# if defined(__STDC__) || defined(sgi)
|
||||
# define SIGRETTYPE void
|
||||
# else
|
||||
# define SIGRETTYPE int
|
||||
# endif
|
||||
|
||||
SIGRETTYPE sig_done(int sig);
|
||||
SIGRETTYPE sig_done(int sig)
|
||||
{
|
||||
signal(SIGALRM, sig_done);
|
||||
run = 0;
|
||||
# ifdef LINT
|
||||
sig = sig;
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#define START 0
|
||||
#define STOP 1
|
||||
|
||||
double Time_F(int s)
|
||||
{
|
||||
double ret;
|
||||
#ifdef TIMES
|
||||
static struct tms tstart, tend;
|
||||
|
||||
if (s == START) {
|
||||
times(&tstart);
|
||||
return (0);
|
||||
} else {
|
||||
times(&tend);
|
||||
ret = ((double)(tend.tms_utime - tstart.tms_utime)) / HZ;
|
||||
return ((ret == 0.0) ? 1e-6 : ret);
|
||||
}
|
||||
#else /* !times() */
|
||||
static struct timeb tstart, tend;
|
||||
long i;
|
||||
|
||||
if (s == START) {
|
||||
ftime(&tstart);
|
||||
return (0);
|
||||
} else {
|
||||
ftime(&tend);
|
||||
i = (long)tend.millitm - (long)tstart.millitm;
|
||||
ret = ((double)(tend.time - tstart.time)) + ((double)i) / 1000.0;
|
||||
return ((ret == 0.0) ? 1e-6 : ret);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef SIGALRM
|
||||
# define print_name(name) fprintf(stderr,"Doing %s's for 10 seconds\n",name); alarm(10);
|
||||
#else
|
||||
# define print_name(name) fprintf(stderr,"Doing %s %ld times\n",name,cb);
|
||||
#endif
|
||||
|
||||
#define time_it(func,name,index) \
|
||||
print_name(name); \
|
||||
Time_F(START); \
|
||||
for (count=0,run=1; COND(cb); count+=4) \
|
||||
{ \
|
||||
unsigned long d[2]; \
|
||||
func(d,&sch); \
|
||||
func(d,&sch); \
|
||||
func(d,&sch); \
|
||||
func(d,&sch); \
|
||||
} \
|
||||
tm[index]=Time_F(STOP); \
|
||||
fprintf(stderr,"%ld %s's in %.2f second\n",count,name,tm[index]); \
|
||||
tm[index]=((double)COUNT(cb))/tm[index];
|
||||
|
||||
#define print_it(name,index) \
|
||||
fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \
|
||||
tm[index]*8,1.0e6/tm[index]);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
long count;
|
||||
static unsigned char buf[BUFSIZE];
|
||||
static char key[16] = { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
|
||||
0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0
|
||||
};
|
||||
CAST_KEY sch;
|
||||
double d, tm[16], max = 0;
|
||||
int rank[16];
|
||||
char *str[16];
|
||||
int max_idx = 0, i, num = 0, j;
|
||||
#ifndef SIGALARM
|
||||
long ca, cb, cc, cd, ce;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 12; i++) {
|
||||
tm[i] = 0.0;
|
||||
rank[i] = 0;
|
||||
}
|
||||
|
||||
#ifndef TIMES
|
||||
fprintf(stderr, "To get the most accurate results, try to run this\n");
|
||||
fprintf(stderr, "program when this computer is idle.\n");
|
||||
#endif
|
||||
|
||||
CAST_set_key(&sch, 16, key);
|
||||
|
||||
#ifndef SIGALRM
|
||||
fprintf(stderr, "First we calculate the approximate speed ...\n");
|
||||
count = 10;
|
||||
do {
|
||||
long i;
|
||||
unsigned long data[2];
|
||||
|
||||
count *= 2;
|
||||
Time_F(START);
|
||||
for (i = count; i; i--)
|
||||
CAST_encrypt(data, &sch);
|
||||
d = Time_F(STOP);
|
||||
} while (d < 3.0);
|
||||
ca = count;
|
||||
cb = count * 3;
|
||||
cc = count * 3 * 8 / BUFSIZE + 1;
|
||||
cd = count * 8 / BUFSIZE + 1;
|
||||
|
||||
ce = count / 20 + 1;
|
||||
# define COND(d) (count != (d))
|
||||
# define COUNT(d) (d)
|
||||
#else
|
||||
# define COND(c) (run)
|
||||
# define COUNT(d) (count)
|
||||
signal(SIGALRM, sig_done);
|
||||
alarm(10);
|
||||
#endif
|
||||
|
||||
time_it(CAST_encrypt_normal, "CAST_encrypt_normal ", 0);
|
||||
time_it(CAST_encrypt_ptr, "CAST_encrypt_ptr ", 1);
|
||||
time_it(CAST_encrypt_ptr2, "CAST_encrypt_ptr2 ", 2);
|
||||
num += 3;
|
||||
|
||||
str[0] = "<nothing>";
|
||||
print_it("CAST_encrypt_normal ", 0);
|
||||
max = tm[0];
|
||||
max_idx = 0;
|
||||
str[1] = "ptr ";
|
||||
print_it("CAST_encrypt_ptr ", 1);
|
||||
if (max < tm[1]) {
|
||||
max = tm[1];
|
||||
max_idx = 1;
|
||||
}
|
||||
str[2] = "ptr2 ";
|
||||
print_it("CAST_encrypt_ptr2 ", 2);
|
||||
if (max < tm[2]) {
|
||||
max = tm[2];
|
||||
max_idx = 2;
|
||||
}
|
||||
|
||||
printf("options CAST ecb/s\n");
|
||||
printf("%s %12.2f 100.0%%\n", str[max_idx], tm[max_idx]);
|
||||
d = tm[max_idx];
|
||||
tm[max_idx] = -2.0;
|
||||
max = -1.0;
|
||||
for (;;) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (max < tm[i]) {
|
||||
max = tm[i];
|
||||
j = i;
|
||||
}
|
||||
}
|
||||
if (max < 0.0)
|
||||
break;
|
||||
printf("%s %12.2f %4.1f%%\n", str[j], tm[j], tm[j] / d * 100.0);
|
||||
tm[j] = -2.0;
|
||||
max = -1.0;
|
||||
}
|
||||
|
||||
switch (max_idx) {
|
||||
case 0:
|
||||
printf("-DCAST_DEFAULT_OPTIONS\n");
|
||||
break;
|
||||
case 1:
|
||||
printf("-DCAST_PTR\n");
|
||||
break;
|
||||
case 2:
|
||||
printf("-DCAST_PTR2\n");
|
||||
break;
|
||||
}
|
||||
exit(0);
|
||||
#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
|
||||
return (0);
|
||||
#endif
|
||||
}
|
||||
@@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <openssl/cast.h>
|
||||
|
||||
void main(int argc,char *argv[])
|
||||
{
|
||||
CAST_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};
|
||||
|
||||
CAST_set_key(&key, 16,d);
|
||||
|
||||
for (j=0; j<6; j++)
|
||||
{
|
||||
for (i=0; i<1000; i++) /**/
|
||||
{
|
||||
CAST_encrypt(&data[0],&key);
|
||||
GetTSC(s1);
|
||||
CAST_encrypt(&data[0],&key);
|
||||
CAST_encrypt(&data[0],&key);
|
||||
CAST_encrypt(&data[0],&key);
|
||||
GetTSC(e1);
|
||||
GetTSC(s2);
|
||||
CAST_encrypt(&data[0],&key);
|
||||
CAST_encrypt(&data[0],&key);
|
||||
CAST_encrypt(&data[0],&key);
|
||||
CAST_encrypt(&data[0],&key);
|
||||
GetTSC(e2);
|
||||
CAST_encrypt(&data[0],&key);
|
||||
}
|
||||
|
||||
printf("cast %d %d (%d)\n",
|
||||
e1-s1,e2-s2,((e2-s2)-(e1-s1)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,241 +0,0 @@
|
||||
/* crypto/cast/casttest.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 <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <openssl/opensslconf.h> /* To see if OPENSSL_NO_CAST is defined */
|
||||
|
||||
#include "../e_os.h"
|
||||
|
||||
#ifdef OPENSSL_NO_CAST
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("No CAST support\n");
|
||||
return (0);
|
||||
}
|
||||
#else
|
||||
# include <openssl/cast.h>
|
||||
|
||||
# define FULL_TEST
|
||||
|
||||
static unsigned char k[16] = {
|
||||
0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
|
||||
0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9A
|
||||
};
|
||||
|
||||
static unsigned char in[8] =
|
||||
{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF };
|
||||
|
||||
static int k_len[3] = { 16, 10, 5 };
|
||||
|
||||
static unsigned char c[3][8] = {
|
||||
{0x23, 0x8B, 0x4F, 0xE5, 0x84, 0x7E, 0x44, 0xB2},
|
||||
{0xEB, 0x6A, 0x71, 0x1A, 0x2C, 0x02, 0x27, 0x1B},
|
||||
{0x7A, 0xC8, 0x16, 0xD1, 0x6E, 0x9B, 0x30, 0x2E},
|
||||
};
|
||||
|
||||
static unsigned char out[80];
|
||||
|
||||
static unsigned char in_a[16] = {
|
||||
0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
|
||||
0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9A
|
||||
};
|
||||
|
||||
static unsigned char in_b[16] = {
|
||||
0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
|
||||
0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9A
|
||||
};
|
||||
|
||||
static unsigned char c_a[16] = {
|
||||
0xEE, 0xA9, 0xD0, 0xA2, 0x49, 0xFD, 0x3B, 0xA6,
|
||||
0xB3, 0x43, 0x6F, 0xB8, 0x9D, 0x6D, 0xCA, 0x92
|
||||
};
|
||||
|
||||
static unsigned char c_b[16] = {
|
||||
0xB2, 0xC9, 0x5E, 0xB0, 0x0C, 0x31, 0xAD, 0x71,
|
||||
0x80, 0xAC, 0x05, 0xB8, 0xE8, 0x3D, 0x69, 0x6E
|
||||
};
|
||||
|
||||
# if 0
|
||||
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,*/
|
||||
};
|
||||
# endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# ifdef FULL_TEST
|
||||
long l;
|
||||
CAST_KEY key_b;
|
||||
# endif
|
||||
int i, z, err = 0;
|
||||
CAST_KEY key;
|
||||
|
||||
for (z = 0; z < 3; z++) {
|
||||
CAST_set_key(&key, k_len[z], k);
|
||||
|
||||
CAST_ecb_encrypt(in, out, &key, CAST_ENCRYPT);
|
||||
if (memcmp(out, &(c[z][0]), 8) != 0) {
|
||||
printf("ecb cast error encrypting for keysize %d\n",
|
||||
k_len[z] * 8);
|
||||
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[z][i]);
|
||||
err = 20;
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
CAST_ecb_encrypt(out, out, &key, CAST_DECRYPT);
|
||||
if (memcmp(out, in, 8) != 0) {
|
||||
printf("ecb cast error decrypting for keysize %d\n",
|
||||
k_len[z] * 8);
|
||||
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 cast5 ok\n");
|
||||
|
||||
# ifdef FULL_TEST
|
||||
{
|
||||
unsigned char out_a[16], out_b[16];
|
||||
static char *hex = "0123456789ABCDEF";
|
||||
|
||||
printf("This test will take some time....");
|
||||
fflush(stdout);
|
||||
memcpy(out_a, in_a, sizeof(in_a));
|
||||
memcpy(out_b, in_b, sizeof(in_b));
|
||||
i = 1;
|
||||
|
||||
for (l = 0; l < 1000000L; l++) {
|
||||
CAST_set_key(&key_b, 16, out_b);
|
||||
CAST_ecb_encrypt(&(out_a[0]), &(out_a[0]), &key_b, CAST_ENCRYPT);
|
||||
CAST_ecb_encrypt(&(out_a[8]), &(out_a[8]), &key_b, CAST_ENCRYPT);
|
||||
CAST_set_key(&key, 16, out_a);
|
||||
CAST_ecb_encrypt(&(out_b[0]), &(out_b[0]), &key, CAST_ENCRYPT);
|
||||
CAST_ecb_encrypt(&(out_b[8]), &(out_b[8]), &key, CAST_ENCRYPT);
|
||||
if ((l & 0xffff) == 0xffff) {
|
||||
printf("%c", hex[i & 0x0f]);
|
||||
fflush(stdout);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if ((memcmp(out_a, c_a, sizeof(c_a)) != 0) ||
|
||||
(memcmp(out_b, c_b, sizeof(c_b)) != 0)) {
|
||||
printf("\n");
|
||||
printf("Error\n");
|
||||
|
||||
printf("A out =");
|
||||
for (i = 0; i < 16; i++)
|
||||
printf("%02X ", out_a[i]);
|
||||
printf("\nactual=");
|
||||
for (i = 0; i < 16; i++)
|
||||
printf("%02X ", c_a[i]);
|
||||
printf("\n");
|
||||
|
||||
printf("B out =");
|
||||
for (i = 0; i < 16; i++)
|
||||
printf("%02X ", out_b[i]);
|
||||
printf("\nactual=");
|
||||
for (i = 0; i < 16; i++)
|
||||
printf("%02X ", c_b[i]);
|
||||
printf("\n");
|
||||
} else
|
||||
printf(" ok\n");
|
||||
}
|
||||
# endif
|
||||
|
||||
EXIT(err);
|
||||
return (err);
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user