PSARC 2013/034 OpenSSL 1.0.1
authorMisaki Miyashita <Misaki.Miyashita@Oracle.COM>
Thu, 27 Jun 2013 14:24:42 -0700
changeset 1373 2fd83bee8884
parent 1372 5f183c30981d
child 1374 2e547cd16aec
PSARC 2013/034 OpenSSL 1.0.1 16921388 T4 DES should be embedded in the OpenSSL upstream src
components/openssl/openssl-1.0.1/Makefile
components/openssl/openssl-1.0.1/engines/t4/eng_t4.c
components/openssl/openssl-1.0.1/engines/t4/eng_t4_des.c
components/openssl/openssl-1.0.1/engines/t4/eng_t4_des_asm.h
components/openssl/openssl-1.0.1/engines/t4/t4_des.S
components/openssl/openssl-1.0.1/inline-t4/dest4-sparcv9.pl
components/openssl/openssl-1.0.1/inline-t4/sparcv9_modes.pl
components/openssl/openssl-1.0.1/patches/openssl-1.0.1e-t4-engine.sparc-patch
components/openssl/openssl-1.0.1/patches/openssl-t4-inline.sparc-patch
--- a/components/openssl/openssl-1.0.1/Makefile	Thu Jun 27 13:48:41 2013 -0700
+++ b/components/openssl/openssl-1.0.1/Makefile	Thu Jun 27 14:24:42 2013 -0700
@@ -177,13 +177,13 @@
       $(LN) -fs $(COMPONENT_DIR)/engines/pkcs11/*.[ch]		$(@D)/crypto/engine; \
       $(LN) -fs $(COMPONENT_DIR)/engines/t4/eng_t4*.[ch]	$(@D)/crypto/engine; \
       $(LN) -fs $(COMPONENT_DIR)/engines/t4/t4_aes.S		$(@D)/crypto/aes/asm; \
-      $(LN) -fs $(COMPONENT_DIR)/engines/t4/t4_des.S		$(@D)/crypto/des/asm; \
       $(LN) -fs $(COMPONENT_DIR)/engines/t4/t4_md5.S		$(@D)/crypto/md5/asm; \
       $(LN) -fs $(COMPONENT_DIR)/engines/t4/t4_sha?.S		$(@D)/crypto/sha/asm; \
       $(LN) -fs $(COMPONENT_DIR)/wanboot-openssl/wanboot-stubs.c	$(@D)/crypto; \
       $(LN) -fs $(COMPONENT_DIR)/inline-t4/sparc_arch.h		$(@D)/crypto/; \
       $(LN) -fs $(COMPONENT_DIR)/inline-t4/md5-sparcv9.pl		$(@D)/crypto/md5/asm; \
       $(LN) -fs $(COMPONENT_DIR)/inline-t4/aest4-sparcv9.pl		$(@D)/crypto/aes/asm; \
+      $(LN) -fs $(COMPONENT_DIR)/inline-t4/dest4-sparcv9.pl		$(@D)/crypto/des/asm; \
       $(LN) -fs $(COMPONENT_DIR)/inline-t4/sparcv9_modes.pl		$(@D)/crypto/perlasm; )
 
 # OpenSSL for wanboot is built on sparc only.
@@ -246,7 +246,8 @@
     crypto/conf/conf_mod.o crypto/cpt_err.o crypto/cryptlib.o \
     crypto/des/cfb64ede.o crypto/des/cfb64enc.o crypto/des/cfb_enc.o \
     crypto/des/des_enc-sparc.o crypto/des/ecb3_enc.o crypto/des/ecb_enc.o \
-    crypto/des/ofb64ede.o crypto/des/ofb64enc.o crypto/des/set_key.o \
+    crypto/des/ofb64ede.o crypto/des/ofb64enc.o crypto/des/dest4-sparcv9.o \
+    crypto/des/set_key.o \
     crypto/des/xcbc_enc.o crypto/dh/dh_ameth.o crypto/dh/dh_asn1.o \
     crypto/dh/dh_check.o crypto/dh/dh_err.o crypto/dh/dh_gen.o \
     crypto/dh/dh_key.o crypto/dh/dh_lib.o crypto/dh/dh_pmeth.o \
--- a/components/openssl/openssl-1.0.1/engines/t4/eng_t4.c	Thu Jun 27 13:48:41 2013 -0700
+++ b/components/openssl/openssl-1.0.1/engines/t4/eng_t4.c	Thu Jun 27 14:24:42 2013 -0700
@@ -58,7 +58,7 @@
  */
 
 /*
- * This engine supports SPARC microprocessors that provide T4 DES and MONTMUL
+ * This engine supports SPARC microprocessors that provide T4 MONTMUL
  * instructions, such as the T4 microprocessor.
  */
 
@@ -117,7 +117,7 @@
 #ifndef	DYNAMIC_ENGINE
 #pragma inline(t4_bind)
 #endif
-static void t4_instructions_present(_Bool *des_present, _Bool *montmul_present);
+static void t4_instructions_present(_Bool *montmul_present);
 #pragma inline(t4_instructions_present)
 
 /* RSA_METHOD structure used by ENGINE_set_RSA() */
@@ -129,111 +129,24 @@
 /* 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[] = {
-#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 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
- */
-
-
-#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 */
-
-
 /*
  * Utility Functions
  */
 
 /*
- * Set des_present and montmul_present to B_FALSE or B_TRUE
- * depending on whether the current SPARC processor supports DES
- * and MONTMUL, respectively.
+ * Set montmul_present to B_FALSE or B_TRUE depending on whether the
+ * current SPARC processor supports MONTMUL.
  */
 static void
-t4_instructions_present(_Bool *des_present, _Bool *montmul_present)
+t4_instructions_present(_Bool *montmul_present)
 {
-#ifdef	OPENSSL_NO_DES
-#undef	AV_SPARC_DES
-#define	AV_SPARC_DES	0
-#endif
 	uint_t		ui;
 
 	(void) getisax(&ui, 1);
-	*des_present = ((ui & AV_SPARC_DES) != 0);
 	*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) {
-#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 */
-	default:
-		/* cipher not supported */
-		*cipher = NULL;
-		return (0);
-	}
-
-	return (1);
-}
-
 
 /*
  * Is the t4 engine available?
@@ -246,7 +159,6 @@
 	return (1);
 }
 
-
 /* Passed to ENGINE_set_destroy_function(). */
 /* ARGSUSED */
 static int
