SF.net SVN: gar:[22856] csw/mgar/pkg/openssl1/trunk
chninkel at users.sourceforge.net
chninkel at users.sourceforge.net
Sun Jan 19 18:48:32 CET 2014
Revision: 22856
http://sourceforge.net/p/gar/code/22856
Author: chninkel
Date: 2014-01-19 17:48:29 +0000 (Sun, 19 Jan 2014)
Log Message:
-----------
openssl1/trunk: Updated t4 engine patch from Oracle userland sources
Modified Paths:
--------------
csw/mgar/pkg/openssl1/trunk/Makefile
csw/mgar/pkg/openssl1/trunk/files/changelog.CSW
csw/mgar/pkg/openssl1/trunk/files/update-t4-patch.sh
Added Paths:
-----------
csw/mgar/pkg/openssl1/trunk/files/openssl-1.0.1e-t4-engine-sparcv9+vis.sparc.5.11.patch
csw/mgar/pkg/openssl1/trunk/files/openssl-1.0.1f-t4-engine.sparc.5.11.patch
Removed Paths:
-------------
csw/mgar/pkg/openssl1/trunk/files/openssl-1.0.1e-t4-engine.sparc-patch
csw/mgar/pkg/openssl1/trunk/files/openssl-1.0.1e-t4-engine.sparc-patch.sparcv9+vis
Modified: csw/mgar/pkg/openssl1/trunk/Makefile
===================================================================
--- csw/mgar/pkg/openssl1/trunk/Makefile 2014-01-19 12:06:08 UTC (rev 22855)
+++ csw/mgar/pkg/openssl1/trunk/Makefile 2014-01-19 17:48:29 UTC (rev 22856)
@@ -135,8 +135,8 @@
# To update the patch, do:
# cd files && ./update-t4-patch.sh OPENSSL_VERSION
#
-PATCHFILES.sparc.5.11 += openssl-1.0.1e-t4-engine.sparc-patch
-PATCHFILES.sparc.5.11 += openssl-1.0.1e-t4-engine.sparc-patch.sparcv9+vis
+PATCHFILES.sparc.5.11 += openssl-1.0.1f-t4-engine.sparc.5.11.patch
+PATCHFILES.sparc.5.11 += openssl-1.0.1e-t4-engine-sparcv9+vis.sparc.5.11.patch
PATCHFILES += $(PATCHFILES.$(GARCH).$(GAROSREL))
Modified: csw/mgar/pkg/openssl1/trunk/files/changelog.CSW
===================================================================
--- csw/mgar/pkg/openssl1/trunk/files/changelog.CSW 2014-01-19 12:06:08 UTC (rev 22855)
+++ csw/mgar/pkg/openssl1/trunk/files/changelog.CSW 2014-01-19 17:48:29 UTC (rev 22856)
@@ -2,6 +2,7 @@
* Update pkcs11 engine patch from Oracle userland sources.
* Re-enabled pkcs11 engine support for sparc.
+ * Update t4 engine patch from Oracle userland sources.
-- yann rouillard <yann at opencsw.org> Sun, 19 Jan 2014 13:05:33 +0100
Copied: csw/mgar/pkg/openssl1/trunk/files/openssl-1.0.1e-t4-engine-sparcv9+vis.sparc.5.11.patch (from rev 22198, csw/mgar/pkg/openssl1/trunk/files/openssl-1.0.1e-t4-engine.sparc-patch.sparcv9+vis)
===================================================================
--- csw/mgar/pkg/openssl1/trunk/files/openssl-1.0.1e-t4-engine-sparcv9+vis.sparc.5.11.patch (rev 0)
+++ csw/mgar/pkg/openssl1/trunk/files/openssl-1.0.1e-t4-engine-sparcv9+vis.sparc.5.11.patch 2014-01-19 17:48:29 UTC (rev 22856)
@@ -0,0 +1,25 @@
+From 3b63574c8a3ba589f9a69bece6931a22a73675d2 Mon Sep 17 00:00:00 2001
+From: Yann Rouillard <yann at pleiades.fr.eu.org>
+Date: Mon, 11 Mar 2013 23:41:45 +0100
+Subject: [PATCH] t4 engine complement patch for sparcv9+vis target
+
+---
+ Configure | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Configure b/Configure
+index 3f32e5a..e3bf481 100755
+--- a/Configure
++++ b/Configure
+@@ -278,7 +278,7 @@ my %table=(
+ #
+ "solaris-sparcv8-cc-sunw","cc:-xtarget=v8 -m32 -Qoption cg -xregs=no%appl -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -lc:BN_LLONG RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-m32 -G -dy -z text -zdefs -Bdirect -zignore -M/usr/lib/ld/map.pagealign:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+ #
+-"solaris-sparcv9+vis-cc-sunw","cc:-xtarget=ultra -m32 -xarch=sparcvis -Qoption cg -xregs=no%appl -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -lc:BN_LLONG RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-m32 -G -dy -z text -zdefs -Bdirect -zignore -M/usr/lib/ld/map.pagealign:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
++"solaris-sparcv9+vis-cc-sunw","cc:-xtarget=ultra -m32 -xarch=sparcvis -Qoption cg -xregs=no%appl -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -lc -lsoftcrypto:BN_LLONG RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-m32 -G -dy -z text -zdefs -Bdirect -zignore -M/usr/lib/ld/map.pagealign:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+
+
+ #### IRIX 5.x configs
+--
+1.8.1.4
+
Deleted: csw/mgar/pkg/openssl1/trunk/files/openssl-1.0.1e-t4-engine.sparc-patch
===================================================================
--- csw/mgar/pkg/openssl1/trunk/files/openssl-1.0.1e-t4-engine.sparc-patch 2014-01-19 12:06:08 UTC (rev 22855)
+++ csw/mgar/pkg/openssl1/trunk/files/openssl-1.0.1e-t4-engine.sparc-patch 2014-01-19 17:48:29 UTC (rev 22856)
@@ -1,8618 +0,0 @@
-#
-# Engine t4 patch openssl-1.0.0d-t4-engine.sparc-patch.
-# This engine is SPARC-only.
-#
-Index: Configure
-===================================================================
-diff -ru openssl-1.0.0d/Configure openssl-1.0.0d/Configure
---- openssl-1.0.0d/Configure 2011-05-24 17:02:24.000000000 -0700
-+++ openssl-1.0.0d/Configure 2011-07-27 10:48:17.817470000 -0700
-@@ -135,8 +135,9 @@
-
- my $x86_64_asm="x86_64cpuid.o:x86_64-gcc.o x86_64-mont.o x86_64-mont5.o x86_64-gf2m.o modexp512-x86_64.o::aes-x86_64.o vpaes-x86_64.o bsaes-x86_64.o aesni-x86_64.o aesni-sha1-x86_64.o::md5-x86_64.o:sha1-x86_64.o sha256-x86_64.o sha512-x86_64.o::rc4-x86_64.o rc4-md5-x86_64.o:::wp-x86_64.o:cmll-x86_64.o cmll_misc.o:ghash-x86_64.o:";
- my $ia64_asm="ia64cpuid.o:bn-ia64.o ia64-mont.o::aes_core.o aes_cbc.o aes-ia64.o::md5-ia64.o:sha1-ia64.o sha256-ia64.o sha512-ia64.o::rc4-ia64.o rc4_skey.o:::::ghash-ia64.o::void";
--my $sparcv9_asm="sparcv9cap.o sparccpuid.o:bn-sparcv9.o sparcv9-mont.o sparcv9a-mont.o:des_enc-sparc.o fcrypt_b.o:aes_core.o aes_cbc.o aes-sparcv9.o:::sha1-sparcv9.o sha256-sparcv9.o sha512-sparcv9.o:::::::ghash-sparcv9.o::void";
--my $sparcv8_asm=":sparcv8.o:des_enc-sparc.o fcrypt_b.o:::::::::::::void";
-+my $sparcv9_asm="sparcv9cap.o sparccpuid.o:bn-sparcv9.o sparcv9-mont.o sparcv9a-mont.o:des_enc-sparc.o fcrypt_b.o t4_des.o:aes_core.o aes_cbc.o aes-sparcv9.o t4_aes.o::t4_md5.o:sha1-sparcv9.o sha256-sparcv9.o sha512-sparcv9.o t4_sha1.o t4_sha2.o:::::::ghash-sparcv9.o::void";
-+my $sparcv9_fips_asm="sparcv9cap.o sparccpuid.o:bn-sparcv9.o sparcv9-mont.o:des_enc-sparc.o fcrypt_b.o t4_des.o:aes_core.o aes_cbc.o aes-sparcv9.o t4_aes.o::t4_md5.o:sha1-sparcv9.o sha256-sparcv9.o sha512-sparcv9.o t4_sha1.o t4_sha2.o:::::::ghash-sparcv9.o::void";
-+my $sparcv8_asm=":sparcv8.o:des_enc-sparc.o fcrypt_b.o t4_des.o:t4_aes.o::t4_md5.o:t4_sha1.o t4_sha2.o:::::::void";
- my $alpha_asm="alphacpuid.o:bn_asm.o alpha-mont.o:::::sha1-alpha.o:::::::ghash-alpha.o::void";
- my $mips32_asm=":bn-mips.o::aes_cbc.o aes-mips.o:::sha1-mips.o sha256-mips.o::::::::";
- my $mips64_asm=":bn-mips.o mips-mont.o::aes_cbc.o aes-mips.o:::sha1-mips.o sha256-mips.o sha512-mips.o::::::::";
-@@ -264,9 +264,11 @@
- #
- "solaris64-x86_64-cc-sunw","cc:-xO3 -m64 -xstrconst -Xa -DL_ENDIAN::-D_REENTRANT::-lsocket -lnsl -lc:SIXTY_FOUR_BIT_LONG RC4_CHUNK BF_PTR DES_PTR DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:solaris-shared:-KPIC:-m64 -G -dy -z text -zdefs -Bdirect -zignore -M/usr/lib/ld/map.pagealign -M/usr/lib/ld/map.noexdata:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
- #
--"solaris-sparcv9-cc-sunw","cc:-xtarget=ultra -m32 -Qoption cg -xregs=no%appl -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -lc:BN_LLONG RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-m32 -G -dy -z text -zdefs -Bdirect -zignore -M/usr/lib/ld/map.pagealign:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-+"solaris-sparcv9-cc-sunw","cc:-xtarget=ultra -m32 -Qoption cg -xregs=no%appl -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -lc -lsoftcrypto:BN_LLONG RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-m32 -G -dy -z text -zdefs -Bdirect -zignore -M/usr/lib/ld/map.pagealign:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-+"solaris-sparcv9-cc-sunw-fips","cc:-xtarget=ultra -m32 -Qoption cg -xregs=no%appl -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -lc -lsoftcrypto:BN_LLONG RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_fips_asm}:dlfcn:solaris-shared:-KPIC:-m32 -G -dy -z text -zdefs -Bdirect -zignore -M/usr/lib/ld/map.pagealign:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
- #
--"solaris64-sparcv9-cc-sunw","cc:-xtarget=ultra -m64 -Qoption cg -xregs=no%appl -xO5 -xstrconst -xdepend -xspace -Xa -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -lc:BN_LLONG RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-m64 -G -dy -z text -zdefs -Bdirect -zignore -M/usr/lib/ld/map.pagealign:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):/usr/ccs/bin/ar rs::/64",
-+"solaris64-sparcv9-cc-sunw","cc:-xtarget=ultra -m64 -Qoption cg -xregs=no%appl -xO5 -xstrconst -xdepend -xspace -Xa -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -lc -lsoftcrypto:BN_LLONG RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-m64 -G -dy -z text -zdefs -Bdirect -zignore -M/usr/lib/ld/map.pagealign:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):/usr/ccs/bin/ar rs::/64",
-+"solaris64-sparcv9-cc-sunw-fips","cc:-xtarget=ultra -m64 -Qoption cg -xregs=no%appl -xO5 -xstrconst -xdepend -xspace -Xa -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -lc -lsoftcrypto:BN_LLONG RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_fips_asm}:dlfcn:solaris-shared:-KPIC:-m64 -G -dy -z text -zdefs -Bdirect -zignore -M/usr/lib/ld/map.pagealign:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):/usr/ccs/bin/ar rs::/64",
- # Option -xF=%all instructs the compiler to place functions and data
- # variables into separate section fragments. This enables the link editor
- # to discard unused sections and files when linking wanboot-openssl.o
-Index: crypto/aes/Makefile
-===================================================================
-diff -ru openssl-1.0.0d/crypto/aes/ openssl-1.0.0d/crypto/aes/Makefile
---- openssl-1.0.0d/crypto/aes/Makefile 2011-05-24 17:03:31.000000000 -0700
-+++ openssl-1.0.0d/crypto/aes/Makefile 2011-06-30 17:26:34.980110000 -0700
-@@ -17,6 +17,10 @@
- ASFLAGS= $(INCLUDES) $(ASFLAG)
- AFLAGS= $(ASFLAGS)
-
-+BITS:= $(shell if grep '^SHARED_LDFLAGS.*=.*-m32' ../../Makefile >/dev/null; \
-+ then echo 32; else echo 64; fi)
-+ASFLAGSYF= -xregsym=no -K pic -P -xarch=v9v -D_sparcv9 -D_ASM -Dsparc -m$(BITS)
-+
- GENERAL=Makefile
- #TEST=aestest.c
- TEST=
-@@ -69,6 +73,10 @@
- aes-sparcv9.s: asm/aes-sparcv9.pl
- $(PERL) asm/aes-sparcv9.pl $(CFLAGS) > $@
-
-+t4_aes.o: asm/t4_aes.S
-+ as $(ASFLAGSYF) -o $@ asm/t4_aes.S
-+ elfedit -e 'cap:hw1 -and -cmp vis vis3' $@
-+
- aes-ppc.s: asm/aes-ppc.pl
- $(PERL) asm/aes-ppc.pl $(PERLASM_SCHEME) $@
-
-Index: crypto/des/Makefile
-===================================================================
-diff -ru openssl-1.0.0d/crypto/des/ openssl-1.0.0d/crypto/des/Makefile
---- openssl-1.0.0d/crypto/des/Makefile 2011-07-26 17:47:28.530315349 -0700
-+++ openssl-1.0.0d/crypto/des/Makefile 2011-07-27 10:41:47.362058958 -0700
-@@ -17,6 +17,10 @@
- ASFLAGS= $(INCLUDES) $(ASFLAG)
- AFLAGS= $(ASFLAGS)
-
-+BITS:= $(shell if grep '^SHARED_LDFLAGS.*=.*-m32' ../../Makefile >/dev/null; \
-+ then echo 32; else echo 64; fi)
-+ASFLAGSYF= -xregsym=no -K pic -P -xarch=v9v -D_sparcv9 -D_ASM -Dsparc -m$(BITS)
-+
- GENERAL=Makefile
- TEST=destest.c
- APPS=
-@@ -61,6 +65,10 @@
-
- des_enc-sparc.S: asm/des_enc.m4
- m4 -B 8192 asm/des_enc.m4 > des_enc-sparc.S
-+
-+t4_des.o: asm/t4_des.S
-+ as $(ASFLAGSYF) -o $@ asm/t4_des.S
-+ elfedit -e 'cap:hw1 -and -cmp vis vis3' $@
-
- des-586.s: asm/des-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
- $(PERL) asm/des-586.pl $(PERLASM_SCHEME) $(CFLAGS) > $@
-Index: crypto/engine/Makefile
-===================================================================
-diff -ru openssl-1.0.0d/crypto/engine/Makefile openssl-1.0.0d/crypto/engine/Makefile
---- openssl-1.0.0d/crypto/engine/Makefile 2011-05-24 17:04:12.000000000 -0700
-+++ openssl-1.0.0d/crypto/engine/Makefile 2011-07-28 10:10:00.000000000 -0700
-@@ -22,12 +22,16 @@
- tb_rsa.c tb_dsa.c tb_ecdsa.c tb_dh.c tb_ecdh.c tb_rand.c tb_store.c \
- tb_cipher.c tb_digest.c tb_pkmeth.c tb_asnmth.c \
- eng_openssl.c eng_cnf.c eng_dyn.c eng_cryptodev.c \
-+ eng_t4.c eng_t4_des.c eng_t4_md5.c \
-+ eng_t4_sha1.c eng_t4_sha256.c eng_t4_sha512.c eng_t4_montmul.c \
- eng_rsax.c eng_rdrand.c
- LIBOBJ= eng_err.o eng_lib.o eng_list.o eng_init.o eng_ctrl.o \
- eng_table.o eng_pkey.o eng_fat.o eng_all.o \
- tb_rsa.o tb_dsa.o tb_ecdsa.o tb_dh.o tb_ecdh.o tb_rand.o tb_store.o \
- tb_cipher.o tb_digest.o tb_pkmeth.o tb_asnmth.o \
- eng_openssl.o eng_cnf.o eng_dyn.o eng_cryptodev.o \
-+ eng_t4.o eng_t4_des.o eng_t4_md5.o \
-+ eng_t4_sha1.o eng_t4_sha256.o eng_t4_sha512.o eng_t4_montmul.o \
- eng_rsax.o eng_rdrand.o
-
- SRC= $(LIBSRC)
-Index: crypto/engine/eng_all.c
-===================================================================
-diff -ru openssl-1.0.0d/crypto/engine/eng_all.c openssl-1.0.0d/crypto/engine/eng_all.c
---- openssl-1.0.0d/crypto/engine/eng_all.c 2011-05-24 17:02:20.000000000 -0700
-+++ openssl-1.0.0d/crypto/engine/eng_all.c 2011-06-22 17:34:25.145829355 -0700
-@@ -79,6 +79,10 @@
- #ifndef OPENSSL_NO_RDRAND
- ENGINE_load_rdrand();
- #endif
-+#if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_T4)
-+ ENGINE_load_t4();
-+ ENGINE_register_all_complete();
-+#endif
- ENGINE_load_dynamic();
- #ifndef OPENSSL_NO_HW_PKCS11
- ENGINE_load_pk11();
-Index: crypto/engine/engine.h
-==================================================================
-diff -ru openssl-1.0.0d/crypto/engine/engine.h openssl-1.0.0d/crypto/engine/engine.h
---- openssl-1.0.0d/crypto/engine/engine.h 2011-05-24 17:02:20.000000000 -0700
-+++ openssl-1.0.0d/crypto/engine/engine.h 2011-05-24 18:05:29.075766123 -0700
-@@ -351,5 +351,6 @@
- #endif
- #endif
- void ENGINE_load_cryptodev(void);
-+void ENGINE_load_t4(void);
- void ENGINE_load_rsax(void);
- void ENGINE_load_rdrand(void);
-Index: crypto/md5/Makefile
-==================================================================
-diff -ru openssl-1.0.0d/crypto/md5/Makefile openssl-1.0.0d/crypto/md5/Makefile
---- openssl-1.0.0d/crypto/md5/Makefile 2011-05-24 17:03:14.000000000 -0700
-+++ openssl-1.0.0d/crypto/md5/Makefile 2011-08-27 16:01:49.000000000 -0700
-@@ -17,6 +17,10 @@
- ASFLAGS= $(INCLUDES) $(ASFLAG)
- AFLAGS= $(ASFLAGS)
-
-+BITS:= $(shell if grep '^SHARED_LDFLAGS.*=.*-m32' ../../Makefile >/dev/null; \
-+ then echo 32; else echo 64; fi)
-+ASFLAGSYF= -xregsym=no -K pic -P -xarch=v9v -D_sparcv9 -D_ASM -Dsparc -m$(BITS)
-+
- GENERAL=Makefile
- TEST=md5test.c
- APPS=
-@@ -52,6 +58,10 @@
- $(CC) $(CFLAGS) -E asm/md5-ia64.S | \
- $(PERL) -ne 's/;\s+/;\n/g; print;' > $@
-
-+t4_md5.o: asm/t4_md5.S
-+ as $(ASFLAGSYF) -o $@ asm/t4_md5.S
-+ elfedit -e 'cap:hw1 -and -cmp vis vis3' $@
-+
- files:
- $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
-
-Index: crypto/sha/Makefile
-==================================================================
-diff -ru openssl-1.0.0d/crypto/sha/Makefile openssl-1.0.0d/crypto/sha/Makefile
---- openssl-1.0.0d/crypto/sha/Makefile 2011-05-24 17:03:18.000000000 -0700
-+++ openssl-1.0.0d/crypto/sha/Makefile 2011-08-27 16:01:49.000000000 -0700
-@@ -17,6 +17,10 @@
- ASFLAGS= $(INCLUDES) $(ASFLAG)
- AFLAGS= $(ASFLAGS)
-
-+BITS:= $(shell if grep '^SHARED_LDFLAGS.*=.*-m32' ../../Makefile >/dev/null; \
-+ then echo 32; else echo 64; fi)
-+ASFLAGSYF= -xregsym=no -K pic -P -xarch=v9v -D_sparcv9 -D_ASM -Dsparc -m$(BITS)
-+
- GENERAL=Makefile
- TEST=shatest.c sha1test.c sha256t.c sha512t.c
- APPS=
-@@ -91,6 +95,14 @@
- sha256-armv4.o: sha256-armv4.S
- sha512-armv4.o: sha512-armv4.S
-
-+t4_sha1.o: asm/t4_sha1.S
-+ as $(ASFLAGSYF) -o $@ asm/t4_sha1.S
-+ elfedit -e 'cap:hw1 -and -cmp vis vis3' $@
-+
-+t4_sha2.o: asm/t4_sha2.S
-+ as $(ASFLAGSYF) -o $@ asm/t4_sha2.S
-+ elfedit -e 'cap:hw1 -and -cmp vis vis3' $@
-+
- files:
- $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
-
-Index: util/libeay.num
-==================================================================
-diff -ru openssl-1.0.0d/util/libeay.num openssl-1.0.0d/util/libeay.num
---- openssl-1.0.0d/util/libeay.num 2010-07-25 09:56:06.000000000 -0700
-+++ openssl-1.0.0d/util/libeay.num 2011-05-25 11:19:15.585211842 -0700
-@@ -4179,6 +4179,7 @@
- UI_method_set_prompt_constructor 4551 EXIST:!VMS:FUNCTION:
- UI_method_set_prompt_constructr 4551 EXIST:VMS:FUNCTION:
- EVP_read_pw_string_min 4552 EXIST::FUNCTION:
-+ENGINE_load_t4 4553 EXIST::FUNCTION:ENGINE
- CRYPTO_cts128_encrypt 4553 EXIST::FUNCTION:
- CRYPTO_cts128_decrypt_block 4554 EXIST::FUNCTION:
- CRYPTO_cfb128_1_encrypt 4555 EXIST::FUNCTION:
-Index: crypto/engine/eng_t4_aes_asm.h
-===================================================================
-diff -uNr openssl-1.0.1e/engine/eng_t4_aes_asm.h openssl-1.0.1e/engine/eng_t4_aes_asm.h
---- openssl-1.0.1e/crypto/engine/eng_t4_aes_asm.h 1970-01-01 01:00:00.000000000 +0100
-+++ openssl-1.0.1e/crypto/engine/eng_t4_aes_asm.h 2013-03-11 18:15:54.571043544 +0100
-@@ -0,0 +1,147 @@
-+/*
-+ * This product includes cryptographic software developed by the OpenSSL
-+ * Project for use in the OpenSSL Toolkit (http://www.openssl.org/).
-+ */
-+
-+/*
-+ * ====================================================================
-+ * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved.
-+ *
-+ * 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 above 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 acknowledgment:
-+ * "This product includes software developed by the OpenSSL Project
-+ * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
-+ *
-+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
-+ * endorse or promote products derived from this software without
-+ * prior written permission. For written permission, please contact
-+ * licensing at OpenSSL.org.
-+ *
-+ * 5. Products derived from this software may not be called "OpenSSL"
-+ * nor may "OpenSSL" appear in their names without prior written
-+ * permission of the OpenSSL Project.
-+ *
-+ * 6. Redistributions of any form whatsoever must retain the following
-+ * acknowledgment:
-+ * "This product includes software developed by the OpenSSL Project
-+ * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
-+ * EXPRESSED 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 OpenSSL PROJECT OR
-+ * ITS 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.
-+ * ====================================================================
-+ */
-+
-+/*
-+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
-+ */
-+
-+#ifndef ENG_T4_AES_ASM_H
-+#define ENG_T4_AES_ASM_H
-+
-+/*
-+ * SPARC AES assembly language functions.
-+ *
-+ * Based on Solaris file aes_impl.h.
-+ */
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-+
-+#include <sys/types.h>
-+
-+#if (defined(sun4v) || defined(__sparcv9) || defined(__sparcv8plus) || \
-+ defined(__sparcv8)) && ! defined(OPENSSL_NO_ASM)
-+
-+extern void t4_aes_expand128(uint64_t *rk, const uint32_t *key);
-+extern void t4_aes_expand192(uint64_t *rk, const uint32_t *key);
-+extern void t4_aes_expand256(uint64_t *rk, const uint32_t *key);
-+extern void t4_aes_encrypt128(const uint64_t *rk, const uint32_t *pt,
-+ uint32_t *ct);
-+extern void t4_aes_encrypt192(const uint64_t *rk, const uint32_t *pt,
-+ uint32_t *ct);
-+extern void t4_aes_encrypt256(const uint64_t *rk, const uint32_t *pt,
-+ uint32_t *ct);
-+extern void t4_aes_decrypt128(const uint64_t *rk, const uint32_t *ct,
-+ uint32_t *pt);
-+extern void t4_aes_decrypt192(const uint64_t *rk, const uint32_t *ct,
-+ uint32_t *pt);
-+extern void t4_aes_decrypt256(const uint64_t *rk, const uint32_t *ct,
-+ uint32_t *pt);
-+extern void t4_aes128_load_keys_for_encrypt(uint64_t *ks);
-+extern void t4_aes192_load_keys_for_encrypt(uint64_t *ks);
-+extern void t4_aes256_load_keys_for_encrypt(uint64_t *ks);
-+extern void t4_aes128_ecb_encrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_encrypt, uint64_t *dummy);
-+extern void t4_aes192_ecb_encrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_encrypt, uint64_t *dummy);
-+extern void t4_aes256_ecb_encrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_encrypt, uint64_t *dummy);
-+extern void t4_aes128_cbc_encrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_encrypt, uint64_t *iv);
-+extern void t4_aes192_cbc_encrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_encrypt, uint64_t *iv);
-+extern void t4_aes256_cbc_encrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_encrypt, uint64_t *iv);
-+extern void t4_aes128_ctr_crypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_encrypt, uint64_t *iv);
-+extern void t4_aes192_ctr_crypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_encrypt, uint64_t *iv);
-+extern void t4_aes256_ctr_crypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_encrypt, uint64_t *iv);
-+extern void t4_aes128_cfb128_encrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_encrypt, uint64_t *iv);
-+extern void t4_aes192_cfb128_encrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_encrypt, uint64_t *iv);
-+extern void t4_aes256_cfb128_encrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_encrypt, uint64_t *iv);
-+extern void t4_aes128_load_keys_for_decrypt(uint64_t *ks);
-+extern void t4_aes192_load_keys_for_decrypt(uint64_t *ks);
-+extern void t4_aes256_load_keys_for_decrypt(uint64_t *ks);
-+extern void t4_aes128_ecb_decrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_decrypt, uint64_t *dummy);
-+extern void t4_aes192_ecb_decrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_decrypt, uint64_t *dummy);
-+extern void t4_aes256_ecb_decrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_decrypt, uint64_t *dummy);
-+extern void t4_aes128_cbc_decrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_decrypt, uint64_t *iv);
-+extern void t4_aes192_cbc_decrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_decrypt, uint64_t *iv);
-+extern void t4_aes256_cbc_decrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_decrypt, uint64_t *iv);
-+extern void t4_aes128_cfb128_decrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_decrypt, uint64_t *iv);
-+extern void t4_aes192_cfb128_decrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_decrypt, uint64_t *iv);
-+extern void t4_aes256_cfb128_decrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_decrypt, uint64_t *iv);
-+
-+#endif /* (sun4v||__sparv9||__sparcv8plus||__sparvc8) && !OPENSSL_NO_ASM */
-+
-+#ifdef __cplusplus
-+}
-+#endif
-+#endif /* ENG_T4_AES_ASM_H */
-Index: crypto/engine/eng_t4_bignum.h
-===================================================================
-diff -uNr openssl-1.0.1e/engine/eng_t4_bignum.h openssl-1.0.1e/engine/eng_t4_bignum.h
---- openssl-1.0.1e/crypto/engine/eng_t4_bignum.h 1970-01-01 01:00:00.000000000 +0100
-+++ openssl-1.0.1e/crypto/engine/eng_t4_bignum.h 2013-03-11 18:15:54.571043544 +0100
-@@ -0,0 +1,287 @@
-+/*
-+ * This product includes cryptographic software developed by the OpenSSL
-+ * Project for use in the OpenSSL Toolkit (http://www.openssl.org/).
-+ */
-+
-+/*
-+ * ====================================================================
-+ * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved.
-+ *
-+ * 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 above 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 acknowledgment:
-+ * "This product includes software developed by the OpenSSL Project
-+ * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
-+ *
-+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
-+ * endorse or promote products derived from this software without
-+ * prior written permission. For written permission, please contact
-+ * licensing at OpenSSL.org.
-+ *
-+ * 5. Products derived from this software may not be called "OpenSSL"
-+ * nor may "OpenSSL" appear in their names without prior written
-+ * permission of the OpenSSL Project.
-+ *
-+ * 6. Redistributions of any form whatsoever must retain the following
-+ * acknowledgment:
-+ * "This product includes software developed by the OpenSSL Project
-+ * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
-+ * EXPRESSED 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 OpenSSL PROJECT OR
-+ * ITS 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.
-+ * ====================================================================
-+ */
-+
-+/*
-+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
-+ */
-+
-+/*
-+ * This file is a copy of the ON gate's usr/src/common/bignum/bignum.h file
-+ */
-+
-+#ifndef _BIGNUM_H
-+#define _BIGNUM_H
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-+
-+#include <sys/types.h>
-+
-+#if defined(__sparcv9) || defined(__amd64) || defined(__sparc)
-+ /* 64-bit chunk size */
-+#ifndef UMUL64
-+#define UMUL64 /* 64-bit multiplication results are supported */
-+#endif
-+#else
-+#define BIGNUM_CHUNK_32
-+#endif
-+
-+
-+#define BITSINBYTE 8
-+
-+/* Bignum "digits" (aka "chunks" or "words") are either 32- or 64-bits */
-+#ifdef BIGNUM_CHUNK_32
-+#define BIG_CHUNK_SIZE 32
-+#define BIG_CHUNK_TYPE uint32_t
-+#define BIG_CHUNK_TYPE_SIGNED int32_t
-+#define BIG_CHUNK_HIGHBIT 0x80000000
-+#define BIG_CHUNK_ALLBITS 0xffffffff
-+#define BIG_CHUNK_LOWHALFBITS 0xffff
-+#define BIG_CHUNK_HALF_HIGHBIT 0x8000
-+
-+#else
-+#define BIG_CHUNK_SIZE 64
-+#define BIG_CHUNK_TYPE uint64_t
-+#define BIG_CHUNK_TYPE_SIGNED int64_t
-+#define BIG_CHUNK_HIGHBIT 0x8000000000000000ULL
-+#define BIG_CHUNK_ALLBITS 0xffffffffffffffffULL
-+#define BIG_CHUNK_LOWHALFBITS 0xffffffffULL
-+#define BIG_CHUNK_HALF_HIGHBIT 0x80000000ULL
-+#endif
-+
-+#define BITLEN2BIGNUMLEN(x) ((x) > 0 ? \
-+ ((((x) - 1) / BIG_CHUNK_SIZE) + 1) : 0)
-+#define CHARLEN2BIGNUMLEN(x) ((x) > 0 ? \
-+ ((((x) - 1) / sizeof (BIG_CHUNK_TYPE)) + 1) : 0)
-+
-+#define BIGNUM_WORDSIZE (BIG_CHUNK_SIZE / BITSINBYTE) /* word size in bytes */
-+#define BIG_CHUNKS_FOR_160BITS BITLEN2BIGNUMLEN(160)
-+
-+
-+/*
-+ * leading 0's are permitted
-+ * 0 should be represented by size>=1, size>=len>=1, sign=1,
-+ * value[i]=0 for 0<i<len
-+ */
-+typedef struct {
-+ /* size and len in units of BIG_CHUNK_TYPE words */
-+ uint32_t size; /* size of memory allocated for value */
-+ uint32_t len; /* number of valid data words in value */
-+ int sign; /* 1 for nonnegative, -1 for negative */
-+ int malloced; /* 1 if value was malloced, 0 if not */
-+ BIG_CHUNK_TYPE *value;
-+} BIGNUM;
-+
-+#define BIGTMPSIZE 65
-+
-+#define BIG_TRUE 1
-+#define BIG_FALSE 0
-+
-+typedef int BIG_ERR_CODE;
-+
-+/* error codes */
-+#define BIG_OK 0
-+#define BIG_NO_MEM -1
-+#define BIG_INVALID_ARGS -2
-+#define BIG_DIV_BY_0 -3
-+#define BIG_NO_RANDOM -4
-+#define BIG_GENERAL_ERR -5
-+#define BIG_TEST_FAILED -6
-+#define BIG_BUFFER_TOO_SMALL -7
-+
-+/*
-+ * this is not an error code, but should be different from possible error codes
-+ */
-+#define RND_TEST_VALUE_SUPPLIED -8
-+
-+
-+#define arraysize(x) (sizeof (x) / sizeof (x[0]))
-+
-+typedef BIG_ERR_CODE (*big_modexp_ncp_func_ptr)(BIGNUM *result,
-+ BIGNUM *ma, BIGNUM *e, BIGNUM *n,
-+ BIGNUM *tmp, BIG_CHUNK_TYPE n0, void *ncp, void *req);
-+
-+typedef struct {
-+ big_modexp_ncp_func_ptr func;
-+ void *ncp;
-+ void *reqp;
-+} big_modexp_ncp_info_t;
-+
-+#ifdef YF_MODEXP
-+BIG_ERR_CODE big_modexp_ncp_yf(BIGNUM *result, BIGNUM *ma, BIGNUM *e, BIGNUM *n,
-+ BIGNUM *tmp, BIG_CHUNK_TYPE n0);
-+#endif
-+
-+#ifdef YF_MONTMUL
-+BIG_ERR_CODE big_mont_mul_yf(BIGNUM *ret,
-+ BIGNUM *a, BIGNUM *b, BIGNUM *n, BIG_CHUNK_TYPE n0);
-+#endif
-+
-+#ifdef YF_MPMUL
-+BIG_ERR_CODE big_mp_mul_yf(BIGNUM *ret, BIGNUM *a, BIGNUM *b);
-+void mpmul_arr_yf(uint64_t *res, uint64_t *m1, uint64_t *m2, int len);
-+#endif
-+
-+#ifdef USE_FLOATING_POINT
-+void conv_d16_to_i32(uint32_t *i32, double *d16, int64_t *tmp, int ilen);
-+void conv_i32_to_d32(double *d32, uint32_t *i32, int len);
-+void conv_i32_to_d16(double *d16, uint32_t *i32, int len);
-+void conv_i32_to_d32_and_d16(double *d32, double *d16,
-+ uint32_t *i32, int len);
-+void mont_mulf_noconv(uint32_t *result, double *dm1, double *dm2, double *dt,
-+ double *dn, uint32_t *nint, int nlen, double dn0);
-+#endif /* USE_FLOATING_POINT */
-+
-+extern BIGNUM big_One;
-+extern BIGNUM big_Two;
-+
-+void printbignum(char *aname, BIGNUM *a);
-+
-+BIG_ERR_CODE big_init(BIGNUM *number, int size);
-+BIG_ERR_CODE big_extend(BIGNUM *number, int size);
-+void big_finish(BIGNUM *number);
-+void bytestring2bignum(BIGNUM *bn, uchar_t *kn, size_t len);
-+void bignum2bytestring(uchar_t *kn, BIGNUM *bn, size_t len);
-+BIG_ERR_CODE big_mont_rr(BIGNUM *result, BIGNUM *n);
-+BIG_ERR_CODE big_modexp(BIGNUM *result, BIGNUM *a, BIGNUM *e,
-+ BIGNUM *n, BIGNUM *n_rr);
-+BIG_ERR_CODE big_modexp_ext(BIGNUM *result, BIGNUM *a, BIGNUM *e,
-+ BIGNUM *n, BIGNUM *n_rr, big_modexp_ncp_info_t *info);
-+BIG_ERR_CODE big_modexp_crt(BIGNUM *result, BIGNUM *a, BIGNUM *dmodpminus1,
-+ BIGNUM *dmodqminus1, BIGNUM *p, BIGNUM *q, BIGNUM *pinvmodq,
-+ BIGNUM *p_rr, BIGNUM *q_rr);
-+BIG_ERR_CODE big_modexp_crt_ext(BIGNUM *result, BIGNUM *a, BIGNUM *dmodpminus1,
-+ BIGNUM *dmodqminus1, BIGNUM *p, BIGNUM *q, BIGNUM *pinvmodq,
-+ BIGNUM *p_rr, BIGNUM *q_rr, big_modexp_ncp_info_t *info);
-+int big_cmp_abs(BIGNUM *a, BIGNUM *b);
-+BIG_ERR_CODE big_random(BIGNUM *r, size_t length,
-+ int (*rfunc)(void *, size_t), boolean_t precise);
-+BIG_ERR_CODE big_div_pos(BIGNUM *result, BIGNUM *remainder,
-+ BIGNUM *aa, BIGNUM *bb);
-+BIG_ERR_CODE big_ext_gcd_pos(BIGNUM *gcd, BIGNUM *cm, BIGNUM *ce,
-+ BIGNUM *m, BIGNUM *e);
-+BIG_ERR_CODE big_add(BIGNUM *result, BIGNUM *aa, BIGNUM *bb);
-+BIG_ERR_CODE big_add_abs(BIGNUM *result, BIGNUM *aa, BIGNUM *bb);
-+void big_mul_arr_64(uint64_t *result, uint64_t *a, uint64_t *b, int alen);
-+BIG_ERR_CODE big_mul(BIGNUM *result, BIGNUM *aa, BIGNUM *bb);
-+void big_shiftright(BIGNUM *result, BIGNUM *aa, int offs);
-+BIG_ERR_CODE big_nextprime_pos(BIGNUM *result, BIGNUM *n);
-+BIG_ERR_CODE big_nextprime_pos_ext(BIGNUM *result, BIGNUM *n,
-+ big_modexp_ncp_info_t *info);
-+BIG_ERR_CODE big_sub_pos(BIGNUM *result, BIGNUM *aa, BIGNUM *bb);
-+BIG_ERR_CODE big_copy(BIGNUM *dest, BIGNUM *src);
-+BIG_ERR_CODE big_sub(BIGNUM *result, BIGNUM *aa, BIGNUM *bb);
-+int big_bitlength(BIGNUM *n);
-+BIG_ERR_CODE big_init1(BIGNUM *number, int size,
-+ BIG_CHUNK_TYPE *buf, int bufsize);
-+BIG_ERR_CODE big_mont_mul(BIGNUM *ret,
-+ BIGNUM *a, BIGNUM *b, BIGNUM *n, BIG_CHUNK_TYPE n0);
-+int big_is_zero(BIGNUM *n);
-+BIG_CHUNK_TYPE big_n0(BIG_CHUNK_TYPE n);
-+
-+
-+/*
-+ * Kernel bignum module: module integrity test
-+ */
-+extern int bignum_fips_check(void);
-+
-+#if defined(HWCAP)
-+
-+#if (BIG_CHUNK_SIZE != 32)
-+#error HWCAP works only with 32-bit bignum chunks
-+#endif
-+
-+#define BIG_MUL_SET_VEC(r, a, len, digit) \
-+ (*big_mul_set_vec_impl)(r, a, len, digit)
-+#define BIG_MUL_ADD_VEC(r, a, len, digit) \
-+ (*big_mul_add_vec_impl)(r, a, len, digit)
-+#define BIG_MUL_VEC(r, a, alen, b, blen) \
-+ (*big_mul_vec_impl)(r, a, alen, b, blen)
-+#define BIG_SQR_VEC(r, a, len) \
-+ (*big_sqr_vec_impl)(r, a, len)
-+
-+extern BIG_CHUNK_TYPE (*big_mul_set_vec_impl)
-+ (BIG_CHUNK_TYPE *r, BIG_CHUNK_TYPE *a, int len, BIG_CHUNK_TYPE digit);
-+extern BIG_CHUNK_TYPE (*big_mul_add_vec_impl)
-+ (BIG_CHUNK_TYPE *r, BIG_CHUNK_TYPE *a, int len, BIG_CHUNK_TYPE digit);
-+extern void (*big_mul_vec_impl)
-+ (BIG_CHUNK_TYPE *r, BIG_CHUNK_TYPE *a, int alen, BIG_CHUNK_TYPE *b,
-+ int blen);
-+extern void (*big_sqr_vec_impl)
-+ (BIG_CHUNK_TYPE *r, BIG_CHUNK_TYPE *a, int len);
-+
-+#else /* ! HWCAP */
-+
-+#define BIG_MUL_SET_VEC(r, a, len, digit) big_mul_set_vec(r, a, len, digit)
-+#define BIG_MUL_ADD_VEC(r, a, len, digit) big_mul_add_vec(r, a, len, digit)
-+#define BIG_MUL_VEC(r, a, alen, b, blen) big_mul_vec(r, a, alen, b, blen)
-+#define BIG_SQR_VEC(r, a, len) big_sqr_vec(r, a, len)
-+
-+extern BIG_CHUNK_TYPE big_mul_set_vec(BIG_CHUNK_TYPE *r, BIG_CHUNK_TYPE *a,
-+ int len, BIG_CHUNK_TYPE d);
-+extern BIG_CHUNK_TYPE big_mul_add_vec(BIG_CHUNK_TYPE *r,
-+ BIG_CHUNK_TYPE *a, int len, BIG_CHUNK_TYPE d);
-+extern void big_mul_vec(BIG_CHUNK_TYPE *r, BIG_CHUNK_TYPE *a, int alen,
-+ BIG_CHUNK_TYPE *b, int blen);
-+extern void big_sqr_vec(BIG_CHUNK_TYPE *r, BIG_CHUNK_TYPE *a, int len);
-+
-+#endif /* HWCAP */
-+
-+#ifdef __cplusplus
-+}
-+#endif
-+
-+#endif /* _BIGNUM_H */
-Index: crypto/engine/eng_t4_des_asm.h
-===================================================================
-diff -uNr openssl-1.0.1e/engine/eng_t4_des_asm.h openssl-1.0.1e/engine/eng_t4_des_asm.h
---- openssl-1.0.1e/crypto/engine/eng_t4_des_asm.h 1970-01-01 01:00:00.000000000 +0100
-+++ openssl-1.0.1e/crypto/engine/eng_t4_des_asm.h 2013-03-11 18:15:54.571043544 +0100
-@@ -0,0 +1,98 @@
-+/*
-+ * This product includes cryptographic software developed by the OpenSSL
-+ * Project for use in the OpenSSL Toolkit (http://www.openssl.org/).
-+ */
-+
-+/*
-+ * ====================================================================
-+ * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
-+ *
-+ * 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 above 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 acknowledgment:
-+ * "This product includes software developed by the OpenSSL Project
-+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
-+ *
-+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
-+ * endorse or promote products derived from this software without
-+ * prior written permission. For written permission, please contact
-+ * openssl-core at openssl.org.
-+ *
-+ * 5. Products derived from this software may not be called "OpenSSL"
-+ * nor may "OpenSSL" appear in their names without prior written
-+ * permission of the OpenSSL Project.
-+ *
-+ * 6. Redistributions of any form whatsoever must retain the following
-+ * acknowledgment:
-+ * "This product includes software developed by the OpenSSL Project
-+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
-+ * EXPRESSED 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 OpenSSL PROJECT OR
-+ * ITS 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.
-+ * ====================================================================
-+ */
-+
-+/*
-+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
-+ */
-+
-+#ifndef ENG_T4_DES_ASM_H
-+#define ENG_T4_DES_ASM_H
-+
-+/* SPARC DES assembly language functions. */
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-+
-+#include <sys/types.h>
-+
-+#if (defined(sun4v) || defined(__sparcv9) || defined(__sparcv8plus) || \
-+ defined(__sparcv8)) && ! defined(OPENSSL_NO_ASM)
-+
-+extern void t4_des_expand(uint64_t *rk, const uint32_t *key);
-+extern void t4_des_encrypt(const uint64_t *rk, const uint64_t *pt,
-+ uint64_t *ct);
-+extern void t4_des_load_keys(uint64_t *ks);
-+void t4_des_ecb_crypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_crypt, uint64_t *iv);
-+extern void t4_des_cbc_encrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_crypt, uint64_t *iv);
-+extern void t4_des_cbc_decrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_crypt, uint64_t *iv);
-+extern void t4_des3_load_keys(uint64_t *ks);
-+extern void t4_des3_ecb_crypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_crypt, uint64_t *iv);
-+extern void t4_des3_cbc_encrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_crypt, uint64_t *iv);
-+extern void t4_des3_cbc_decrypt(uint64_t *ks, uint64_t *asm_in,
-+ uint64_t *asm_out, size_t amount_to_crypt, uint64_t *iv);
-+
-+
-+#endif /* (sun4v||__sparv9||__sparcv8plus||__sparvc8) && !OPENSSL_NO_ASM */
-+
-+#ifdef __cplusplus
-+}
-+#endif
-+#endif /* ENG_T4_DES_ASM_H */
-Index: crypto/engine/eng_t4_err.h
-===================================================================
-diff -uNr openssl-1.0.1e/engine/eng_t4_err.h openssl-1.0.1e/engine/eng_t4_err.h
---- openssl-1.0.1e/crypto/engine/eng_t4_err.h 1970-01-01 01:00:00.000000000 +0100
-+++ openssl-1.0.1e/crypto/engine/eng_t4_err.h 2013-03-11 18:15:54.571043544 +0100
-@@ -0,0 +1,97 @@
-+/*
-+ * This product includes cryptographic software developed by the OpenSSL
-+ * Project for use in the OpenSSL Toolkit (http://www.openssl.org/).
-+ */
-+
-+/*
-+ * ====================================================================
-+ * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
-+ *
-+ * 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 above 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 acknowledgment:
-+ * "This product includes software developed by the OpenSSL Project
-+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
-+ *
-+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
-+ * endorse or promote products derived from this software without
-+ * prior written permission. For written permission, please contact
-+ * openssl-core at openssl.org.
-+ *
-+ * 5. Products derived from this software may not be called "OpenSSL"
-+ * nor may "OpenSSL" appear in their names without prior written
-+ * permission of the OpenSSL Project.
-+ *
-+ * 6. Redistributions of any form whatsoever must retain the following
-+ * acknowledgment:
-+ * "This product includes software developed by the OpenSSL Project
-+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
-+ * EXPRESSED 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 OpenSSL PROJECT OR
-+ * ITS 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.
-+ * ====================================================================
-+ */
-+
-+/*
-+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
-+ */
-+
-+#ifndef ENG_T4_ERR_H
-+#define ENG_T4_ERR_H
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-+
-+static void ERR_unload_t4_strings(void);
-+#pragma inline(ERR_unload_t4_strings)
-+static void ERR_t4_error(int function, int reason, char *file, int line);
-+
-+#define T4err(f, r) ERR_t4_error((f), (r), __FILE__, __LINE__)
-+
-+/* Function codes */
-+#define T4_F_INIT 100
-+#define T4_F_DESTROY 101
-+#define T4_F_FINISH 102
-+#define T4_F_CIPHER_INIT_AES 103
-+#define T4_F_ADD_NID 104
-+#define T4_F_GET_ALL_CIPHERS 105
-+#define T4_F_CIPHER_DO_AES 106
-+#define T4_F_CIPHER_CLEANUP 107
-+#define T4_F_CIPHER_INIT_DES 108
-+#define T4_F_CIPHER_DO_DES 109
-+
-+/* Reason codes */
-+#define T4_R_CIPHER_KEY 100
-+#define T4_R_CIPHER_NID 101
-+#define T4_R_IV_LEN_INCORRECT 102
-+#define T4_R_KEY_LEN_INCORRECT 103
-+#define T4_R_ASN1_OBJECT_CREATE 104
-+#define T4_R_NOT_BLOCKSIZE_LENGTH 105
-+
-+#ifdef __cplusplus
-+}
-+#endif
-+
-+#endif /* ENG_T4_ERR_H */
-Index: crypto/engine/eng_t4_sha2_asm.h
-===================================================================
-diff -uNr openssl-1.0.1e/engine/eng_t4_sha2_asm.h openssl-1.0.1e/engine/eng_t4_sha2_asm.h
---- openssl-1.0.1e/crypto/engine/eng_t4_sha2_asm.h 1970-01-01 01:00:00.000000000 +0100
-+++ openssl-1.0.1e/crypto/engine/eng_t4_sha2_asm.h 2013-03-11 18:15:54.571043544 +0100
-@@ -0,0 +1,135 @@
-+/*
-+ * This product includes cryptographic software developed by the OpenSSL
-+ * Project for use in the OpenSSL Toolkit (http://www.openssl.org/). This
-+ * product includes cryptographic software written by Eric Young
-+ * (eay at cryptsoft.com).
-+ */
-+
-+/*
-+ * ====================================================================
-+ * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
-+ *
-+ * 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 above 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 acknowledgment:
-+ * "This product includes software developed by the OpenSSL Project
-+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
-+ *
-+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
-+ * endorse or promote products derived from this software without
-+ * prior written permission. For written permission, please contact
-+ * openssl-core at openssl.org.
-+ *
-+ * 5. Products derived from this software may not be called "OpenSSL"
-+ * nor may "OpenSSL" appear in their names without prior written
-+ * permission of the OpenSSL Project.
-+ *
-+ * 6. Redistributions of any form whatsoever must retain the following
-+ * acknowledgment:
-+ * "This product includes software developed by the OpenSSL Project
-+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
-+ * EXPRESSED 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 OpenSSL PROJECT OR
-+ * ITS 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.
-+ * ====================================================================
-+ */
-+
-+/*
-+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
-+ */
-+
-+#ifndef ENG_T4_SHA2_ASM_H
-+#define ENG_T4_SHA2_ASM_H
-+
-+/*
-+ * SPARC T4 SHA2 (SHA256/SHA512) assembly language functions and context.
-+ * The context must match that used by the Solaris SPARC T4 assembly
-+ * (except for OpenSSL-specific fields num and md_len that aren't in Solaris).
-+ *
-+ * Based on OpenSSL file openssl/sha.h and Solaris file sys/sha2.h.
-+ */
-+
-+#include <stddef.h>
-+#include <sys/types.h>
-+#include <openssl/sha.h>
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-+
-+#ifndef OPENSSL_NO_SHA256
-+/*
-+ * The contents of this structure are a private interface between the
-+ * Init/Update/Multiblock/Final functions.
-+ * Callers must never attempt to read or write any of the fields
-+ * in this structure directly.
-+ */
-+typedef struct t4_SHA256state_st {
-+ uint32_t algotype; /* Solaris-only field; unused here */
-+ uint32_t algotype_pad; /* Pad to align next field 0 mod 8 */
-+ uint32_t h[8]; /* State (ABCDEFGH) */
-+ uint32_t h_pad[8]; /* Pad fields to match T4_SHA512_CTX */
-+ uint32_t Nl, Nh; /* Number of bits, module 2^64 */
-+ uint32_t Nl_pad, Nh_pad; /* Pad fields to match T4_SHA512_CTX */
-+ uint32_t data[SHA_LBLOCK]; /* Input */
-+ unsigned int num, md_len; /* Fields unused by Solaris assembly */
-+} T4_SHA256_CTX;
-+#endif /* !OPENSSL_NO_SHA256 */
-+
-+
-+#ifndef OPENSSL_NO_SHA512
-+/*
-+ * The contents of this structure are a private interface between the
-+ * Init/Update/Multiblock/Final functions.
-+ * Callers must never attempt to read or write any of the fields
-+ * in this structure directly.
-+ */
-+typedef struct t4_SHA512state_st {
-+ uint32_t algotype; /* Solaris-only field; unused here */
-+ uint64_t h[8]; /* State (ABCDEFGH) */
-+ uint64_t Nl, Nh; /* Number of bits, module 2^128 */
-+ union {
-+ uint64_t d[SHA_LBLOCK];
-+ unsigned char p[SHA512_CBLOCK];
-+ } u; /* Input */
-+ unsigned int num, md_len; /* Fields unused by Solaris assembly */
-+} T4_SHA512_CTX;
-+#endif /* !OPENSSL_NO_SHA512 */
-+
-+/*
-+ * SPARC T4 assembly language functions
-+ */
-+#ifndef OPENSSL_NO_SHA256
-+extern void t4_sha256_multiblock(T4_SHA256_CTX *c, const void *input,
-+ size_t num);
-+#endif
-+#ifndef OPENSSL_NO_SHA512
-+extern void t4_sha512_multiblock(T4_SHA512_CTX *c, const void *input,
-+ size_t num);
-+#endif
-+
-+#ifdef __cplusplus
-+}
-+#endif
-+#endif /* ENG_T4_SHA2_ASM_H */
-Index: crypto/engine/eng_t4.c
-===================================================================
-diff -uNr openssl-1.0.1e/engine/eng_t4.c openssl-1.0.1e/engine/eng_t4.c
---- openssl-1.0.1e/crypto/engine/eng_t4.c 1970-01-01 01:00:00.000000000 +0100
-+++ openssl-1.0.1e/crypto/engine/eng_t4.c 2013-03-11 18:15:54.571043544 +0100
-@@ -0,0 +1,1010 @@
-+/*
-+ * This product includes cryptographic software developed by the OpenSSL
-+ * Project for use in the OpenSSL Toolkit (http://www.openssl.org/).
-+ */
-+
-+/*
-+ * ====================================================================
-+ * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
-+ *
-+ * 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 above 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 acknowledgment:
-+ * "This product includes software developed by the OpenSSL Project
-+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
-+ *
-+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
-+ * endorse or promote products derived from this software without
-+ * prior written permission. For written permission, please contact
-+ * openssl-core at openssl.org.
-+ *
-+ * 5. Products derived from this software may not be called "OpenSSL"
-+ * nor may "OpenSSL" appear in their names without prior written
-+ * permission of the OpenSSL Project.
-+ *
-+ * 6. Redistributions of any form whatsoever must retain the following
-+ * acknowledgment:
-+ * "This product includes software developed by the OpenSSL Project
-+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
-+ * EXPRESSED 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 OpenSSL PROJECT OR
-+ * ITS 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.
-+ * ====================================================================
-+ */
-+
-+/*
-+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
-+ */
-+
-+/*
-+ * This engine supports SPARC microprocessors that provide AES and other
-+ * cipher and hash instructions, such as the T4 microprocessor.
-+ */
-+
-+#include <openssl/opensslconf.h>
-+
-+#if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_AES_T4) && \
-+ !defined(OPENSSL_NO_AES)
-+#include <sys/types.h>
-+#include <sys/auxv.h> /* getisax() */
-+#include <stdlib.h>
-+#include <stdbool.h>
-+#include <string.h>
-+#include <errno.h>
-+#include <openssl/aes.h>
-+#include <openssl/engine.h>
-+#include "eng_t4_aes_asm.h"
-+
-+#define T4_LIB_NAME "SPARC T4 engine"
-+#include "eng_t4_err.c"
-+
-+/* Copied from Solaris aes_impl.h */
-+#ifndef MAX_AES_NR
-+#define MAX_AES_NR 14 /* Maximum number of rounds */
-+#endif
-+#ifndef MAX_AES_NB
-+#define MAX_AES_NB 4 /* Number of columns comprising a state */
-+#endif
-+
-+/* Index for the supported ciphers */
-+typedef enum {
-+ T4_AES_128_CBC,
-+ T4_AES_192_CBC,
-+ T4_AES_256_CBC,
-+#ifndef SOLARIS_NO_AES_CFB128
-+ T4_AES_128_CFB128,
-+ T4_AES_192_CFB128,
-+ T4_AES_256_CFB128,
-+#endif /* !SOLARIS_NO_AES_CFB128 */
-+ T4_AES_128_CTR,
-+ T4_AES_192_CTR,
-+ T4_AES_256_CTR,
-+ T4_AES_128_ECB,
-+ T4_AES_192_ECB,
-+ T4_AES_256_ECB,
-+ T4_CIPHER_MAX
-+} t4_cipher_id;
-+
-+/* T4 cipher context; must be 8-byte aligned (last field must be uint64_t) */
-+typedef struct t4_cipher_ctx {
-+ t4_cipher_id index;
-+ uint64_t *iv;
-+ uint64_t aligned_iv_buffer[2]; /* use if original IV unaligned */
-+ /* Encryption and decryption key schedule are the same: */
-+ uint64_t t4_ks[((MAX_AES_NR) + 1) * (MAX_AES_NB)];
-+} t4_cipher_ctx_t;
-+
-+typedef struct t4_cipher {
-+ t4_cipher_id id;
-+ int nid;
-+ int iv_len;
-+ int min_key_len;
-+ int max_key_len;
-+ unsigned long flags;
-+} t4_cipher_t;
-+
-+/* Constants used when creating the ENGINE */
-+static const char *ENGINE_T4_ID = "t4";
-+static const char *ENGINE_T4_NAME = "SPARC T4 engine support";
-+static const char *ENGINE_NO_T4_NAME = "SPARC T4 engine support (no T4)";
-+
-+
-+#if (defined(sun4v) || defined(__sparcv9) || defined(__sparcv8plus) || \
-+ defined(__sparcv8)) && !defined(OPENSSL_NO_ASM)
-+#define COMPILE_HW_T4
-+static int t4_bind_helper(ENGINE *e, const char *id);
-+#pragma inline(t4_bind_helper)
-+#endif
-+
-+/*
-+ * This makes the engine "built-in" with OpenSSL.
-+ * On non-T4 CPUs this just returns.
-+ * Called by ENGINE_load_builtin_engines().
-+ */
-+void
-+ENGINE_load_t4(void)
-+{
-+#ifdef COMPILE_HW_T4
-+ ENGINE *toadd = ENGINE_new();
-+ if (toadd != NULL) {
-+ if (t4_bind_helper(toadd, ENGINE_T4_ID) != 0) {
-+ (void) ENGINE_add(toadd);
-+ (void) ENGINE_free(toadd);
-+ ERR_clear_error();
-+ } else {
-+ (void) ENGINE_free(toadd);
-+ }
-+ }
-+#endif
-+}
-+
-+
-+#ifdef COMPILE_HW_T4
-+static int t4_bind(ENGINE *e);
-+#ifndef DYNAMIC_ENGINE
-+#pragma inline(t4_bind)
-+#endif
-+static t4_cipher_id get_cipher_index_by_nid(int nid);
-+#pragma inline(get_cipher_index_by_nid)
-+static void t4_instructions_present(_Bool *aes_present, _Bool *des_present,
-+ _Bool *digest_present, _Bool *montmul_present);
-+#pragma inline(t4_instructions_present)
-+
-+/* Digest registration function. Called by ENGINE_set_ciphers() */
-+int t4_get_all_digests(ENGINE *e, const EVP_MD **digest,
-+ const int **nids, int nid);
-+
-+/* RSA_METHOD structure used by ENGINE_set_RSA() */
-+extern RSA_METHOD *t4_RSA(void);
-+
-+/* DH_METHOD structure used by ENGINE_set_DH() */
-+extern DH_METHOD *t4_DH(void);
-+
-+/* DSA_METHOD structure used by ENGINE_set_DSA() */
-+extern DSA_METHOD *t4_DSA(void);
-+
-+/* Static variables */
-+/* This can't be const as NID*ctr is inserted when the engine is initialized */
-+static int t4_cipher_nids[] = {
-+ NID_aes_128_cbc, NID_aes_192_cbc, NID_aes_256_cbc,
-+#ifndef SOLARIS_NO_AES_CFB128
-+ NID_aes_128_cfb128, NID_aes_192_cfb128, NID_aes_256_cfb128,
-+#endif
-+ NID_aes_128_ctr, NID_aes_192_ctr, NID_aes_256_ctr,
-+ NID_aes_128_ecb, NID_aes_192_ecb, NID_aes_256_ecb,
-+#ifndef OPENSSL_NO_DES
-+ /* Must be at end of list (see t4_des_cipher_count in t4_bind() */
-+ NID_des_cbc, NID_des_ede3_cbc, NID_des_ecb, NID_des_ede3_ecb,
-+#endif
-+};
-+static const int t4_des_cipher_count = 4;
-+static int t4_cipher_count =
-+ (sizeof (t4_cipher_nids) / sizeof (t4_cipher_nids[0]));
-+
-+/*
-+ * Cipher Table for all supported symmetric ciphers.
-+ * Must be in same order as t4_cipher_id.
-+ */
-+static t4_cipher_t t4_cipher_table[] = {
-+ /* ID NID IV min- max-key flags */
-+ {T4_AES_128_CBC, NID_aes_128_cbc, 16, 16, 16, 0},
-+ {T4_AES_192_CBC, NID_aes_192_cbc, 16, 24, 24, 0},
-+ {T4_AES_256_CBC, NID_aes_256_cbc, 16, 32, 32, 0},
-+#ifndef SOLARIS_NO_AES_CFB128
-+ {T4_AES_128_CFB128, NID_aes_128_cfb128, 16, 16, 16,
-+ EVP_CIPH_NO_PADDING},
-+ {T4_AES_192_CFB128, NID_aes_192_cfb128, 16, 24, 24,
-+ EVP_CIPH_NO_PADDING},
-+ {T4_AES_256_CFB128, NID_aes_256_cfb128, 16, 32, 32,
-+ EVP_CIPH_NO_PADDING},
-+#endif
-+ {T4_AES_128_CTR, NID_aes_128_ctr, 16, 16, 16,
-+ EVP_CIPH_NO_PADDING},
-+ {T4_AES_192_CTR, NID_aes_192_ctr, 16, 24, 24,
-+ EVP_CIPH_NO_PADDING},
-+ {T4_AES_256_CTR, NID_aes_256_ctr, 16, 32, 32,
-+ EVP_CIPH_NO_PADDING},
-+ {T4_AES_128_ECB, NID_aes_128_ecb, 0, 16, 16, 0},
-+ {T4_AES_192_ECB, NID_aes_192_ecb, 0, 24, 24, 0},
-+ {T4_AES_256_ECB, NID_aes_256_ecb, 0, 32, 32, 0},
-+};
-+
-+
-+/* Formal declaration for functions in EVP_CIPHER structure */
-+static int t4_cipher_init_aes(EVP_CIPHER_CTX *ctx, const unsigned char *key,
-+ const unsigned char *iv, int enc);
-+
-+static int t4_cipher_do_aes_128_cbc(EVP_CIPHER_CTX *ctx, unsigned char *out,
-+ const unsigned char *in, size_t inl);
-+static int t4_cipher_do_aes_192_cbc(EVP_CIPHER_CTX *ctx, unsigned char *out,
-+ const unsigned char *in, size_t inl);
-+static int t4_cipher_do_aes_256_cbc(EVP_CIPHER_CTX *ctx, unsigned char *out,
-+ const unsigned char *in, size_t inl);
-+#ifndef SOLARIS_NO_AES_CFB128
-+static int t4_cipher_do_aes_128_cfb128(EVP_CIPHER_CTX *ctx, unsigned char *out,
-+ const unsigned char *in, size_t inl);
-+static int t4_cipher_do_aes_192_cfb128(EVP_CIPHER_CTX *ctx, unsigned char *out,
-+ const unsigned char *in, size_t inl);
-+static int t4_cipher_do_aes_256_cfb128(EVP_CIPHER_CTX *ctx, unsigned char *out,
-+ const unsigned char *in, size_t inl);
-+#endif
-+static int t4_cipher_do_aes_128_ctr(EVP_CIPHER_CTX *ctx, unsigned char *out,
-+ const unsigned char *in, size_t inl);
-+static int t4_cipher_do_aes_192_ctr(EVP_CIPHER_CTX *ctx, unsigned char *out,
-+ const unsigned char *in, size_t inl);
-+static int t4_cipher_do_aes_256_ctr(EVP_CIPHER_CTX *ctx, unsigned char *out,
-+ const unsigned char *in, size_t inl);
-+static int t4_cipher_do_aes_128_ecb(EVP_CIPHER_CTX *ctx, unsigned char *out,
-+ const unsigned char *in, size_t inl);
-+static int t4_cipher_do_aes_192_ecb(EVP_CIPHER_CTX *ctx, unsigned char *out,
-+ const unsigned char *in, size_t inl);
-+static int t4_cipher_do_aes_256_ecb(EVP_CIPHER_CTX *ctx, unsigned char *out,
-+ const unsigned char *in, size_t inl);
-+
-+
-+/*
-+ * Cipher Algorithms
-+ *
-+ * OpenSSL's libcrypto EVP stuff. This is how this engine gets wired to EVP.
-+ * EVP_CIPHER is defined in evp.h. To maintain binary compatibility the
-+ * definition cannot be modified.
-+ * Stuff specific to the t4 engine is kept in t4_cipher_ctx_t, which is
-+ * pointed to by cipher_data or md_data
-+ *
-+ * Fields: nid, block_size, key_len, iv_len, flags,
-+ * init(), do_cipher(), cleanup(),
-+ * ctx_size,
-+ * set_asn1_parameters(), get_asn1_parameters(), ctrl(), app_data
-+ */
-+
-+static const EVP_CIPHER t4_aes_128_cbc = {
-+ NID_aes_128_cbc,
-+ 16, 16, 16,
-+ EVP_CIPH_CBC_MODE,
-+ t4_cipher_init_aes, t4_cipher_do_aes_128_cbc, NULL,
-+ sizeof (t4_cipher_ctx_t),
-+ EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv,
-+ NULL, NULL
-+};
-+static const EVP_CIPHER t4_aes_192_cbc = {
-+ NID_aes_192_cbc,
-+ 16, 24, 16,
-+ EVP_CIPH_CBC_MODE,
-+ t4_cipher_init_aes, t4_cipher_do_aes_192_cbc, NULL,
-+ sizeof (t4_cipher_ctx_t),
-+ EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv,
-+ NULL, NULL
-+};
-+static const EVP_CIPHER t4_aes_256_cbc = {
-+ NID_aes_256_cbc,
-+ 16, 32, 16,
-+ EVP_CIPH_CBC_MODE,
-+ t4_cipher_init_aes, t4_cipher_do_aes_256_cbc, NULL,
-+ sizeof (t4_cipher_ctx_t),
-+ EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv,
-+ NULL, NULL
-+};
-+
-+#ifndef SOLARIS_NO_AES_CFB128
-+static const EVP_CIPHER t4_aes_128_cfb128 = {
-+ NID_aes_128_cfb128,
-+ 16, 16, 16,
-+ EVP_CIPH_CFB_MODE,
-+ t4_cipher_init_aes, t4_cipher_do_aes_128_cfb128, NULL,
-+ sizeof (t4_cipher_ctx_t),
-+ EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv,
-+ NULL, NULL
-+};
-+static const EVP_CIPHER t4_aes_192_cfb128 = {
-+ NID_aes_192_cfb128,
-+ 16, 24, 16,
-+ EVP_CIPH_CFB_MODE,
-+ t4_cipher_init_aes, t4_cipher_do_aes_192_cfb128, NULL,
-+ sizeof (t4_cipher_ctx_t),
-+ EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv,
-+ NULL, NULL
-+};
-+static const EVP_CIPHER t4_aes_256_cfb128 = {
-+ NID_aes_256_cfb128,
-+ 16, 32, 16,
-+ EVP_CIPH_CFB_MODE,
-+ t4_cipher_init_aes, t4_cipher_do_aes_256_cfb128, NULL,
-+ sizeof (t4_cipher_ctx_t),
-+ EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv,
-+ NULL, NULL
-+};
-+#endif /* !SOLARIS_NO_AES_CFB128 */
-+
-+static EVP_CIPHER t4_aes_128_ctr = {
-+ NID_aes_128_ctr,
-+ 16, 16, 16,
-+ EVP_CIPH_CTR_MODE,
-+ t4_cipher_init_aes, t4_cipher_do_aes_128_ctr, NULL,
-+ sizeof (t4_cipher_ctx_t),
-+ EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv,
-+ NULL, NULL
-+};
-+static EVP_CIPHER t4_aes_192_ctr = {
-+ NID_aes_192_ctr,
-+ 16, 24, 16,
-+ EVP_CIPH_CTR_MODE,
-+ t4_cipher_init_aes, t4_cipher_do_aes_192_ctr, NULL,
-+ sizeof (t4_cipher_ctx_t),
-+ EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv,
-+ NULL, NULL
-+};
-+static EVP_CIPHER t4_aes_256_ctr = {
-+ NID_aes_256_ctr,
-+ 16, 32, 16,
-+ EVP_CIPH_CTR_MODE,
-+ t4_cipher_init_aes, t4_cipher_do_aes_256_ctr, NULL,
-+ sizeof (t4_cipher_ctx_t),
-+ EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv,
-+ NULL, NULL
-+};
-+
-+/*
-+ * ECB modes don't use an Initial Vector, so that's why set_asn1_parameters,
-+ * get_asn1_parameters, and cleanup fields are set to NULL.
-+ */
-+static const EVP_CIPHER t4_aes_128_ecb = {
-+ NID_aes_128_ecb,
-+ 16, 16, 0,
-+ EVP_CIPH_ECB_MODE,
-+ t4_cipher_init_aes, t4_cipher_do_aes_128_ecb, NULL,
-+ sizeof (t4_cipher_ctx_t),
-+ NULL, NULL, NULL, NULL
-+};
-+static const EVP_CIPHER t4_aes_192_ecb = {
-+ NID_aes_192_ecb,
-+ 16, 24, 0,
-+ EVP_CIPH_ECB_MODE,
-+ t4_cipher_init_aes, t4_cipher_do_aes_192_ecb, NULL,
-+ sizeof (t4_cipher_ctx_t),
-+ NULL, NULL, NULL, NULL
-+};
-+static const EVP_CIPHER t4_aes_256_ecb = {
-+ NID_aes_256_ecb,
-+ 16, 32, 0,
-+ EVP_CIPH_ECB_MODE,
-+ t4_cipher_init_aes, t4_cipher_do_aes_256_ecb, NULL,
-+ sizeof (t4_cipher_ctx_t),
-+ NULL, NULL, NULL, NULL
-+};
-+
-+#ifndef OPENSSL_NO_DES
-+extern const EVP_CIPHER t4_des_cbc;
-+extern const EVP_CIPHER t4_des3_cbc;
-+extern const EVP_CIPHER t4_des_ecb;
-+extern const EVP_CIPHER t4_des3_ecb;
-+#endif /* OPENSSL_NO_DES */
-+
-+
-+/*
-+ * Message Digest variables
-+ */
-+static const int t4_digest_nids[] = {
-+#ifndef OPENSSL_NO_MD5
-+ NID_md5,
-+#endif
-+#ifndef OPENSSL_NO_SHA
-+#ifndef OPENSSL_NO_SHA1
-+ NID_sha1,
-+#endif
-+#ifndef OPENSSL_NO_SHA256
-+ NID_sha224,
-+ NID_sha256,
-+#endif
-+#ifndef OPENSSL_NO_SHA512
-+ NID_sha384,
-+ NID_sha512,
-+#endif
-+#endif /* !OPENSSL_NO_SHA */
-+};
-+static const int t4_digest_count =
-+ (sizeof (t4_digest_nids) / sizeof (t4_digest_nids[0]));
-+
-+#ifndef OPENSSL_NO_MD5
-+extern const EVP_MD t4_md5;
-+#endif
-+#ifndef OPENSSL_NO_SHA
-+#ifndef OPENSSL_NO_SHA1
-+extern const EVP_MD t4_sha1;
-+#endif
-+#ifndef OPENSSL_NO_SHA256
-+extern const EVP_MD t4_sha224;
-+extern const EVP_MD t4_sha256;
-+#endif
-+#ifndef OPENSSL_NO_SHA512
-+extern const EVP_MD t4_sha384;
-+extern const EVP_MD t4_sha512;
-+#endif
-+#endif /* !OPENSSL_NO_SHA */
-+
-+/*
-+ * Message Digest functions
-+ */
-+
-+/*
-+ * Registered by the ENGINE with ENGINE_set_digests().
-+ * Finds out how to deal with a particular digest NID in the ENGINE.
-+ */
-+/* ARGSUSED */
-+int
-+t4_get_all_digests(ENGINE *e, const EVP_MD **digest,
-+ const int **nids, int nid)
-+{
-+ if (digest == NULL) { /* return a list of all supported digests */
-+ *nids = (t4_digest_count > 0) ? t4_digest_nids : NULL;
-+ return (t4_digest_count);
-+ }
-+
-+ switch (nid) {
-+#ifndef OPENSSL_NO_MD5
-+ case NID_md5:
-+ *digest = &t4_md5;
-+ break;
-+#endif
-+#ifndef OPENSSL_NO_SHA
-+#ifndef OPENSSL_NO_SHA1
-+ /*
-+ * A special case. For "openssl dgst -dss1 ...",
-+ * OpenSSL calls EVP_get_digestbyname() on "dss1" which ends up
-+ * calling t4_get_all_digests() for NID_dsa. Internally, if an
-+ * engine is not used, OpenSSL uses SHA1_Init() as expected for
-+ * DSA. So, we must return t4_sha1 for NID_dsa as well. Note
-+ * that this must have changed between 0.9.8 and 1.0.0 since we
-+ * did not have the problem with the 0.9.8 version.
-+ */
-+ case NID_dsa:
-+ case NID_sha1:
-+ *digest = &t4_sha1;
-+ break;
-+#endif
-+#ifndef OPENSSL_NO_SHA256
-+ case NID_sha224:
-+ *digest = &t4_sha224;
-+ break;
-+ case NID_sha256:
-+ *digest = &t4_sha256;
-+ break;
-+#endif
-+#ifndef OPENSSL_NO_SHA512
-+ case NID_sha384:
-+ *digest = &t4_sha384;
-+ break;
-+ case NID_sha512:
-+ *digest = &t4_sha512;
-+ break;
-+#endif
-+#endif /* !OPENSSL_NO_SHA */
-+ default:
-+ /* digest not supported */
-+ *digest = NULL;
-+ return (0);
-+ }
-+
-+ return (1);
-+}
-+
-+
-+/*
-+ * Utility Functions
-+ */
-+
-+/*
-+ * Set aes_present, des_present, digest_present and montmul_present
-+ * to B_FALSE or B_TRUE depending on
-+ * whether the current SPARC processor supports AES, DES,
-+ * MD5/SHA1/SHA256/SHA512 and MONTMUL, respectively.
-+ */
-+static void
-+t4_instructions_present(_Bool *aes_present, _Bool *des_present,
-+ _Bool *digest_present, _Bool *montmul_present)
-+{
-+#ifdef OPENSSL_NO_DES
-+#undef AV_SPARC_DES
-+#define AV_SPARC_DES 0
-+#endif
-+#ifdef OPENSSL_NO_MD5
-+#undef AV_SPARC_MD5
-+#define AV_SPARC_MD5 0
-+#endif
-+#ifndef OPENSSL_NO_SHA
-+#ifdef OPENSSL_NO_SHA1
-+#undef AV_SPARC_SHA1
-+#define AV_SPARC_SHA1 0
-+#endif
-+#ifdef OPENSSL_NO_SHA256
-+#undef AV_SPARC_SHA256
-+#define AV_SPARC_SHA256 0
-+#endif
-+#ifdef OPENSSL_NO_SHA512
-+#undef AV_SPARC_SHA512
-+#define AV_SPARC_SHA512 0
-+#endif
-+#else
-+#undef AV_SPARC_SHA1
-+#undef AV_SPARC_SHA256
-+#undef AV_SPARC_SHA512
-+#define AV_SPARC_SHA1 0
-+#define AV_SPARC_SHA256 0
-+#define AV_SPARC_SHA512 0
-+#endif /* !OPENSSL_NO_SHA */
-+
-+#define DIGEST_MASK (AV_SPARC_MD5 | AV_SPARC_SHA1 | AV_SPARC_SHA256 | \
-+ AV_SPARC_SHA512)
-+ uint_t ui;
-+
-+ (void) getisax(&ui, 1);
-+ *aes_present = ((ui & AV_SPARC_AES) != 0);
-+ *des_present = ((ui & AV_SPARC_DES) != 0);
-+ *digest_present = ((ui & DIGEST_MASK) == DIGEST_MASK);
-+ *montmul_present = ((ui & AV_SPARC_MONT) != 0);
-+}
-+
-+
-+
-+/*
-+ * Cipher functions
-+ */
-+
-+
-+/*
-+ * Registered by the ENGINE with ENGINE_set_ciphers().
-+ * Finds out how to deal with a particular cipher NID in the ENGINE.
-+ */
-+/* ARGSUSED */
-+static int
-+t4_get_all_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
-+ const int **nids, int nid)
-+{
-+ if (cipher == NULL) { /* return a list of all supported ciphers */
-+ *nids = (t4_cipher_count > 0) ? t4_cipher_nids : NULL;
-+ return (t4_cipher_count);
-+ }
-+
-+ switch (nid) {
-+ case NID_aes_128_cbc:
-+ *cipher = &t4_aes_128_cbc;
-+ break;
-+ case NID_aes_192_cbc:
-+ *cipher = &t4_aes_192_cbc;
-+ break;
-+ case NID_aes_256_cbc:
-+ *cipher = &t4_aes_256_cbc;
-+ break;
-+ case NID_aes_128_ecb:
-+ *cipher = &t4_aes_128_ecb;
-+ break;
-+ case NID_aes_192_ecb:
-+ *cipher = &t4_aes_192_ecb;
-+ break;
-+ case NID_aes_256_ecb:
-+ *cipher = &t4_aes_256_ecb;
-+ break;
-+#ifndef SOLARIS_NO_AES_CFB128
-+ case NID_aes_128_cfb128:
-+ *cipher = &t4_aes_128_cfb128;
-+ break;
-+ case NID_aes_192_cfb128:
-+ *cipher = &t4_aes_192_cfb128;
-+ break;
-+ case NID_aes_256_cfb128:
-+ *cipher = &t4_aes_256_cfb128;
-+ break;
-+#endif /* !SOLARIS_NO_AES_CFB128 */
-+#ifndef OPENSSL_NO_DES
-+ case NID_des_cbc:
-+ *cipher = &t4_des_cbc;
-+ break;
-+ case NID_des_ede3_cbc:
-+ *cipher = &t4_des3_cbc;
-+ break;
-+ case NID_des_ecb:
-+ *cipher = &t4_des_ecb;
-+ break;
-+ case NID_des_ede3_ecb:
-+ *cipher = &t4_des3_ecb;
-+ break;
-+#endif /* !OPENSSL_NO_DES */
-+ case NID_aes_128_ctr:
-+ *cipher = &t4_aes_128_ctr;
-+ break;
-+ case NID_aes_192_ctr:
-+ *cipher = &t4_aes_192_ctr;
-+ break;
-+ case NID_aes_256_ctr:
-+ *cipher = &t4_aes_256_ctr;
-+ break;
-+
-+ default:
-+ /* cipher not supported */
-+ *cipher = NULL;
-+ return (0);
-+ }
-+
-+ return (1);
-+}
-+
-+
-+/* Called by t4_cipher_init_aes() */
-+static t4_cipher_id
-+get_cipher_index_by_nid(int nid)
-+{
-+ t4_cipher_id i;
-+
-+ for (i = (t4_cipher_id)0; i < T4_CIPHER_MAX; ++i)
-+ if (t4_cipher_table[i].nid == nid)
-+ return (i);
-+ return (T4_CIPHER_MAX);
-+}
-+
-+
-+/* ARGSUSED2 */
-+static int
-+t4_cipher_init_aes(EVP_CIPHER_CTX *ctx, const unsigned char *key,
-+ const unsigned char *iv, int enc)
-+{
-+ t4_cipher_ctx_t *tctx = ctx->cipher_data;
-+ uint64_t *t4_ks = tctx->t4_ks;
-+ t4_cipher_t *t4_cipher;
-+ t4_cipher_id index;
-+ int key_len = ctx->key_len;
-+ uint64_t aligned_key_buffer[4]; /* 16, 24, or 32 bytes long */
-+ uint64_t *aligned_key;
-+
-+ if (key == NULL) {
-+ T4err(T4_F_CIPHER_INIT_AES, T4_R_CIPHER_KEY);
-+ return (0);
-+ }
-+
-+ /* Get the cipher entry index in t4_cipher_table from nid */
-+ index = get_cipher_index_by_nid(ctx->cipher->nid);
-+ if (index >= T4_CIPHER_MAX) {
-+ T4err(T4_F_CIPHER_INIT_AES, T4_R_CIPHER_NID);
-+ return (0); /* Error */
-+ }
-+ t4_cipher = &t4_cipher_table[index];
-+
-+ /* Check key size and iv size */
-+ if (ctx->cipher->iv_len < t4_cipher->iv_len) {
-+ T4err(T4_F_CIPHER_INIT_AES, T4_R_IV_LEN_INCORRECT);
-+ return (0); /* Error */
-+ }
-+ if ((key_len < t4_cipher->min_key_len) ||
-+ (key_len > t4_cipher->max_key_len)) {
-+ T4err(T4_F_CIPHER_INIT_AES, T4_R_KEY_LEN_INCORRECT);
-+ return (0); /* Error */
-+ }
-+
-+ /* Set cipher flags, if any */
-+ ctx->flags |= t4_cipher->flags;
-+
-+ /* Align the key */
-+ if (((unsigned long)key & 0x7) == 0) /* already aligned */
-+ aligned_key = (uint64_t *)key;
-+ else { /* key is not 8-byte aligned */
-+#ifdef DEBUG_T4
-+ (void) fprintf(stderr, "T4: key is not 8 byte aligned\n");
-+#endif
-+ (void) memcpy(aligned_key_buffer, key, key_len);
-+ aligned_key = aligned_key_buffer;
-+ }
-+
-+
-+ /*
-+ * Expand the key schedule.
-+ * Copy original key to start of t4_ks key schedule. Note that the
-+ * encryption and decryption key schedule are the same for T4.
-+ */
-+ switch (key_len) {
-+ case 16:
-+ t4_aes_expand128(&t4_ks[2],
-+ (const uint32_t *)aligned_key);
-+ t4_ks[0] = aligned_key[0];
-+ t4_ks[1] = aligned_key[1];
-+ break;
-+ case 24:
-+ t4_aes_expand192(&t4_ks[3],
-+ (const uint32_t *)aligned_key);
-+ t4_ks[0] = aligned_key[0];
-+ t4_ks[1] = aligned_key[1];
-+ t4_ks[2] = aligned_key[2];
-+ break;
-+ case 32:
-+ t4_aes_expand256(&t4_ks[4],
-+ (const uint32_t *)aligned_key);
-+ t4_ks[0] = aligned_key[0];
-+ t4_ks[1] = aligned_key[1];
-+ t4_ks[2] = aligned_key[2];
-+ t4_ks[3] = aligned_key[3];
-+ break;
-+ default:
-+ T4err(T4_F_CIPHER_INIT_AES, T4_R_CIPHER_KEY);
-+ return (0);
-+ }
-+
-+ /* Save index to cipher */
-+ tctx->index = index;
-+
-+ /* Align IV, if needed */
-+ if (t4_cipher->iv_len <= 0) { /* no IV (such as with ECB mode) */
-+ tctx->iv = NULL;
-+ } else if (((unsigned long)ctx->iv & 0x7) == 0) { /* already aligned */
-+ tctx->iv = (uint64_t *)ctx->iv;
-+ } else {
-+ /* IV is not 8 byte aligned */
-+ (void) memcpy(tctx->aligned_iv_buffer, ctx->iv,
-+ ctx->cipher->iv_len);
-+ tctx->iv = tctx->aligned_iv_buffer;
-+#ifdef DEBUG_T4
-+ (void) fprintf(stderr,
-+ "t4_cipher_init_aes: IV is not 8 byte aligned\n");
-+ (void) fprintf(stderr,
-+ "t4_cipher_init_aes: ctx->cipher->iv_len =%d\n",
-+ ctx->cipher->iv_len);
-+ (void) fprintf(stderr, "t4_cipher_init_aes: after "
-+ "re-alignment, tctx->iv = %p\n", (void *)tctx->iv);
-+#endif /* DEBUG_T4 */
-+ }
-+
-+ return (1);
-+}
-+
-+
-+/*
-+ * ENCRYPT_UPDATE or DECRYPT_UPDATE
-+ */
-+#define T4_CIPHER_DO_AES(t4_cipher_do_aes, t4_aes_load_keys_for_encrypt, \
-+ t4_aes_encrypt, t4_aes_load_keys_for_decrypt, t4_aes_decrypt, iv) \
-+static int \
-+t4_cipher_do_aes(EVP_CIPHER_CTX *ctx, unsigned char *out, \
-+ const unsigned char *in, size_t inl) \
-+{ \
-+ t4_cipher_ctx_t *tctx = ctx->cipher_data; \
-+ uint64_t *t4_ks = tctx->t4_ks; \
-+ unsigned long outl = inl; \
-+ unsigned char *bufin_alloc = NULL, *bufout_alloc = NULL; \
-+ unsigned char *bufin, *bufout; \
-+ \
-+ /* "in" and "out" must be 8 byte aligned */ \
-+ if (((unsigned long)in & 0x7) == 0) { /* already aligned */ \
-+ bufin = (unsigned char *)in; \
-+ } else { /* "in" is not 8 byte aligned */ \
-+ if (((unsigned long)out & 0x7) == 0) { /* aligned */ \
-+ /* use output buffer for input */ \
-+ bufin = out; \
-+ } else { \
-+ bufin = bufin_alloc = OPENSSL_malloc(inl); \
-+ if (bufin_alloc == NULL) \
-+ return (0); /* error */ \
-+ } \
-+ (void) memcpy(bufin, in, inl); \
-+ } \
-+ \
-+ if (((unsigned long)out & 0x7) == 0) { /* already aligned */ \
-+ bufout = out; \
-+ } else { /* "out" is not 8 byte aligned */ \
-+ if (bufin_alloc != NULL) { \
-+ /* use allocated input buffer for output */ \
-+ bufout = bufin_alloc; \
-+ } else { \
-+ bufout = bufout_alloc = OPENSSL_malloc(outl); \
-+ if (bufout_alloc == NULL) { \
-+ OPENSSL_free(bufin_alloc); \
-+ return (0); /* error */ \
-+ } \
-+ } \
-+ } \
-+ \
-+ /* Data length must be an even multiple of block size. */ \
-+ if ((inl & 0xf) != 0) { \
-+ OPENSSL_free(bufout_alloc); \
-+ OPENSSL_free(bufin_alloc); \
-+ T4err(T4_F_CIPHER_DO_AES, T4_R_NOT_BLOCKSIZE_LENGTH); \
-+ return (0); \
-+ } \
-+ \
-+ if (ctx->encrypt) { \
-+ t4_aes_load_keys_for_encrypt(t4_ks); \
-+ t4_aes_encrypt(t4_ks, (uint64_t *)bufin, \
-+ (uint64_t *)bufout, (size_t)inl, iv); \
-+ } else { /* decrypt */ \
-+ t4_aes_load_keys_for_decrypt(t4_ks); \
-+ t4_aes_decrypt(t4_ks, (uint64_t *)bufin, \
-+ (uint64_t *)bufout, (size_t)inl, iv); \
-+ } \
-+ \
-+ /* Cleanup */ \
-+ if (bufin_alloc != NULL) { \
-+ if (bufout == bufin_alloc) \
-+ (void) memcpy(out, bufout, outl); \
-+ OPENSSL_free(bufin_alloc); \
-+ } \
-+ if (bufout_alloc != NULL) { \
-+ (void) memcpy(out, bufout_alloc, outl); \
-+ OPENSSL_free(bufout_alloc); \
-+ } \
-+ \
-+ return (1); \
-+}
-+
-+
-+/* AES CBC mode. */
-+T4_CIPHER_DO_AES(t4_cipher_do_aes_128_cbc,
-+ t4_aes128_load_keys_for_encrypt, t4_aes128_cbc_encrypt,
-+ t4_aes128_load_keys_for_decrypt, t4_aes128_cbc_decrypt, tctx->iv)
-+T4_CIPHER_DO_AES(t4_cipher_do_aes_192_cbc,
-+ t4_aes192_load_keys_for_encrypt, t4_aes192_cbc_encrypt,
-+ t4_aes192_load_keys_for_decrypt, t4_aes192_cbc_decrypt, tctx->iv)
-+T4_CIPHER_DO_AES(t4_cipher_do_aes_256_cbc,
-+ t4_aes256_load_keys_for_encrypt, t4_aes256_cbc_encrypt,
-+ t4_aes256_load_keys_for_decrypt, t4_aes256_cbc_decrypt, tctx->iv)
-+
-+/*
-+ * AES CFB128 mode.
-+ * CFB128 decrypt uses load_keys_for_encrypt() as the mode uses
-+ * the raw AES encrypt operation for the decryption, too.
-+ */
-+#ifndef SOLARIS_NO_AES_CFB128
-+T4_CIPHER_DO_AES(t4_cipher_do_aes_128_cfb128,
-+ t4_aes128_load_keys_for_encrypt, t4_aes128_cfb128_encrypt,
-+ t4_aes128_load_keys_for_encrypt, t4_aes128_cfb128_decrypt, tctx->iv)
-+T4_CIPHER_DO_AES(t4_cipher_do_aes_192_cfb128,
-+ t4_aes192_load_keys_for_encrypt, t4_aes192_cfb128_encrypt,
-+ t4_aes192_load_keys_for_encrypt, t4_aes192_cfb128_decrypt, tctx->iv)
-+T4_CIPHER_DO_AES(t4_cipher_do_aes_256_cfb128,
-+ t4_aes256_load_keys_for_encrypt, t4_aes256_cfb128_encrypt,
-+ t4_aes256_load_keys_for_encrypt, t4_aes256_cfb128_decrypt, tctx->iv)
-+#endif /* !SOLARIS_NO_AES_CFB128 */
-+
-+/* AES CTR mode. */
-+T4_CIPHER_DO_AES(t4_cipher_do_aes_128_ctr,
-+ t4_aes128_load_keys_for_encrypt, t4_aes128_ctr_crypt,
-+ t4_aes128_load_keys_for_decrypt, t4_aes128_ctr_crypt, tctx->iv)
-+T4_CIPHER_DO_AES(t4_cipher_do_aes_192_ctr,
-+ t4_aes192_load_keys_for_encrypt, t4_aes192_ctr_crypt,
-+ t4_aes192_load_keys_for_decrypt, t4_aes192_ctr_crypt, tctx->iv)
-+T4_CIPHER_DO_AES(t4_cipher_do_aes_256_ctr,
-+ t4_aes256_load_keys_for_encrypt, t4_aes256_ctr_crypt,
-+ t4_aes256_load_keys_for_decrypt, t4_aes256_ctr_crypt, tctx->iv)
-+
-+/* AES ECB mode. */
-+T4_CIPHER_DO_AES(t4_cipher_do_aes_128_ecb,
-+ t4_aes128_load_keys_for_encrypt, t4_aes128_ecb_encrypt,
-+ t4_aes128_load_keys_for_decrypt, t4_aes128_ecb_decrypt, NULL)
-+T4_CIPHER_DO_AES(t4_cipher_do_aes_192_ecb,
-+ t4_aes192_load_keys_for_encrypt, t4_aes192_ecb_encrypt,
-+ t4_aes192_load_keys_for_decrypt, t4_aes192_ecb_decrypt, NULL)
-+T4_CIPHER_DO_AES(t4_cipher_do_aes_256_ecb,
-+ t4_aes256_load_keys_for_encrypt, t4_aes256_ecb_encrypt,
-+ t4_aes256_load_keys_for_decrypt, t4_aes256_ecb_decrypt, NULL)
-+
-+
-+/*
-+ * Is the t4 engine available?
-+ * Passed to ENGINE_set_init_function().
-+ */
-+/* ARGSUSED */
-+static int
-+t4_init(ENGINE *e)
-+{
-+ return (1);
-+}
-+
-+
-+/* Passed to ENGINE_set_destroy_function(). */
-+/* ARGSUSED */
-+static int
-+t4_destroy(ENGINE *e)
-+{
-+ ERR_unload_t4_strings();
-+ return (1);
-+}
-+
-+
-+/*
-+ * Called by t4_bind_helper().
-+ * Note: too early to use T4err() functions on errors.
-+ */
-+/* ARGSUSED */
-+static int
-+t4_bind(ENGINE *e)
-+{
-+ _Bool aes_engage, digest_engage, des_engage, montmul_engage;
-+
-+ t4_instructions_present(&aes_engage, &des_engage, &digest_engage,
-+ &montmul_engage);
-+#ifdef DEBUG_T4
-+ (void) fprintf(stderr,
-+ "t4_bind: engage aes=%d, des=%d, digest=%d\n",
-+ aes_engage, des_engage, digest_engage);
-+#endif
-+#ifndef OPENSSL_NO_DES
-+ if (!des_engage) { /* Remove DES ciphers from list */
-+ t4_cipher_count -= t4_des_cipher_count;
-+ }
-+#endif
-+
-+#ifdef DEBUG_T4
-+ (void) fprintf(stderr, "t4_cipher_count = %d; t4_cipher_nids[] =\n",
-+ t4_cipher_count);
-+ for (int i = 0; i < t4_cipher_count; ++i) {
-+ (void) fprintf(stderr, " %d", t4_cipher_nids[i]);
-+ }
-+ (void) fprintf(stderr, "\n");
-+#endif /* DEBUG_T4 */
-+
-+ /* Register T4 engine ID, name, and functions */
-+ if (!ENGINE_set_id(e, ENGINE_T4_ID) ||
-+ !ENGINE_set_name(e,
-+ aes_engage ? ENGINE_T4_NAME: ENGINE_NO_T4_NAME) ||
-+ !ENGINE_set_init_function(e, t4_init) ||
-+ (aes_engage && !ENGINE_set_ciphers(e, t4_get_all_ciphers)) ||
-+ (digest_engage && !ENGINE_set_digests(e, t4_get_all_digests)) ||
-+#ifndef OPENSSL_NO_RSA
-+ (montmul_engage && !ENGINE_set_RSA(e, t4_RSA())) ||
-+#endif /* OPENSSL_NO_RSA */
-+#ifndef OPENSSL_NO_DH
-+ (montmul_engage && !ENGINE_set_DH(e, t4_DH())) ||
-+#endif /* OPENSSL_NO_DH */
-+#ifndef OPENSSL_NO_DSA
-+ (montmul_engage && !ENGINE_set_DSA(e, t4_DSA())) ||
-+#endif /* OPENSSL_NO_DSA */
-+ !ENGINE_set_destroy_function(e, t4_destroy)) {
-+ return (0);
-+ }
-+
-+ return (1);
-+}
-+
-+
-+/*
-+ * Called by ENGINE_load_t4().
-+ * Note: too early to use T4err() functions on errors.
-+ */
-+static int
-+t4_bind_helper(ENGINE *e, const char *id)
-+{
-+ if (id != NULL && (strcmp(id, ENGINE_T4_ID) != 0)) {
-+ (void) fprintf(stderr, "T4: bad t4 engine ID\n");
-+ return (0);
-+ }
-+ if (!t4_bind(e)) {
-+ (void) fprintf(stderr,
-+ "T4: failed to bind t4 engine\n");
-+ return (0);
-+ }
-+
-+ return (1);
-+}
-+
-+
-+#ifdef DYNAMIC_ENGINE
-+IMPLEMENT_DYNAMIC_CHECK_FN()
-+IMPLEMENT_DYNAMIC_BIND_FN(t4_bind_helper)
-+#endif /* DYNAMIC_ENGINE */
-+#endif /* COMPILE_HW_T4 */
-+#endif /* !OPENSSL_NO_HW && !OPENSSL_NO_HW_AES_T4 && !OPENSSL_NO_AES */
-Index: crypto/engine/eng_t4_des.c
-===================================================================
-diff -uNr openssl-1.0.1e/engine/eng_t4_des.c openssl-1.0.1e/engine/eng_t4_des.c
---- openssl-1.0.1e/crypto/engine/eng_t4_des.c 1970-01-01 01:00:00.000000000 +0100
-+++ openssl-1.0.1e/crypto/engine/eng_t4_des.c 2013-03-11 18:15:54.571043544 +0100
-@@ -0,0 +1,486 @@
-+/*
-+ * This product includes cryptographic software developed by the OpenSSL
-+ * Project for use in the OpenSSL Toolkit (http://www.openssl.org/).
-+ */
-+
-+/*
-+ * ====================================================================
-+ * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
-+ *
-+ * 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 above 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 acknowledgment:
-+ * "This product includes software developed by the OpenSSL Project
-+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
-+ *
-+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
-+ * endorse or promote products derived from this software without
-+ * prior written permission. For written permission, please contact
-+ * openssl-core at openssl.org.
-+ *
-+ * 5. Products derived from this software may not be called "OpenSSL"
-+ * nor may "OpenSSL" appear in their names without prior written
-+ * permission of the OpenSSL Project.
-+ *
-+ * 6. Redistributions of any form whatsoever must retain the following
-+ * acknowledgment:
-+ * "This product includes software developed by the OpenSSL Project
-+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
-+ * EXPRESSED 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 OpenSSL PROJECT OR
-+ * ITS 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.
-+ * ====================================================================
-+ */
-+
-+/*
-+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
-+ */
-+
-+/*
-+ * This engine supports SPARC microprocessors that provide DES and other
-+ * cipher and hash instructions, such as the T4 microprocessor.
-+ *
-+ * This file implements the DES and DES3 cipher operations.
-+ */
-+
-+#include <openssl/opensslconf.h>
-+
-+#if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_DES_T4) && \
-+ !defined(OPENSSL_NO_DES)
-+#include <sys/types.h>
-+#include <stdlib.h>
-+#include <string.h>
-+#include <errno.h>
-+#include <openssl/engine.h>
-+#include "eng_t4_des_asm.h"
-+
-+#include "eng_t4_err.c"
-+
-+/* Index for the supported DES ciphers */
-+typedef enum {
-+ T4_DES_CBC,
-+ T4_DES3_CBC,
-+ T4_DES_ECB,
-+ T4_DES3_ECB,
-+ T4_DES_MAX
-+} t4_des_cipher_id;
-+
-+/* From Solaris file usr/src/common/crypto/des/des_impl.c */
-+typedef struct {
-+ uint64_t ksch_encrypt[16];
-+ uint64_t ksch_decrypt[16];
-+} t4_keysched_t;
-+
-+typedef struct {
-+ uint64_t ksch_encrypt[16 * 3];
-+ uint64_t ksch_decrypt[16 * 3];
-+} t4_keysched3_t;
-+
-+/* T4 cipher context; must be 8-byte aligned (last field must be uint64_t) */
-+typedef struct t4_des_cipher_ctx {
-+ t4_des_cipher_id index;
-+ uint64_t *iv;
-+ uint64_t aligned_iv_buffer; /* use if IV unaligned */
-+ union {
-+ t4_keysched_t des;
-+ t4_keysched3_t des3;
-+ } ks;
-+} t4_des_cipher_ctx_t;
-+
-+typedef struct t4_cipher {
-+ t4_des_cipher_id id;
-+ int nid;
-+ int iv_len;
-+ int min_key_len;
-+ int max_key_len;
-+} t4_des_cipher_t;
-+
-+
-+#if (defined(sun4v) || defined(__sparcv9) || defined(__sparcv8plus) || \
-+ defined(__sparcv8)) && !defined(OPENSSL_NO_ASM)
-+#define COMPILE_HW_T4
-+#endif
-+
-+#ifdef COMPILE_HW_T4
-+static t4_des_cipher_id get_des_cipher_index_by_nid(int nid);
-+#pragma inline(get_des_cipher_index_by_nid)
-+
-+
-+/*
-+ * Cipher Table for all supported symmetric ciphers.
-+ * Must be in same order as t4_des_cipher_id.
-+ */
-+static t4_des_cipher_t t4_des_cipher_table[] = {
-+ /* ID NID IV min-key max-key */
-+ {T4_DES_CBC, NID_des_cbc, 8, 8, 8},
-+ {T4_DES3_CBC, NID_des_ede3_cbc, 8, 24, 24},
-+ {T4_DES_ECB, NID_des_ecb, 0, 8, 8},
-+ {T4_DES3_ECB, NID_des_ede3_ecb, 0, 24, 24},
-+};
-+
-+
-+/* Formal declaration for functions in EVP_CIPHER structure */
-+static int t4_cipher_init_des(EVP_CIPHER_CTX *ctx, const unsigned char *key,
-+ const unsigned char *iv, int enc);
-+
-+static int t4_cipher_do_des_cbc(EVP_CIPHER_CTX *ctx, unsigned char *out,
-+ const unsigned char *in, size_t inl);
-+static int t4_cipher_do_des3_cbc(EVP_CIPHER_CTX *ctx, unsigned char *out,
-+ const unsigned char *in, size_t inl);
-+static int t4_cipher_do_des_ecb(EVP_CIPHER_CTX *ctx, unsigned char *out,
-+ const unsigned char *in, size_t inl);
-+static int t4_cipher_do_des3_ecb(EVP_CIPHER_CTX *ctx, unsigned char *out,
-+ const unsigned char *in, size_t inl);
-+
-+
-+/*
-+ * Cipher Algorithms
-+ *
-+ * OpenSSL's libcrypto EVP stuff. This is how this engine gets wired to EVP.
-+ * EVP_CIPHER is defined in evp.h. To maintain binary compatibility the
-+ * definition cannot be modified.
-+ * Stuff specific to the t4 engine is kept in t4_des_cipher_ctx_t, which is
-+ * pointed to by cipher_data or md_data
-+ *
-+ * Fields: nid, block_size, key_len, iv_len, flags,
-+ * init(), do_cipher(), cleanup(),
-+ * ctx_size,
-+ * set_asn1_parameters(), get_asn1_parameters(), ctrl(), app_data
-+ */
-+
-+const EVP_CIPHER t4_des_cbc = {
-+ NID_des_cbc,
-+ 8, 8, 8,
-+ EVP_CIPH_CBC_MODE,
-+ t4_cipher_init_des, t4_cipher_do_des_cbc, NULL,
-+ sizeof (t4_des_cipher_ctx_t),
-+ EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv,
-+ NULL, NULL
-+};
-+const EVP_CIPHER t4_des3_cbc = {
-+ NID_des_ede3_cbc,
-+ 8, 24, 8,
-+ EVP_CIPH_CBC_MODE,
-+ t4_cipher_init_des, t4_cipher_do_des3_cbc, NULL,
-+ sizeof (t4_des_cipher_ctx_t),
-+ EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv,
-+ NULL, NULL
-+};
-+
-+/*
-+ * ECB modes don't use an Initial Vector, so that's why set_asn1_parameters,
-+ * get_asn1_parameters, and cleanup fields are set to NULL.
-+ */
-+const EVP_CIPHER t4_des_ecb = {
-+ NID_des_ecb,
-+ 8, 8, 8,
-+ EVP_CIPH_ECB_MODE,
-+ t4_cipher_init_des, t4_cipher_do_des_ecb, NULL,
-+ sizeof (t4_des_cipher_ctx_t),
-+ NULL, NULL, NULL, NULL
-+};
-+const EVP_CIPHER t4_des3_ecb = {
-+ NID_des_ede3_ecb,
-+ 8, 24, 8,
-+ EVP_CIPH_ECB_MODE,
-+ t4_cipher_init_des, t4_cipher_do_des3_ecb, NULL,
-+ sizeof (t4_des_cipher_ctx_t),
-+ NULL, NULL, NULL, NULL
-+};
-+
-+
-+/*
-+ * DES Cipher functions
-+ */
-+
-+/* Called by t4_cipher_init_des() */
-+static t4_des_cipher_id
-+get_des_cipher_index_by_nid(int nid)
-+{
-+ t4_des_cipher_id i;
-+
-+ for (i = (t4_des_cipher_id)0; i < T4_DES_MAX; ++i)
-+ if (t4_des_cipher_table[i].nid == nid)
-+ return (i);
-+ return (T4_DES_MAX);
-+}
-+
-+
-+/*
-+ * Initialize encryption and decryption key schedules for DES or DES3.
-+ * Called by t4_cipher_init_des().
-+ *
-+ * Modified from Solaris DES function des_init_keysched().
-+ */
-+static int
-+t4_des_init_keysched(const unsigned char *cipherKey,
-+ unsigned int keysize, void *ks)
-+{
-+ uint64_t *encryption_ks, *decryption_ks;
-+ uint64_t keysched[16 * 3]; /* 128 or 384 bytes for DES or DES3 */
-+ uint64_t key_uint64[3]; /* 8 or 24 bytes for DES or DES3 */
-+ uint64_t *aligned_key;
-+ uint64_t tmp;
-+ uint_t i, j;
-+
-+ switch (keysize) {
-+ case 8: /* DES */
-+ encryption_ks = ((t4_keysched_t *)ks)->ksch_encrypt;
-+ decryption_ks = ((t4_keysched_t *)ks)->ksch_decrypt;
-+ break;
-+ case 24: /* DES3 */
-+ encryption_ks = ((t4_keysched3_t *)ks)->ksch_encrypt;
-+ decryption_ks = ((t4_keysched3_t *)ks)->ksch_decrypt;
-+ break;
-+ default:
-+ T4err(T4_F_CIPHER_INIT_DES, T4_R_CIPHER_KEY);
-+ return (0);
-+ }
-+
-+ /* Align key, if needed */
-+ if (((unsigned long)cipherKey & 0x7) == 0) { /* aligned */
-+ /* LINTED: pointer alignment */
-+ aligned_key = (uint64_t *)cipherKey;
-+ } else { /* unaligned--copy byte-by-byte */
-+ for (i = 0, j = 0; j < keysize; ++i, j += 8) {
-+ key_uint64[i] = (((uint64_t)cipherKey[j] << 56) |
-+ ((uint64_t)cipherKey[j + 1] << 48) |
-+ ((uint64_t)cipherKey[j + 2] << 40) |
-+ ((uint64_t)cipherKey[j + 3] << 32) |
-+ ((uint64_t)cipherKey[j + 4] << 24) |
-+ ((uint64_t)cipherKey[j + 5] << 16) |
-+ ((uint64_t)cipherKey[j + 6] << 8) |
-+ (uint64_t)cipherKey[j + 7]);
-+ }
-+ aligned_key = key_uint64;
-+ }
-+
-+ /* Expand key schedule */
-+ switch (keysize) {
-+ case 8: /* DES */
-+ t4_des_expand(keysched, (const uint32_t *)aligned_key);
-+ break;
-+
-+ case 24: /* DES3 */
-+ t4_des_expand(keysched, (const uint32_t *)aligned_key);
-+ t4_des_expand(keysched + 16,
-+ (const uint32_t *)&aligned_key[1]);
-+ for (i = 0; i < 8; ++i) {
-+ tmp = keysched[16 + i];
-+ keysched[16 + i] = keysched[31 - i];
-+ keysched[31 - i] = tmp;
-+ }
-+ t4_des_expand(keysched + 32,
-+ (const uint32_t *)&aligned_key[2]);
-+ break;
-+
-+ default:
-+ T4err(T4_F_CIPHER_INIT_DES, T4_R_CIPHER_KEY);
-+ return (0);
-+ }
-+
-+ /* Save encryption key schedule */
-+ memcpy(encryption_ks, keysched, keysize * 16);
-+
-+ /* Reverse key schedule */
-+ for (i = 0; i < keysize; ++i) {
-+ tmp = keysched[i];
-+ keysched[i] = keysched[2 * keysize - 1 - i];
-+ keysched[2 * keysize -1 -i] = tmp;
-+ }
-+
-+ /* Save decryption key schedule */
-+ memcpy(decryption_ks, keysched, keysize * 16);
-+
-+ return (1);
-+}
-+
-+
-+/* ARGSUSED2 */
-+static int
-+t4_cipher_init_des(EVP_CIPHER_CTX *ctx, const unsigned char *key,
-+ const unsigned char *iv, int enc)
-+{
-+ t4_des_cipher_ctx_t *tctx = ctx->cipher_data;
-+ uint64_t *encryption_ks, *decryption_ks;
-+ t4_des_cipher_t *t4_cipher;
-+ t4_des_cipher_id index;
-+ unsigned int key_len = ctx->key_len;
-+ uint64_t aligned_key_buffer[3]; /* 8 or 24 bytes long */
-+ uint64_t *aligned_key;
-+
-+ if (key == NULL) {
-+ T4err(T4_F_CIPHER_INIT_DES, T4_R_CIPHER_KEY);
-+ return (0);
-+ }
-+
-+ /* Get the cipher entry index in t4_des_cipher_table from nid */
-+ index = get_des_cipher_index_by_nid(ctx->cipher->nid);
-+ if (index >= T4_DES_MAX) {
-+ T4err(T4_F_CIPHER_INIT_DES, T4_R_CIPHER_NID);
-+ return (0); /* Error */
-+ }
-+ t4_cipher = &t4_des_cipher_table[index];
-+
-+ /* Check key size and iv size */
-+ if (ctx->cipher->iv_len < t4_cipher->iv_len) {
-+ T4err(T4_F_CIPHER_INIT_DES, T4_R_IV_LEN_INCORRECT);
-+ return (0); /* Error */
-+ }
-+ if ((key_len < t4_cipher->min_key_len) ||
-+ (key_len > t4_cipher->max_key_len)) {
-+ T4err(T4_F_CIPHER_INIT_DES, T4_R_KEY_LEN_INCORRECT);
-+ return (0); /* Error */
-+ }
-+
-+ /* Expand key schedule */
-+ if (t4_des_init_keysched(key, key_len, &tctx->ks) == 0)
-+ return (0); /* Error */
-+
-+ /* Save index to cipher */
-+ tctx->index = index;
-+
-+ /* Align IV, if needed */
-+ if (t4_cipher->iv_len <= 0) { /* no IV (such as with ECB mode) */
-+ tctx->iv = NULL;
-+ } else if (((unsigned long)ctx->iv & 0x7) == 0) { /* already aligned */
-+ tctx->iv = (uint64_t *)ctx->iv;
-+ } else {
-+ /* IV is not 8 byte aligned */
-+ (void) memcpy(&tctx->aligned_iv_buffer, ctx->iv,
-+ ctx->cipher->iv_len);
-+ tctx->iv = &tctx->aligned_iv_buffer;
-+#ifdef DEBUG_T4
-+ (void) fprintf(stderr,
-+ "t4_cipher_init_des: IV is not 8 byte aligned\n");
-+ (void) fprintf(stderr,
-+ "t4_cipher_init_des: ctx->cipher->iv_len =%d\n",
-+ ctx->cipher->iv_len);
-+ (void) fprintf(stderr, "t4_cipher_init_des: after "
-+ "re-alignment, tctx->iv = %p\n", (void *)tctx->iv);
-+#endif /* DEBUG_T4 */
-+ }
-+
-+ return (1);
-+}
-+
-+
-+/*
-+ * ENCRYPT_UPDATE or DECRYPT_UPDATE
-+ */
-+#define T4_CIPHER_DO_DES(t4_cipher_do_des, t4_des_load_keys, \
-+ t4_des_encrypt, t4_des_decrypt, ksched_encrypt, ksched_decrypt, iv) \
-+static int \
-+t4_cipher_do_des(EVP_CIPHER_CTX *ctx, unsigned char *out, \
-+ const unsigned char *in, size_t inl) \
-+{ \
-+ t4_des_cipher_ctx_t *tctx = ctx->cipher_data; \
-+ unsigned long outl = inl; \
-+ unsigned char *bufin_alloc = NULL, *bufout_alloc = NULL; \
-+ unsigned char *bufin, *bufout; \
-+ \
-+ /* "in" and "out" must be 8 byte aligned */ \
-+ if (((unsigned long)in & 0x7) == 0) { /* already aligned */ \
-+ bufin = (unsigned char *)in; \
-+ } else { /* "in" is not 8 byte aligned */ \
-+ if (((unsigned long)out & 0x7) == 0) { /* aligned */ \
-+ /* use output buffer for input */ \
-+ bufin = out; \
-+ } else { \
-+ bufin = bufin_alloc = OPENSSL_malloc(inl); \
-+ if (bufin_alloc == NULL) \
-+ return (0); /* error */ \
-+ } \
-+ (void) memcpy(bufin, in, inl); \
-+ } \
-+ \
-+ /* Data length must be an even multiple of block size. */ \
-+ if ((inl & 0x7) != 0) { \
-+ OPENSSL_free(bufout_alloc); \
-+ OPENSSL_free(bufin_alloc); \
-+ T4err(T4_F_CIPHER_DO_DES, T4_R_NOT_BLOCKSIZE_LENGTH); \
-+ return (0); \
-+ } \
-+ \
-+ if (((unsigned long)out & 0x7) == 0) { /* already aligned */ \
-+ bufout = out; \
-+ } else { /* "out" is not 8 byte aligned */ \
-+ if (bufin_alloc != NULL) { \
-+ /* use allocated input buffer for output */ \
-+ bufout = bufin_alloc; \
-+ } else { \
-+ bufout = bufout_alloc = OPENSSL_malloc(outl); \
-+ if (bufout_alloc == NULL) { \
-+ OPENSSL_free(bufin_alloc); \
-+ return (0); /* error */ \
-+ } \
-+ } \
-+ } \
-+ \
-+ if (ctx->encrypt) { \
-+ uint64_t *ksch_encrypt = ksched_encrypt; \
-+ t4_des_load_keys(ksch_encrypt); \
-+ t4_des_encrypt(ksch_encrypt, (uint64_t *)bufin, \
-+ (uint64_t *)bufout, (size_t)inl, iv); \
-+ } else { /* decrypt */ \
-+ uint64_t *ksch_decrypt = ksched_decrypt; \
-+ t4_des_load_keys(ksch_decrypt); \
-+ t4_des_decrypt(ksch_decrypt, (uint64_t *)bufin, \
-+ (uint64_t *)bufout, (size_t)inl, iv); \
-+ } \
-+ \
-+ /* Cleanup */ \
-+ if (bufin_alloc != NULL) { \
-+ if (bufout == bufin_alloc) \
-+ (void) memcpy(out, bufout, outl); \
-+ OPENSSL_free(bufin_alloc); \
-+ } \
-+ if (bufout_alloc != NULL) { \
-+ (void) memcpy(out, bufout_alloc, outl); \
-+ OPENSSL_free(bufout_alloc); \
-+ } \
-+ \
-+ return (1); \
-+}
-+
-+
-+/* DES CBC mode. */
-+T4_CIPHER_DO_DES(t4_cipher_do_des_cbc, t4_des_load_keys,
-+ t4_des_cbc_encrypt, t4_des_cbc_decrypt,
-+ tctx->ks.des.ksch_encrypt, tctx->ks.des.ksch_decrypt, tctx->iv)
-+T4_CIPHER_DO_DES(t4_cipher_do_des3_cbc, t4_des3_load_keys,
-+ t4_des3_cbc_encrypt, t4_des3_cbc_decrypt,
-+ tctx->ks.des3.ksch_encrypt, tctx->ks.des3.ksch_decrypt, tctx->iv)
-+
-+/* DES ECB mode. */
-+T4_CIPHER_DO_DES(t4_cipher_do_des_ecb, t4_des_load_keys,
-+ t4_des_ecb_crypt, t4_des_ecb_crypt,
-+ tctx->ks.des.ksch_encrypt, tctx->ks.des.ksch_decrypt, NULL)
-+T4_CIPHER_DO_DES(t4_cipher_do_des3_ecb, t4_des3_load_keys,
-+ t4_des3_ecb_crypt, t4_des3_ecb_crypt,
-+ tctx->ks.des3.ksch_encrypt, tctx->ks.des3.ksch_decrypt, NULL)
-+
-+
-+#endif /* COMPILE_HW_T4 */
-+#endif /* !OPENSSL_NO_HW && !OPENSSL_NO_HW_DES_T4 && !OPENSSL_NO_DES */
-Index: crypto/engine/eng_t4_err.c
-===================================================================
-diff -uNr openssl-1.0.1e/engine/eng_t4_err.c openssl-1.0.1e/engine/eng_t4_err.c
---- openssl-1.0.1e/crypto/engine/eng_t4_err.c 1970-01-01 01:00:00.000000000 +0100
-+++ openssl-1.0.1e/crypto/engine/eng_t4_err.c 2013-03-11 18:15:54.571043544 +0100
-@@ -0,0 +1,157 @@
-+/*
-+ * This product includes cryptographic software developed by the OpenSSL
-+ * Project for use in the OpenSSL Toolkit (http://www.openssl.org/).
-+ */
-+
-+/*
-+ * ====================================================================
-+ * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
-+ *
-+ * 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 above 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 acknowledgment:
-+ * "This product includes software developed by the OpenSSL Project
-+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
-+ *
-+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
-+ * endorse or promote products derived from this software without
-+ * prior written permission. For written permission, please contact
-+ * openssl-core at openssl.org.
-+ *
-+ * 5. Products derived from this software may not be called "OpenSSL"
-+ * nor may "OpenSSL" appear in their names without prior written
-+ * permission of the OpenSSL Project.
-+ *
-+ * 6. Redistributions of any form whatsoever must retain the following
-+ * acknowledgment:
-+ * "This product includes software developed by the OpenSSL Project
-+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
-+ * EXPRESSED 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 OpenSSL PROJECT OR
-+ * ITS 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.
-+ * ====================================================================
-+ */
-+
-+/*
-+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
-+ */
-+
-+#include <openssl/err.h>
-+#include "eng_t4_err.h"
-+
-+/* BEGIN ERROR CODES */
-+
-+#ifndef OPENSSL_NO_ERR
-+
-+#define ERR_FUNC(func) ERR_PACK(0, func, 0)
-+#define ERR_REASON(reason) ERR_PACK(0, 0, reason)
-+
-+static ERR_STRING_DATA t4_str_functs[] = {
-+ {ERR_FUNC(T4_F_INIT), "T4_INIT"},
-+ {ERR_FUNC(T4_F_DESTROY), "T4_DESTROY"},
-+ {ERR_FUNC(T4_F_FINISH), "T4_FINISH"},
-+ {ERR_FUNC(T4_F_CIPHER_INIT_AES), "T4_CIPHER_INIT_AES"},
-+ {ERR_FUNC(T4_F_ADD_NID), "T4_ADD_NID"},
-+ {ERR_FUNC(T4_F_GET_ALL_CIPHERS), "T4_GET_ALL_CIPHERS"},
-+ {ERR_FUNC(T4_F_CIPHER_DO_AES), "T4_CIPHER_DO_AES"},
-+ {ERR_FUNC(T4_F_CIPHER_CLEANUP), "T4_CIPHER_CLEANUP"},
-+ {ERR_FUNC(T4_F_CIPHER_INIT_DES), "T4_CIPHER_INIT_DES"},
-+ {ERR_FUNC(T4_F_CIPHER_DO_DES), "T4_CIPHER_DO_DES"},
-+ {0, NULL}
-+};
-+
-+static ERR_STRING_DATA t4_str_reasons[] = {
-+ {ERR_REASON(T4_R_CIPHER_KEY), "invalid cipher key"},
-+ {ERR_REASON(T4_R_CIPHER_NID), "invalid cipher NID"},
-+ {ERR_REASON(T4_R_IV_LEN_INCORRECT), "IV length incorrect"},
-+ {ERR_REASON(T4_R_KEY_LEN_INCORRECT), "key length incorrect"},
-+ {ERR_REASON(T4_R_ASN1_OBJECT_CREATE), "ASN1_OBJECT_create failed"},
-+ {ERR_REASON(T4_R_NOT_BLOCKSIZE_LENGTH), "blocksize length not even"},
-+ {0, NULL}
-+};
-+#endif /* OPENSSL_NO_ERR */
-+
-+
-+#ifdef T4_LIB_NAME
-+static ERR_STRING_DATA T4_lib_name[] = {
-+ {0, T4_LIB_NAME},
-+ {0, NULL}
-+};
-+#endif
-+
-+static int t4_error_code = 0;
-+static int t4_error_init = 1;
-+
-+
-+static void
-+ERR_load_t4_strings(void)
-+{
-+ if (t4_error_code == 0)
-+ t4_error_code = ERR_get_next_error_library();
-+
-+ if (t4_error_init != 0) {
-+ t4_error_init = 0;
-+
-+#ifndef OPENSSL_NO_ERR
-+ ERR_load_strings(t4_error_code, t4_str_functs);
-+ ERR_load_strings(t4_error_code, t4_str_reasons);
-+#endif
-+
-+#ifdef T4_LIB_NAME
-+ T4_lib_name->error =
-+ ERR_PACK(t4_error_code, 0, 0);
-+ ERR_load_strings(0, T4_lib_name);
-+#endif
-+ }
-+}
-+
-+
-+static void
-+ERR_unload_t4_strings(void)
-+{
-+ if (t4_error_init == 0) {
-+#ifndef OPENSSL_NO_ERR
-+ ERR_unload_strings(t4_error_code, t4_str_functs);
-+ ERR_unload_strings(t4_error_code, t4_str_reasons);
-+#endif
-+
-+#ifdef T4_LIB_NAME
-+ ERR_unload_strings(0, T4_lib_name);
-+#endif
-+ t4_error_init = 1;
-+ }
-+}
-+
-+
-+static void
-+ERR_t4_error(int function, int reason, char *file, int line)
-+{
-+ if (t4_error_init != 0) {
-+ ERR_load_t4_strings();
-+ }
-+
-+ if (t4_error_code == 0)
-+ t4_error_code = ERR_get_next_error_library();
-+ ERR_PUT_error(t4_error_code, function, reason, file, line);
-+}
-Index: crypto/engine/eng_t4_md5.c
-===================================================================
-diff -uNr openssl-1.0.1e/engine/eng_t4_md5.c openssl-1.0.1e/engine/eng_t4_md5.c
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list