@@ -265,29 +177,13 @@
 static int
 t4_bind(ENGINE *e)
 {
-	_Bool des_engage, montmul_engage;
-
-#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 */
+	_Bool montmul_engage;
 
 	/* Register T4 engine ID, name, and functions */
 	if (!ENGINE_set_id(e, ENGINE_T4_ID) ||
 	    !ENGINE_set_name(e,
-	    des_engage ? ENGINE_T4_NAME : ENGINE_NO_T4_NAME) ||
+	    montmul_engage ? ENGINE_T4_NAME : ENGINE_NO_T4_NAME) ||
 	    !ENGINE_set_init_function(e, t4_init) ||
-	    (des_engage && !ENGINE_set_ciphers(e, t4_get_all_ciphers)) ||
 #ifndef OPENSSL_NO_RSA
 	    (montmul_engage && !ENGINE_set_RSA(e, t4_RSA())) ||
 #endif	/* OPENSSL_NO_RSA */
--- a/components/openssl/openssl-1.0.1/engines/t4/eng_t4_des.c	Thu Jun 27 13:48:41 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,486 +0,0 @@
-/*
- * 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
- *    [email protected].
- *
- * 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 */
--- a/components/openssl/openssl-1.0.1/engines/t4/eng_t4_des_asm.h	Thu Jun 27 13:48:41 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/*
- * 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
- *    [email protected].
- *
- * 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 */
--- a/components/openssl/openssl-1.0.1/engines/t4/t4_des.S	Thu Jun 27 13:48:41 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,786 +0,0 @@
-/*
- * ====================================================================
- * 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
- *    [email protected].
- *
- * 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.
- */
-
-/*LINTLIBRARY*/
-
-#if defined(lint) || defined(__lint)
-
-#include <sys/types.h>
-#include "../engine/eng_t4_des_asm.h"
-
-/*ARGSUSED*/
-void t4_des_expand(uint64_t *rk, const uint32_t *key)
-{ return; }
-
-/*ARGSUSED*/
-void t4_des_encrypt(const uint64_t *rk, const uint64_t *pt, uint64_t *ct)
-{ return; }
-
-
-/*ARGSUSED*/
-void t4_des_load_keys(uint64_t *ks)
-{ return; }
-
-/*ARGSUSED*/
-void t4_des_ecb_crypt(uint64_t *ks, uint64_t *asm_in,
-    uint64_t *asm_out, size_t amount_to_crypt, uint64_t *iv)
-{ return; }
-
-/*ARGSUSED*/
-void t4_des_cbc_encrypt(uint64_t *ks, uint64_t *asm_in,
-    uint64_t *asm_out, size_t amount_to_crypt, uint64_t *iv)
-{ return; }
-
-/*ARGSUSED*/
-void t4_des_cbc_decrypt(uint64_t *ks, uint64_t *asm_in,
-    uint64_t *asm_out, size_t amount_to_crypt, uint64_t *iv)
-{ return; }
-
-/*ARGSUSED*/
-void t4_des3_load_keys(uint64_t *ks)
-{ return; }
-
-/*ARGSUSED*/
-void t4_des3_ecb_crypt(uint64_t *ks, uint64_t *asm_in,
-    uint64_t *asm_out, size_t amount_to_crypt, uint64_t *iv)
-{ return; }
-
-/*ARGSUSED*/
-void t4_des3_cbc_encrypt(uint64_t *ks, uint64_t *asm_in,
-    uint64_t *asm_out, size_t amount_to_crypt, uint64_t *iv)
-{ return; }
-
-/*ARGSUSED*/
-void t4_des3_cbc_decrypt(uint64_t *ks, uint64_t *asm_in,
-    uint64_t *asm_out, size_t amount_to_crypt, uint64_t *iv)
-{ return; }
-
-#else	/* lint || __lint */
-
-#include <sys/asm_linkage.h>
-
-
-	ENTRY(t4_des_expand)
-
-!load key
-	ld	[%o1], %f0
-	ld	[%o1 + 0x4], %f1
-
-!expand the key
-	!des_kexpand %f0, 0, %f0
-	!des_kexpand %f0, 1, %f2
-	!des_kexpand %f2, 3, %f6
-	!des_kexpand %f2, 2, %f4
-	!des_kexpand %f6, 3, %f10
-	!des_kexpand %f6, 2, %f8
-	!des_kexpand %f10, 3, %f14
-	!des_kexpand %f10, 2, %f12
-	!des_kexpand %f14, 1, %f16
-	!des_kexpand %f16, 3, %f20
-	!des_kexpand %f16, 2, %f18
-	!des_kexpand %f20, 3, %f24
-	!des_kexpand %f20, 2, %f22
-	!des_kexpand %f24, 3, %f28
-	!des_kexpand %f24, 2, %f26
-	!des_kexpand %f28, 1, %f30
-	.byte	0x81, 0xb0, 0x26, 0xc0
-	.byte	0x85, 0xb0, 0x26, 0xc1
-	.byte	0x8d, 0xb0, 0xa6, 0xc3
-	.byte	0x89, 0xb0, 0xa6, 0xc2
-	.byte	0x95, 0xb1, 0xa6, 0xc3
-	.byte	0x91, 0xb1, 0xa6, 0xc2
-	.byte	0x9d, 0xb2, 0xa6, 0xc3
-	.byte	0x99, 0xb2, 0xa6, 0xc2
-	.byte	0xa1, 0xb3, 0xa6, 0xc1
-	.byte	0xa9, 0xb4, 0x26, 0xc3
-	.byte	0xa5, 0xb4, 0x26, 0xc2
-	.byte	0xb1, 0xb5, 0x26, 0xc3
-	.byte	0xad, 0xb5, 0x26, 0xc2
-	.byte	0xb9, 0xb6, 0x26, 0xc3
-	.byte	0xb5, 0xb6, 0x26, 0xc2
-	.byte	0xbd, 0xb7, 0x26, 0xc1
-
-!copy expanded key back into array
-	std	%f0, [%o0]
-	std	%f2, [%o0 + 0x8]
-	std	%f4, [%o0 + 0x10]
-	std	%f6, [%o0 + 0x18]
-	std	%f8, [%o0 + 0x20]
-	std	%f10, [%o0 + 0x28]
-	std	%f12, [%o0 + 0x30]
-	std	%f14, [%o0 + 0x38]
-	std	%f16, [%o0 + 0x40]
-	std	%f18, [%o0 + 0x48]
-	std	%f20, [%o0 + 0x50]
-	std	%f22, [%o0 + 0x58]
-	std	%f24, [%o0 + 0x60]
-	std	%f26, [%o0 + 0x68]
-	std	%f28, [%o0 + 0x70]
-	retl
-	std	%f30, [%o0 + 0x78]
-
-	SET_SIZE(t4_des_expand)
-
-
-	ENTRY(t4_des_encrypt)
-
-!load expanded key
-	ldd	[%o0], %f0
-	ldd	[%o0 + 0x8], %f2
-	ldd	[%o0 + 0x10], %f4
-	ldd	[%o0 + 0x18], %f6
-	ldd	[%o0 + 0x20], %f8
-	ldd	[%o0 + 0x28], %f10
-	ldd	[%o0 + 0x30], %f12
-	ldd	[%o0 + 0x38], %f14
-	ldd	[%o0 + 0x40], %f16
-	ldd	[%o0 + 0x48], %f18
-	ldd	[%o0 + 0x50], %f20
-	ldd	[%o0 + 0x58], %f22
-	ldd	[%o0 + 0x60], %f24
-	ldd	[%o0 + 0x68], %f26
-	ldd	[%o0 + 0x70], %f28
-	ldd	[%o0 + 0x78], %f30
-
-!load input
-	ldd	[%o1], %f32
-
-!perform the cipher transformation
-	!des_ip	%f32, %f32
-	!des_round %f0,  %f2,  %f32, %f32
-	!des_round %f4,  %f6,  %f32, %f32
-	!des_round %f8,  %f10, %f32, %f32
-	!des_round %f12, %f14, %f32, %f32
-	!des_round %f16, %f18, %f32, %f32
-	!des_round %f20, %f22, %f32, %f32
-	!des_round %f24, %f26, %f32, %f32
-	!des_round %f28, %f30, %f32, %f32
-	!des_iip	%f32, %f32
-	.byte	0x83, 0xb0, 0x66, 0x80
-	.byte	0x82, 0xc8, 0x03, 0x22
-	.byte	0x82, 0xc9, 0x03, 0x26
-	.byte	0x82, 0xca, 0x03, 0x2a
-	.byte	0x82, 0xcb, 0x03, 0x2e
-	.byte	0x82, 0xcc, 0x03, 0x32
-	.byte	0x82, 0xcd, 0x03, 0x36
-	.byte	0x82, 0xce, 0x03, 0x3a
-	.byte	0x82, 0xcf, 0x03, 0x3e
-	.byte	0x83, 0xb0, 0x66, 0xa0
-
-!copy output back to array
-	retl
-	std	%f32, [%o2]
-
-	SET_SIZE(t4_des_encrypt)
-
-	ENTRY(t4_des_load_keys)
-
-!load expanded key
-	ldd	[%o0], %f0
-	ldd	[%o0 + 0x8], %f2
-	ldd	[%o0 + 0x10], %f4
-	ldd	[%o0 + 0x18], %f6
-	ldd	[%o0 + 0x20], %f8
-	ldd	[%o0 + 0x28], %f10
-	ldd	[%o0 + 0x30], %f12
-	ldd	[%o0 + 0x38], %f14
-	ldd	[%o0 + 0x40], %f16
-	ldd	[%o0 + 0x48], %f18
-	ldd	[%o0 + 0x50], %f20
-	ldd	[%o0 + 0x58], %f22
-	ldd	[%o0 + 0x60], %f24
-	ldd	[%o0 + 0x68], %f26
-	ldd	[%o0 + 0x70], %f28
-	retl
-	ldd	[%o0 + 0x78], %f30
-
-	SET_SIZE(t4_des_load_keys)
-
-	ENTRY(t4_des3_load_keys)
-
-!load first 30 pieces of the expanded key
-	ldd	[%o0], %f0
-	ldd	[%o0 + 0x8], %f2
-	ldd	[%o0 + 0x10], %f4
-	ldd	[%o0 + 0x18], %f6
-	ldd	[%o0 + 0x20], %f8
-	ldd	[%o0 + 0x28], %f10
-	ldd	[%o0 + 0x30], %f12
-	ldd	[%o0 + 0x38], %f14
-	ldd	[%o0 + 0x40], %f16
-	ldd	[%o0 + 0x48], %f18
-	ldd	[%o0 + 0x50], %f20
-	ldd	[%o0 + 0x58], %f22
-	ldd	[%o0 + 0x60], %f24
-	ldd	[%o0 + 0x68], %f26
-	ldd	[%o0 + 0x70], %f28
-	ldd	[%o0 + 0x78], %f30
-	ldd	[%o0 + 0x80], %f32
-	ldd	[%o0 + 0x88], %f34
-	ldd	[%o0 + 0x90], %f36
-	ldd	[%o0 + 0x98], %f38
-	ldd	[%o0 + 0xa0], %f40
-	ldd	[%o0 + 0xa8], %f42
-	ldd	[%o0 + 0xb0], %f44
-	ldd	[%o0 + 0xb8], %f46
-	ldd	[%o0 + 0xc0], %f48
-	ldd	[%o0 + 0xc8], %f50
-	ldd	[%o0 + 0xd0], %f52
-	ldd	[%o0 + 0xd8], %f54
-	ldd	[%o0 + 0xe0], %f56
-	retl
-	ldd	[%o0 + 0xe8], %f58
-
-	SET_SIZE(t4_des3_load_keys)
-
-	ENTRY(t4_des_ecb_crypt)
-
-des_ecb_loop:
-!load input
-	ldd	[%o1], %f62
-
-!perform the cipher transformation
-	!des_ip	%f62, %f62
-	!des_round %f0,  %f2,  %f62, %f62
-	!des_round %f4,  %f6,  %f62, %f62
-	!des_round %f8,  %f10, %f62, %f62
-	!des_round %f12, %f14, %f62, %f62
-	!des_round %f16, %f18, %f62, %f62
-	!des_round %f20, %f22, %f62, %f62
-	!des_round %f24, %f26, %f62, %f62
-	!des_round %f28, %f30, %f62, %f62
-	!des_iip	%f62, %f62
-	.byte	0xbf, 0xb7, 0xe6, 0x80
-	.byte	0xbe, 0xc8, 0x3f, 0x22
-	.byte	0xbe, 0xc9, 0x3f, 0x26
-	.byte	0xbe, 0xca, 0x3f, 0x2a
-	.byte	0xbe, 0xcb, 0x3f, 0x2e
-	.byte	0xbe, 0xcc, 0x3f, 0x32
-	.byte	0xbe, 0xcd, 0x3f, 0x36
-	.byte	0xbe, 0xce, 0x3f, 0x3a
-	.byte	0xbe, 0xcf, 0x3f, 0x3e
-	.byte	0xbf, 0xb7, 0xe6, 0xa0
-
-!copy output back to array
-	std	%f62, [%o2]
-	sub	%o3, 8, %o3
-	add	%o1, 8, %o1
-	brnz	%o3, des_ecb_loop
-	add	%o2, 8, %o2
-
-	retl
-	nop
-
-	SET_SIZE(t4_des_ecb_crypt)
-
-
-	ENTRY(t4_des_cbc_encrypt)
-
-	ldd	[%o4], %f60
-des_cbc_encrypt_loop:
-!load input
-	ldd	[%o1], %f58
-	fxor	%f58, %f60, %f62
-
-!perform the cipher transformation
-	!des_ip	%f62, %f62
-	!des_round %f0,  %f2,  %f62, %f62
-	!des_round %f4,  %f6,  %f62, %f62
-	!des_round %f8,  %f10, %f62, %f62
-	!des_round %f12, %f14, %f62, %f62
-	!des_round %f16, %f18, %f62, %f62
-	!des_round %f20, %f22, %f62, %f62
-	!des_round %f24, %f26, %f62, %f62
-	!des_round %f28, %f30, %f62, %f62
-	!des_iip	%f62, %f60
-	.byte	0xbf, 0xb7, 0xe6, 0x80
-	.byte	0xbe, 0xc8, 0x3f, 0x22
-	.byte	0xbe, 0xc9, 0x3f, 0x26
-	.byte	0xbe, 0xca, 0x3f, 0x2a
-	.byte	0xbe, 0xcb, 0x3f, 0x2e
-	.byte	0xbe, 0xcc, 0x3f, 0x32
-	.byte	0xbe, 0xcd, 0x3f, 0x36
-	.byte	0xbe, 0xce, 0x3f, 0x3a
-	.byte	0xbe, 0xcf, 0x3f, 0x3e
-	.byte	0xbb, 0xb7, 0xe6, 0xa0
-
-!copy output back to array
-	std	%f60, [%o2]
-	sub	%o3, 8, %o3
-	add	%o1, 8, %o1
-	brnz	%o3, des_cbc_encrypt_loop
-	add	%o2, 8, %o2
-
-	retl
-	std	%f60, [%o4]
-
-	SET_SIZE(t4_des_cbc_encrypt)
-
-
-
-	ENTRY(t4_des_cbc_decrypt)
-
-	ldd	[%o4], %f60
-des_cbc_decrypt_loop:
-!load input
-	ldd	[%o1], %f62
-	ldx	[%o1], %o5
-
-!perform the cipher transformation
-	!des_ip	%f62, %f62
-	!des_round %f0,  %f2,  %f62, %f62
-	!des_round %f4,  %f6,  %f62, %f62
-	!des_round %f8,  %f10, %f62, %f62
-	!des_round %f12, %f14, %f62, %f62
-	!des_round %f16, %f18, %f62, %f62
-	!des_round %f20, %f22, %f62, %f62
-	!des_round %f24, %f26, %f62, %f62
-	!des_round %f28, %f30, %f62, %f62
-	!des_iip	%f62, %f62
-	.byte	0xbf, 0xb7, 0xe6, 0x80
-	.byte	0xbe, 0xc8, 0x3f, 0x22
-	.byte	0xbe, 0xc9, 0x3f, 0x26
-	.byte	0xbe, 0xca, 0x3f, 0x2a
-	.byte	0xbe, 0xcb, 0x3f, 0x2e
-	.byte	0xbe, 0xcc, 0x3f, 0x32
-	.byte	0xbe, 0xcd, 0x3f, 0x36
-	.byte	0xbe, 0xce, 0x3f, 0x3a
-	.byte	0xbe, 0xcf, 0x3f, 0x3e
-	.byte	0xbf, 0xb7, 0xe6, 0xa0
-	fxor	%f60, %f62, %f62
-	movxtod	%o5, %f60
-
-!copy output back to array
-	std	%f62, [%o2]
-	sub	%o3, 8, %o3
-	add	%o1, 8, %o1
-	brnz	%o3, des_cbc_decrypt_loop
-	add	%o2, 8, %o2
-
-	retl
-	std	%f60, [%o4]
-
-	SET_SIZE(t4_des_cbc_decrypt)
-
-
-
-	ENTRY(t4_des3_ecb_crypt)
-
-des3_ecb_loop:
-!load input
-	ldd	[%o1], %f62
-
-!perform the cipher transformation
-	!des_ip	%f62, %f62
-	!des_round %f0,  %f2,  %f62, %f62
-	!des_round %f4,  %f6,  %f62, %f62
-	!des_round %f8,  %f10, %f62, %f62
-	!des_round %f12, %f14, %f62, %f62
-	!des_round %f16, %f18, %f62, %f62
-	.byte	0xbf, 0xb7, 0xe6, 0x80
-	.byte	0xbe, 0xc8, 0x3f, 0x22
-	.byte	0xbe, 0xc9, 0x3f, 0x26
-	.byte	0xbe, 0xca, 0x3f, 0x2a
-	.byte	0xbe, 0xcb, 0x3f, 0x2e
-	.byte	0xbe, 0xcc, 0x3f, 0x32
-
-	ldd	[%o0 + 0xf0], %f16
-	ldd	[%o0 + 0xf8], %f18
-	!des_round %f20, %f22, %f62, %f62
-	.byte	0xbe, 0xcd, 0x3f, 0x36
-	ldd	[%o0 + 0x100], %f20
-	ldd	[%o0 + 0x108], %f22
-	!des_round %f24, %f26, %f62, %f62
-	.byte	0xbe, 0xce, 0x3f, 0x3a
-	ldd	[%o0 + 0x110], %f24
-	ldd	[%o0 + 0x118], %f26
-	!des_round %f28, %f30, %f62, %f62
-	.byte	0xbe, 0xcf, 0x3f, 0x3e
-	ldd	[%o0 + 0x120], %f28
-	ldd	[%o0 + 0x128], %f30
-
-	!des_iip	%f62, %f62
-	!des_ip	%f62, %f62
-	.byte	0xbf, 0xb7, 0xe6, 0xa0
-	.byte	0xbf, 0xb7, 0xe6, 0x80
-
-	!des_round %f32, %f34, %f62, %f62
-	.byte	0xbe, 0xc8, 0x7f, 0x23
-	ldd	[%o0 + 0x130], %f0
-	ldd	[%o0 + 0x138], %f2
-	!des_round %f36, %f38,  %f62, %f62
-	.byte	0xbe, 0xc9, 0x7f, 0x27
-	ldd	[%o0 + 0x140], %f4
-	ldd	[%o0 + 0x148], %f6
-	!des_round %f40, %f42, %f62, %f62
-	.byte	0xbe, 0xca, 0x7f, 0x2b
-	ldd	[%o0 + 0x150], %f8
-	ldd	[%o0 + 0x158], %f10
-	!des_round %f44, %f46, %f62, %f62
-	.byte	0xbe, 0xcb, 0x7f, 0x2f
-	ldd	[%o0 + 0x160], %f12
-	ldd	[%o0 + 0x168], %f14
-	!des_round %f48, %f50, %f62, %f62
-	!des_round %f52, %f54, %f62, %f62
-	!des_round %f56, %f58, %f62, %f62
-	!des_round %f16, %f18, %f62, %f62
-	.byte	0xbe, 0xcc, 0x7f, 0x33
-	.byte	0xbe, 0xcd, 0x7f, 0x37
-	.byte	0xbe, 0xce, 0x7f, 0x3b
-	.byte	0xbe, 0xcc, 0x3f, 0x32
-	ldd	[%o0 + 0x170], %f16
-	ldd	[%o0 + 0x178], %f18
-
-	!des_iip	%f62, %f62
-	!des_ip	%f62, %f62
-	.byte	0xbf, 0xb7, 0xe6, 0xa0
-	.byte	0xbf, 0xb7, 0xe6, 0x80
-
-	!des_round %f20, %f22, %f62, %f62
-	.byte	0xbe, 0xcd, 0x3f, 0x36
-	ldd	[%o0 + 0x50], %f20
-	ldd	[%o0 + 0x58], %f22
-	!des_round %f24, %f26, %f62, %f62
-	.byte	0xbe, 0xce, 0x3f, 0x3a
-	ldd	[%o0 + 0x60], %f24
-	ldd	[%o0 + 0x68], %f26
-	!des_round %f28, %f30, %f62, %f62
-	.byte	0xbe, 0xcf, 0x3f, 0x3e
-	ldd	[%o0 + 0x70], %f28
-	ldd	[%o0 + 0x78], %f30
-	!des_round %f0,  %f2,  %f62, %f62
-	.byte	0xbe, 0xc8, 0x3f, 0x22
-	ldd	[%o0], %f0
-	ldd	[%o0 + 0x8], %f2
-	!des_round %f4,  %f6,  %f62, %f62
-	.byte	0xbe, 0xc9, 0x3f, 0x26
-
-	ldd	[%o0 + 0x10], %f4
-	ldd	[%o0 + 0x18], %f6
-	!des_round %f8,  %f10, %f62, %f62
-	.byte	0xbe, 0xca, 0x3f, 0x2a
-	ldd	[%o0 + 0x20], %f8
-	ldd	[%o0 + 0x28], %f10
-	!des_round %f12, %f14, %f62, %f62
-	.byte	0xbe, 0xcb, 0x3f, 0x2e
-	ldd	[%o0 + 0x30], %f12
-	ldd	[%o0 + 0x38], %f14
-	!des_round %f16, %f18, %f62, %f62
-	.byte	0xbe, 0xcc, 0x3f, 0x32
-	ldd	[%o0 + 0x40], %f16
-	ldd	[%o0 + 0x48], %f18
-
-	!des_iip	%f62, %f62
-	.byte	0xbf, 0xb7, 0xe6, 0xa0
-
-!copy output back to array
-	std	%f62, [%o2]
-	sub	%o3, 8, %o3
-	add	%o1, 8, %o1
-	brnz	%o3, des3_ecb_loop
-	add	%o2, 8, %o2
-
-	retl
-	nop
-
-	SET_SIZE(t4_des3_ecb_crypt)
-
-
-	ENTRY(t4_des3_cbc_encrypt)
-
-	ldd	[%o4], %f62
-des3_cbc_encrypt_loop:
-!load input
-	ldd	[%o1], %f60
-	fxor	%f60, %f62, %f62
-
-!perform the cipher transformation
-	!des_ip	%f62, %f62
-	.byte	0xbf, 0xb7, 0xe6, 0x80
-	!des_round %f0,  %f2,  %f62, %f62
-	!des_round %f4,  %f6,  %f62, %f62
-	!des_round %f8,  %f10, %f62, %f62
-	!des_round %f12, %f14, %f62, %f62
-	!des_round %f16, %f18, %f62, %f62
-	.byte	0xbe, 0xc8, 0x3f, 0x22
-	.byte	0xbe, 0xc9, 0x3f, 0x26
-	.byte	0xbe, 0xca, 0x3f, 0x2a
-	.byte	0xbe, 0xcb, 0x3f, 0x2e
-	.byte	0xbe, 0xcc, 0x3f, 0x32
-	ldd	[%o0 + 0xf0], %f16
-	ldd	[%o0 + 0xf8], %f18
-	!des_round %f20, %f22, %f62, %f62
-	.byte	0xbe, 0xcd, 0x3f, 0x36
-	ldd	[%o0 + 0x100], %f20
-	ldd	[%o0 + 0x108], %f22
-	!des_round %f24, %f26, %f62, %f62
-	.byte	0xbe, 0xce, 0x3f, 0x3a
-	ldd	[%o0 + 0x110], %f24
-	ldd	[%o0 + 0x118], %f26
-	!des_round %f28, %f30, %f62, %f62
-	.byte	0xbe, 0xcf, 0x3f, 0x3e
-	ldd	[%o0 + 0x120], %f28
-	ldd	[%o0 + 0x128], %f30
-
-	!des_iip	%f62, %f62
-	!des_ip	%f62, %f62
-	.byte	0xbf, 0xb7, 0xe6, 0xa0
-	.byte	0xbf, 0xb7, 0xe6, 0x80
-
-	!des_round %f32, %f34, %f62, %f62
-	.byte	0xbe, 0xc8, 0x7f, 0x23
-	ldd	[%o0 + 0x130], %f0
-	ldd	[%o0 + 0x138], %f2
-	!des_round %f36, %f38,  %f62, %f62
-	.byte	0xbe, 0xc9, 0x7f, 0x27
-	ldd	[%o0 + 0x140], %f4
-	ldd	[%o0 + 0x148], %f6
-	!des_round %f40, %f42, %f62, %f62
-	.byte	0xbe, 0xca, 0x7f, 0x2b
-	ldd	[%o0 + 0x150], %f8
-	ldd	[%o0 + 0x158], %f10
-	!des_round %f44, %f46, %f62, %f62
-	.byte	0xbe, 0xcb, 0x7f, 0x2f
-	ldd	[%o0 + 0x160], %f12
-	ldd	[%o0 + 0x168], %f14
-	!des_round %f48, %f50, %f62, %f62
-	!des_round %f52, %f54, %f62, %f62
-	!des_round %f56, %f58, %f62, %f62
-	!des_round %f16, %f18, %f62, %f62
-	.byte	0xbe, 0xcc, 0x7f, 0x33
-	.byte	0xbe, 0xcd, 0x7f, 0x37
-	.byte	0xbe, 0xce, 0x7f, 0x3b
-	.byte	0xbe, 0xcc, 0x3f, 0x32
-	ldd	[%o0 + 0x170], %f16
-	ldd	[%o0 + 0x178], %f18
-
-	!des_iip	%f62, %f62
-	!des_ip	%f62, %f62
-	.byte	0xbf, 0xb7, 0xe6, 0xa0
-	.byte	0xbf, 0xb7, 0xe6, 0x80
-
-	!des_round %f20, %f22, %f62, %f62
-	.byte	0xbe, 0xcd, 0x3f, 0x36
-	ldd	[%o0 + 0x50], %f20
-	ldd	[%o0 + 0x58], %f22
-	!des_round %f24, %f26, %f62, %f62
-	.byte	0xbe, 0xce, 0x3f, 0x3a
-	ldd	[%o0 + 0x60], %f24
-	ldd	[%o0 + 0x68], %f26
-	!des_round %f28, %f30, %f62, %f62
-	.byte	0xbe, 0xcf, 0x3f, 0x3e
-	ldd	[%o0 + 0x70], %f28
-	ldd	[%o0 + 0x78], %f30
-	!des_round %f0,  %f2,  %f62, %f62
-	.byte	0xbe, 0xc8, 0x3f, 0x22
-	ldd	[%o0], %f0
-	ldd	[%o0 + 0x8], %f2
-	!des_round %f4,  %f6,  %f62, %f62
-	.byte	0xbe, 0xc9, 0x3f, 0x26
-	ldd	[%o0 + 0x10], %f4
-	ldd	[%o0 + 0x18], %f6
-	!des_round %f8,  %f10, %f62, %f62
-	.byte	0xbe, 0xca, 0x3f, 0x2a
-	ldd	[%o0 + 0x20], %f8
-	ldd	[%o0 + 0x28], %f10
-	!des_round %f12, %f14, %f62, %f62
-	.byte	0xbe, 0xcb, 0x3f, 0x2e
-	ldd	[%o0 + 0x30], %f12
-	ldd	[%o0 + 0x38], %f14
-	!des_round %f16, %f18, %f62, %f62
-	.byte	0xbe, 0xcc, 0x3f, 0x32
-	ldd	[%o0 + 0x40], %f16
-	ldd	[%o0 + 0x48], %f18
-
-	!des_iip	%f62, %f62
-	.byte	0xbf, 0xb7, 0xe6, 0xa0
-
-!copy output back to array
-	std	%f62, [%o2]
-	sub	%o3, 8, %o3
-	add	%o1, 8, %o1
-	brnz	%o3, des3_cbc_encrypt_loop
-	add	%o2, 8, %o2
-
-	retl
-	std	%f62, [%o4]
-
-	SET_SIZE(t4_des3_cbc_encrypt)
-
-
-	ENTRY(t4_des3_cbc_decrypt)
-
-	ldd	[%o4], %f60
-des3_cbc_decrypt_loop:
-!load input
-	ldx	[%o1], %o5
-	movxtod	%o5, %f62
-
-!perform the cipher transformation
-	!des_ip	%f62, %f62
-	.byte	0xbf, 0xb7, 0xe6, 0x80
-	!des_round %f0,  %f2,  %f62, %f62
-	!des_round %f4,  %f6,  %f62, %f62
-	!des_round %f8,  %f10, %f62, %f62
-	!des_round %f12, %f14, %f62, %f62
-	!des_round %f16, %f18, %f62, %f62
-	.byte	0xbe, 0xc8, 0x3f, 0x22
-	.byte	0xbe, 0xc9, 0x3f, 0x26
-	.byte	0xbe, 0xca, 0x3f, 0x2a
-	.byte	0xbe, 0xcb, 0x3f, 0x2e
-	.byte	0xbe, 0xcc, 0x3f, 0x32
-	ldd	[%o0 + 0xf0], %f16
-	ldd	[%o0 + 0xf8], %f18
-	!des_round %f20, %f22, %f62, %f62
-	.byte	0xbe, 0xcd, 0x3f, 0x36
-	ldd	[%o0 + 0x100], %f20
-	ldd	[%o0 + 0x108], %f22
-	!des_round %f24, %f26, %f62, %f62
-	.byte	0xbe, 0xce, 0x3f, 0x3a
-	ldd	[%o0 + 0x110], %f24
-	ldd	[%o0 + 0x118], %f26
-	!des_round %f28, %f30, %f62, %f62
-	.byte	0xbe, 0xcf, 0x3f, 0x3e
-	ldd	[%o0 + 0x120], %f28
-	ldd	[%o0 + 0x128], %f30
-
-	!des_iip	%f62, %f62
-	!des_ip	%f62, %f62
-	.byte	0xbf, 0xb7, 0xe6, 0xa0
-	.byte	0xbf, 0xb7, 0xe6, 0x80
-
-	!des_round %f32, %f34, %f62, %f62
-	.byte	0xbe, 0xc8, 0x7f, 0x23
-	ldd	[%o0 + 0x130], %f0
-	ldd	[%o0 + 0x138], %f2
-	!des_round %f36, %f38,  %f62, %f62
-	.byte	0xbe, 0xc9, 0x7f, 0x27
-	ldd	[%o0 + 0x140], %f4
-	ldd	[%o0 + 0x148], %f6
-	!des_round %f40, %f42, %f62, %f62
-	.byte	0xbe, 0xca, 0x7f, 0x2b
-	ldd	[%o0 + 0x150], %f8
-	ldd	[%o0 + 0x158], %f10
-	!des_round %f44, %f46, %f62, %f62
-	.byte	0xbe, 0xcb, 0x7f, 0x2f
-	ldd	[%o0 + 0x160], %f12
-	ldd	[%o0 + 0x168], %f14
-	!des_round %f48, %f50, %f62, %f62
-	!des_round %f52, %f54, %f62, %f62
-	!des_round %f56, %f58, %f62, %f62
-	!des_round %f16, %f18, %f62, %f62
-	.byte	0xbe, 0xcc, 0x7f, 0x33
-	.byte	0xbe, 0xcd, 0x7f, 0x37
-	.byte	0xbe, 0xce, 0x7f, 0x3b
-	.byte	0xbe, 0xcc, 0x3f, 0x32
-	ldd	[%o0 + 0x170], %f16
-	ldd	[%o0 + 0x178], %f18
-
-	!des_iip	%f62, %f62
-	!des_ip	%f62, %f62
-	.byte	0xbf, 0xb7, 0xe6, 0xa0
-	.byte	0xbf, 0xb7, 0xe6, 0x80
-
-	!des_round %f20, %f22, %f62, %f62
-	.byte	0xbe, 0xcd, 0x3f, 0x36
-	ldd	[%o0 + 0x50], %f20
-	ldd	[%o0 + 0x58], %f22
-	!des_round %f24, %f26, %f62, %f62
-	.byte	0xbe, 0xce, 0x3f, 0x3a
-	ldd	[%o0 + 0x60], %f24
-	ldd	[%o0 + 0x68], %f26
-	!des_round %f28, %f30, %f62, %f62
-	.byte	0xbe, 0xcf, 0x3f, 0x3e
-	ldd	[%o0 + 0x70], %f28
-	ldd	[%o0 + 0x78], %f30
-	!des_round %f0,  %f2,  %f62, %f62
-	.byte	0xbe, 0xc8, 0x3f, 0x22
-	ldd	[%o0], %f0
-	ldd	[%o0 + 0x8], %f2
-	!des_round %f4,  %f6,  %f62, %f62
-	.byte	0xbe, 0xc9, 0x3f, 0x26
-	ldd	[%o0 + 0x10], %f4
-	ldd	[%o0 + 0x18], %f6
-	!des_round %f8,  %f10, %f62, %f62
-	.byte	0xbe, 0xca, 0x3f, 0x2a
-	ldd	[%o0 + 0x20], %f8
-	ldd	[%o0 + 0x28], %f10
-	!des_round %f12, %f14, %f62, %f62
-	.byte	0xbe, 0xcb, 0x3f, 0x2e
-	ldd	[%o0 + 0x30], %f12
-	ldd	[%o0 + 0x38], %f14
-	!des_round %f16, %f18, %f62, %f62
-	.byte	0xbe, 0xcc, 0x3f, 0x32
-	ldd	[%o0 + 0x40], %f16
-	ldd	[%o0 + 0x48], %f18
-
-	!des_iip	%f62, %f62
-	.byte	0xbf, 0xb7, 0xe6, 0xa0
-	fxor	%f60, %f62, %f62
-	movxtod	%o5, %f60
-
-!copy output back to array
-	std	%f62, [%o2]
-	sub	%o3, 8, %o3
-	add	%o1, 8, %o1
-	brnz	%o3, des3_cbc_decrypt_loop
-	add	%o2, 8, %o2
-
-	retl
-	stx	%o5, [%o4]
-
-	SET_SIZE(t4_des3_cbc_decrypt)
-
-
-#endif  /* lint || __lint */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/openssl/openssl-1.0.1/inline-t4/dest4-sparcv9.pl	Thu Jun 27 14:24:42 2013 -0700
@@ -0,0 +1,602 @@
+#!/usr/bin/env perl
+
+# ====================================================================
+# Written by David S. Miller <[email protected]> and Andy Polyakov
+# <[email protected]>. The module is licensed under 2-clause BSD
+# license. March 2013. All rights reserved.
+# ====================================================================
+
+######################################################################
+# DES for SPARC T4.
+#
+# As with other hardware-assisted ciphers CBC encrypt results [for
+# aligned data] are virtually identical to critical path lengths:
+#
+#		DES		Triple-DES
+# CBC encrypt	4.14/4.15(*)	11.7/11.7
+# CBC decrypt	1.77/4.11(**)	6.42/7.47
+#
+#			 (*)	numbers after slash are for
+#				misaligned data;
+#			 (**)	this is result for largest
+#				block size, unlike all other
+#				cases smaller blocks results
+#				are better[?];
+
+$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
+push(@INC,"${dir}","${dir}../../perlasm");
+require "sparcv9_modes.pl";
+
+&asm_init(@ARGV);
+
+$code.=<<___ if ($::abibits==64);
+.register       %g2,#scratch
+.register       %g3,#scratch
+___
+
+$code.=<<___;
+.text
+___
+
+{ my ($inp,$out)=("%o0","%o1");
+
+$code.=<<___;
+.align	32
+.globl	des_t4_key_expand
+.type	des_t4_key_expand,#function
+des_t4_key_expand:
+	andcc		$inp, 0x7, %g0
+	alignaddr	$inp, %g0, $inp
+	bz,pt		%icc, 1f
+	ldd		[$inp + 0x00], %f0
+	ldd		[$inp + 0x08], %f2
+	faligndata	%f0, %f2, %f0
+1:	des_kexpand	%f0, 0, %f0
+	des_kexpand	%f0, 1, %f2
+	std		%f0, [$out + 0x00]
+	des_kexpand	%f2, 3, %f6
+	std		%f2, [$out + 0x08]
+	des_kexpand	%f2, 2, %f4
+	des_kexpand	%f6, 3, %f10
+	std		%f6, [$out + 0x18]
+	des_kexpand	%f6, 2, %f8
+	std		%f4, [$out + 0x10]
+	des_kexpand	%f10, 3, %f14
+	std		%f10, [$out + 0x28]
+	des_kexpand	%f10, 2, %f12
+	std		%f8, [$out + 0x20]
+	des_kexpand	%f14, 1, %f16
+	std		%f14, [$out + 0x38]
+	des_kexpand	%f16, 3, %f20
+	std		%f12, [$out + 0x30]
+	des_kexpand	%f16, 2, %f18
+	std		%f16, [$out + 0x40]
+	des_kexpand	%f20, 3, %f24
+	std		%f20, [$out + 0x50]
+	des_kexpand	%f20, 2, %f22
+	std		%f18, [$out + 0x48]
+	des_kexpand	%f24, 3, %f28
+	std		%f24, [$out + 0x60]
+	des_kexpand	%f24, 2, %f26
+	std		%f22, [$out + 0x58]
+	des_kexpand	%f28, 1, %f30
+	std		%f28, [$out + 0x70]
+	std		%f26, [$out + 0x68]
+	retl
+	std		%f30, [$out + 0x78]
+.size	des_t4_key_expand,.-des_t4_key_expand
+___
+}
+{ my ($inp,$out,$len,$key,$ivec) = map("%o$_",(0..4));
+  my ($ileft,$iright,$omask) = map("%g$_",(1..3));
+
+$code.=<<___;
+.globl	des_t4_cbc_encrypt
+.align	32
+des_t4_cbc_encrypt:
+	ld		[$ivec + 0], %f0	! load ivec
+	ld		[$ivec + 4], %f1
+
+	and		$inp, 7, $ileft
+	andn		$inp, 7, $inp
+	sll		$ileft, 3, $ileft
+	mov		0xff, $omask
+	prefetch	[$inp], 20
+	prefetch	[$inp + 63], 20
+	sub		%g0, $ileft, $iright
+	and		$out, 7, %g4
+	alignaddrl	$out, %g0, $out
+	srl		$omask, %g4, $omask
+	srlx		$len, 3, $len
+	movrz		%g4, 0, $omask
+	prefetch	[$out], 22
+
+	ldd		[$key + 0x00], %f4	! load key schedule
+	ldd		[$key + 0x08], %f6
+	ldd		[$key + 0x10], %f8
+	ldd		[$key + 0x18], %f10
+	ldd		[$key + 0x20], %f12
+	ldd		[$key + 0x28], %f14
+	ldd		[$key + 0x30], %f16
+	ldd		[$key + 0x38], %f18
+	ldd		[$key + 0x40], %f20
+	ldd		[$key + 0x48], %f22
+	ldd		[$key + 0x50], %f24
+	ldd		[$key + 0x58], %f26
+	ldd		[$key + 0x60], %f28
+	ldd		[$key + 0x68], %f30
+	ldd		[$key + 0x70], %f32
+	ldd		[$key + 0x78], %f34
+
+.Ldes_cbc_enc_loop:
+	ldx		[$inp + 0], %g4
+	brz,pt		$ileft, 4f
+	nop
+
+	ldx		[$inp + 8], %g5
+	sllx		%g4, $ileft, %g4
+	srlx		%g5, $iright, %g5
+	or		%g5, %g4, %g4
+4:
+	movxtod		%g4, %f2
+	prefetch	[$inp + 8+63], 20
+	add		$inp, 8, $inp
+	fxor		%f2, %f0, %f0		! ^= ivec
+	prefetch	[$out + 63], 22
+
+	des_ip		%f0, %f0
+	des_round	%f4, %f6, %f0, %f0
+	des_round	%f8, %f10, %f0, %f0
+	des_round	%f12, %f14, %f0, %f0
+	des_round	%f16, %f18, %f0, %f0
+	des_round	%f20, %f22, %f0, %f0
+	des_round	%f24, %f26, %f0, %f0
+	des_round	%f28, %f30, %f0, %f0
+	des_round	%f32, %f34, %f0, %f0
+	des_iip		%f0, %f0
+
+	brnz,pn		$omask, 2f
+	sub		$len, 1, $len
+
+	std		%f0, [$out + 0]
+	brnz,pt		$len, .Ldes_cbc_enc_loop
+	add		$out, 8, $out
+
+	st		%f0, [$ivec + 0]	! write out ivec
+	retl
+	st		%f1, [$ivec + 4]
+
+.align	16
+2:	ldxa		[$inp]0x82, %g4		! avoid read-after-write hazard
+						! and ~4x deterioration
+						! in inp==out case
+	faligndata	%f0, %f0, %f2		! handle unaligned output
+
+	stda		%f2, [$out + $omask]0xc0	! partial store
+	add		$out, 8, $out
+	orn		%g0, $omask, $omask
+	stda		%f2, [$out + $omask]0xc0	! partial store
+
+	brnz,pt		$len, .Ldes_cbc_enc_loop+4
+	orn		%g0, $omask, $omask
+
+	st		%f0, [$ivec + 0]	! write out ivec
+	retl
+	st		%f1, [$ivec + 4]
+.type	des_t4_cbc_encrypt,#function
+.size	des_t4_cbc_encrypt,.-des_t4_cbc_encrypt
+
+.globl	des_t4_cbc_decrypt
+.align	32
+des_t4_cbc_decrypt:
+	ld		[$ivec + 0], %f2	! load ivec
+	ld		[$ivec + 4], %f3
+
+	and		$inp, 7, $ileft
+	andn		$inp, 7, $inp
+	sll		$ileft, 3, $ileft
+	mov		0xff, $omask
+	prefetch	[$inp], 20
+	prefetch	[$inp + 63], 20
+	sub		%g0, $ileft, $iright
+	and		$out, 7, %g4
+	alignaddrl	$out, %g0, $out
+	srl		$omask, %g4, $omask
+	srlx		$len, 3, $len
+	movrz		%g4, 0, $omask
+	prefetch	[$out], 22
+
+	ldd		[$key + 0x78], %f4	! load key schedule
+	ldd		[$key + 0x70], %f6
+	ldd		[$key + 0x68], %f8
+	ldd		[$key + 0x60], %f10
+	ldd		[$key + 0x58], %f12
+	ldd		[$key + 0x50], %f14
+	ldd		[$key + 0x48], %f16
+	ldd		[$key + 0x40], %f18
+	ldd		[$key + 0x38], %f20
+	ldd		[$key + 0x30], %f22
+	ldd		[$key + 0x28], %f24
+	ldd		[$key + 0x20], %f26
+	ldd		[$key + 0x18], %f28
+	ldd		[$key + 0x10], %f30
+	ldd		[$key + 0x08], %f32
+	ldd		[$key + 0x00], %f34
+
+.Ldes_cbc_dec_loop:
+	ldx		[$inp + 0], %g4
+	brz,pt		$ileft, 4f
+	nop
+
+	ldx		[$inp + 8], %g5
+	sllx		%g4, $ileft, %g4
+	srlx		%g5, $iright, %g5
+	or		%g5, %g4, %g4
+4:
+	movxtod		%g4, %f0
+	prefetch	[$inp + 8+63], 20
+	add		$inp, 8, $inp
+	prefetch	[$out + 63], 22
+
+	des_ip		%f0, %f0
+	des_round	%f4, %f6, %f0, %f0
+	des_round	%f8, %f10, %f0, %f0
+	des_round	%f12, %f14, %f0, %f0
+	des_round	%f16, %f18, %f0, %f0
+	des_round	%f20, %f22, %f0, %f0
+	des_round	%f24, %f26, %f0, %f0
+	des_round	%f28, %f30, %f0, %f0
+	des_round	%f32, %f34, %f0, %f0
+	des_iip		%f0, %f0
+
+	fxor		%f2, %f0, %f0		! ^= ivec
+	movxtod		%g4, %f2
+
+	brnz,pn		$omask, 2f
+	sub		$len, 1, $len
+
+	std		%f0, [$out + 0]
+	brnz,pt		$len, .Ldes_cbc_dec_loop
+	add		$out, 8, $out
+
+	st		%f2, [$ivec + 0]	! write out ivec
+	retl
+	st		%f3, [$ivec + 4]
+
+.align	16
+2:	ldxa		[$inp]0x82, %g4		! avoid read-after-write hazard
+						! and ~4x deterioration
+						! in inp==out case
+	faligndata	%f0, %f0, %f0		! handle unaligned output
+
+	stda		%f0, [$out + $omask]0xc0	! partial store
+	add		$out, 8, $out
+	orn		%g0, $omask, $omask
+	stda		%f0, [$out + $omask]0xc0	! partial store
+
+	brnz,pt		$len, .Ldes_cbc_dec_loop+4
+	orn		%g0, $omask, $omask
+
+	st		%f2, [$ivec + 0]	! write out ivec
+	retl
+	st		%f3, [$ivec + 4]
+.type	des_t4_cbc_decrypt,#function
+.size	des_t4_cbc_decrypt,.-des_t4_cbc_decrypt
+___
+
+# One might wonder why does one have back-to-back des_iip/des_ip
+# pairs between EDE passes. Indeed, aren't they inverse of each other?
+# They almost are. Outcome of the pair is 32-bit words being swapped
+# in target register. Consider pair of des_iip/des_ip as a way to
+# perform the due swap, it's actually fastest way in this case.
+
+$code.=<<___;
+.globl	des_t4_ede3_cbc_encrypt
+.align	32
+des_t4_ede3_cbc_encrypt:
+	ld		[$ivec + 0], %f0	! load ivec
+	ld		[$ivec + 4], %f1
+
+	and		$inp, 7, $ileft
+	andn		$inp, 7, $inp
+	sll		$ileft, 3, $ileft
+	mov		0xff, $omask
+	prefetch	[$inp], 20
+	prefetch	[$inp + 63], 20
+	sub		%g0, $ileft, $iright
+	and		$out, 7, %g4
+	alignaddrl	$out, %g0, $out
+	srl		$omask, %g4, $omask
+	srlx		$len, 3, $len
+	movrz		%g4, 0, $omask
+	prefetch	[$out], 22
+
+	ldd		[$key + 0x00], %f4	! load key schedule
+	ldd		[$key + 0x08], %f6
+	ldd		[$key + 0x10], %f8
+	ldd		[$key + 0x18], %f10
+	ldd		[$key + 0x20], %f12
+	ldd		[$key + 0x28], %f14
+	ldd		[$key + 0x30], %f16
+	ldd		[$key + 0x38], %f18
+	ldd		[$key + 0x40], %f20
+	ldd		[$key + 0x48], %f22
+	ldd		[$key + 0x50], %f24
+	ldd		[$key + 0x58], %f26
+	ldd		[$key + 0x60], %f28
+	ldd		[$key + 0x68], %f30
+	ldd		[$key + 0x70], %f32
+	ldd		[$key + 0x78], %f34
+
+.Ldes_ede3_cbc_enc_loop:
+	ldx		[$inp + 0], %g4
+	brz,pt		$ileft, 4f
+	nop
+
+	ldx		[$inp + 8], %g5
+	sllx		%g4, $ileft, %g4
+	srlx		%g5, $iright, %g5
+	or		%g5, %g4, %g4
+4:
+	movxtod		%g4, %f2
+	prefetch	[$inp + 8+63], 20
+	add		$inp, 8, $inp
+	fxor		%f2, %f0, %f0		! ^= ivec
+	prefetch	[$out + 63], 22
+
+	des_ip		%f0, %f0
+	des_round	%f4, %f6, %f0, %f0
+	des_round	%f8, %f10, %f0, %f0
+	des_round	%f12, %f14, %f0, %f0
+	des_round	%f16, %f18, %f0, %f0
+	ldd		[$key + 0x100-0x08], %f36
+	ldd		[$key + 0x100-0x10], %f38
+	des_round	%f20, %f22, %f0, %f0
+	ldd		[$key + 0x100-0x18], %f40
+	ldd		[$key + 0x100-0x20], %f42
+	des_round	%f24, %f26, %f0, %f0
+	ldd		[$key + 0x100-0x28], %f44
+	ldd		[$key + 0x100-0x30], %f46
+	des_round	%f28, %f30, %f0, %f0
+	ldd		[$key + 0x100-0x38], %f48
+	ldd		[$key + 0x100-0x40], %f50
+	des_round	%f32, %f34, %f0, %f0
+	ldd		[$key + 0x100-0x48], %f52
+	ldd		[$key + 0x100-0x50], %f54
+	des_iip		%f0, %f0
+
+	ldd		[$key + 0x100-0x58], %f56
+	ldd		[$key + 0x100-0x60], %f58
+	des_ip		%f0, %f0
+	ldd		[$key + 0x100-0x68], %f60
+	ldd		[$key + 0x100-0x70], %f62
+	des_round	%f36, %f38, %f0, %f0
+	ldd		[$key + 0x100-0x78], %f36
+	ldd		[$key + 0x100-0x80], %f38
+	des_round	%f40, %f42, %f0, %f0
+	des_round	%f44, %f46, %f0, %f0
+	des_round	%f48, %f50, %f0, %f0
+	ldd		[$key + 0x100+0x00], %f40
+	ldd		[$key + 0x100+0x08], %f42
+	des_round	%f52, %f54, %f0, %f0
+	ldd		[$key + 0x100+0x10], %f44
+	ldd		[$key + 0x100+0x18], %f46
+	des_round	%f56, %f58, %f0, %f0
+	ldd		[$key + 0x100+0x20], %f48
+	ldd		[$key + 0x100+0x28], %f50
+	des_round	%f60, %f62, %f0, %f0
+	ldd		[$key + 0x100+0x30], %f52
+	ldd		[$key + 0x100+0x38], %f54
+	des_round	%f36, %f38, %f0, %f0
+	ldd		[$key + 0x100+0x40], %f56
+	ldd		[$key + 0x100+0x48], %f58
+	des_iip		%f0, %f0
+
+	ldd		[$key + 0x100+0x50], %f60
+	ldd		[$key + 0x100+0x58], %f62
+	des_ip		%f0, %f0
+	ldd		[$key + 0x100+0x60], %f36
+	ldd		[$key + 0x100+0x68], %f38
+	des_round	%f40, %f42, %f0, %f0
+	ldd		[$key + 0x100+0x70], %f40
+	ldd		[$key + 0x100+0x78], %f42
+	des_round	%f44, %f46, %f0, %f0
+	des_round	%f48, %f50, %f0, %f0
+	des_round	%f52, %f54, %f0, %f0
+	des_round	%f56, %f58, %f0, %f0
+	des_round	%f60, %f62, %f0, %f0
+	des_round	%f36, %f38, %f0, %f0
+	des_round	%f40, %f42, %f0, %f0
+	des_iip		%f0, %f0
+
+	brnz,pn		$omask, 2f
+	sub		$len, 1, $len
+
+	std		%f0, [$out + 0]
+	brnz,pt		$len, .Ldes_ede3_cbc_enc_loop
+	add		$out, 8, $out
+
+	st		%f0, [$ivec + 0]	! write out ivec
+	retl
+	st		%f1, [$ivec + 4]
+
+.align	16
+2:	ldxa		[$inp]0x82, %g4		! avoid read-after-write hazard
+						! and ~2x deterioration
+						! in inp==out case
+	faligndata	%f0, %f0, %f2		! handle unaligned output
+
+	stda		%f2, [$out + $omask]0xc0	! partial store
+	add		$out, 8, $out
+	orn		%g0, $omask, $omask
+	stda		%f2, [$out + $omask]0xc0	! partial store
+
+	brnz,pt		$len, .Ldes_ede3_cbc_enc_loop+4
+	orn		%g0, $omask, $omask
+
+	st		%f0, [$ivec + 0]	! write out ivec
+	retl
+	st		%f1, [$ivec + 4]
+.type	des_t4_ede3_cbc_encrypt,#function
+.size	des_t4_ede3_cbc_encrypt,.-des_t4_ede3_cbc_encrypt
+
+.globl	des_t4_ede3_cbc_decrypt
+.align	32
+des_t4_ede3_cbc_decrypt:
+	ld		[$ivec + 0], %f2	! load ivec
+	ld		[$ivec + 4], %f3
+
+	and		$inp, 7, $ileft
+	andn		$inp, 7, $inp
+	sll		$ileft, 3, $ileft
+	mov		0xff, $omask
+	prefetch	[$inp], 20
+	prefetch	[$inp + 63], 20
+	sub		%g0, $ileft, $iright
+	and		$out, 7, %g4
+	alignaddrl	$out, %g0, $out
+	srl		$omask, %g4, $omask
+	srlx		$len, 3, $len
+	movrz		%g4, 0, $omask
+	prefetch	[$out], 22
+
+	ldd		[$key + 0x100+0x78], %f4	! load key schedule
+	ldd		[$key + 0x100+0x70], %f6
+	ldd		[$key + 0x100+0x68], %f8
+	ldd		[$key + 0x100+0x60], %f10
+	ldd		[$key + 0x100+0x58], %f12
+	ldd		[$key + 0x100+0x50], %f14
+	ldd		[$key + 0x100+0x48], %f16
+	ldd		[$key + 0x100+0x40], %f18
+	ldd		[$key + 0x100+0x38], %f20
+	ldd		[$key + 0x100+0x30], %f22
+	ldd		[$key + 0x100+0x28], %f24
+	ldd		[$key + 0x100+0x20], %f26
+	ldd		[$key + 0x100+0x18], %f28
+	ldd		[$key + 0x100+0x10], %f30
+	ldd		[$key + 0x100+0x08], %f32
+	ldd		[$key + 0x100+0x00], %f34
+
+.Ldes_ede3_cbc_dec_loop:
+	ldx		[$inp + 0], %g4
+	brz,pt		$ileft, 4f
+	nop
+
+	ldx		[$inp + 8], %g5
+	sllx		%g4, $ileft, %g4
+	srlx		%g5, $iright, %g5
+	or		%g5, %g4, %g4
+4:
+	movxtod		%g4, %f0
+	prefetch	[$inp + 8+63], 20
+	add		$inp, 8, $inp
+	prefetch	[$out + 63], 22
+
+	des_ip		%f0, %f0
+	des_round	%f4, %f6, %f0, %f0
+	des_round	%f8, %f10, %f0, %f0
+	des_round	%f12, %f14, %f0, %f0
+	des_round	%f16, %f18, %f0, %f0
+	ldd		[$key + 0x80+0x00], %f36
+	ldd		[$key + 0x80+0x08], %f38
+	des_round	%f20, %f22, %f0, %f0
+	ldd		[$key + 0x80+0x10], %f40
+	ldd		[$key + 0x80+0x18], %f42
+	des_round	%f24, %f26, %f0, %f0
+	ldd		[$key + 0x80+0x20], %f44
+	ldd		[$key + 0x80+0x28], %f46
+	des_round	%f28, %f30, %f0, %f0
+	ldd		[$key + 0x80+0x30], %f48
+	ldd		[$key + 0x80+0x38], %f50
+	des_round	%f32, %f34, %f0, %f0
+	ldd		[$key + 0x80+0x40], %f52
+	ldd		[$key + 0x80+0x48], %f54
+	des_iip		%f0, %f0
+
+	ldd		[$key + 0x80+0x50], %f56
+	ldd		[$key + 0x80+0x58], %f58
+	des_ip		%f0, %f0
+	ldd		[$key + 0x80+0x60], %f60
+	ldd		[$key + 0x80+0x68], %f62
+	des_round	%f36, %f38, %f0, %f0
+	ldd		[$key + 0x80+0x70], %f36
+	ldd		[$key + 0x80+0x78], %f38
+	des_round	%f40, %f42, %f0, %f0
+	des_round	%f44, %f46, %f0, %f0
+	des_round	%f48, %f50, %f0, %f0
+	ldd		[$key + 0x80-0x08], %f40
+	ldd		[$key + 0x80-0x10], %f42
+	des_round	%f52, %f54, %f0, %f0
+	ldd		[$key + 0x80-0x18], %f44
+	ldd		[$key + 0x80-0x20], %f46
+	des_round	%f56, %f58, %f0, %f0
+	ldd		[$key + 0x80-0x28], %f48
+	ldd		[$key + 0x80-0x30], %f50
+	des_round	%f60, %f62, %f0, %f0
+	ldd		[$key + 0x80-0x38], %f52
+	ldd		[$key + 0x80-0x40], %f54
+	des_round	%f36, %f38, %f0, %f0
+	ldd		[$key + 0x80-0x48], %f56
+	ldd		[$key + 0x80-0x50], %f58
+	des_iip		%f0, %f0
+
+	ldd		[$key + 0x80-0x58], %f60
+	ldd		[$key + 0x80-0x60], %f62
+	des_ip		%f0, %f0
+	ldd		[$key + 0x80-0x68], %f36
+	ldd		[$key + 0x80-0x70], %f38
+	des_round	%f40, %f42, %f0, %f0
+	ldd		[$key + 0x80-0x78], %f40
+	ldd		[$key + 0x80-0x80], %f42
+	des_round	%f44, %f46, %f0, %f0
+	des_round	%f48, %f50, %f0, %f0
+	des_round	%f52, %f54, %f0, %f0
+	des_round	%f56, %f58, %f0, %f0
+	des_round	%f60, %f62, %f0, %f0
+	des_round	%f36, %f38, %f0, %f0
+	des_round	%f40, %f42, %f0, %f0
+	des_iip		%f0, %f0
+
+	fxor		%f2, %f0, %f0		! ^= ivec
+	movxtod		%g4, %f2
+
+	brnz,pn		$omask, 2f
+	sub		$len, 1, $len
+
+	std		%f0, [$out + 0]
+	brnz,pt		$len, .Ldes_ede3_cbc_dec_loop
+	add		$out, 8, $out
+
+	st		%f2, [$ivec + 0]	! write out ivec
+	retl
+	st		%f3, [$ivec + 4]
+
+.align	16
+2:	ldxa		[$inp]0x82, %g4		! avoid read-after-write hazard
+						! and ~3x deterioration
+						! in inp==out case
+	faligndata	%f0, %f0, %f0		! handle unaligned output
+
+	stda		%f0, [$out + $omask]0xc0	! partial store
+	add		$out, 8, $out
+	orn		%g0, $omask, $omask
+	stda		%f0, [$out + $omask]0xc0	! partial store
+
+	brnz,pt		$len, .Ldes_ede3_cbc_dec_loop+4
+	orn		%g0, $omask, $omask
+
+	st		%f2, [$ivec + 0]	! write out ivec
+	retl
+	st		%f3, [$ivec + 4]
+.type	des_t4_ede3_cbc_decrypt,#function
+.size	des_t4_ede3_cbc_decrypt,.-des_t4_ede3_cbc_decrypt
+___
+}
+$code.=<<___;
+.asciz  "DES for SPARC T4, David S. Miller, Andy Polyakov"
+.align  4
+___
+
+&emit_assembler();
+
+close STDOUT;
--- a/components/openssl/openssl-1.0.1/inline-t4/sparcv9_modes.pl	Thu Jun 27 13:48:41 2013 -0700
+++ b/components/openssl/openssl-1.0.1/inline-t4/sparcv9_modes.pl	Thu Jun 27 14:24:42 2013 -0700
@@ -900,6 +900,480 @@
 ___
 }
 
+sub alg_xts_implement {
+my ($alg,$bits,$dir) = @_;
+my ($inp,$out,$len,$key1,$key2,$ivec)=map("%i$_",(0..5));
+my $rem=$ivec;
+
+$::code.=<<___;
+.globl	${alg}${bits}_t4_xts_${dir}crypt
+.align	32
+${alg}${bits}_t4_xts_${dir}crypt:
+	save		%sp, -$::frame-16, %sp
+
+	mov		$ivec, %o0
+	add		%fp, $::bias-16, %o1
+	call		${alg}_t4_encrypt
+	mov		$key2, %o2
+
+	add		%fp, $::bias-16, %l7
+	ldxa		[%l7]0x88, %g2
+	add		%fp, $::bias-8, %l7
+	ldxa		[%l7]0x88, %g3		! %g3:%g2 is tweak
+
+	sethi		%hi(0x76543210), %l7
+	or		%l7, %lo(0x76543210), %l7
+	bmask		%l7, %g0, %g0		! byte swap mask
+
+	prefetch	[$inp], 20
+	prefetch	[$inp + 63], 20
+	call		_${alg}${bits}_load_${dir}ckey
+	and		$len, 15,  $rem
+	and		$len, -16, $len
+___
+$code.=<<___ if ($dir eq "de");
+	mov		0, %l7
+	movrnz		$rem, 16,  %l7
+	sub		$len, %l7, $len
+___
+$code.=<<___;
+
+	sub		$inp, $out, $blk_init	! $inp!=$out
+	and		$inp, 7, $ileft
+	andn		$inp, 7, $inp
+	sll		$ileft, 3, $ileft
+	mov		64, $iright
+	mov		0xff, $omask
+	sub		$iright, $ileft, $iright
+	and		$out, 7, $ooff
+	cmp		$len, 255
+	movrnz		$ooff, 0, $blk_init		! if (	$out&7 ||
+	movleu		$::size_t_cc, 0, $blk_init	!	$len<256 ||
+	brnz,pn		$blk_init, .L${bits}_xts_${dir}blk !	$inp==$out)
+	srl		$omask, $ooff, $omask
+
+	andcc		$len, 16, %g0		! is number of blocks even?
+___
+$code.=<<___ if ($dir eq "de");
+	brz,pn		$len, .L${bits}_xts_${dir}steal
+___
+$code.=<<___;
+	alignaddrl	$out, %g0, $out
+	bz		%icc, .L${bits}_xts_${dir}loop2x
+	srlx		$len, 4, $len
+.L${bits}_xts_${dir}loop:
+	ldx		[$inp + 0], %o0
+	brz,pt		$ileft, 4f
+	ldx		[$inp + 8], %o1
+
+	ldx		[$inp + 16], %o2
+	sllx		%o0, $ileft, %o0
+	srlx		%o1, $iright, %g1
+	sllx		%o1, $ileft, %o1
+	or		%g1, %o0, %o0
+	srlx		%o2, $iright, %o2
+	or		%o2, %o1, %o1
+4:
+	movxtod		%g2, %f12
+	movxtod		%g3, %f14
+	bshuffle	%f12, %f12, %f12
+	bshuffle	%f14, %f14, %f14
+
+	xor		%g4, %o0, %o0		! ^= rk[0]
+	xor		%g5, %o1, %o1
+	movxtod		%o0, %f0
+	movxtod		%o1, %f2
+
+	fxor		%f12, %f0, %f0		! ^= tweak[0]
+	fxor		%f14, %f2, %f2
+
+	prefetch	[$out + 63], 22
+	prefetch	[$inp + 16+63], 20
+	call		_${alg}${bits}_${dir}crypt_1x
+	add		$inp, 16, $inp
+
+	fxor		%f12, %f0, %f0		! ^= tweak[0]
+	fxor		%f14, %f2, %f2
+
+	srax		%g3, 63, %l7		! next tweak value
+	addcc		%g2, %g2, %g2
+	and		%l7, 0x87, %l7
+	addxc		%g3, %g3, %g3
+	xor		%l7, %g2, %g2
+
+	brnz,pn		$ooff, 2f
+	sub		$len, 1, $len
+		
+	std		%f0, [$out + 0]
+	std		%f2, [$out + 8]
+	brnz,pt		$len, .L${bits}_xts_${dir}loop2x
+	add		$out, 16, $out
+
+	brnz,pn		$rem, .L${bits}_xts_${dir}steal
+	nop
+
+	ret
+	restore
+
+.align	16
+2:	ldxa		[$inp]0x82, %o0		! avoid read-after-write hazard
+						! and ~3x deterioration
+						! in inp==out case
+	faligndata	%f0, %f0, %f4		! handle unaligned output
+	faligndata	%f0, %f2, %f6
+	faligndata	%f2, %f2, %f8
+	stda		%f4, [$out + $omask]0xc0	! partial store
+	std		%f6, [$out + 8]
+	add		$out, 16, $out
+	orn		%g0, $omask, $omask
+	stda		%f8, [$out + $omask]0xc0	! partial store
+
+	brnz,pt		$len, .L${bits}_xts_${dir}loop2x+4
+	orn		%g0, $omask, $omask
+
+	brnz,pn		$rem, .L${bits}_xts_${dir}steal
+	nop
+
+	ret
+	restore
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+.align	32
+.L${bits}_xts_${dir}loop2x:
+	ldx		[$inp + 0], %o0
+	ldx		[$inp + 8], %o1
+	ldx		[$inp + 16], %o2
+	brz,pt		$ileft, 4f
+	ldx		[$inp + 24], %o3
+
+	ldx		[$inp + 32], %o4
+	sllx		%o0, $ileft, %o0
+	srlx		%o1, $iright, %g1
+	or		%g1, %o0, %o0
+	sllx		%o1, $ileft, %o1
+	srlx		%o2, $iright, %g1
+	or		%g1, %o1, %o1
+	sllx		%o2, $ileft, %o2
+	srlx		%o3, $iright, %g1
+	or		%g1, %o2, %o2
+	sllx		%o3, $ileft, %o3
+	srlx		%o4, $iright, %o4
+	or		%o4, %o3, %o3
+4:
+	movxtod		%g2, %f12
+	movxtod		%g3, %f14
+	bshuffle	%f12, %f12, %f12
+	bshuffle	%f14, %f14, %f14
+
+	srax		%g3, 63, %l7		! next tweak value
+	addcc		%g2, %g2, %g2
+	and		%l7, 0x87, %l7
+	addxc		%g3, %g3, %g3
+	xor		%l7, %g2, %g2
+
+	movxtod		%g2, %f8
+	movxtod		%g3, %f10
+	bshuffle	%f8,  %f8,  %f8
+	bshuffle	%f10, %f10, %f10
+
+	xor		%g4, %o0, %o0		! ^= rk[0]
+	xor		%g5, %o1, %o1
+	xor		%g4, %o2, %o2		! ^= rk[0]
+	xor		%g5, %o3, %o3
+	movxtod		%o0, %f0
+	movxtod		%o1, %f2
+	movxtod		%o2, %f4
+	movxtod		%o3, %f6
+
+	fxor		%f12, %f0, %f0		! ^= tweak[0]
+	fxor		%f14, %f2, %f2
+	fxor		%f8,  %f4, %f4		! ^= tweak[0]
+	fxor		%f10, %f6, %f6
+
+	prefetch	[$out + 63], 22
+	prefetch	[$inp + 32+63], 20
+	call		_${alg}${bits}_${dir}crypt_2x
+	add		$inp, 32, $inp
+
+	movxtod		%g2, %f8
+	movxtod		%g3, %f10
+
+	srax		%g3, 63, %l7		! next tweak value
+	addcc		%g2, %g2, %g2
+	and		%l7, 0x87, %l7
+	addxc		%g3, %g3, %g3
+	xor		%l7, %g2, %g2
+
+	bshuffle	%f8,  %f8,  %f8
+	bshuffle	%f10, %f10, %f10
+
+	fxor		%f12, %f0, %f0		! ^= tweak[0]
+	fxor		%f14, %f2, %f2
+	fxor		%f8,  %f4, %f4
+	fxor		%f10, %f6, %f6
+
+	brnz,pn		$ooff, 2f
+	sub		$len, 2, $len
+		
+	std		%f0, [$out + 0]
+	std		%f2, [$out + 8]
+	std		%f4, [$out + 16]
+	std		%f6, [$out + 24]
+	brnz,pt		$len, .L${bits}_xts_${dir}loop2x
+	add		$out, 32, $out
+
+	fsrc2		%f4, %f0
+	fsrc2		%f6, %f2
+	brnz,pn		$rem, .L${bits}_xts_${dir}steal
+	nop
+
+	ret
+	restore
+
+.align	16
+2:	ldxa		[$inp]0x82, %o0		! avoid read-after-write hazard
+						! and ~3x deterioration
+						! in inp==out case
+	faligndata	%f0, %f0, %f8		! handle unaligned output
+	faligndata	%f0, %f2, %f10
+	faligndata	%f2, %f4, %f12
+	faligndata	%f4, %f6, %f14
+	faligndata	%f6, %f6, %f0
+
+	stda		%f8, [$out + $omask]0xc0	! partial store
+	std		%f10, [$out + 8]
+	std		%f12, [$out + 16]
+	std		%f14, [$out + 24]
+	add		$out, 32, $out
+	orn		%g0, $omask, $omask
+	stda		%f0, [$out + $omask]0xc0	! partial store
+
+	brnz,pt		$len, .L${bits}_xts_${dir}loop2x+4
+	orn		%g0, $omask, $omask
+
+	fsrc2		%f4, %f0
+	fsrc2		%f6, %f2
+	brnz,pn		$rem, .L${bits}_xts_${dir}steal
+	nop
+
+	ret
+	restore
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+.align	32
+.L${bits}_xts_${dir}blk:
+	add	$out, $len, $blk_init
+	and	$blk_init, 63, $blk_init	! tail
+	sub	$len, $blk_init, $len
+	add	$blk_init, 15, $blk_init	! round up to 16n
+	srlx	$len, 4, $len
+	srl	$blk_init, 4, $blk_init
+	sub	$len, 1, $len
+	add	$blk_init, 1, $blk_init
+
+.L${bits}_xts_${dir}blk2x:
+	ldx		[$inp + 0], %o0
+	ldx		[$inp + 8], %o1
+	ldx		[$inp + 16], %o2
+	brz,pt		$ileft, 5f
+	ldx		[$inp + 24], %o3
+
+	ldx		[$inp + 32], %o4
+	sllx		%o0, $ileft, %o0
+	srlx		%o1, $iright, %g1
+	or		%g1, %o0, %o0
+	sllx		%o1, $ileft, %o1
+	srlx		%o2, $iright, %g1
+	or		%g1, %o1, %o1
+	sllx		%o2, $ileft, %o2
+	srlx		%o3, $iright, %g1
+	or		%g1, %o2, %o2
+	sllx		%o3, $ileft, %o3
+	srlx		%o4, $iright, %o4
+	or		%o4, %o3, %o3
+5:
+	movxtod		%g2, %f12
+	movxtod		%g3, %f14
+	bshuffle	%f12, %f12, %f12
+	bshuffle	%f14, %f14, %f14
+
+	srax		%g3, 63, %l7		! next tweak value
+	addcc		%g2, %g2, %g2
+	and		%l7, 0x87, %l7
+	addxc		%g3, %g3, %g3
+	xor		%l7, %g2, %g2
+
+	movxtod		%g2, %f8
+	movxtod		%g3, %f10
+	bshuffle	%f8,  %f8,  %f8
+	bshuffle	%f10, %f10, %f10
+
+	xor		%g4, %o0, %o0		! ^= rk[0]
+	xor		%g5, %o1, %o1
+	xor		%g4, %o2, %o2		! ^= rk[0]
+	xor		%g5, %o3, %o3
+	movxtod		%o0, %f0
+	movxtod		%o1, %f2
+	movxtod		%o2, %f4
+	movxtod		%o3, %f6
+
+	fxor		%f12, %f0, %f0		! ^= tweak[0]
+	fxor		%f14, %f2, %f2
+	fxor		%f8,  %f4, %f4		! ^= tweak[0]
+	fxor		%f10, %f6, %f6
+
+	prefetch	[$inp + 32+63], 20
+	call		_${alg}${bits}_${dir}crypt_2x
+	add		$inp, 32, $inp
+
+	movxtod		%g2, %f8
+	movxtod		%g3, %f10
+
+	srax		%g3, 63, %l7		! next tweak value
+	addcc		%g2, %g2, %g2
+	and		%l7, 0x87, %l7
+	addxc		%g3, %g3, %g3
+	xor		%l7, %g2, %g2
+
+	bshuffle	%f8,  %f8,  %f8
+	bshuffle	%f10, %f10, %f10
+
+	fxor		%f12, %f0, %f0		! ^= tweak[0]
+	fxor		%f14, %f2, %f2
+	fxor		%f8,  %f4, %f4
+	fxor		%f10, %f6, %f6
+
+	stda		%f0, [$out]0xe2		! ASI_BLK_INIT, T4-specific
+	add		$out, 8, $out
+	stda		%f2, [$out]0xe2		! ASI_BLK_INIT, T4-specific
+	add		$out, 8, $out
+	stda		%f4, [$out]0xe2		! ASI_BLK_INIT, T4-specific
+	add		$out, 8, $out
+	stda		%f6, [$out]0xe2		! ASI_BLK_INIT, T4-specific
+	bgu,pt		$::size_t_cc, .L${bits}_xts_${dir}blk2x
+	add		$out, 8, $out
+
+	add		$blk_init, $len, $len
+	andcc		$len, 1, %g0		! is number of blocks even?
+	membar		#StoreLoad|#StoreStore
+	bnz,pt		%icc, .L${bits}_xts_${dir}loop
+	srl		$len, 0, $len
+	brnz,pn		$len, .L${bits}_xts_${dir}loop2x
+	nop
+
+	fsrc2		%f4, %f0
+	fsrc2		%f6, %f2
+	brnz,pn		$rem, .L${bits}_xts_${dir}steal
+	nop
+
+	ret
+	restore
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+___
+$code.=<<___ if ($dir eq "en");
+.align	32
+.L${bits}_xts_${dir}steal:
+	std		%f0, [%fp + $::bias-16]	! copy of output
+	std		%f2, [%fp + $::bias-8]
+
+	srl		$ileft, 3, $ileft
+	add		%fp, $::bias-16, %l7
+	add		$inp, $ileft, $inp	! original $inp+$len&-15
+	add		$out, $ooff, $out	! original $out+$len&-15
+	mov		0, $ileft
+	nop					! align
+
+.L${bits}_xts_${dir}stealing:
+	ldub		[$inp + $ileft], %o0
+	ldub		[%l7  + $ileft], %o1
+	dec		$rem
+	stb		%o0, [%l7  + $ileft]
+	stb		%o1, [$out + $ileft]
+	brnz		$rem, .L${bits}_xts_${dir}stealing
+	inc		$ileft
+
+	mov		%l7, $inp
+	sub		$out, 16, $out
+	mov		0, $ileft
+	sub		$out, $ooff, $out
+	ba		.L${bits}_xts_${dir}loop	! one more time
+	mov		1, $len				! $rem is 0
+___
+$code.=<<___ if ($dir eq "de");
+.align	32
+.L${bits}_xts_${dir}steal:
+	ldx		[$inp + 0], %o0
+	brz,pt		$ileft, 8f
+	ldx		[$inp + 8], %o1
+
+	ldx		[$inp + 16], %o2
+	sllx		%o0, $ileft, %o0
+	srlx		%o1, $iright, %g1
+	sllx		%o1, $ileft, %o1
+	or		%g1, %o0, %o0
+	srlx		%o2, $iright, %o2
+	or		%o2, %o1, %o1
+8:
+	srax		%g3, 63, %l7		! next tweak value
+	addcc		%g2, %g2, %o2
+	and		%l7, 0x87, %l7
+	addxc		%g3, %g3, %o3
+	xor		%l7, %o2, %o2
+
+	movxtod		%o2, %f12
+	movxtod		%o3, %f14
+	bshuffle	%f12, %f12, %f12
+	bshuffle	%f14, %f14, %f14
+
+	xor		%g4, %o0, %o0		! ^= rk[0]
+	xor		%g5, %o1, %o1
+	movxtod		%o0, %f0
+	movxtod		%o1, %f2
+
+	fxor		%f12, %f0, %f0		! ^= tweak[0]
+	fxor		%f14, %f2, %f2
+
+	call		_${alg}${bits}_${dir}crypt_1x
+	add		$inp, 16, $inp
+
+	fxor		%f12, %f0, %f0		! ^= tweak[0]
+	fxor		%f14, %f2, %f2
+
+	std		%f0, [%fp + $::bias-16]
+	std		%f2, [%fp + $::bias-8]
+
+	srl		$ileft, 3, $ileft
+	add		%fp, $::bias-16, %l7
+	add		$inp, $ileft, $inp	! original $inp+$len&-15
+	add		$out, $ooff, $out	! original $out+$len&-15
+	mov		0, $ileft
+	add		$out, 16, $out
+	nop					! align
+
+.L${bits}_xts_${dir}stealing:
+	ldub		[$inp + $ileft], %o0
+	ldub		[%l7  + $ileft], %o1
+	dec		$rem
+	stb		%o0, [%l7  + $ileft]
+	stb		%o1, [$out + $ileft]
+	brnz		$rem, .L${bits}_xts_${dir}stealing
+	inc		$ileft
+
+	mov		%l7, $inp
+	sub		$out, 16, $out
+	mov		0, $ileft
+	sub		$out, $ooff, $out
+	ba		.L${bits}_xts_${dir}loop	! one more time
+	mov		1, $len				! $rem is 0
+___
+$code.=<<___;
+	ret
+	restore
+.type	${alg}${bits}_t4_xts_${dir}crypt,#function
+.size	${alg}${bits}_t4_xts_${dir}crypt,.-${alg}${bits}_t4_xts_${dir}crypt
+___
+}
+
 # Purpose of these subroutines is to explicitly encode VIS instructions,
 # so that one can compile the module without having to specify VIS
 # extentions on compiler command line, e.g. -xarch=v9 vs. -xarch=v9a.
@@ -909,6 +1383,7 @@
 my ($mnemonic,$rs1,$rs2,$rd)=@_;
 my ($ref,$opf);
 my %visopf = (	"faligndata"	=> 0x048,
+		"bshuffle"	=> 0x04c,
 		"fnot2"		=> 0x066,
 		"fxor"		=> 0x06c,
 		"fsrc2"		=> 0x078	);
@@ -933,13 +1408,17 @@
 	return $ref;
     }
 }
+
 sub unvis3 {
 my ($mnemonic,$rs1,$rs2,$rd)=@_;
 my %bias = ( "g" => 0, "o" => 8, "l" => 16, "i" => 24 );
 my ($ref,$opf);
 my %visopf = (	"addxc"		=> 0x011,
 		"addxccc"	=> 0x013,
-		"umulxhi"	=> 0x016	);
+		"umulxhi"	=> 0x016,
+		"alignaddr"	=> 0x018,
+		"bmask"		=> 0x019,
+		"alignaddrl"	=> 0x01a	);
 
     $ref = "$mnemonic\t$rs1,$rs2,$rd";
 
@@ -956,20 +1435,6 @@
 	return $ref;
     }
 }
-sub unalignaddr {
-my ($mnemonic,$rs1,$rs2,$rd)=@_;
-my %bias = ( "g" => 0, "o" => 8, "l" => 16, "i" => 24 );
-my $ref = "$mnemonic\t$rs1,$rs2,$rd";
-my $opf = $mnemonic =~ /l$/ ? 0x01a :0x18;
-
-    foreach ($rs1,$rs2,$rd) {
-	if (/%([goli])([0-7])/)	{ $_=$bias{$1}+$2; }
-	else			{ return $ref; }
-    }
-    return  sprintf ".word\t0x%08x !%s",
-		    0x81b00000|$rd<<25|$rs1<<14|$opf<<5|$rs2,
-		    $ref;
-}
 
 sub unaes_round {	# 4-argument instructions
 my ($mnemonic,$rs1,$rs2,$rs3,$rd)=@_;
@@ -1117,39 +1582,96 @@
     }
 }
 
+sub undes {
+my ($mnemonic)=shift;
+my @args=@_;
+my ($ref,$opf);
+my %desopf = (	"des_round"	=> 0b1001,
+		"des_ip"	=> 0b100110100,
+		"des_iip"	=> 0b100110101,
+		"des_kexpand"	=> 0b100110110	);
+
+    $ref = "$mnemonic\t".join(",",@_);
+
+    if (defined($opf=$desopf{$mnemonic})) {	# 4-arg
+	if ($mnemonic eq "des_round") {
+	    foreach (@args[0..3]) {
+		return $ref if (!/%f([0-9]{1,2})/);
+		$_=$1;
+		if ($1>=32) {
+		    return $ref if ($1&1);
+		    # re-encode for upper double register addressing
+		    $_=($1|$1>>5)&31;
+		}
+	    }
+	    return  sprintf ".word\t0x%08x !%s",
+			    2<<30|0b011001<<19|$opf<<5|$args[0]<<14|$args[1]|$args[2]<<9|$args[3]<<25,
+			    $ref;
+	} elsif ($mnemonic eq "des_kexpand") {	# 3-arg
+	    foreach (@args[0..2]) {
+		return $ref if (!/(%f)?([0-9]{1,2})/);
+		$_=$2;
+		if ($2>=32) {
+		    return $ref if ($2&1);
+		    # re-encode for upper double register addressing
+		    $_=($2|$2>>5)&31;
+		}
+	    }
+	    return  sprintf ".word\t0x%08x !%s",
+			    2<<30|0b110110<<19|$opf<<5|$args[0]<<14|$args[1]|$args[2]<<25,
+			    $ref;
+	} else {				# 2-arg
+	    foreach (@args[0..1]) {
+		return $ref if (!/%f([0-9]{1,2})/);
+		$_=$1;
+		if ($1>=32) {
+		    return $ref if ($2&1);
+		    # re-encode for upper double register addressing
+		    $_=($1|$1>>5)&31;
+		}
+	    }
+	    return  sprintf ".word\t0x%08x !%s",
+			    2<<30|0b110110<<19|$opf<<5|$args[0]<<14|$args[1]<<25,
+			    $ref;
+	}
+    } else {
+	return $ref;
+    }
+}
+
 sub emit_assembler {
     foreach (split("\n",$::code)) {
 	s/\`([^\`]*)\`/eval $1/ge;
 
-	s/\b(f[a-z]+2[sd]*)\s+(%f[0-9]{1,2}),\s*(%f[0-9]{1,2})\s*$/$1\t%f0,$2,$3/g;
+	s/\b(f[a-z]+2[sd]*)\s+(%f[0-9]{1,2}),\s*(%f[0-9]{1,2})\s*$/$1\t%f0,$2,$3/go;
 
 	s/\b(aes_[edk][^\s]*)\s+(%f[0-9]{1,2}),\s*(%f[0-9]{1,2}),\s*([%fx0-9]+),\s*(%f[0-9]{1,2})/
 		&unaes_round($1,$2,$3,$4,$5)
-	 /ge or
+	 /geo or
 	s/\b(aes_kexpand[02])\s+(%f[0-9]{1,2}),\s*(%f[0-9]{1,2}),\s*(%f[0-9]{1,2})/
 		&unaes_kexpand($1,$2,$3,$4)
-	 /ge or
+	 /geo or
 	s/\b(camellia_f)\s+(%f[0-9]{1,2}),\s*(%f[0-9]{1,2}),\s*([%fx0-9]+),\s*(%f[0-9]{1,2})/
 		&uncamellia_f($1,$2,$3,$4,$5)
-	 /ge or
+	 /geo or
 	s/\b(camellia_[^s]+)\s+(%f[0-9]{1,2}),\s*(%f[0-9]{1,2}),\s*(%f[0-9]{1,2})/
 		&uncamellia3($1,$2,$3,$4)
-	 /ge or
+	 /geo or
+	s/\b(des_\w+)\s+(?<rs1>%f[0-9]{1,2}),\s*(?<rs2>[%fx0-9]+)(,\s*(?<rs3>%f[0-9]{1,2})(,\s*(?<rs4>%f[0-9]{1,2}))?)?/
+		&undes($1,$+{rs1},$+{rs2},$+{rs3},$+{rs4})
+	 /geo or
 	s/\b(mov[ds]to\w+)\s+(%f[0-9]{1,2}),\s*(%[goli][0-7])/
 		&unmovxtox($1,$2,$3)
-	 /ge or
+	 /geo or
 	s/\b(mov[xw]to[ds])\s+(%[goli][0-7]),\s*(%f[0-9]{1,2})/
 		&unmovxtox($1,$2,$3)
-	 /ge or
-	s/\b(f[^\s]*)\s+(%f[0-9]{1,2}),\s*(%f[0-9]{1,2}),\s*(%f[0-9]{1,2})/
+	 /geo or
+	s/\b([fb][^\s]*)\s+(%f[0-9]{1,2}),\s*(%f[0-9]{1,2}),\s*(%f[0-9]{1,2})/
 		&unvis($1,$2,$3,$4)
-	 /ge or
-	s/\b(alignaddr[l]*)\s+(%[goli][0-7]),\s*(%[goli][0-7]),\s*(%[goli][0-7])/
-		&unalignaddr($1,$2,$3,$4)
-	 /ge or
-	s/\b(umulxhi|addxc[c]{0,2})\s+(%[goli][0-7]),\s*(%[goli][0-7]),\s*(%[goli][0-7])/
+	 /geo or
+	s/\b(umulxhi|bmask|addxc[c]{0,2}|alignaddr[l]*)\s+(%[goli][0-7]),\s*(%[goli][0-7]),\s*(%[goli][0-7])/
 		&unvis3($1,$2,$3,$4)
-	 /ge;
+	 /geo;
 
 	print $_,"\n";
     }
--- a/components/openssl/openssl-1.0.1/patches/openssl-1.0.1e-t4-engine.sparc-patch	Thu Jun 27 13:48:41 2013 -0700
+++ b/components/openssl/openssl-1.0.1/patches/openssl-1.0.1e-t4-engine.sparc-patch	Thu Jun 27 14:24:42 2013 -0700
@@ -11,11 +11,11 @@
 
  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 aest4-sparcv9.o::md5-sparcv9.o:sha1-sparcv9.o sha256-sparcv9.o sha512-sparcv9.o:::::::ghash-sparcv9.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 dest4-sparcv9.o:aes_core.o aes_cbc.o aes-sparcv9.o aest4-sparcv9.o::md5-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 aest4-sparcv9.o::md5-sparcv9.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 aest4-sparcv9.o::md5-sparcv9.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 $sparcv9_asm="sparcv9cap.o sparccpuid.o:bn-sparcv9.o sparcv9-mont.o sparcv9a-mont.o:des_enc-sparc.o fcrypt_b.o dest4-sparcv9.o:aes_core.o aes_cbc.o aes-sparcv9.o aest4-sparcv9.o::md5-sparcv9.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 dest4-sparcv9.o:aes_core.o aes_cbc.o aes-sparcv9.o aest4-sparcv9.o::md5-sparcv9.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_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::::::::";
@@ -49,7 +49,7 @@
  GENERAL=Makefile
  #TEST=aestest.c
  TEST=
-@@ -69,6 +73,10 @@
+@@ -72,6 +76,10 @@
  aes-sparcv9.s: asm/aes-sparcv9.pl
  	$(PERL) asm/aes-sparcv9.pl $(CFLAGS) > $@
 
@@ -60,33 +60,6 @@
  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
@@ -96,7 +69,7 @@
  	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.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 hw_pk11.c hw_pk11_pub.c hw_pk11_uri.c
  LIBOBJ= eng_err.o eng_lib.o eng_list.o eng_init.o eng_ctrl.o \
@@ -104,7 +77,7 @@
  	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.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 hw_pk11.o hw_pk11_pub.o hw_pk11_uri.o
  
--- a/components/openssl/openssl-1.0.1/patches/openssl-t4-inline.sparc-patch	Thu Jun 27 13:48:41 2013 -0700
+++ b/components/openssl/openssl-1.0.1/patches/openssl-t4-inline.sparc-patch	Thu Jun 27 14:24:42 2013 -0700
@@ -11,7 +11,7 @@
  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 $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 aest4-sparcv9.o::md5-sparcv9.o:sha1-sparcv9.o sha256-sparcv9.o sha512-sparcv9.o:::::::ghash-sparcv9.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 dest4-sparcv9.o:aes_core.o aes_cbc.o aes-sparcv9.o aest4-sparcv9.o::md5-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 $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::::::::";
@@ -829,6 +829,340 @@
 +}
 +
  close STDOUT;
+Index: crypto/des/Makefile
+===================================================================
+diff -ru openssl-1.0.1e/crypto/des/Makefile.orig openssl-1.0.1e/crypto/des/Makefile
+--- a/crypto/des/Makefile
++++ b/crypto/des/Makefile
+@@ -61,6 +61,8 @@ des: des.o cbc3_enc.o lib
+ 
+ des_enc-sparc.S:	asm/des_enc.m4
+ 	m4 -B 8192 asm/des_enc.m4 > des_enc-sparc.S
++dest4-sparcv9.s:	asm/dest4-sparcv9.pl
++	$(PERL) asm/dest4-sparcv9.pl $(CFLAGS) > $@
+ 
+ des-586.s:	asm/des-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
+ 	$(PERL) asm/des-586.pl $(PERLASM_SCHEME) $(CFLAGS) > $@
+Index: crypto/evp/e_des.c
+===================================================================
+diff -ru openssl-1.0.1e/crypto/evp/e_des.c.orig openssl-1.0.1e/crypto/evp/e_des.c
+--- a/crypto/evp/e_des.c
++++ b/crypto/evp/e_des.c
+@@ -65,6 +65,30 @@
+ #include <openssl/des.h>
+ #include <openssl/rand.h>
+ 
++typedef struct
++	{
++	union { double align; DES_key_schedule ks; } ks;
++	union {
++		void (*cbc)(const void *,void *,size_t,const void *,void *);
++	} stream;
++	} EVP_DES_KEY;
++
++#if defined(AES_ASM) && (defined(__sparc) || defined(__sparc__))
++/* ---------^^^ this is not a typo, just a way to detect that
++ * assembler support was in general requested... */
++#include "sparc_arch.h"
++
++extern unsigned int OPENSSL_sparcv9cap_P[];
++
++#define SPARC_DES_CAPABLE	(OPENSSL_sparcv9cap_P[1] & CFR_DES)
++
++void	des_t4_key_expand(const void *key, DES_key_schedule *ks);
++void	des_t4_cbc_encrypt(const void *inp,void *out,size_t len,
++				DES_key_schedule *ks,unsigned char iv[8]);
++void	des_t4_cbc_decrypt(const void *inp,void *out,size_t len,
++				DES_key_schedule *ks,unsigned char iv[8]);
++#endif
++
+ static int des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
+ 			const unsigned char *iv, int enc);
+ static int des_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr);
+@@ -99,6 +123,13 @@ static int des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ static int des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ 			  const unsigned char *in, size_t inl)
+ {
++	EVP_DES_KEY *dat = (EVP_DES_KEY *)ctx->cipher_data;
++
++	if (dat->stream.cbc)
++		{
++		(*dat->stream.cbc)(in,out,inl,&dat->ks.ks,ctx->iv);
++		return 1;
++		}
+ 	while(inl>=EVP_MAXCHUNK)
+ 		{
+ 		DES_ncbc_encrypt(in, out, (long)EVP_MAXCHUNK, ctx->cipher_data,
+@@ -176,18 +207,18 @@
+     return 1;
+     }
+ 
+-BLOCK_CIPHER_defs(des, DES_key_schedule, NID_des, 8, 8, 8, 64,
++BLOCK_CIPHER_defs(des, EVP_DES_KEY, NID_des, 8, 8, 8, 64,
+ 			EVP_CIPH_RAND_KEY, des_init_key, NULL,
+ 			EVP_CIPHER_set_asn1_iv,
+ 			EVP_CIPHER_get_asn1_iv,
+ 			des_ctrl)
+ 
+-BLOCK_CIPHER_def_cfb(des,DES_key_schedule,NID_des,8,8,1,
++BLOCK_CIPHER_def_cfb(des,EVP_DES_KEY,NID_des,8,8,1,
+ 		     EVP_CIPH_RAND_KEY, des_init_key,NULL,
+ 		     EVP_CIPHER_set_asn1_iv,
+ 		     EVP_CIPHER_get_asn1_iv,des_ctrl)
+ 
+-BLOCK_CIPHER_def_cfb(des,DES_key_schedule,NID_des,8,8,8,
++BLOCK_CIPHER_def_cfb(des,EVP_DES_KEY,NID_des,8,8,8,
+ 		     EVP_CIPH_RAND_KEY,des_init_key,NULL,
+ 		     EVP_CIPHER_set_asn1_iv,
+ 		     EVP_CIPHER_get_asn1_iv,des_ctrl)
+@@ -196,8 +227,25 @@ static int des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
+ 			const unsigned char *iv, int enc)
+ 	{
+ 	DES_cblock *deskey = (DES_cblock *)key;
++	EVP_DES_KEY *dat = (EVP_DES_KEY *)ctx->cipher_data;
++
++	dat->stream.cbc = NULL;
++#if defined(SPARC_DES_CAPABLE)
++	if (SPARC_DES_CAPABLE)
++		{
++		int mode = ctx->cipher->flags & EVP_CIPH_MODE;
++
++		if (mode == EVP_CIPH_CBC_MODE)
++			{
++			des_t4_key_expand(key,&dat->ks.ks);
++			dat->stream.cbc = enc ? des_t4_cbc_encrypt :
++						des_t4_cbc_decrypt;
++			return 1;
++			}
++		}
++#endif
+ #ifdef EVP_CHECK_DES_KEY
+-	if(DES_set_key_checked(deskey,ctx->cipher_data) != 0)
++	if(DES_set_key_checked(deskey,dat->ks.ks) != 0)
+ 		return 0;
+ #else
+ 	DES_set_key_unchecked(deskey,ctx->cipher_data);
+Index: crypto/evp/e_des3.c
+===================================================================
+diff -ru openssl-1.0.1e/crypto/evp/e_des3.c.orig openssl-1.0.1e/crypto/evp/e_des3.c
+--- a/crypto/evp/e_des3.c
++++ b/crypto/evp/e_des3.c
+@@ -65,6 +65,33 @@
+ #include <openssl/des.h>
+ #include <openssl/rand.h>
+ 
++typedef struct
++	{
++	union { double align; DES_key_schedule ks[3]; } ks;
++	union {
++		void (*cbc)(const void *,void *,size_t,const void *,void *);
++	} stream;
++	} DES_EDE_KEY;
++#define ks1 ks.ks[0]
++#define ks2 ks.ks[1]
++#define ks3 ks.ks[2]
++
++#if defined(AES_ASM) && (defined(__sparc) || defined(__sparc__))
++/* ---------^^^ this is not a typo, just a way to detect that
++ * assembler support was in general requested... */
++#include "sparc_arch.h"
++
++extern unsigned int OPENSSL_sparcv9cap_P[];
++
++#define SPARC_DES_CAPABLE	(OPENSSL_sparcv9cap_P[1] & CFR_DES)
++
++void	des_t4_key_expand(const void *key, DES_key_schedule *ks);
++void	des_t4_ede3_cbc_encrypt(const void *inp,void *out,size_t len,
++				DES_key_schedule *ks,unsigned char iv[8]);
++void	des_t4_ede3_cbc_decrypt(const void *inp,void *out,size_t len,
++				DES_key_schedule *ks,unsigned char iv[8]);
++#endif
++
+ #ifndef OPENSSL_FIPS
+ 
+ static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
+@@ -75,13 +100,6 @@ static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
+ 
+ static int des3_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr);
+ 
+-typedef struct
+-    {
+-    DES_key_schedule ks1;/* key schedule */
+-    DES_key_schedule ks2;/* key schedule (for ede) */
+-    DES_key_schedule ks3;/* key schedule (for ede3) */
+-    } DES_EDE_KEY;
+-
+ #define data(ctx) ((DES_EDE_KEY *)(ctx)->cipher_data)
+ 
+ /* Because of various casts and different args can't use IMPLEMENT_BLOCK_CIPHER */
+@@ -121,6 +141,8 @@ static int des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ 			      const unsigned char *in, size_t inl)
+ {
++	DES_EDE_KEY *dat = data(ctx);
++
+ #ifdef KSSL_DEBUG
+ 	{
+         int i;
+@@ -132,10 +152,16 @@ static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ 	printf("\n");
+ 	}
+ #endif    /* KSSL_DEBUG */
++	if (dat->stream.cbc)
++		{
++		(*dat->stream.cbc)(in,out,inl,&dat->ks,ctx->iv);
++		return 1;
++		}
++
+ 	if (inl>=EVP_MAXCHUNK)
+ 		{
+ 		DES_ede3_cbc_encrypt(in, out, (long)EVP_MAXCHUNK,
+-			     &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3,
++			     &dat->ks1, &dat->ks2, &dat->ks3,
+ 			     (DES_cblock *)ctx->iv, ctx->encrypt);
+ 		inl-=EVP_MAXCHUNK;
+ 		in +=EVP_MAXCHUNK;
+@@ -143,7 +169,7 @@ static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ 		}
+ 	if (inl)
+ 		DES_ede3_cbc_encrypt(in, out, (long)inl,
+-			     &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3,
++			     &dat->ks1, &dat->ks2, &dat->ks3,
+                              (DES_cblock *)ctx->iv, ctx->encrypt);
+ 	return 1;
+ }
+@@ -208,9 +234,8 @@ static int des_ede3_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+     }
+ 
+ BLOCK_CIPHER_defs(des_ede, DES_EDE_KEY, NID_des_ede, 8, 16, 8, 64,
+-			EVP_CIPH_RAND_KEY, des_ede_init_key, NULL, 
+-			EVP_CIPHER_set_asn1_iv,
+-			EVP_CIPHER_get_asn1_iv,
++			EVP_CIPH_RAND_KEY|EVP_CIPH_FLAG_DEFAULT_ASN1,
++			des_ede_init_key, NULL, NULL, NULL,
+ 			des3_ctrl)
+ 
+ #define des_ede3_cfb64_cipher des_ede_cfb64_cipher
+@@ -219,37 +246,53 @@
+ #define des_ede3_ecb_cipher des_ede_ecb_cipher
+ 
+ BLOCK_CIPHER_defs(des_ede3, DES_EDE_KEY, NID_des_ede3, 8, 24, 8, 64,
+-			EVP_CIPH_RAND_KEY, des_ede3_init_key, NULL, 
+-			EVP_CIPHER_set_asn1_iv,
+-			EVP_CIPHER_get_asn1_iv,
+-			des3_ctrl)
++		EVP_CIPH_RAND_KEY|EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1,
++		des_ede3_init_key, NULL, NULL, NULL,
++		des3_ctrl)
+ 
+ BLOCK_CIPHER_def_cfb(des_ede3,DES_EDE_KEY,NID_des_ede3,24,8,1,
+-		     EVP_CIPH_RAND_KEY, des_ede3_init_key,NULL,
+-		     EVP_CIPHER_set_asn1_iv,
+-		     EVP_CIPHER_get_asn1_iv,
+-		     des3_ctrl)
++		EVP_CIPH_RAND_KEY|EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1,
++		des_ede3_init_key, NULL, NULL, NULL,
++		des3_ctrl)
+ 
+ BLOCK_CIPHER_def_cfb(des_ede3,DES_EDE_KEY,NID_des_ede3,24,8,8,
+-		     EVP_CIPH_RAND_KEY, des_ede3_init_key,NULL,
+-		     EVP_CIPHER_set_asn1_iv,
+-		     EVP_CIPHER_get_asn1_iv,
+-		     des3_ctrl)
++		EVP_CIPH_RAND_KEY|EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_DEFAULT_ASN1,
++		des_ede3_init_key, NULL, NULL, NULL,
++		des3_ctrl)
+ 
+ static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
+ 			    const unsigned char *iv, int enc)
+ 	{
+ 	DES_cblock *deskey = (DES_cblock *)key;
++	DES_EDE_KEY *dat = data(ctx);
++
++	dat->stream.cbc = NULL;
++#if defined(SPARC_DES_CAPABLE)
++	if (SPARC_DES_CAPABLE)
++		{
++		int mode = ctx->cipher->flags & EVP_CIPH_MODE;
++
++		if (mode == EVP_CIPH_CBC_MODE)
++			{
++			des_t4_key_expand(&deskey[0],&dat->ks1);
++			des_t4_key_expand(&deskey[1],&dat->ks2);
++			memcpy(&dat->ks3,&dat->ks1,sizeof(dat->ks1));
++			dat->stream.cbc = enc ? des_t4_ede3_cbc_encrypt :
++						des_t4_ede3_cbc_decrypt;
++			return 1;
++			}
++		}
++#endif
+ #ifdef EVP_CHECK_DES_KEY
+-	if (DES_set_key_checked(&deskey[0],&data(ctx)->ks1)
+-		!! DES_set_key_checked(&deskey[1],&data(ctx)->ks2))
++	if (DES_set_key_checked(&deskey[0],&dat->ks1)
++		!! DES_set_key_checked(&deskey[1],&dat->ks2))
+ 		return 0;
+ #else
+-	DES_set_key_unchecked(&deskey[0],&data(ctx)->ks1);
+-	DES_set_key_unchecked(&deskey[1],&data(ctx)->ks2);
++	DES_set_key_unchecked(&deskey[0],&dat->ks1);
++	DES_set_key_unchecked(&deskey[1],&dat->ks2);
+ #endif
+-	memcpy(&data(ctx)->ks3,&data(ctx)->ks1,
+-	       sizeof(data(ctx)->ks1));
++	memcpy(&dat->ks3,&dat->ks1,
++		sizeof(dat->ks1));
+ 	return 1;
+ 	}
+ 
+@@ -257,6 +300,8 @@ static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
+ 			     const unsigned char *iv, int enc)
+ 	{
+ 	DES_cblock *deskey = (DES_cblock *)key;
++	DES_EDE_KEY *dat = data(ctx);
++
+ #ifdef KSSL_DEBUG
+ 	{
+         int i;
+@@ -268,15 +313,32 @@ static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
+ 	}
+ #endif	/* KSSL_DEBUG */
+ 
++	dat->stream.cbc = NULL;
++#if defined(SPARC_DES_CAPABLE)
++	if (SPARC_DES_CAPABLE)
++		{
++		int mode = ctx->cipher->flags & EVP_CIPH_MODE;
++
++		if (mode == EVP_CIPH_CBC_MODE)
++			{
++			des_t4_key_expand(&deskey[0],&dat->ks1);
++			des_t4_key_expand(&deskey[1],&dat->ks2);
++			des_t4_key_expand(&deskey[2],&dat->ks3);
++			dat->stream.cbc = enc ? des_t4_ede3_cbc_encrypt :
++						des_t4_ede3_cbc_decrypt;
++			return 1;
++			}
++		}
++#endif
+ #ifdef EVP_CHECK_DES_KEY
+-	if (DES_set_key_checked(&deskey[0],&data(ctx)->ks1)
+-		|| DES_set_key_checked(&deskey[1],&data(ctx)->ks2)
+-		|| DES_set_key_checked(&deskey[2],&data(ctx)->ks3))
++	if (DES_set_key_checked(&deskey[0],&dat->ks1)
++		|| DES_set_key_checked(&deskey[1],&dat->ks2)
++		|| DES_set_key_checked(&deskey[2],&dat->ks3))
+ 		return 0;
+ #else
+-	DES_set_key_unchecked(&deskey[0],&data(ctx)->ks1);
+-	DES_set_key_unchecked(&deskey[1],&data(ctx)->ks2);
+-	DES_set_key_unchecked(&deskey[2],&data(ctx)->ks3);
++	DES_set_key_unchecked(&deskey[0],&dat->ks1);
++	DES_set_key_unchecked(&deskey[1],&dat->ks2);
++	DES_set_key_unchecked(&deskey[2],&dat->ks3);
+ #endif
+ 	return 1;
+ 	}
 Index: openssl/apps/speed.c
 ===================================================================
 diff -ru openssl-1.0.1e/apps/spped.c openssl-1.0.1e/apps/speed.c
@@ -856,7 +1190,7 @@
 ===================================================================
 --- Makefile    Thu May  2 13:42:37 2013
 +++ Makefile.orig       Thu May  2 13:41:51 2013
-@@ -73,6 +73,9 @@
+@@ -69,6 +69,9 @@
  aes-sparcv9.s: asm/aes-sparcv9.pl
  	$(PERL) asm/aes-sparcv9.pl $(CFLAGS) > $@