7069023 OpenSSL t4 engine improvements: des, 3des, sha-224/384, and remove proprietary code
--- a/components/openssl/openssl-1.0.0/Makefile Tue Nov 29 05:42:26 2011 -0800
+++ b/components/openssl/openssl-1.0.0/Makefile Tue Nov 29 11:18:53 2011 -0800
@@ -129,6 +129,7 @@
$(CP) -fp engines/pkcs11/*.[ch] $(@D)/crypto/engine; \
$(CP) -fp engines/t4/eng_t4*.[ch] $(@D)/crypto/engine; \
$(CP) -fp engines/t4/t4_aes.S $(@D)/crypto/aes/asm; \
+ $(CP) -fp engines/t4/t4_des.S $(@D)/crypto/des/asm; \
$(CP) -fp engines/t4/t4_md5.S $(@D)/crypto/md5/asm; \
$(CP) -fp engines/t4/t4_sha?.S $(@D)/crypto/sha/asm; )
--- a/components/openssl/openssl-1.0.0/engines/devcrypto/e_devcrypto.c Tue Nov 29 05:42:26 2011 -0800
+++ b/components/openssl/openssl-1.0.0/engines/devcrypto/e_devcrypto.c Tue Nov 29 11:18:53 2011 -0800
@@ -71,6 +71,7 @@
int max_key_len;
CK_KEY_TYPE key_type;
CK_MECHANISM_TYPE mech_type;
+ unsigned long flags;
crypto_mech_type_t pn_internal_number;
} devcrypto_cipher_t;
@@ -101,40 +102,45 @@
* Cipher Table for all supported symmetric ciphers.
*/
static devcrypto_cipher_t cipher_table[] = {
+ /* id, nid, iv_len, min_, max_key_len, */
+ /* key_type, mech_type, flags, pn_internal_number */
{ DEV_DES_CBC, NID_des_cbc, 8, 8, 8,
- CKK_DES, CKM_DES_CBC, CRYPTO_MECH_INVALID},
+ CKK_DES, CKM_DES_CBC, 0, CRYPTO_MECH_INVALID},
{ DEV_DES3_CBC, NID_des_ede3_cbc, 8, 24, 24,
- CKK_DES3, CKM_DES3_CBC, CRYPTO_MECH_INVALID},
+ CKK_DES3, CKM_DES3_CBC, 0, CRYPTO_MECH_INVALID},
{ DEV_DES_ECB, NID_des_ecb, 0, 8, 8,
- CKK_DES, CKM_DES_ECB, CRYPTO_MECH_INVALID},
+ CKK_DES, CKM_DES_ECB, 0, CRYPTO_MECH_INVALID},
{ DEV_DES3_ECB, NID_des_ede3_ecb, 0, 24, 24,
- CKK_DES3, CKM_DES3_ECB, CRYPTO_MECH_INVALID},
+ CKK_DES3, CKM_DES3_ECB, 0, CRYPTO_MECH_INVALID},
{ DEV_RC4, NID_rc4, 0, 16, 256,
- CKK_RC4, CKM_RC4, CRYPTO_MECH_INVALID},
+ CKK_RC4, CKM_RC4, 0, CRYPTO_MECH_INVALID},
{ DEV_AES_128_CBC, NID_aes_128_cbc, 16, 16, 16,
- CKK_AES, CKM_AES_CBC, CRYPTO_MECH_INVALID},
+ CKK_AES, CKM_AES_CBC, 0, CRYPTO_MECH_INVALID},
{ DEV_AES_192_CBC, NID_aes_192_cbc, 16, 24, 24,
- CKK_AES, CKM_AES_CBC, CRYPTO_MECH_INVALID},
+ CKK_AES, CKM_AES_CBC, 0, CRYPTO_MECH_INVALID},
{ DEV_AES_256_CBC, NID_aes_256_cbc, 16, 32, 32,
- CKK_AES, CKM_AES_CBC, CRYPTO_MECH_INVALID},
+ CKK_AES, CKM_AES_CBC, 0, CRYPTO_MECH_INVALID},
{ DEV_AES_128_ECB, NID_aes_128_ecb, 0, 16, 16,
- CKK_AES, CKM_AES_ECB, CRYPTO_MECH_INVALID},
+ CKK_AES, CKM_AES_ECB, 0, CRYPTO_MECH_INVALID},
{ DEV_AES_192_ECB, NID_aes_192_ecb, 0, 24, 24,
- CKK_AES, CKM_AES_ECB, CRYPTO_MECH_INVALID},
+ CKK_AES, CKM_AES_ECB, 0, CRYPTO_MECH_INVALID},
{ DEV_AES_256_ECB, NID_aes_256_ecb, 0, 32, 32,
- CKK_AES, CKM_AES_ECB, CRYPTO_MECH_INVALID},
+ CKK_AES, CKM_AES_ECB, 0, CRYPTO_MECH_INVALID},
{ DEV_BLOWFISH_CBC, NID_bf_cbc, 8, 16, 16,
- CKK_BLOWFISH, CKM_BLOWFISH_CBC, CRYPTO_MECH_INVALID},
+ CKK_BLOWFISH, CKM_BLOWFISH_CBC, 0, CRYPTO_MECH_INVALID},
/*
* For the following 3 AES counter mode entries, we don't know the
* NIDs until the engine is initialized
*/
{ DEV_AES_128_CTR, NID_undef, 16, 16, 16,
- CKK_AES, CKM_AES_CTR, CRYPTO_MECH_INVALID},
+ CKK_AES, CKM_AES_CTR, EVP_CIPH_NO_PADDING,
+ CRYPTO_MECH_INVALID},
{ DEV_AES_192_CTR, NID_undef, 16, 24, 24,
- CKK_AES, CKM_AES_CTR, CRYPTO_MECH_INVALID},
+ CKK_AES, CKM_AES_CTR, EVP_CIPH_NO_PADDING,
+ CRYPTO_MECH_INVALID},
{ DEV_AES_256_CTR, NID_undef, 16, 32, 32,
- CKK_AES, CKM_AES_CTR, CRYPTO_MECH_INVALID},
+ CKK_AES, CKM_AES_CTR, EVP_CIPH_NO_PADDING,
+ CRYPTO_MECH_INVALID},
};
@@ -145,7 +151,20 @@
const unsigned char *in, size_t inl);
static int devcrypto_cipher_cleanup(EVP_CIPHER_CTX *ctx);
-/* OpenSSL's libcrypto EVP stuff. This is how this engine gets wired to EVP. */
+/*
+ * 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 devcrypto engine is kept in devcrypto_ctx_t, which is
+ * pointed to by cipher_data or md_data.
+ *
+ * Fields: nid, block_size, key_len, iv_len, flags,
+ * init(), do_cipher(), cleanup(),
+ * ctx_size,
+ * set_asn1_parameters(), get_asn1_parameters(), ctrl(), app_data
+ */
static const EVP_CIPHER dev_des_cbc = {
NID_des_cbc,
8, 8, 8,
@@ -802,7 +821,6 @@
int r;
uint_t rv = 0;
-
if (key == NULL) {
DEVCRYPTOerr(DEVC_F_CIPHER_INIT, DEVC_R_CIPHER_KEY);
return (0);
@@ -824,6 +842,9 @@
return (0);
}
+ /* Set cipher flags, if any */
+ ctx->flags |= the_cipher->flags;
+
/* get the mechanism string */
mech_string = pkcs11_mech2str(the_cipher->mech_type);
if (mech_string == NULL) {
--- a/components/openssl/openssl-1.0.0/engines/t4/eng_t4.c Tue Nov 29 05:42:26 2011 -0800
+++ b/components/openssl/openssl-1.0.0/engines/t4/eng_t4.c Tue Nov 29 11:18:53 2011 -0800
@@ -1,22 +1,56 @@
/*
- * CDDL HEADER START
+ * 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:
*
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
+ * 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/)"
*
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
+ * 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/)"
*
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
+ * 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.
+ * ====================================================================
*/
/*
@@ -35,10 +69,9 @@
#include <sys/types.h>
#include <sys/auxv.h> /* getisax() */
#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
#include <errno.h>
-
-#include <openssl/bio.h>
#include <openssl/aes.h>
#include <openssl/engine.h>
#include "eng_t4_aes_asm.h"
@@ -114,7 +147,7 @@
void
ENGINE_load_t4(void)
{
-#ifdef COMPILE_HW_T4
+#ifdef COMPILE_HW_T4
ENGINE *toadd = ENGINE_new();
if (toadd != NULL) {
if (t4_bind_helper(toadd, ENGINE_T4_ID) != 0) {
@@ -131,15 +164,14 @@
#ifdef COMPILE_HW_T4
static int t4_bind(ENGINE *e);
-#ifndef DYNAMIC_ENGINE
+#ifndef DYNAMIC_ENGINE
#pragma inline(t4_bind)
#endif
static t4_cipher_id get_cipher_index_by_nid(int nid);
#pragma inline(get_cipher_index_by_nid)
-static boolean_t t4_aes_instructions_present(void);
-#pragma inline(t4_aes_instructions_present)
-static boolean_t t4_digest_instructions_present(void);
-#pragma inline(t4_digest_instructions_present)
+static void t4_instructions_present(_Bool *aes_present, _Bool *des_present,
+ _Bool *digest_present);
+#pragma inline(t4_instructions_present)
/* Digest registration function. Called by ENGINE_set_ciphers() */
int t4_get_all_digests(ENGINE *e, const EVP_MD **digest,
@@ -166,27 +198,24 @@
/* Static variables */
/* This can't be const as NID*ctr is inserted when the engine is initialized */
static int t4_cipher_nids[] = {
- NID_aes_128_cbc,
- NID_aes_192_cbc,
- NID_aes_256_cbc,
+ NID_aes_128_cbc, NID_aes_192_cbc, NID_aes_256_cbc,
#ifndef SOLARIS_NO_AES_CFB128
- NID_aes_128_cfb128,
- NID_aes_192_cfb128,
- NID_aes_256_cfb128,
+ NID_aes_128_cfb128, NID_aes_192_cfb128, NID_aes_256_cfb128,
#endif
#ifndef SOLARIS_NO_AES_CTR
- NID_undef, /* NID_t4_aes_128_ctr */
- NID_undef, /* NID_t4_aes_192_ctr */
- NID_undef, /* NID_t4_aes_256_ctr */
+ /* NID_t4_aes_128_ctr, NID_t4_aes_192, NID_t4_aes_256 */
+ NID_undef, NID_undef, NID_undef,
#endif
- NID_aes_128_ecb,
- NID_aes_192_ecb,
- NID_aes_256_ecb,
+ NID_aes_128_ecb, NID_aes_192_ecb, NID_aes_256_ecb,
+#ifndef OPENSSL_NO_DES
+ /* Must be at end of list (see t4_des_cipher_count in t4_bind() */
+ NID_des_cbc, NID_des_ede3_cbc, NID_des_ecb, NID_des_ede3_ecb,
+#endif
};
-static const int t4_cipher_count =
+static const int t4_des_cipher_count = 4;
+static int t4_cipher_count =
(sizeof (t4_cipher_nids) / sizeof (t4_cipher_nids[0]));
-
/*
* Cipher Table for all supported symmetric ciphers.
* Must be in same order as t4_cipher_id.
@@ -260,13 +289,12 @@
* 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 the last field, app_data.
+ * 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
- * For the T4 engine, field app_data points to t4_cipher_ctx_t.
*/
static const EVP_CIPHER t4_aes_128_cbc = {
@@ -393,38 +421,173 @@
NULL, NULL, NULL, NULL
};
+#ifndef OPENSSL_NO_DES
+extern const EVP_CIPHER t4_des_cbc;
+extern const EVP_CIPHER t4_des3_cbc;
+extern const EVP_CIPHER t4_des_ecb;
+extern const EVP_CIPHER t4_des3_ecb;
+#endif /* OPENSSL_NO_DES */
+
+
+/*
+ * Message Digest variables
+ */
+static const int t4_digest_nids[] = {
+#ifndef OPENSSL_NO_MD5
+ NID_md5,
+#endif
+#ifndef OPENSSL_NO_SHA
+#ifndef OPENSSL_NO_SHA1
+ NID_sha1,
+#endif
+#ifndef OPENSSL_NO_SHA256
+ NID_sha224,
+ NID_sha256,
+#endif
+#ifndef OPENSSL_NO_SHA512
+ NID_sha384,
+ NID_sha512,
+#endif
+#endif /* !OPENSSL_NO_SHA */
+};
+static const int t4_digest_count =
+ (sizeof (t4_digest_nids) / sizeof (t4_digest_nids[0]));
+
+#ifndef OPENSSL_NO_MD5
+extern const EVP_MD t4_md5;
+#endif
+#ifndef OPENSSL_NO_SHA
+#ifndef OPENSSL_NO_SHA1
+extern const EVP_MD t4_sha1;
+#endif
+#ifndef OPENSSL_NO_SHA256
+extern const EVP_MD t4_sha224;
+extern const EVP_MD t4_sha256;
+#endif
+#ifndef OPENSSL_NO_SHA512
+extern const EVP_MD t4_sha384;
+extern const EVP_MD t4_sha512;
+#endif
+#endif /* !OPENSSL_NO_SHA */
+
+/*
+ * Message Digest functions
+ */
/*
- * Return true if executing on a SPARC processor with AES instruction support,
- * such as a T4; otherwise false.
+ * Registered by the ENGINE with ENGINE_set_digests().
+ * Finds out how to deal with a particular digest NID in the ENGINE.
*/
-static boolean_t
-t4_aes_instructions_present(void)
+/* ARGSUSED */
+int
+t4_get_all_digests(ENGINE *e, const EVP_MD **digest,
+ const int **nids, int nid)
{
- uint_t ui;
+ if (digest == NULL) { /* return a list of all supported digests */
+ *nids = (t4_digest_count > 0) ? t4_digest_nids : NULL;
+ return (t4_digest_count);
+ }
- (void) getisax(&ui, 1);
- return ((ui & AV_SPARC_AES) != 0);
+ switch (nid) {
+#ifndef OPENSSL_NO_MD5
+ case NID_md5:
+ *digest = &t4_md5;
+ break;
+#endif
+#ifndef OPENSSL_NO_SHA
+#ifndef OPENSSL_NO_SHA1
+ /*
+ * A special case. For "openssl dgst -dss1 ...",
+ * OpenSSL calls EVP_get_digestbyname() on "dss1" which ends up
+ * calling t4_get_all_digests() for NID_dsa. Internally, if an
+ * engine is not used, OpenSSL uses SHA1_Init() as expected for
+ * DSA. So, we must return t4_sha1 for NID_dsa as well. Note
+ * that this must have changed between 0.9.8 and 1.0.0 since we
+ * did not have the problem with the 0.9.8 version.
+ */
+ case NID_dsa:
+ case NID_sha1:
+ *digest = &t4_sha1;
+ break;
+#endif
+#ifndef OPENSSL_NO_SHA256
+ case NID_sha224:
+ *digest = &t4_sha224;
+ break;
+ case NID_sha256:
+ *digest = &t4_sha256;
+ break;
+#endif
+#ifndef OPENSSL_NO_SHA512
+ case NID_sha384:
+ *digest = &t4_sha384;
+ break;
+ case NID_sha512:
+ *digest = &t4_sha512;
+ break;
+#endif
+#endif /* !OPENSSL_NO_SHA */
+ default:
+ /* digest not supported */
+ *digest = NULL;
+ return (0);
+ }
+
+ return (1);
}
/*
- * Return true if executing on a SPARC processor with MD5/SHA1/SHA{1,256,512}
- * instruction support, such as a T4; otherwise false.
+ * Utility Functions
*/
-static boolean_t
-t4_digest_instructions_present(void)
+
+/*
+ * Set aes_present, des_present, and digest_present to 0 or 1 depending on
+ * whether the current SPARC processor supports AES, DES, and
+ * MD5/SHA1/SHA256/SHA512, respectively.
+ */
+static void
+t4_instructions_present(_Bool *aes_present, _Bool *des_present,
+ _Bool *digest_present)
{
+#ifdef OPENSSL_NO_DES
+#undef AV_SPARC_DES
+#define AV_SPARC_DES 0
+#endif
+#ifdef OPENSSL_NO_MD5
+#undef AV_SPARC_MD5
+#define AV_SPARC_MD5 0
+#endif
#ifndef OPENSSL_NO_SHA
-#define UI_MASK (AV_SPARC_MD5 | AV_SPARC_SHA1 | AV_SPARC_SHA256 | \
+#ifdef OPENSSL_NO_SHA1
+#undef AV_SPARC_SHA1
+#define AV_SPARC_SHA1 0
+#endif
+#ifdef OPENSSL_NO_SHA256
+#undef AV_SPARC_SHA256
+#define AV_SPARC_SHA256 0
+#endif
+#ifdef OPENSSL_NO_SHA512
+#undef AV_SPARC_SHA512
+#define AV_SPARC_SHA512 0
+#endif
+#else
+#undef AV_SPARC_SHA1
+#undef AV_SPARC_SHA256
+#undef AV_SPARC_SHA512
+#define AV_SPARC_SHA1 0
+#define AV_SPARC_SHA256 0
+#define AV_SPARC_SHA512 0
+#endif /* !OPENSSL_NO_SHA */
+
+#define DIGEST_MASK (AV_SPARC_MD5 | AV_SPARC_SHA1 | AV_SPARC_SHA256 | \
AV_SPARC_SHA512)
-#else
-#define UI_MASK (AV_SPARC_MD5)
-#endif
uint_t ui;
(void) getisax(&ui, 1);
- return ((ui & UI_MASK) == UI_MASK);
+ *aes_present = (ui & AV_SPARC_AES) != 0;
+ *des_present = (ui & AV_SPARC_DES) != 0;
+ *digest_present = (ui & DIGEST_MASK) == DIGEST_MASK;
}
@@ -595,6 +758,20 @@
*cipher = &t4_aes_256_cfb128;
break;
#endif /* !SOLARIS_NO_AES_CFB128 */
+#ifndef OPENSSL_NO_DES
+ case NID_des_cbc:
+ *cipher = &t4_des_cbc;
+ break;
+ case NID_des_ede3_cbc:
+ *cipher = &t4_des3_cbc;
+ break;
+ case NID_des_ecb:
+ *cipher = &t4_des_ecb;
+ break;
+ case NID_des_ede3_ecb:
+ *cipher = &t4_des3_ecb;
+ break;
+#endif /* !OPENSSL_NO_DES */
default:
#ifndef SOLARIS_NO_AES_CTR
@@ -678,7 +855,7 @@
if (((unsigned long)key & 0x7) == 0) /* already aligned */
aligned_key = (uint64_t *)key;
else { /* key is not 8-byte aligned */
-#ifdef DEBUG_T4
+#ifdef DEBUG_T4
(void) fprintf(stderr, "T4: key is not 8 byte aligned\n");
#endif
(void) memcpy(aligned_key_buffer, key, key_len);
@@ -721,7 +898,7 @@
/* Save index to cipher */
tctx->index = index;
- /* Process IV */
+ /* 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 */
@@ -731,7 +908,7 @@
(void) memcpy(tctx->aligned_iv_buffer, ctx->iv,
ctx->cipher->iv_len);
tctx->iv = tctx->aligned_iv_buffer;
-#ifdef DEBUG_T4
+#ifdef DEBUG_T4
(void) fprintf(stderr,
"t4_cipher_init_aes: IV is not 8 byte aligned\n");
(void) fprintf(stderr,
@@ -806,8 +983,7 @@
} else { /* decrypt */ \
t4_aes_load_keys_for_decrypt(t4_ks); \
t4_aes_decrypt(t4_ks, (uint64_t *)bufin, \
- (uint64_t *)bufout, \
- (size_t)inl, iv); \
+ (uint64_t *)bufout, (size_t)inl, iv); \
} \
\
/* Cleanup */ \
@@ -909,21 +1085,21 @@
static int
t4_bind(ENGINE *e)
{
- static int aes_engage = -1, digest_engage = -1;
+ _Bool aes_engage, digest_engage, des_engage;
- if (aes_engage == -1) {
- aes_engage = (t4_aes_instructions_present() != 0);
+ t4_instructions_present(&aes_engage, &des_engage, &digest_engage);
+#ifdef DEBUG_T4
+ (void) fprintf(stderr,
+ "t4_bind: engage aes=%d, des=%d, digest=%d\n",
+ aes_engage, des_engage, digest_engage);
+#endif
+#ifndef OPENSSL_NO_DES
+ if (!des_engage) { /* Remove DES ciphers from list */
+ t4_cipher_count -= t4_des_cipher_count;
}
- if (digest_engage == -1) {
- digest_engage = (t4_digest_instructions_present() != 0);
- }
-
-#ifdef DEBUG_T4
- (void) fprintf(stderr,
- "t4_bind: engage aes=%d, digest=%d\n", aes_engage, digest_engage);
#endif
-#ifndef SOLARIS_NO_AES_CTR
+#ifndef SOLARIS_NO_AES_CTR
/*
* We must do this before we start working with slots since we need all
* NIDs there.
@@ -936,7 +1112,7 @@
}
#endif /* !SOLARIS_NO_AES_CTR */
-#ifdef DEBUG_T4
+#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) {
@@ -982,7 +1158,7 @@
}
-#ifdef DYNAMIC_ENGINE
+#ifdef DYNAMIC_ENGINE
IMPLEMENT_DYNAMIC_CHECK_FN()
IMPLEMENT_DYNAMIC_BIND_FN(t4_bind_helper)
#endif /* DYNAMIC_ENGINE */
--- a/components/openssl/openssl-1.0.0/engines/t4/eng_t4_aes_asm.h Tue Nov 29 05:42:26 2011 -0800
+++ b/components/openssl/openssl-1.0.0/engines/t4/eng_t4_aes_asm.h Tue Nov 29 11:18:53 2011 -0800
@@ -1,22 +1,56 @@
/*
- * CDDL HEADER START
+ * This product includes cryptographic software developed by the OpenSSL
+ * Project for use in the OpenSSL Toolkit (http://www.openssl.org/).
+ */
+
+/*
+ * ====================================================================
+ * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
*
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
+ * 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/)"
*
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
+ * 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/)"
*
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
+ * 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.
+ * ====================================================================
*/
/*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/components/openssl/openssl-1.0.0/engines/t4/eng_t4_des.c Tue Nov 29 11:18:53 2011 -0800
@@ -0,0 +1,486 @@
+/*
+ * This product includes cryptographic software developed by the OpenSSL
+ * Project for use in the OpenSSL Toolkit (http://www.openssl.org/).
+ */
+
+/*
+ * ====================================================================
+ * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * [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 */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/components/openssl/openssl-1.0.0/engines/t4/eng_t4_des_asm.h Tue Nov 29 11:18:53 2011 -0800
@@ -0,0 +1,98 @@
+/*
+ * This product includes cryptographic software developed by the OpenSSL
+ * Project for use in the OpenSSL Toolkit (http://www.openssl.org/).
+ */
+
+/*
+ * ====================================================================
+ * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * [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.0/engines/t4/eng_t4_digest.c Tue Nov 29 05:42:26 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,766 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- */
-
-/*
- * The basic framework for this code came from the reference
- * implementation for MD5 provided in RFC 1321.
- *
- * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
- * rights reserved.
- *
- * License to copy and use this software is granted provided that it
- * is identified as the "RSA Data Security, Inc. MD5 Message-Digest
- * Algorithm" in all material mentioning or referencing this software
- * or this function.
- *
- * License is also granted to make and use derivative works provided
- * that such works are identified as "derived from the RSA Data
- * Security, Inc. MD5 Message-Digest Algorithm" in all material
- * mentioning or referencing the derived work.
- *
- * RSA Data Security, Inc. makes no representations concerning either
- * the merchantability of this software or the suitability of this
- * software for any particular purpose. It is provided "as is"
- * without express or implied warranty of any kind.
- *
- * These notices must be retained in any copies of any part of this
- * documentation and/or software.
- */
-
-
-/*
- * This engine supports SPARC microprocessors that provide AES and other
- * cipher and hash instructions, such as the T4 microprocessor.
- *
- * This file implements the MD5, SHA1, and SHA2 message digest operations.
- */
-
-#include <openssl/opensslconf.h>
-
-#if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_MD_T4)
-#include <sys/types.h>
-#include <sys/auxv.h> /* getisax() */
-#include <sys/sysmacros.h> /* IS_P2ALIGNED() */
-#include <sys/byteorder.h> /* htonl() and friends */
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-#ifndef OPENSSL_NO_SHA
-/*
- * Solaris sys/sha2.h and OpenSSL openssl/sha.h both define
- * SHA256_CTX, SHA512_CTX, SHA256, SHA384, and SHA512.
- */
-#define SHA256_CTX OPENSSL_SHA256_CTX
-#define SHA512_CTX OPENSSL_SHA512_CTX
-#define SHA256 OPENSSL_SHA256
-#define SHA512 OPENSSL_SHA512
-#include <openssl/sha.h>
-#undef SHA256_CTX
-#undef SHA512_CTX
-#undef SHA256
-#undef SHA512
-#endif /* !OPENSSL_NO_SHA */
-
-#include <openssl/bio.h>
-#include <openssl/aes.h>
-#include <openssl/engine.h>
-
-/* Solaris digest definitions (must follow openssl/sha.h) */
-#include <sys/md5.h>
-#ifndef OPENSSL_NO_SHA
-#include <sys/sha1.h>
-#define _SHA2_IMPL /* Required for SHA*_MECH_INFO_TYPE enum */
-#include <sys/sha2.h>
-#endif /* !OPENSSL_NO_SHA */
-
-#if (defined(sun4v) || defined(__sparcv9) || defined(__sparcv8plus) || \
- defined(__sparcv8)) && !defined(OPENSSL_NO_ASM)
-#define COMPILE_HW_T4
-#endif
-
-#ifdef COMPILE_HW_T4
-
-/* Copied from OpenSSL md5.h */
-#ifndef MD5_CBLOCK
-#define MD5_CBLOCK 64
-#endif
-
-/* Padding needed is 64 bytes for MD5 and SHA1, 128 for SHA2 */
-static const uint8_t PADDING[128] = { 0x80, 0 /* all zeros */ };
-
-static const int t4_digest_nids[] = {
- NID_md5,
-#ifndef OPENSSL_NO_SHA
- NID_sha1,
- NID_sha256,
- NID_sha512,
-#endif /* !OPENSSL_NO_SHA */
-};
-static const int t4_digest_count =
- (sizeof (t4_digest_nids) / sizeof (t4_digest_nids[0]));
-
-/* Assembly language functions */
-extern void t4_md5_multiblock(MD5_CTX *ctx, const uint8_t *input,
- unsigned int input_length_in_blocks);
-extern void t4_sha1_multiblock(SHA1_CTX *ctx, const uint8_t *input,
- size_t nr_blocks);
-extern void t4_sha256_multiblock(SHA2_CTX *ctx, const uint8_t *input,
- size_t nr_blocks);
-extern void t4_sha512_multiblock(SHA2_CTX *ctx, const uint8_t *input,
- size_t nr_blocks);
-
-/* Internal functions */
-static void t4_md5_encode(uint8_t *restrict output,
- const uint32_t *restrict input, size_t input_len);
-#pragma inline(t4_md5_encode)
-static void t4_sha1_256_encode(uint8_t *restrict output,
- const uint32_t *restrict input, size_t len);
-#pragma inline(t4_sha1_256_encode)
-static void t4_sha512_encode64(uint8_t *restrict output,
- const uint64_t *restrict input, size_t len);
-#pragma inline(t4_sha512_encode64)
-
-/* Formal declaration for functions in EVP_MD structure */
-static int t4_digest_init_md5(EVP_MD_CTX *ctx);
-static int t4_digest_update_md5(EVP_MD_CTX *ctx, const void *data,
- size_t count);
-static int t4_digest_final_md5(EVP_MD_CTX *ctx, unsigned char *md);
-static int t4_digest_copy_md5(EVP_MD_CTX *to, const EVP_MD_CTX *from);
-#ifndef OPENSSL_NO_SHA
-static int t4_digest_init_sha1(EVP_MD_CTX *ctx);
-static int t4_digest_update_sha1(EVP_MD_CTX *ctx, const void *data,
- size_t count);
-static int t4_digest_final_sha1(EVP_MD_CTX *ctx, unsigned char *md);
-static int t4_digest_copy_sha1(EVP_MD_CTX *to, const EVP_MD_CTX *from);
-static int t4_digest_copy_sha2(EVP_MD_CTX *to, const EVP_MD_CTX *from);
-static int t4_digest_init_sha256(EVP_MD_CTX *ctx);
-static int t4_digest_update_sha256(EVP_MD_CTX *ctx, const void *data,
- size_t count);
-static int t4_digest_final_sha256(EVP_MD_CTX *ctx, unsigned char *md);
-static int t4_digest_init_sha512(EVP_MD_CTX *ctx);
-static int t4_digest_update_sha512(EVP_MD_CTX *ctx, const void *data,
- size_t count);
-static int t4_digest_final_sha512(EVP_MD_CTX *ctx, unsigned char *md);
-#endif /* !OPENSSL_NO_SHA */
-
-
-/*
- * Message Digests (MD5 and SHA*)
- *
- * OpenSSL's libcrypto EVP stuff. This is how this engine gets wired to EVP.
- * EVP_MD 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 the last field, app_data.
- *
- * Fields: type, pkey_type, md_size, flags,
- * init(), update(), final(),
- * copy(), cleanup(), sign(), verify(),
- * required_pkey_type, block_size, ctx_size, md5_ctrl()
- */
-static const EVP_MD t4_md5 = {
- NID_md5, NID_md5WithRSAEncryption, MD5_DIGEST_LENGTH, 0,
- t4_digest_init_md5, t4_digest_update_md5, t4_digest_final_md5,
- t4_digest_copy_md5, NULL,
- EVP_PKEY_RSA_method, MD5_CBLOCK,
- sizeof (MD5_CTX), NULL
- };
-
-#ifndef OPENSSL_NO_SHA
-static const EVP_MD t4_sha1 = {
- NID_sha1, NID_sha1WithRSAEncryption, SHA_DIGEST_LENGTH,
- EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT,
- t4_digest_init_sha1, t4_digest_update_sha1, t4_digest_final_sha1,
- t4_digest_copy_sha1, NULL,
- EVP_PKEY_RSA_method, SHA_CBLOCK,
- sizeof (SHA1_CTX), NULL
- };
-
-static const EVP_MD t4_sha256 = {
- NID_sha256, NID_sha256WithRSAEncryption, SHA256_DIGEST_LENGTH,
- EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT,
- t4_digest_init_sha256, t4_digest_update_sha256, t4_digest_final_sha256,
- t4_digest_copy_sha2, NULL,
- EVP_PKEY_RSA_method, SHA256_CBLOCK,
- sizeof (SHA2_CTX), NULL
- };
-
-static const EVP_MD t4_sha512 = {
- NID_sha512, NID_sha512WithRSAEncryption, SHA512_DIGEST_LENGTH,
- EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT,
- t4_digest_init_sha512, t4_digest_update_sha512, t4_digest_final_sha512,
- t4_digest_copy_sha2, NULL,
- EVP_PKEY_RSA_method, SHA512_CBLOCK,
- sizeof (SHA2_CTX), NULL
- };
-#endif /* !OPENSSL_NO_SHA */
-
-
-/*
- * Message Digest functions
- */
-
-/*
- * Registered by the ENGINE with ENGINE_set_digests().
- * Finds out how to deal with a particular digest NID in the ENGINE.
- */
-/* ARGSUSED */
-int
-t4_get_all_digests(ENGINE *e, const EVP_MD **digest,
- const int **nids, int nid)
-{
- if (digest == NULL) { /* return a list of all supported digests */
- *nids = (t4_digest_count > 0) ? t4_digest_nids : NULL;
- return (t4_digest_count);
- }
-
- switch (nid) {
- case NID_md5:
- *digest = &t4_md5;
- break;
-#ifndef OPENSSL_NO_SHA
- /*
- * A special case. For "openssl dgst -dss1 ...",
- * OpenSSL calls EVP_get_digestbyname() on "dss1" which ends up
- * calling t4_get_all_digests() for NID_dsa. Internally, if an
- * engine is not used, OpenSSL uses SHA1_Init() as expected for
- * DSA. So, we must return t4_sha1 for NID_dsa as well. Note
- * that this must have changed between 0.9.8 and 1.0.0 since we
- * did not have the problem with the 0.9.8 version.
- */
- case NID_dsa:
- case NID_sha1:
- *digest = &t4_sha1;
- break;
- case NID_sha256:
- *digest = &t4_sha256;
- break;
- case NID_sha512:
- *digest = &t4_sha512;
- break;
-#endif /* !OPENSSL_NO_SHA */
- default:
- /* digest not supported */
- *digest = NULL;
- return (0);
- }
-
- return (1);
-}
-
-
-/*
- * MD5 functions
- */
-static int
-t4_digest_init_md5(EVP_MD_CTX *ctx)
-{
- MD5_CTX *md5_ctx = (MD5_CTX *)ctx->md_data;
-
- md5_ctx->state[0] = 0x01234567U;
- md5_ctx->state[1] = 0x89abcdefU;
- md5_ctx->state[2] = 0xfedcba98U;
- md5_ctx->state[3] = 0x76543210U;
- md5_ctx->count[0] = md5_ctx->count[1] = 0;
-
- return (1);
-}
-
-
-/*
- * Continue a MD5 digest operation, using the message block to update the
- * context. MD5 crunches in 64-byte blocks.
- */
-static int
-t4_digest_update_md5(EVP_MD_CTX *ctx, const void *data, size_t count)
-{
- MD5_CTX *md5_ctx = (MD5_CTX *)ctx->md_data;
-
- uint32_t i = 0, buf_index, remaining_len;
- const uint32_t buf_limit = 64;
- uint32_t block_count;
- const unsigned char *input = (const unsigned char *)data;
-
- if (count == 0)
- return (1);
-
- /* Compute (number of bytes computed so far) mod 64 */
- buf_index = (md5_ctx->count[0] >> 3) & 0x3F;
-
- /* Update number of bits hashed into this MD5 computation so far */
- if ((md5_ctx->count[0] += (count << 3)) < (count << 3))
- md5_ctx->count[1]++;
- md5_ctx->count[1] += (count >> 29);
-
- remaining_len = buf_limit - buf_index;
-
- if (count >= remaining_len) {
- if (buf_index != 0) {
- (void) memcpy(&md5_ctx->buf_un.buf8[buf_index], input,
- remaining_len);
- t4_md5_multiblock(md5_ctx, md5_ctx->buf_un.buf8, 1);
- i = remaining_len;
- }
-
- block_count = (count - i) >> 6;
- if (block_count > 0) {
- t4_md5_multiblock(md5_ctx, &input[i], block_count);
- i += block_count << 6;
- }
-
- if (count == i) {
- return (1);
- }
-
- buf_index = 0;
- }
-
- /* Buffer remaining input */
- (void) memcpy(&md5_ctx->buf_un.buf8[buf_index], &input[i], count - i);
-
- return (1);
-}
-
-
-/* Convert numbers from big endian to little endian. */
-static void
-t4_md5_encode(uint8_t *restrict output, const uint32_t *restrict input,
- size_t input_len)
-{
- size_t i, j;
-
- for (i = 0, j = 0; j < input_len; i++, j += sizeof (uint32_t)) {
- output[j] = input[i] & 0xff;
- output[j + 1] = (input[i] >> 8) & 0xff;
- output[j + 2] = (input[i] >> 16) & 0xff;
- output[j + 3] = (input[i] >> 24) & 0xff;
- }
-}
-
-
-/* End MD5 digest operation, finalizing message digest and zeroing context. */
-static int
-t4_digest_final_md5(EVP_MD_CTX *ctx, unsigned char *md)
-{
- MD5_CTX *md5_ctx = (MD5_CTX *)ctx->md_data;
- uint8_t bitcount_le[sizeof (md5_ctx->count)];
- uint32_t index = (md5_ctx->count[0] >> 3) & 0x3f;
-
- /* store bit count, little endian */
- t4_md5_encode(bitcount_le, md5_ctx->count, sizeof (bitcount_le));
-
- /* pad out to 56 mod 64 */
- (void) t4_digest_update_md5(ctx, PADDING,
- ((index < 56) ? 56 : 120) - index);
-
- /* append length (before padding) */
- (void) t4_digest_update_md5(ctx, bitcount_le, sizeof (bitcount_le));
-
- (void) memcpy(md, md5_ctx->state, 16);
-
- /* zeroize sensitive information */
- (void) memset(md5_ctx, 0, sizeof (*md5_ctx));
-
- return (1);
-}
-
-
-static int
-t4_digest_copy_md5(EVP_MD_CTX *to, const EVP_MD_CTX *from)
-{
- if ((to->md_data == NULL) || (from->md_data == NULL)) {
- return (1);
- }
- (void) memcpy(to->md_data, from->md_data, sizeof (MD5_CTX));
- return (1);
-}
-
-
-#ifndef OPENSSL_NO_SHA
-/*
- * SHA1 functions
- */
-static int
-t4_digest_init_sha1(EVP_MD_CTX *ctx)
-{
- SHA1_CTX *sha1_ctx = (SHA1_CTX *)ctx->md_data;
-
- sha1_ctx->state[0] = 0x67452301U;
- sha1_ctx->state[1] = 0xefcdab89U;
- sha1_ctx->state[2] = 0x98badcfeU;
- sha1_ctx->state[3] = 0x10325476U;
- sha1_ctx->state[4] = 0xc3d2e1f0U;
- sha1_ctx->count[0] = sha1_ctx->count[1] = 0;
-
- return (1);
-}
-
-
-/*
- * Continue a SHA1 digest operation, using the message block to update the
- * context.
- */
-static int
-t4_digest_update_sha1(EVP_MD_CTX *ctx, const void *data, size_t count)
-{
- SHA1_CTX *sha1_ctx = (SHA1_CTX *)ctx->md_data;
- size_t i;
- uint32_t buf_index, remaining_len;
- const uint32_t buf_limit = 64;
- const uint8_t *input = data;
- size_t block_count;
-
- if (count == 0)
- return (1);
-
- /* compute number of bytes mod 64 */
- buf_index = (sha1_ctx->count[1] >> 3) & 0x3F;
-
- /* update number of bits */
- if ((sha1_ctx->count[1] += (count << 3)) < (count << 3))
- sha1_ctx->count[0]++;
-
- sha1_ctx->count[0] += (count >> 29);
-
- remaining_len = buf_limit - buf_index;
-
- i = 0;
- if (count >= remaining_len) {
- if (buf_index) {
- (void) memcpy(&sha1_ctx->buf_un.buf8[buf_index], input,
- remaining_len);
-
- t4_sha1_multiblock(sha1_ctx, sha1_ctx->buf_un.buf8, 1);
- i = remaining_len;
- }
-
- block_count = (count - i) >> 6;
- if (block_count > 0) {
- t4_sha1_multiblock(sha1_ctx, &input[i], block_count);
- i += block_count << 6;
- }
-
- if (count == i)
- return (1);
-
- buf_index = 0;
- }
-
- /* buffer remaining input */
- (void) memcpy(&sha1_ctx->buf_un.buf8[buf_index], &input[i], count - i);
-
- return (1);
-}
-
-
-/* Convert numbers from little endian to big endian for SHA1/SHA384/SHA256. */
-static void
-t4_sha1_256_encode(uint8_t *restrict output,
- const uint32_t *restrict input, size_t len)
-{
- size_t i, j;
-
- if (IS_P2ALIGNED(output, sizeof (uint32_t))) {
- for (i = 0, j = 0; j < len; i++, j += sizeof (uint32_t)) {
- /* LINTED E_BAD_PTR_CAST_ALIGN */
- *((uint32_t *)(output + j)) = htonl(input[i]);
- }
- } else { /* Big and little endian independent, but slower */
- for (i = 0, j = 0; j < len; i++, j += 4) {
- output[j] = (input[i] >> 24) & 0xff;
- output[j + 1] = (input[i] >> 16) & 0xff;
- output[j + 2] = (input[i] >> 8) & 0xff;
- output[j + 3] = input[i] & 0xff;
- }
- }
-}
-
-
-/* End SHA1 digest operation, finalizing message digest and zeroing context. */
-static int
-t4_digest_final_sha1(EVP_MD_CTX *ctx, unsigned char *md)
-{
- SHA1_CTX *sha1_ctx = (SHA1_CTX *)ctx->md_data;
- uint8_t bitcount_be[sizeof (sha1_ctx->count)];
- uint32_t index = (sha1_ctx->count[1] >> 3) & 0x3f;
-
- /* store bit count, big endian */
- t4_sha1_256_encode(bitcount_be, sha1_ctx->count, sizeof (bitcount_be));
-
- /* pad out to 56 mod 64 */
- (void) t4_digest_update_sha1(ctx, PADDING,
- ((index < 56) ? 56 : 120) - index);
-
- /* append length (before padding) */
- (void) t4_digest_update_sha1(ctx, bitcount_be, sizeof (bitcount_be));
-
- /* store state in digest */
- t4_sha1_256_encode(md, sha1_ctx->state, sizeof (sha1_ctx->state));
-
- /* zeroize sensitive information */
- (void) memset(sha1_ctx, 0, sizeof (*sha1_ctx));
-
- return (1);
-}
-
-
-static int
-t4_digest_copy_sha1(EVP_MD_CTX *to, const EVP_MD_CTX *from)
-{
- if ((to->md_data == NULL) || (from->md_data == NULL)) {
- return (1);
- }
- (void) memcpy(to->md_data, from->md_data, sizeof (SHA1_CTX));
- return (1);
-}
-#endif /* !OPENSSL_NO_SHA */
-
-
-#ifndef OPENSSL_NO_SHA
-/* SHA2 (SHA256/SHA512) functions */
-static int
-t4_digest_copy_sha2(EVP_MD_CTX *to, const EVP_MD_CTX *from)
-{
- if ((to->md_data == NULL) || (from->md_data == NULL)) {
- return (1);
- }
- (void) memcpy(to->md_data, from->md_data, sizeof (SHA2_CTX));
- return (1);
-}
-
-
-/* Convert numbers from little endian to big endian for SHA384/SHA512. */
-static void t4_sha512_encode64(uint8_t *restrict output,
- const uint64_t *restrict input, size_t len)
-{
- size_t i, j;
-
- if (IS_P2ALIGNED(output, sizeof (uint64_t))) {
- for (i = 0, j = 0; j < len; i++, j += sizeof (uint64_t)) {
- /* LINTED E_BAD_PTR_CAST_ALIGN */
- *((uint64_t *)(output + j)) = htonll(input[i]);
- }
- } else { /* Big and little endian independent, but slower */
- for (i = 0, j = 0; j < len; i++, j += 8) {
- output[j] = (input[i] >> 56) & 0xff;
- output[j + 1] = (input[i] >> 48) & 0xff;
- output[j + 2] = (input[i] >> 40) & 0xff;
- output[j + 3] = (input[i] >> 32) & 0xff;
- output[j + 4] = (input[i] >> 24) & 0xff;
- output[j + 5] = (input[i] >> 16) & 0xff;
- output[j + 6] = (input[i] >> 8) & 0xff;
- output[j + 7] = input[i] & 0xff;
- }
- }
-}
-
-
-/*
- * SHA256 functions
- */
-static int
-t4_digest_init_sha256(EVP_MD_CTX *ctx)
-{
- SHA2_CTX *sha2_ctx = (SHA2_CTX *)ctx->md_data;
-
- sha2_ctx->algotype = SHA256_MECH_INFO_TYPE;
- sha2_ctx->state.s32[0] = 0x6a09e667U;
- sha2_ctx->state.s32[1] = 0xbb67ae85U;
- sha2_ctx->state.s32[2] = 0x3c6ef372U;
- sha2_ctx->state.s32[3] = 0xa54ff53aU;
- sha2_ctx->state.s32[4] = 0x510e527fU;
- sha2_ctx->state.s32[5] = 0x9b05688cU;
- sha2_ctx->state.s32[6] = 0x1f83d9abU;
- sha2_ctx->state.s32[7] = 0x5be0cd19U;
- sha2_ctx->count.c64[0] = sha2_ctx->count.c64[1] = 0;
-
- return (1);
-}
-
-
-/*
- * Continue a SHA256 digest operation, using the message block to update the
- * context.
- */
-static int
-t4_digest_update_sha256(EVP_MD_CTX *ctx, const void *data, size_t count)
-{
- SHA2_CTX *sha2_ctx = (SHA2_CTX *)ctx->md_data;
- size_t i;
- uint32_t buf_index, remaining_len;
- const uint32_t buf_limit = 64;
- const uint8_t *input = data;
- size_t block_count;
-
- if (count == 0)
- return (1);
-
- /* compute number of bytes mod 64 */
- buf_index = (sha2_ctx->count.c32[1] >> 3) & 0x3F;
-
- /* update number of bits */
- if ((sha2_ctx->count.c32[1] += (count << 3)) < (count << 3))
- sha2_ctx->count.c32[0]++;
-
- sha2_ctx->count.c32[0] += (count >> 29);
-
- remaining_len = buf_limit - buf_index;
-
- i = 0;
- if (count >= remaining_len) {
- if (buf_index) {
- (void) memcpy(&sha2_ctx->buf_un.buf8[buf_index], input,
- remaining_len);
- t4_sha256_multiblock(sha2_ctx, sha2_ctx->buf_un.buf8,
- 1);
- i = remaining_len;
- }
-
- block_count = (count - i) >> 6;
- if (block_count > 0) {
- t4_sha256_multiblock(sha2_ctx, &input[i], block_count);
- i += block_count << 6;
- }
-
- if (count == i)
- return (1);
-
- buf_index = 0;
- }
-
- /* buffer remaining input */
- (void) memcpy(&sha2_ctx->buf_un.buf8[buf_index], &input[i], count - i);
- return (1);
-}
-
-
-/* End SHA256 digest operation, finalizing message digest and zeroing context */
-static int
-t4_digest_final_sha256(EVP_MD_CTX *ctx, unsigned char *md)
-{
- SHA2_CTX *sha2_ctx = (SHA2_CTX *)ctx->md_data;
- uint8_t bitcount_be[sizeof (sha2_ctx->count.c32)];
- uint32_t index = (sha2_ctx->count.c32[1] >> 3) & 0x3f;
-
- t4_sha1_256_encode(bitcount_be, sha2_ctx->count.c32,
- sizeof (bitcount_be));
- (void) t4_digest_update_sha256(ctx, PADDING,
- ((index < 56) ? 56 : 120) - index);
- (void) t4_digest_update_sha256(ctx, bitcount_be, sizeof (bitcount_be));
- t4_sha1_256_encode(md, sha2_ctx->state.s32,
- sizeof (sha2_ctx->state.s32));
-
- /* zeroize sensitive information */
- (void) memset(sha2_ctx, 0, sizeof (*sha2_ctx));
-
- return (1);
-}
-
-
-/*
- * SHA512 functions
- */
-static int
-t4_digest_init_sha512(EVP_MD_CTX *ctx)
-{
- SHA2_CTX *sha2_ctx = (SHA2_CTX *)ctx->md_data;
-
- sha2_ctx->algotype = SHA512_MECH_INFO_TYPE;
- sha2_ctx->state.s64[0] = 0x6a09e667f3bcc908ULL;
- sha2_ctx->state.s64[1] = 0xbb67ae8584caa73bULL;
- sha2_ctx->state.s64[2] = 0x3c6ef372fe94f82bULL;
- sha2_ctx->state.s64[3] = 0xa54ff53a5f1d36f1ULL;
- sha2_ctx->state.s64[4] = 0x510e527fade682d1ULL;
- sha2_ctx->state.s64[5] = 0x9b05688c2b3e6c1fULL;
- sha2_ctx->state.s64[6] = 0x1f83d9abfb41bd6bULL;
- sha2_ctx->state.s64[7] = 0x5be0cd19137e2179ULL;
- sha2_ctx->count.c64[0] = sha2_ctx->count.c64[1] = 0;
-
- return (1);
-}
-
-
-/*
- * Continue a SHA512 digest operation, using the message block to update the
- * context.
- */
-static int
-t4_digest_update_sha512(EVP_MD_CTX *ctx, const void *data, size_t count)
-{
- SHA2_CTX *sha2_ctx = (SHA2_CTX *)ctx->md_data;
- size_t i;
- uint32_t buf_index, remaining_len;
- const uint32_t buf_limit = 128;
- const uint8_t *input = data;
- size_t block_count;
-
- if (count == 0)
- return (1);
-
- /* compute number of bytes mod 128 */
- buf_index = (sha2_ctx->count.c64[1] >> 3) & 0x7F;
-
- /* update numb-g -xer of bits */
- if ((sha2_ctx->count.c64[1] += (count << 3)) < (count << 3))
- sha2_ctx->count.c64[0]++;
-
- sha2_ctx->count.c64[0] += (count >> 29);
-
- remaining_len = buf_limit - buf_index;
-
- i = 0;
- if (count >= remaining_len) {
- if (buf_index) {
- (void) memcpy(&sha2_ctx->buf_un.buf8[buf_index], input,
- remaining_len);
- t4_sha512_multiblock(sha2_ctx, sha2_ctx->buf_un.buf8,
- 1);
- i = remaining_len;
- }
-
- block_count = (count - i) >> 7;
- if (block_count > 0) {
- t4_sha512_multiblock(sha2_ctx, &input[i], block_count);
- i += block_count << 7;
- }
-
- if (count == i)
- return (1);
-
- buf_index = 0;
- }
-
- /* buffer remaining input */
- (void) memcpy(&sha2_ctx->buf_un.buf8[buf_index], &input[i], count - i);
- return (1);
-}
-
-
-/* End SHA512 digest operation, finalizing message digest and zeroing context */
-static int
-t4_digest_final_sha512(EVP_MD_CTX *ctx, unsigned char *md)
-{
- SHA2_CTX *sha2_ctx = (SHA2_CTX *)ctx->md_data;
- uint8_t bitcount_be64[sizeof (sha2_ctx->count.c64)];
- uint32_t index = (sha2_ctx->count.c64[1] >> 3) & 0x7f;
-
- t4_sha512_encode64(bitcount_be64, sha2_ctx->count.c64,
- sizeof (bitcount_be64));
- (void) t4_digest_update_sha512(ctx, PADDING,
- ((index < 112) ? 112 : 240) - index);
- (void) t4_digest_update_sha512(ctx, bitcount_be64,
- sizeof (bitcount_be64));
- t4_sha512_encode64(md, sha2_ctx->state.s64,
- sizeof (sha2_ctx->state.s64));
-
- /* zeroize sensitive information */
- (void) memset(sha2_ctx, 0, sizeof (*sha2_ctx));
-
- return (1);
-}
-
-#endif /* !OPENSSL_NO_SHA */
-#endif /* COMPILE_HW_T4 */
-#endif /* !OPENSSL_NO_HW && !OPENSSL_NO_HW_MD_T4 */
--- a/components/openssl/openssl-1.0.0/engines/t4/eng_t4_err.c Tue Nov 29 05:42:26 2011 -0800
+++ b/components/openssl/openssl-1.0.0/engines/t4/eng_t4_err.c Tue Nov 29 11:18:53 2011 -0800
@@ -1,22 +1,56 @@
/*
- * CDDL HEADER START
+ * 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:
*
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
+ * 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/)"
*
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
+ * 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/)"
*
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
+ * 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.
+ * ====================================================================
*/
/*
@@ -42,6 +76,8 @@
{ERR_FUNC(T4_F_GET_ALL_CIPHERS), "T4_GET_ALL_CIPHERS"},
{ERR_FUNC(T4_F_CIPHER_DO_AES), "T4_CIPHER_DO_AES"},
{ERR_FUNC(T4_F_CIPHER_CLEANUP), "T4_CIPHER_CLEANUP"},
+ {ERR_FUNC(T4_F_CIPHER_INIT_DES), "T4_CIPHER_INIT_DES"},
+ {ERR_FUNC(T4_F_CIPHER_DO_DES), "T4_CIPHER_DO_DES"},
{0, NULL}
};
--- a/components/openssl/openssl-1.0.0/engines/t4/eng_t4_err.h Tue Nov 29 05:42:26 2011 -0800
+++ b/components/openssl/openssl-1.0.0/engines/t4/eng_t4_err.h Tue Nov 29 11:18:53 2011 -0800
@@ -1,22 +1,56 @@
/*
- * CDDL HEADER START
+ * 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:
*
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
+ * 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/)"
*
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
+ * 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/)"
*
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
+ * 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.
+ * ====================================================================
*/
/*
@@ -45,6 +79,8 @@
#define T4_F_GET_ALL_CIPHERS 105
#define T4_F_CIPHER_DO_AES 106
#define T4_F_CIPHER_CLEANUP 107
+#define T4_F_CIPHER_INIT_DES 108
+#define T4_F_CIPHER_DO_DES 109
/* Reason codes */
#define T4_R_CIPHER_KEY 100
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/components/openssl/openssl-1.0.0/engines/t4/eng_t4_md5.c Tue Nov 29 11:18:53 2011 -0800
@@ -0,0 +1,207 @@
+/*
+ * This product includes cryptographic software developed by the OpenSSL
+ * Project for use in the OpenSSL Toolkit (http://www.openssl.org/). This
+ * product includes cryptographic software written by Eric Young
+ * ([email protected]).
+ */
+
+/*
+ * ====================================================================
+ * 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 AES and other
+ * cipher and hash instructions, such as the T4 microprocessor.
+ *
+ * This file implements the MD5 message digest operations.
+ */
+
+#include <openssl/opensslconf.h>
+
+#if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_MD_T4)
+#ifndef OPENSSL_NO_MD5
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <openssl/aes.h>
+#include <openssl/engine.h>
+/*
+ * Solaris sys/md5.h and OpenSSL openssl/md5.h both define MD5_CTX.
+ * The OpenSSL MD5_CTX has an extra "num" field at the end.
+ */
+#include <openssl/md5.h>
+
+#if (defined(sun4v) || defined(__sparcv9) || defined(__sparcv8plus) || \
+ defined(__sparcv8)) && !defined(OPENSSL_NO_ASM)
+#define COMPILE_HW_T4
+#endif
+
+#ifdef COMPILE_HW_T4
+
+/* Assembly language function; replaces C function md5_block_data_order(): */
+extern void t4_md5_multiblock(MD5_CTX *ctx, const uint8_t *input,
+ unsigned int input_length_in_blocks);
+
+/* Formal declaration for functions in EVP_MD structure */
+int t4_digest_init_md5(EVP_MD_CTX *ctx);
+int t4_digest_update_md5(EVP_MD_CTX *ctx, const void *data, size_t count);
+int t4_digest_final_md5(EVP_MD_CTX *ctx, unsigned char *md);
+int t4_digest_copy_md5(EVP_MD_CTX *to, const EVP_MD_CTX *from);
+
+
+/*
+ * MD5 Message Digests
+ *
+ * OpenSSL's libcrypto EVP stuff. This is how this engine gets wired to EVP.
+ * EVP_MD 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 the last field, app_data.
+ *
+ * Fields: type, pkey_type, md_size, flags,
+ * init(), update(), final(),
+ * copy(), cleanup(), sign(), verify(),
+ * required_pkey_type, block_size, ctx_size, md5_ctrl()
+ */
+const EVP_MD t4_md5 = {
+ NID_md5, NID_md5WithRSAEncryption, MD5_DIGEST_LENGTH,
+ 0,
+ t4_digest_init_md5, t4_digest_update_md5, t4_digest_final_md5,
+ t4_digest_copy_md5, NULL,
+ EVP_PKEY_RSA_method, MD5_CBLOCK,
+ sizeof (MD5_CTX), NULL
+ };
+
+/* These functions are implemented in md32_common.h: */
+static int t4_md5_update(MD5_CTX *c, const void *data_, size_t len);
+static void t4_md5_transform(MD5_CTX *c, const unsigned char *data);
+static int t4_md5_final(unsigned char *md, MD5_CTX *c);
+#pragma inline(t4_md5_update, t4_md5_transform, t4_md5_final)
+
+#define DATA_ORDER_IS_LITTLE_ENDIAN
+/* HASH_LONG/MD5_LONG is a 32-bit unsigned: */
+#define HASH_LONG MD5_LONG
+#define HASH_CTX MD5_CTX
+#define HASH_CBLOCK MD5_CBLOCK
+#define HASH_UPDATE t4_md5_update
+#define HASH_TRANSFORM t4_md5_transform
+#define HASH_FINAL t4_md5_final
+#define HASH_BLOCK_DATA_ORDER t4_md5_multiblock
+/* HOST_l2c_t4: Hash is already byte-swapped as Little Endian for SPARC T4: */
+#define HOST_l2c_t4(l, c) (*((unsigned int *)(c)) = (l), (c) += 4, l)
+#define HASH_MAKE_STRING(c, s) do { \
+ unsigned int ll; \
+ ll = (c)->A; HOST_l2c_t4(ll, (s)); \
+ ll = (c)->B; HOST_l2c_t4(ll, (s)); \
+ ll = (c)->C; HOST_l2c_t4(ll, (s)); \
+ ll = (c)->D; HOST_l2c_t4(ll, (s)); \
+ } while (0)
+
+/* This defines HASH_UPDATE, HASH_TRANSFORM, HASH_FINAL functions: */
+#include "md32_common.h"
+
+
+/*
+ * MD5 functions (RFC 1321 The MD5 Message-Digest Algorithm)
+ */
+
+int
+t4_digest_init_md5(EVP_MD_CTX *ctx)
+{
+ MD5_CTX *c = (MD5_CTX *)ctx->md_data;
+
+ /* Optimization: don't call memset(c, 0,...) or initialize c->data[] */
+ c->Nl = c->Nh = c->num = 0;
+
+ /* Big Endian for T4 */
+ c->A = 0x01234567U;
+ c->B = 0x89abcdefU;
+ c->C = 0xfedcba98U;
+ c->D = 0x76543210U;
+
+ return (1);
+}
+
+/*
+ * Continue MD5 digest operation, using the message block to update context.
+ * MD5 crunches in 64-byte blocks.
+ */
+int
+t4_digest_update_md5(EVP_MD_CTX *ctx, const void *data, size_t len)
+{
+ return (t4_md5_update((MD5_CTX *)ctx->md_data, data, len));
+}
+
+/* End MD5 digest operation, finalizing message digest and zeroing context. */
+int
+t4_digest_final_md5(EVP_MD_CTX *ctx, unsigned char *md)
+{
+ return (t4_md5_final(md, (MD5_CTX *)ctx->md_data));
+}
+
+/* Required for Engine API */
+int
+t4_digest_copy_md5(EVP_MD_CTX *to, const EVP_MD_CTX *from)
+{
+ if ((to->md_data != NULL) && (from->md_data != NULL)) {
+ (void) memcpy(to->md_data, from->md_data, sizeof (MD5_CTX));
+ }
+ return (1);
+}
+
+#endif /* COMPILE_HW_T4 */
+#endif /* !OPENSSL_NO_MD5 */
+#endif /* !OPENSSL_NO_HW && !OPENSSL_NO_HW_MD_T4 */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/components/openssl/openssl-1.0.0/engines/t4/eng_t4_sha1.c Tue Nov 29 11:18:53 2011 -0800
@@ -0,0 +1,197 @@
+/*
+ * This product includes cryptographic software developed by the OpenSSL
+ * Project for use in the OpenSSL Toolkit (http://www.openssl.org/). This
+ * product includes cryptographic software written by Eric Young
+ * ([email protected]).
+ */
+
+/*
+ * ====================================================================
+ * 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 AES and other
+ * cipher and hash instructions, such as the T4 microprocessor.
+ *
+ * This file implements the SHA-1 message digest operations.
+ */
+
+#include <openssl/opensslconf.h>
+
+#if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_MD_T4)
+#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)
+#include <sys/types.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+/*
+ * For SHA1, OpenSSL SHA_CTX has an extra num field at the end,
+ * while the Solaris SHA1_CTX does not have this field.
+ */
+#include <openssl/engine.h>
+#include <openssl/sha.h>
+
+#if (defined(sun4v) || defined(__sparcv9) || defined(__sparcv8plus) || \
+ defined(__sparcv8)) && !defined(OPENSSL_NO_ASM)
+#define COMPILE_HW_T4
+#endif
+
+#ifdef COMPILE_HW_T4
+
+/* Assembly language function; replaces C function sha1_block_data_order(): */
+extern void t4_sha1_multiblock(SHA_CTX *ctx, const void *input, size_t num);
+
+/* Formal declaration for functions in EVP_MD structure */
+static int t4_digest_init_sha1(EVP_MD_CTX *ctx);
+static int t4_digest_update_sha1(EVP_MD_CTX *ctx, const void *data,
+ size_t len);
+static int t4_digest_final_sha1(EVP_MD_CTX *ctx, unsigned char *md);
+static int t4_digest_copy_sha1(EVP_MD_CTX *to, const EVP_MD_CTX *from);
+
+/*
+ * OpenSSL's libcrypto EVP stuff. This is how this engine gets wired to EVP.
+ * EVP_MD 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 the last field, app_data.
+ *
+ * Fields: type, pkey_type, md_size, flags,
+ * init(), update(), final(),
+ * copy(), cleanup(), sign(), verify(),
+ * required_pkey_type, block_size, ctx_size, md5_ctrl()
+ */
+const EVP_MD t4_sha1 = {
+ NID_sha1, NID_sha1WithRSAEncryption, SHA_DIGEST_LENGTH,
+ EVP_MD_FLAG_PKEY_METHOD_SIGNATURE | EVP_MD_FLAG_DIGALGID_ABSENT,
+ t4_digest_init_sha1, t4_digest_update_sha1, t4_digest_final_sha1,
+ t4_digest_copy_sha1, NULL,
+ EVP_PKEY_RSA_method, SHA_CBLOCK,
+ sizeof (SHA_CTX), NULL
+ };
+
+/* These functions are defined in md32_common.h: */
+static int t4_sha1_update(SHA_CTX *c, const void *data_, size_t len);
+static void t4_sha1_transform(SHA_CTX *c, const unsigned char *data);
+static int t4_sha1_final(unsigned char *md, SHA_CTX *c);
+#pragma inline(t4_sha1_update, t4_sha1_transform, t4_sha1_final)
+
+#define DATA_ORDER_IS_BIG_ENDIAN
+/* HASH_LONG/SHA_LONG is unsigned int (32 bits): */
+#define HASH_LONG SHA_LONG
+#define HASH_CTX SHA_CTX
+#define HASH_CBLOCK SHA_CBLOCK
+#define HASH_UPDATE t4_sha1_update
+#define HASH_TRANSFORM t4_sha1_transform
+#define HASH_FINAL t4_sha1_final
+#define HASH_BLOCK_DATA_ORDER t4_sha1_multiblock
+#define HASH_MAKE_STRING(c, s) do { \
+ unsigned int ll; \
+ ll = (c)->h0; HOST_l2c(ll, (s)); \
+ ll = (c)->h1; HOST_l2c(ll, (s)); \
+ ll = (c)->h2; HOST_l2c(ll, (s)); \
+ ll = (c)->h3; HOST_l2c(ll, (s)); \
+ ll = (c)->h4; HOST_l2c(ll, (s)); \
+ } while (0)
+
+/* This defines HASH_UPDATE, HASH_TRANSFORM, HASH_FINAL functions: */
+#include "md32_common.h"
+
+
+/*
+ * SHA-1 functions (FIPS 180-1 Secure Hash Standard)
+ */
+
+static int
+t4_digest_init_sha1(EVP_MD_CTX *ctx)
+{
+ SHA_CTX *c = (SHA_CTX *)ctx->md_data;
+
+ /* Optimization: don't call memset(c, 0,...) or initialize c->data[] */
+ c->Nl = c->Nh = c->num = 0;
+ c->h0 = 0x67452301U;
+ c->h1 = 0xefcdab89U;
+ c->h2 = 0x98badcfeU;
+ c->h3 = 0x10325476U;
+ c->h4 = 0xc3d2e1f0U;
+
+ return (1);
+}
+
+/* Continue SHA1 digest operation, using the message block to update context. */
+static int
+t4_digest_update_sha1(EVP_MD_CTX *ctx, const void *data, size_t len)
+{
+ return (t4_sha1_update((SHA_CTX *)ctx->md_data, data, len));
+}
+
+/* End SHA1 digest operation, finalizing message digest and zeroing context. */
+static int
+t4_digest_final_sha1(EVP_MD_CTX *ctx, unsigned char *md)
+{
+ return (t4_sha1_final(md, (SHA_CTX *)ctx->md_data));
+}
+
+/* Required for Engine API */
+static int
+t4_digest_copy_sha1(EVP_MD_CTX *to, const EVP_MD_CTX *from)
+{
+ if ((to->md_data != NULL) && (from->md_data != NULL)) {
+ (void) memcpy(to->md_data, from->md_data, sizeof (SHA_CTX));
+ }
+ return (1);
+}
+
+#endif /* COMPILE_HW_T4 */
+#endif /* !OPENSSL_NO_SHA && !OPENSSL_NO_SHA1 */
+#endif /* !OPENSSL_NO_HW && !OPENSSL_NO_HW_MD_T4 */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/components/openssl/openssl-1.0.0/engines/t4/eng_t4_sha256.c Tue Nov 29 11:18:53 2011 -0800
@@ -0,0 +1,246 @@
+/*
+ * This product includes cryptographic software developed by the OpenSSL
+ * Project for use in the OpenSSL Toolkit (http://www.openssl.org/). This
+ * product includes cryptographic software written by Eric Young
+ * ([email protected]).
+ */
+
+/*
+ * ====================================================================
+ * 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 AES and other
+ * cipher and hash instructions, such as the T4 microprocessor.
+ *
+ * This file implements the SHA-256 message digest operations.
+ */
+
+#include <openssl/opensslconf.h>
+
+#if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_MD_T4)
+#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA256)
+#include <sys/types.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <openssl/engine.h>
+/*
+ * Solaris sys/sha2.h and OpenSSL openssl/sha.h both define
+ * SHA256_CTX, SHA512_CTX, SHA256, SHA384, and SHA512.
+ * For SHA2, OpenSSL SHA256_CTX has extra num and md_len fields at
+ * the end and Solaris SHA2_CTX has an extra algotype field at the beginning.
+ */
+#include "eng_t4_sha2_asm.h"
+
+#if (defined(sun4v) || defined(__sparcv9) || defined(__sparcv8plus) || \
+ defined(__sparcv8)) && !defined(OPENSSL_NO_ASM)
+#define COMPILE_HW_T4
+#endif
+
+#ifdef COMPILE_HW_T4
+
+/* Formal declaration for functions in EVP_MD structure */
+static int t4_digest_init_sha256(EVP_MD_CTX *ctx);
+static int t4_digest_init_sha224(EVP_MD_CTX *ctx);
+static int t4_digest_update_sha256(EVP_MD_CTX *ctx, const void *data,
+ size_t len);
+static int t4_digest_final_sha256(EVP_MD_CTX *ctx, unsigned char *md);
+static int t4_digest_copy_sha256(EVP_MD_CTX *to, const EVP_MD_CTX *from);
+
+
+/*
+ * OpenSSL's libcrypto EVP stuff. This is how this engine gets wired to EVP.
+ * EVP_MD 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 the last field, app_data.
+ *
+ * Fields: type, pkey_type, md_size, flags,
+ * init(), update(), final(),
+ * copy(), cleanup(), sign(), verify(),
+ * required_pkey_type, block_size, ctx_size, md5_ctrl()
+ */
+const EVP_MD t4_sha256 = {
+ NID_sha256, NID_sha256WithRSAEncryption, SHA256_DIGEST_LENGTH,
+ EVP_MD_FLAG_PKEY_METHOD_SIGNATURE | EVP_MD_FLAG_DIGALGID_ABSENT,
+ t4_digest_init_sha256, t4_digest_update_sha256, t4_digest_final_sha256,
+ t4_digest_copy_sha256, NULL,
+ EVP_PKEY_RSA_method, SHA256_CBLOCK,
+ sizeof (T4_SHA256_CTX), NULL
+ };
+/* SHA-224 uses the same context, cblock size, & update function as SHA-256: */
+const EVP_MD t4_sha224 = {
+ NID_sha224, NID_sha224WithRSAEncryption, SHA224_DIGEST_LENGTH,
+ EVP_MD_FLAG_PKEY_METHOD_SIGNATURE | EVP_MD_FLAG_DIGALGID_ABSENT,
+ t4_digest_init_sha224, t4_digest_update_sha256, t4_digest_final_sha256,
+ t4_digest_copy_sha256, NULL,
+ EVP_PKEY_RSA_method, SHA256_CBLOCK,
+ sizeof (T4_SHA256_CTX), NULL
+ };
+
+/* These functions are defined in md32_common.h: */
+static int t4_sha256_update(T4_SHA256_CTX *c, const void *data_, size_t len);
+static void t4_sha256_transform(T4_SHA256_CTX *c, const unsigned char *data);
+static int t4_sha256_final(unsigned char *md, T4_SHA256_CTX *c);
+#pragma inline(t4_sha256_update, t4_sha256_transform, t4_sha256_final)
+
+#define DATA_ORDER_IS_BIG_ENDIAN
+/* HASH_LONG/SHA_LONG is unsigned int (32 bits): */
+#define HASH_LONG SHA_LONG
+#define HASH_CTX T4_SHA256_CTX
+#define HASH_CBLOCK SHA_CBLOCK
+#define HASH_UPDATE t4_sha256_update
+#define HASH_TRANSFORM t4_sha256_transform
+#define HASH_FINAL t4_sha256_final
+#define HASH_BLOCK_DATA_ORDER t4_sha256_multiblock
+#define HASH_MAKE_STRING(c, s) \
+ do { \
+ unsigned int ll, nn; \
+ switch ((c)->md_len) { \
+ case SHA256_DIGEST_LENGTH: \
+ for (nn = 0; nn < SHA256_DIGEST_LENGTH / 4; nn++) { \
+ ll = (c)->h[nn]; HOST_l2c(ll, (s)); } \
+ break; \
+ case SHA224_DIGEST_LENGTH: \
+ for (nn = 0; nn < SHA224_DIGEST_LENGTH / 4; nn++) { \
+ ll = (c)->h[nn]; HOST_l2c(ll, (s)); } \
+ break; \
+ default: \
+ if ((c)->md_len > SHA256_DIGEST_LENGTH) \
+ return (0); \
+ for (nn = 0; nn < (c)->md_len / 4; nn++) { \
+ ll = (c)->h[nn]; HOST_l2c(ll, (s)); } \
+ break; \
+ } \
+ } while (0)
+
+/* This defines HASH_UPDATE, HASH_TRANSFORM, HASH_FINAL functions: */
+#include "md32_common.h"
+
+
+/*
+ * SHA256 functions (part of FIPS 180-2 Secure Hash Standard)
+ */
+
+static int
+t4_digest_init_sha256(EVP_MD_CTX *ctx)
+{
+ T4_SHA256_CTX *c = (T4_SHA256_CTX *)ctx->md_data;
+
+ /* Optimization: don't call memset(c, 0,...) or initialize c->data[] */
+ c->Nl = c->Nh = c->num = 0;
+ c->h[0] = 0x6a09e667U;
+ c->h[1] = 0xbb67ae85U;
+ c->h[2] = 0x3c6ef372U;
+ c->h[3] = 0xa54ff53aU;
+ c->h[4] = 0x510e527fU;
+ c->h[5] = 0x9b05688cU;
+ c->h[6] = 0x1f83d9abU;
+ c->h[7] = 0x5be0cd19U;
+ c->md_len = SHA256_DIGEST_LENGTH;
+ return (1);
+}
+
+
+static int
+t4_digest_init_sha224(EVP_MD_CTX *ctx)
+{
+ T4_SHA256_CTX *c = (T4_SHA256_CTX *)ctx->md_data;
+
+ /* Optimization: don't call memset(c, 0,...) or initialize c->data[] */
+ c->Nl = c->Nh = c->num = 0;
+ c->h[0] = 0xc1059ed8UL;
+ c->h[1] = 0x367cd507UL;
+ c->h[2] = 0x3070dd17UL;
+ c->h[3] = 0xf70e5939UL;
+ c->h[4] = 0xffc00b31UL;
+ c->h[5] = 0x68581511UL;
+ c->h[6] = 0x64f98fa7UL;
+ c->h[7] = 0xbefa4fa4UL;
+ c->md_len = SHA224_DIGEST_LENGTH;
+ return (1);
+}
+
+/* Continue SHA256 digest operation, using message block to update context. */
+static int
+t4_digest_update_sha256(EVP_MD_CTX *ctx, const void *data, size_t len)
+{
+ T4_SHA256_CTX *sha256_ctx = (T4_SHA256_CTX *)ctx->md_data;
+
+ return (t4_sha256_update((T4_SHA256_CTX *)ctx->md_data, data, len));
+}
+
+/* End SHA256 digest operation, finalizing message digest and zeroing context */
+static int
+t4_digest_final_sha256(EVP_MD_CTX *ctx, unsigned char *md)
+{
+ T4_SHA256_CTX *sha256_ctx = (T4_SHA256_CTX *)ctx->md_data;
+
+ return (t4_sha256_final(md, (T4_SHA256_CTX *)ctx->md_data));
+}
+
+/* Required for Engine API */
+static int
+t4_digest_copy_sha256(EVP_MD_CTX *to, const EVP_MD_CTX *from)
+{
+ if ((to->md_data != NULL) && (from->md_data != NULL)) {
+ (void) memcpy(to->md_data, from->md_data,
+ sizeof (T4_SHA256_CTX));
+ }
+ return (1);
+}
+
+#endif /* COMPILE_HW_T4 */
+#endif /* !OPENSSL_NO_SHA && !OPENSSL_NO_SHA256 */
+#endif /* !OPENSSL_NO_HW && !OPENSSL_NO_HW_MD_T4 */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/components/openssl/openssl-1.0.0/engines/t4/eng_t4_sha2_asm.h Tue Nov 29 11:18:53 2011 -0800
@@ -0,0 +1,135 @@
+/*
+ * This product includes cryptographic software developed by the OpenSSL
+ * Project for use in the OpenSSL Toolkit (http://www.openssl.org/). This
+ * product includes cryptographic software written by Eric Young
+ * ([email protected]).
+ */
+
+/*
+ * ====================================================================
+ * 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_SHA2_ASM_H
+#define ENG_T4_SHA2_ASM_H
+
+/*
+ * SPARC T4 SHA2 (SHA256/SHA512) assembly language functions and context.
+ * The context must match that used by the Solaris SPARC T4 assembly
+ * (except for OpenSSL-specific fields num and md_len that aren't in Solaris).
+ *
+ * Based on OpenSSL file openssl/sha.h and Solaris file sys/sha2.h.
+ */
+
+#include <stddef.h>
+#include <sys/types.h>
+#include <openssl/sha.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef OPENSSL_NO_SHA256
+/*
+ * The contents of this structure are a private interface between the
+ * Init/Update/Multiblock/Final functions.
+ * Callers must never attempt to read or write any of the fields
+ * in this structure directly.
+ */
+typedef struct t4_SHA256state_st {
+ uint32_t algotype; /* Solaris-only field; unused here */
+ uint32_t algotype_pad; /* Pad to align next field 0 mod 8 */
+ uint32_t h[8]; /* State (ABCDEFGH) */
+ uint32_t h_pad[8]; /* Pad fields to match T4_SHA512_CTX */
+ uint32_t Nl, Nh; /* Number of bits, module 2^64 */
+ uint32_t Nl_pad, Nh_pad; /* Pad fields to match T4_SHA512_CTX */
+ uint32_t data[SHA_LBLOCK]; /* Input */
+ unsigned int num, md_len; /* Fields unused by Solaris assembly */
+} T4_SHA256_CTX;
+#endif /* !OPENSSL_NO_SHA256 */
+
+
+#ifndef OPENSSL_NO_SHA512
+/*
+ * The contents of this structure are a private interface between the
+ * Init/Update/Multiblock/Final functions.
+ * Callers must never attempt to read or write any of the fields
+ * in this structure directly.
+ */
+typedef struct t4_SHA512state_st {
+ uint32_t algotype; /* Solaris-only field; unused here */
+ uint64_t h[8]; /* State (ABCDEFGH) */
+ uint64_t Nl, Nh; /* Number of bits, module 2^128 */
+ union {
+ uint64_t d[SHA_LBLOCK];
+ unsigned char p[SHA512_CBLOCK];
+ } u; /* Input */
+ unsigned int num, md_len; /* Fields unused by Solaris assembly */
+} T4_SHA512_CTX;
+#endif /* !OPENSSL_NO_SHA512 */
+
+/*
+ * SPARC T4 assembly language functions
+ */
+#ifndef OPENSSL_NO_SHA256
+extern void t4_sha256_multiblock(T4_SHA256_CTX *c, const void *input,
+ size_t num);
+#endif
+#ifndef OPENSSL_NO_SHA512
+extern void t4_sha512_multiblock(T4_SHA512_CTX *c, const void *input,
+ size_t num);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* ENG_T4_SHA2_ASM_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/components/openssl/openssl-1.0.0/engines/t4/eng_t4_sha512.c Tue Nov 29 11:18:53 2011 -0800
@@ -0,0 +1,325 @@
+/*
+ * This product includes cryptographic software developed by the OpenSSL
+ * Project for use in the OpenSSL Toolkit (http://www.openssl.org/). This
+ * product includes cryptographic software written by Eric Young
+ * ([email protected]).
+ */
+
+/*
+ * ====================================================================
+ * 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 AES and other
+ * cipher and hash instructions, such as the T4 microprocessor.
+ *
+ * This file implements the SHA-512 message digest operations.
+ */
+
+#include <openssl/opensslconf.h>
+
+#if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_MD_T4)
+#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA512)
+#include <sys/types.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <openssl/engine.h>
+/*
+ * Solaris sys/sha2.h and OpenSSL openssl/sha.h both define
+ * SHA512_CTX, SHA512_CTX, SHA512, SHA384, and SHA512.
+ * For SHA2, OpenSSL SHA512_CTX has extra num and md_len fields at
+ * the end and Solaris SHA2_CTX has an extra algotype field at the beginning.
+ */
+#include "eng_t4_sha2_asm.h"
+
+#if (defined(sun4v) || defined(__sparcv9) || defined(__sparcv8plus) || \
+ defined(__sparcv8)) && !defined(OPENSSL_NO_ASM)
+#define COMPILE_HW_T4
+#endif
+
+#ifdef COMPILE_HW_T4
+
+/* Formal declaration for functions in EVP_MD structure */
+static int t4_digest_init_sha384(EVP_MD_CTX *ctx);
+static int t4_digest_init_sha512(EVP_MD_CTX *ctx);
+static int t4_digest_update_sha512(EVP_MD_CTX *ctx, const void *data,
+ size_t len);
+static int t4_digest_final_sha512(EVP_MD_CTX *ctx, unsigned char *md);
+static int t4_digest_copy_sha512(EVP_MD_CTX *to, const EVP_MD_CTX *from);
+
+
+/*
+ * OpenSSL's libcrypto EVP stuff. This is how this engine gets wired to EVP.
+ * EVP_MD 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 the last field, app_data.
+ *
+ * Fields: type, pkey_type, md_size, flags,
+ * init(), update(), final(),
+ * copy(), cleanup(), sign(), verify(),
+ * required_pkey_type, block_size, ctx_size, md5_ctrl()
+ */
+
+const EVP_MD t4_sha512 = {
+ NID_sha512, NID_sha512WithRSAEncryption, SHA512_DIGEST_LENGTH,
+ EVP_MD_FLAG_PKEY_METHOD_SIGNATURE | EVP_MD_FLAG_DIGALGID_ABSENT,
+ t4_digest_init_sha512, t4_digest_update_sha512, t4_digest_final_sha512,
+ t4_digest_copy_sha512, NULL,
+ EVP_PKEY_RSA_method, SHA512_CBLOCK,
+ sizeof (T4_SHA512_CTX), NULL
+ };
+/* SHA-384 uses the same context, cblock size, & update function as SHA-512: */
+const EVP_MD t4_sha384 = {
+ NID_sha384, NID_sha384WithRSAEncryption, SHA384_DIGEST_LENGTH,
+ EVP_MD_FLAG_PKEY_METHOD_SIGNATURE | EVP_MD_FLAG_DIGALGID_ABSENT,
+ t4_digest_init_sha384, t4_digest_update_sha512, t4_digest_final_sha512,
+ t4_digest_copy_sha512, NULL,
+ EVP_PKEY_RSA_method, SHA512_CBLOCK,
+ sizeof (T4_SHA512_CTX), NULL
+ };
+
+
+/*
+ * SHA512 functions (part of FIPS 180-2 Secure Hash Standard)
+ */
+
+static int
+t4_digest_init_sha512(EVP_MD_CTX *ctx)
+{
+ T4_SHA512_CTX *c = (T4_SHA512_CTX *)ctx->md_data;
+
+ c->Nl = c->Nh = c->num = 0;
+ c->h[0] = 0x6a09e667f3bcc908ULL;
+ c->h[1] = 0xbb67ae8584caa73bULL;
+ c->h[2] = 0x3c6ef372fe94f82bULL;
+ c->h[3] = 0xa54ff53a5f1d36f1ULL;
+ c->h[4] = 0x510e527fade682d1ULL;
+ c->h[5] = 0x9b05688c2b3e6c1fULL;
+ c->h[6] = 0x1f83d9abfb41bd6bULL;
+ c->h[7] = 0x5be0cd19137e2179ULL;
+ c->md_len = SHA512_DIGEST_LENGTH;
+
+ return (1);
+}
+
+
+static int
+t4_digest_init_sha384(EVP_MD_CTX *ctx)
+{
+ T4_SHA512_CTX *c = (T4_SHA512_CTX *)ctx->md_data;
+
+ c->Nl = c->Nh = c->num = 0;
+ c->h[0] = 0xcbbb9d5dc1059ed8ULL;
+ c->h[1] = 0x629a292a367cd507ULL;
+ c->h[2] = 0x9159015a3070dd17ULL;
+ c->h[3] = 0x152fecd8f70e5939ULL;
+ c->h[4] = 0x67332667ffc00b31ULL;
+ c->h[5] = 0x8eb44a8768581511ULL;
+ c->h[6] = 0xdb0c2e0d64f98fa7ULL;
+ c->h[7] = 0x47b5481dbefa4fa4ULL;
+ c->md_len = SHA384_DIGEST_LENGTH;
+
+ return (1);
+}
+
+
+/*
+ * Continue SHA512 or SHA384 digest operation, using the message block to
+ * update context.
+ * Modified from SHA512_Update() in OpenSSL crypto/sha/sha512.c.
+ */
+static int
+t4_digest_update_sha512(EVP_MD_CTX *ctx, const void *_data, size_t len)
+{
+ T4_SHA512_CTX *c = (T4_SHA512_CTX *)ctx->md_data;
+ SHA_LONG64 l;
+ unsigned char *p = c->u.p;
+ const unsigned char *data = (const unsigned char *)_data;
+
+ if (len == 0)
+ return (1);
+
+ l = (c->Nl + (((SHA_LONG64)len) << 3)) & 0xffffffffffffffffULL;
+ if (l < c->Nl)
+ c->Nh++;
+ if (sizeof (len) >= 8) {
+ c->Nh += (((SHA_LONG64)len) >> 61);
+ }
+ c->Nl = l;
+
+ if (c->num != 0) {
+ size_t n = sizeof (c->u) - c->num;
+
+ if (len < n) {
+ memcpy(p + c->num, data, len);
+ c->num += (unsigned int)len;
+ return (1);
+ } else {
+ memcpy(p + c->num, data, n);
+ c->num = 0;
+ len -= n;
+ data += n;
+ t4_sha512_multiblock(c, p, 1);
+ }
+ }
+
+ if (len >= sizeof (c->u)) {
+ if ((size_t)data % sizeof (c->u.d[0]) != 0) {
+ /* Align unaligned data one block-at-a-time */
+ while (len >= sizeof (c->u)) {
+ memcpy(p, data, sizeof (c->u));
+ t4_sha512_multiblock(c, p, 1);
+ len -= sizeof (c->u);
+ data += sizeof (c->u);
+ }
+ } else {
+ t4_sha512_multiblock(c, data, len / sizeof (c->u));
+ data += len;
+ len %= sizeof (c->u);
+ data -= len;
+ }
+ }
+
+ if (len != 0) {
+ memcpy(p, data, len);
+ c->num = (int)len;
+ }
+
+ return (1);
+}
+
+
+/*
+ * End SHA-512 or SHA-384 digest operation, finalizing message digest and
+ * zeroing context.
+ * Modified from SHA512_Final() in OpenSSL crypto/sha/sha512.c.
+ */
+static int
+t4_digest_final_sha512(EVP_MD_CTX *ctx, unsigned char *md)
+{
+ T4_SHA512_CTX *c = (T4_SHA512_CTX *)ctx->md_data;
+ unsigned char *p = (unsigned char *)c->u.p;
+ size_t n = c->num;
+
+ p[n] = 0x80; /* There always is a room for one */
+ n++;
+ if (n > (sizeof (c->u) - 16)) {
+ memset(p + n, 0, sizeof (c->u) - n);
+ n = 0;
+ t4_sha512_multiblock(c, p, 1);
+ }
+
+ memset(p+n, 0, sizeof (c->u) - 16 - n);
+ c->u.d[SHA_LBLOCK - 2] = c->Nh;
+ c->u.d[SHA_LBLOCK - 1] = c->Nl;
+
+ t4_sha512_multiblock(c, p, 1);
+
+ if (md == 0)
+ return (0);
+
+ switch (c->md_len) {
+ /* Let compiler decide if it's appropriate to unroll... */
+ case SHA384_DIGEST_LENGTH:
+ for (n = 0; n < SHA384_DIGEST_LENGTH / 8; n++) {
+ SHA_LONG64 t = c->h[n];
+
+ *(md++) = (unsigned char)(t >> 56);
+ *(md++) = (unsigned char)(t >> 48);
+ *(md++) = (unsigned char)(t >> 40);
+ *(md++) = (unsigned char)(t >> 32);
+ *(md++) = (unsigned char)(t >> 24);
+ *(md++) = (unsigned char)(t >> 16);
+ *(md++) = (unsigned char)(t >> 8);
+ *(md++) = (unsigned char)(t);
+ }
+ break;
+ case SHA512_DIGEST_LENGTH:
+ for (n = 0; n < SHA512_DIGEST_LENGTH / 8; n++) {
+ SHA_LONG64 t = c->h[n];
+
+ *(md++) = (unsigned char)(t >> 56);
+ *(md++) = (unsigned char)(t >> 48);
+ *(md++) = (unsigned char)(t >> 40);
+ *(md++) = (unsigned char)(t >> 32);
+ *(md++) = (unsigned char)(t >> 24);
+ *(md++) = (unsigned char)(t >> 16);
+ *(md++) = (unsigned char)(t >> 8);
+ *(md++) = (unsigned char)(t);
+ }
+ break;
+ /* ... as well as make sure md_len is not abused. */
+ default:
+ return (0);
+ }
+
+ return (1);
+}
+
+
+/* Required for Engine API */
+static int
+t4_digest_copy_sha512(EVP_MD_CTX *to, const EVP_MD_CTX *from)
+{
+ if ((to->md_data != NULL) && (from->md_data != NULL)) {
+ (void) memcpy(to->md_data, from->md_data,
+ sizeof (T4_SHA512_CTX));
+ }
+ return (1);
+}
+
+#endif /* COMPILE_HW_T4 */
+#endif /* !OPENSSL_NO_SHA && !OPENSSL_NO_SHA512 */
+#endif /* !OPENSSL_NO_HW && !OPENSSL_NO_HW_MD_T4 */
--- a/components/openssl/openssl-1.0.0/engines/t4/t4_aes.S Tue Nov 29 05:42:26 2011 -0800
+++ b/components/openssl/openssl-1.0.0/engines/t4/t4_aes.S Tue Nov 29 11:18:53 2011 -0800
@@ -1,22 +1,51 @@
/*
- * CDDL HEADER START
+ * ====================================================================
+ * 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:
*
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
+ * 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/)"
*
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
+ * 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/)"
*
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
+ * 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.
+ * ====================================================================
*/
/*
@@ -183,6 +212,26 @@
ld [%o1 + 0xc], %f3
!expand the key
+ !aes_kexpand1 %f0, %f2, 0x0, %f4
+ !aes_kexpand2 %f2, %f4, %f6
+ !aes_kexpand1 %f4, %f6, 0x1, %f8
+ !aes_kexpand2 %f6, %f8, %f10
+ !aes_kexpand1 %f8, %f10, 0x2, %f12
+ !aes_kexpand2 %f10, %f12, %f14
+ !aes_kexpand1 %f12, %f14, 0x3, %f16
+ !aes_kexpand2 %f14, %f16, %f18
+ !aes_kexpand1 %f16, %f18, 0x4, %f20
+ !aes_kexpand2 %f18, %f20, %f22
+ !aes_kexpand1 %f20, %f22, 0x5, %f24
+ !aes_kexpand2 %f22, %f24, %f26
+ !aes_kexpand1 %f24, %f26, 0x6, %f28
+ !aes_kexpand2 %f26, %f28, %f30
+ !aes_kexpand1 %f28, %f30, 0x7, %f32
+ !aes_kexpand2 %f30, %f32, %f34
+ !aes_kexpand1 %f32, %f34, 0x8, %f36
+ !aes_kexpand2 %f34, %f36, %f38
+ !aes_kexpand1 %f36, %f38, 0x9, %f40
+ !aes_kexpand2 %f38, %f40, %f42
.byte 0x88, 0xc8, 0x01, 0x02
.byte 0x8d, 0xb0, 0xa6, 0x24
.byte 0x90, 0xc9, 0x03, 0x06
@@ -241,6 +290,36 @@
ld [%o1 + 0x14], %f5
!expand the key
+ !aes_kexpand1 %f0, %f4, 0x0, %f6
+ !aes_kexpand2 %f2, %f6, %f8
+ !aes_kexpand2 %f4, %f8, %f10
+
+ !aes_kexpand1 %f6, %f10, 0x1, %f12
+ !aes_kexpand2 %f8, %f12, %f14
+ !aes_kexpand2 %f10, %f14, %f16
+
+ !aes_kexpand1 %f12, %f16, 0x2, %f18
+ !aes_kexpand2 %f14, %f18, %f20
+ !aes_kexpand2 %f16, %f20, %f22
+
+ !aes_kexpand1 %f18, %f22, 0x3, %f24
+ !aes_kexpand2 %f20, %f24, %f26
+ !aes_kexpand2 %f22, %f26, %f28
+
+ !aes_kexpand1 %f24, %f28, 0x4, %f30
+ !aes_kexpand2 %f26, %f30, %f32
+ !aes_kexpand2 %f28, %f32, %f34
+
+ !aes_kexpand1 %f30, %f34, 0x5, %f36
+ !aes_kexpand2 %f32, %f36, %f38
+ !aes_kexpand2 %f34, %f38, %f40
+
+ !aes_kexpand1 %f36, %f40, 0x6, %f42
+ !aes_kexpand2 %f38, %f42, %f44
+ !aes_kexpand2 %f40, %f44, %f46
+
+ !aes_kexpand1 %f42, %f46, 0x7, %f48
+ !aes_kexpand2 %f44, %f48, %f50
.byte 0x8c, 0xc8, 0x01, 0x04
.byte 0x91, 0xb0, 0xa6, 0x26
.byte 0x95, 0xb1, 0x26, 0x28
@@ -307,6 +386,38 @@
ld [%o1 + 0x1c], %f7
!expand the key
+ !aes_kexpand1 %f0, %f6, 0x0, %f8
+ !aes_kexpand2 %f2, %f8, %f10
+ !aes_kexpand0 %f4, %f10, %f12
+ !aes_kexpand2 %f6, %f12, %f14
+
+ !aes_kexpand1 %f8, %f14, 0x1, %f16
+ !aes_kexpand2 %f10, %f16, %f18
+ !aes_kexpand0 %f12, %f18, %f20
+ !aes_kexpand2 %f14, %f20, %f22
+
+ !aes_kexpand1 %f16, %f22, 0x2, %f24
+ !aes_kexpand2 %f18, %f24, %f26
+ !aes_kexpand0 %f20, %f26, %f28
+ !aes_kexpand2 %f22, %f28, %f30
+
+ !aes_kexpand1 %f24, %f30, 0x3, %f32
+ !aes_kexpand2 %f26, %f32, %f34
+ !aes_kexpand0 %f28, %f34, %f36
+ !aes_kexpand2 %f30, %f36, %f38
+
+ !aes_kexpand1 %f32, %f38, 0x4, %f40
+ !aes_kexpand2 %f34, %f40, %f42
+ !aes_kexpand0 %f36, %f42, %f44
+ !aes_kexpand2 %f38, %f44, %f46
+
+ !aes_kexpand1 %f40, %f46, 0x5, %f48
+ !aes_kexpand2 %f42, %f48, %f50
+ !aes_kexpand0 %f44, %f50, %f52
+ !aes_kexpand2 %f46, %f52, %f54
+
+ !aes_kexpand1 %f48, %f54, 0x6, %f56
+ !aes_kexpand2 %f50, %f56, %f58
.byte 0x90, 0xc8, 0x01, 0x06
.byte 0x95, 0xb0, 0xa6, 0x28
.byte 0x99, 0xb1, 0x26, 0x0a
@@ -371,12 +482,20 @@
.byte 0xb6, 0xc8, 0xbe, 0x3d ; \
.byte 0xba, 0xc9, 0x36, 0x19 ; \
.byte 0xbe, 0xc9, 0xb6, 0x39
+ !aes_eround01 %f0, %f60, %f62, %f56 ; \
+ !aes_eround23 %f2, %f60, %f62, %f58 ; \
+ !aes_eround01 %f4, %f56, %f58, %f60 ; \
+ !aes_eround23 %f6, %f56, %f58, %f62
#define MID_TWO_EROUNDS \
.byte 0xb2, 0xca, 0x3e, 0x1d ; \
.byte 0xb6, 0xca, 0xbe, 0x3d ; \
.byte 0xba, 0xcb, 0x36, 0x19 ; \
.byte 0xbe, 0xcb, 0xb6, 0x39
+ !aes_eround01 %f8, %f60, %f62, %f56 ; \
+ !aes_eround23 %f10, %f60, %f62, %f58 ; \
+ !aes_eround01 %f12, %f56, %f58, %f60 ; \
+ !aes_eround23 %f14, %f56, %f58, %f62
#define MID_TWO_EROUNDS_2 \
.byte 0x8c, 0xca, 0x04, 0x00 ; \
@@ -387,6 +506,14 @@
.byte 0x84, 0xcb, 0x88, 0x26 ; \
.byte 0xba, 0xcb, 0x36, 0x19 ; \
.byte 0xbe, 0xcb, 0xb6, 0x39
+ !aes_eround01 %f8, %f0, %f2, %f6 ; \
+ !aes_eround23 %f10, %f0, %f2, %f4 ; \
+ !aes_eround01 %f8, %f60, %f62, %f56 ; \
+ !aes_eround23 %f10, %f60, %f62, %f58 ; \
+ !aes_eround01 %f12, %f6, %f4, %f0 ; \
+ !aes_eround23 %f14, %f6, %f4, %f2 ; \
+ !aes_eround01 %f12, %f56, %f58, %f60 ; \
+ !aes_eround23 %f14, %f56, %f58, %f62
#define TEN_EROUNDS \
.byte 0xb2, 0xcc, 0x3e, 0x1d ; \
@@ -409,6 +536,26 @@
.byte 0xb6, 0xcc, 0xfe, 0x3d ; \
.byte 0xba, 0xcd, 0x76, 0x99 ; \
.byte 0xbe, 0xcd, 0xf6, 0xb9
+ !aes_eround01 %f16, %f60, %f62, %f56 ; \
+ !aes_eround23 %f18, %f60, %f62, %f58 ; \
+ !aes_eround01 %f20, %f56, %f58, %f60 ; \
+ !aes_eround23 %f22, %f56, %f58, %f62 ; \
+ !aes_eround01 %f24, %f60, %f62, %f56 ; \
+ !aes_eround23 %f26, %f60, %f62, %f58 ; \
+ !aes_eround01 %f28, %f56, %f58, %f60 ; \
+ !aes_eround23 %f30, %f56, %f58, %f62 ; \
+ !aes_eround01 %f32, %f60, %f62, %f56 ; \
+ !aes_eround23 %f34, %f60, %f62, %f58 ; \
+ !aes_eround01 %f36, %f56, %f58, %f60 ; \
+ !aes_eround23 %f38, %f56, %f58, %f62 ; \
+ !aes_eround01 %f40, %f60, %f62, %f56 ; \
+ !aes_eround23 %f42, %f60, %f62, %f58 ; \
+ !aes_eround01 %f44, %f56, %f58, %f60 ; \
+ !aes_eround23 %f46, %f56, %f58, %f62 ; \
+ !aes_eround01 %f48, %f60, %f62, %f56 ; \
+ !aes_eround23 %f50, %f60, %f62, %f58 ; \
+ !aes_eround01_l %f52, %f56, %f58, %f60 ; \
+ !aes_eround23_l %f54, %f56, %f58, %f62
#define TEN_EROUNDS_2 \
.byte 0x8c, 0xcc, 0x04, 0x00 ; \
@@ -451,6 +598,46 @@
.byte 0x84, 0xcd, 0xc8, 0xa6 ; \
.byte 0xba, 0xcd, 0x76, 0x99 ; \
.byte 0xbe, 0xcd, 0xf6, 0xb9
+ !aes_eround01 %f16, %f0, %f2, %f6 ; \
+ !aes_eround23 %f18, %f0, %f2, %f4 ; \
+ !aes_eround01 %f16, %f60, %f62, %f56 ; \
+ !aes_eround23 %f18, %f60, %f62, %f58 ; \
+ !aes_eround01 %f20, %f6, %f4, %f0 ; \
+ !aes_eround23 %f22, %f6, %f4, %f2 ; \
+ !aes_eround01 %f20, %f56, %f58, %f60 ; \
+ !aes_eround23 %f22, %f56, %f58, %f62 ; \
+ !aes_eround01 %f24, %f0, %f2, %f6 ; \
+ !aes_eround23 %f26, %f0, %f2, %f4 ; \
+ !aes_eround01 %f24, %f60, %f62, %f56 ; \
+ !aes_eround23 %f26, %f60, %f62, %f58 ; \
+ !aes_eround01 %f28, %f6, %f4, %f0 ; \
+ !aes_eround23 %f30, %f6, %f4, %f2 ; \
+ !aes_eround01 %f28, %f56, %f58, %f60 ; \
+ !aes_eround23 %f30, %f56, %f58, %f62 ; \
+ !aes_eround01 %f32, %f0, %f2, %f6 ; \
+ !aes_eround23 %f34, %f0, %f2, %f4 ; \
+ !aes_eround01 %f32, %f60, %f62, %f56 ; \
+ !aes_eround23 %f34, %f60, %f62, %f58 ; \
+ !aes_eround01 %f36, %f6, %f4, %f0 ; \
+ !aes_eround23 %f38, %f6, %f4, %f2 ; \
+ !aes_eround01 %f36, %f56, %f58, %f60 ; \
+ !aes_eround23 %f38, %f56, %f58, %f62 ; \
+ !aes_eround01 %f40, %f0, %f2, %f6 ; \
+ !aes_eround23 %f42, %f0, %f2, %f4 ; \
+ !aes_eround01 %f40, %f60, %f62, %f56 ; \
+ !aes_eround23 %f42, %f60, %f62, %f58 ; \
+ !aes_eround01 %f44, %f6, %f4, %f0 ; \
+ !aes_eround23 %f46, %f6, %f4, %f2 ; \
+ !aes_eround01 %f44, %f56, %f58, %f60 ; \
+ !aes_eround23 %f46, %f56, %f58, %f62 ; \
+ !aes_eround01 %f48, %f0, %f2, %f6 ; \
+ !aes_eround23 %f50, %f0, %f2, %f4 ; \
+ !aes_eround01 %f48, %f60, %f62, %f56 ; \
+ !aes_eround23 %f50, %f60, %f62, %f58 ; \
+ !aes_eround01_l %f52, %f6, %f4, %f0 ; \
+ !aes_eround23_l %f54, %f6, %f4, %f2 ; \
+ !aes_eround01_l %f52, %f56, %f58, %f60 ; \
+ !aes_eround23_l %f54, %f56, %f58, %f62
#define TWELVE_EROUNDS \
MID_TWO_EROUNDS ; \
@@ -528,18 +715,89 @@
.byte 0xba, 0xcd, 0x76, 0x99 ; \
ldd [%o0 + 0x28], %f6 ; \
.byte 0xbe, 0xcd, 0xf6, 0xb9
+ !aes_eround01 %f0, %f20, %f22, %f24 ; \
+ !aes_eround23 %f2, %f20, %f22, %f22 ; \
+ !ldd [%o0 + 0x60], %f20 ; \
+ !aes_eround01 %f0, %f60, %f62, %f56 ; \
+ !aes_eround23 %f2, %f60, %f62, %f58 ; \
+ !aes_eround01 %f4, %f24, %f22, %f0 ; \
+ !aes_eround23 %f6, %f24, %f22, %f2 ; \
+ !ldd [%o0 + 0x68], %f22 ; \
+ !aes_eround01 %f4, %f56, %f58, %f60 ; \
+ !ldd [%o0 + 0x70], %f24 ; \
+ !aes_eround23 %f6, %f56, %f58, %f62 ; \
+ !aes_eround01 %f8, %f0, %f2, %f6 ; \
+ !aes_eround23 %f10, %f0, %f2, %f4 ; \
+ !aes_eround01 %f8, %f60, %f62, %f56 ; \
+ !aes_eround23 %f10, %f60, %f62, %f58 ; \
+ !aes_eround01 %f12, %f6, %f4, %f0 ; \
+ !aes_eround23 %f14, %f6, %f4, %f2 ; \
+ !aes_eround01 %f12, %f56, %f58, %f60 ; \
+ !aes_eround23 %f14, %f56, %f58, %f62 ; \
+ !aes_eround01 %f16, %f0, %f2, %f6 ; \
+ !aes_eround23 %f18, %f0, %f2, %f4 ; \
+ !aes_eround01 %f16, %f60, %f62, %f56 ; \
+ !aes_eround23 %f18, %f60, %f62, %f58 ; \
+ !aes_eround01 %f20, %f6, %f4, %f0 ; \
+ !aes_eround23 %f22, %f6, %f4, %f2 ; \
+ !aes_eround01 %f20, %f56, %f58, %f60 ; \
+ !aes_eround23 %f22, %f56, %f58, %f62 ; \
+ !aes_eround01 %f24, %f0, %f2, %f6 ; \
+ !aes_eround23 %f26, %f0, %f2, %f4 ; \
+ !aes_eround01 %f24, %f60, %f62, %f56 ; \
+ !aes_eround23 %f26, %f60, %f62, %f58 ; \
+ !aes_eround01 %f28, %f6, %f4, %f0 ; \
+ !aes_eround23 %f30, %f6, %f4, %f2 ; \
+ !aes_eround01 %f28, %f56, %f58, %f60 ; \
+ !aes_eround23 %f30, %f56, %f58, %f62 ; \
+ !aes_eround01 %f32, %f0, %f2, %f6 ; \
+ !aes_eround23 %f34, %f0, %f2, %f4 ; \
+ !aes_eround01 %f32, %f60, %f62, %f56 ; \
+ !aes_eround23 %f34, %f60, %f62, %f58 ; \
+ !aes_eround01 %f36, %f6, %f4, %f0 ; \
+ !aes_eround23 %f38, %f6, %f4, %f2 ; \
+ !aes_eround01 %f36, %f56, %f58, %f60 ; \
+ !aes_eround23 %f38, %f56, %f58, %f62 ; \
+ !aes_eround01 %f40, %f0, %f2, %f6 ; \
+ !aes_eround23 %f42, %f0, %f2, %f4 ; \
+ !aes_eround01 %f40, %f60, %f62, %f56 ; \
+ !aes_eround23 %f42, %f60, %f62, %f58 ; \
+ !aes_eround01 %f44, %f6, %f4, %f0 ; \
+ !aes_eround23 %f46, %f6, %f4, %f2 ; \
+ !aes_eround01 %f44, %f56, %f58, %f60 ; \
+ !aes_eround23 %f46, %f56, %f58, %f62 ; \
+ !aes_eround01 %f48, %f0, %f2, %f6 ; \
+ !aes_eround23 %f50, %f0, %f2, %f4 ; \
+ !ldd [%o0 + 0x10], %f0 ; \
+ !aes_eround01 %f48, %f60, %f62, %f56 ; \
+ !ldd [%o0 + 0x18], %f2 ; \
+ !aes_eround23 %f50, %f60, %f62, %f58 ; \
+ !aes_eround01_l %f52, %f6, %f4, %f20 ; \
+ !aes_eround23_l %f54, %f6, %f4, %f22 ; \
+ !ldd [%o0 + 0x20], %f4 ; \
+ !aes_eround01_l %f52, %f56, %f58, %f60 ; \
+ !ldd [%o0 + 0x28], %f6 ; \
+ !aes_eround23_l %f54, %f56, %f58, %f62
#define FIRST_TWO_DROUNDS \
.byte 0xb2, 0xc8, 0x3e, 0x5d ; \
.byte 0xb6, 0xc8, 0xbe, 0x7d ; \
.byte 0xba, 0xc9, 0x36, 0x59 ; \
.byte 0xbe, 0xc9, 0xb6, 0x79
+ !aes_dround01 %f0, %f60, %f62, %f56 ; \
+ !aes_dround23 %f2, %f60, %f62, %f58 ; \
+ !aes_dround01 %f4, %f56, %f58, %f60 ; \
+ !aes_dround23 %f6, %f56, %f58, %f62
#define MID_TWO_DROUNDS \
.byte 0xb2, 0xca, 0x3e, 0x5d ; \
.byte 0xb6, 0xca, 0xbe, 0x7d ; \
.byte 0xba, 0xcb, 0x36, 0x59 ; \
.byte 0xbe, 0xcb, 0xb6, 0x79
+ !aes_dround01 %f8, %f60, %f62, %f56 ; \
+ !aes_dround23 %f10, %f60, %f62, %f58 ; \
+ !aes_dround01 %f12, %f56, %f58, %f60 ; \
+ !aes_dround23 %f14, %f56, %f58, %f62
#define MID_TWO_DROUNDS_2 \
.byte 0x8c, 0xca, 0x04, 0x40 ; \
@@ -550,6 +808,14 @@
.byte 0x84, 0xcb, 0x88, 0x66 ; \
.byte 0xba, 0xcb, 0x36, 0x59 ; \
.byte 0xbe, 0xcb, 0xb6, 0x79
+ !aes_dround01 %f8, %f0, %f2, %f6 ; \
+ !aes_dround23 %f10, %f0, %f2, %f4 ; \
+ !aes_dround01 %f8, %f60, %f62, %f56 ; \
+ !aes_dround23 %f10, %f60, %f62, %f58 ; \
+ !aes_dround01 %f12, %f6, %f4, %f0 ; \
+ !aes_dround23 %f14, %f6, %f4, %f2 ; \
+ !aes_dround01 %f12, %f56, %f58, %f60 ; \
+ !aes_dround23 %f14, %f56, %f58, %f62
#define TEN_DROUNDS \
.byte 0xb2, 0xcc, 0x3e, 0x5d ; \
@@ -572,6 +838,26 @@
.byte 0xb6, 0xcc, 0xfe, 0x7d ; \
.byte 0xba, 0xcd, 0x76, 0xd9 ; \
.byte 0xbe, 0xcd, 0xf6, 0xf9
+ !aes_dround01 %f16, %f60, %f62, %f56 ; \
+ !aes_dround23 %f18, %f60, %f62, %f58 ; \
+ !aes_dround01 %f20, %f56, %f58, %f60 ; \
+ !aes_dround23 %f22, %f56, %f58, %f62 ; \
+ !aes_dround01 %f24, %f60, %f62, %f56 ; \
+ !aes_dround23 %f26, %f60, %f62, %f58 ; \
+ !aes_dround01 %f28, %f56, %f58, %f60 ; \
+ !aes_dround23 %f30, %f56, %f58, %f62 ; \
+ !aes_dround01 %f32, %f60, %f62, %f56 ; \
+ !aes_dround23 %f34, %f60, %f62, %f58 ; \
+ !aes_dround01 %f36, %f56, %f58, %f60 ; \
+ !aes_dround23 %f38, %f56, %f58, %f62 ; \
+ !aes_dround01 %f40, %f60, %f62, %f56 ; \
+ !aes_dround23 %f42, %f60, %f62, %f58 ; \
+ !aes_dround01 %f44, %f56, %f58, %f60 ; \
+ !aes_dround23 %f46, %f56, %f58, %f62 ; \
+ !aes_dround01 %f48, %f60, %f62, %f56 ; \
+ !aes_dround23 %f50, %f60, %f62, %f58 ; \
+ !aes_dround01_l %f52, %f56, %f58, %f60 ; \
+ !aes_dround23_l %f54, %f56, %f58, %f62
#define TEN_DROUNDS_2 \
.byte 0x8c, 0xcc, 0x04, 0x40 ; \
@@ -614,6 +900,46 @@
.byte 0x84, 0xcd, 0xc8, 0xe6 ; \
.byte 0xba, 0xcd, 0x76, 0xd9 ; \
.byte 0xbe, 0xcd, 0xf6, 0xf9
+ !aes_dround01 %f16, %f0, %f2, %f6 ; \
+ !aes_dround23 %f18, %f0, %f2, %f4 ; \
+ !aes_dround01 %f16, %f60, %f62, %f56 ; \
+ !aes_dround23 %f18, %f60, %f62, %f58 ; \
+ !aes_dround01 %f20, %f6, %f4, %f0 ; \
+ !aes_dround23 %f22, %f6, %f4, %f2 ; \
+ !aes_dround01 %f20, %f56, %f58, %f60 ; \
+ !aes_dround23 %f22, %f56, %f58, %f62 ; \
+ !aes_dround01 %f24, %f0, %f2, %f6 ; \
+ !aes_dround23 %f26, %f0, %f2, %f4 ; \
+ !aes_dround01 %f24, %f60, %f62, %f56 ; \
+ !aes_dround23 %f26, %f60, %f62, %f58 ; \
+ !aes_dround01 %f28, %f6, %f4, %f0 ; \
+ !aes_dround23 %f30, %f6, %f4, %f2 ; \
+ !aes_dround01 %f28, %f56, %f58, %f60 ; \
+ !aes_dround23 %f30, %f56, %f58, %f62 ; \
+ !aes_dround01 %f32, %f0, %f2, %f6 ; \
+ !aes_dround23 %f34, %f0, %f2, %f4 ; \
+ !aes_dround01 %f32, %f60, %f62, %f56 ; \
+ !aes_dround23 %f34, %f60, %f62, %f58 ; \
+ !aes_dround01 %f36, %f6, %f4, %f0 ; \
+ !aes_dround23 %f38, %f6, %f4, %f2 ; \
+ !aes_dround01 %f36, %f56, %f58, %f60 ; \
+ !aes_dround23 %f38, %f56, %f58, %f62 ; \
+ !aes_dround01 %f40, %f0, %f2, %f6 ; \
+ !aes_dround23 %f42, %f0, %f2, %f4 ; \
+ !aes_dround01 %f40, %f60, %f62, %f56 ; \
+ !aes_dround23 %f42, %f60, %f62, %f58 ; \
+ !aes_dround01 %f44, %f6, %f4, %f0 ; \
+ !aes_dround23 %f46, %f6, %f4, %f2 ; \
+ !aes_dround01 %f44, %f56, %f58, %f60 ; \
+ !aes_dround23 %f46, %f56, %f58, %f62 ; \
+ !aes_dround01 %f48, %f0, %f2, %f6 ; \
+ !aes_dround23 %f50, %f0, %f2, %f4 ; \
+ !aes_dround01 %f48, %f60, %f62, %f56 ; \
+ !aes_dround23 %f50, %f60, %f62, %f58 ; \
+ !aes_dround01_l %f52, %f6, %f4, %f0 ; \
+ !aes_dround23_l %f54, %f6, %f4, %f2 ; \
+ !aes_dround01_l %f52, %f56, %f58, %f60 ; \
+ !aes_dround23_l %f54, %f56, %f58, %f62
#define TWELVE_DROUNDS \
MID_TWO_DROUNDS ; \
@@ -691,6 +1017,69 @@
.byte 0xba, 0xcd, 0x76, 0xd9 ; \
ldd [%o0 + 0xc8], %f6 ; \
.byte 0xbe, 0xcd, 0xf6, 0xf9
+ !aes_dround01 %f0, %f20, %f22, %f24 ; \
+ !aes_dround23 %f2, %f20, %f22, %f22 ; \
+ !ldd [%o0 + 0x80], %f20 ; \
+ !aes_dround01 %f0, %f60, %f62, %f56 ; \
+ !aes_dround23 %f2, %f60, %f62, %f58 ; \
+ !aes_dround01 %f4, %f24, %f22, %f0 ; \
+ !aes_dround23 %f6, %f24, %f22, %f2 ; \
+ !ldd [%o0 + 0x88], %f22 ; \
+ !aes_dround01 %f4, %f56, %f58, %f60 ; \
+ !ldd [%o0 + 0x70], %f24 ; \
+ !aes_dround23 %f6, %f56, %f58, %f62 ; \
+ !aes_dround01 %f8, %f0, %f2, %f6 ; \
+ !aes_dround23 %f10, %f0, %f2, %f4 ; \
+ !aes_dround01 %f8, %f60, %f62, %f56 ; \
+ !aes_dround23 %f10, %f60, %f62, %f58 ; \
+ !aes_dround01 %f12, %f6, %f4, %f0 ; \
+ !aes_dround23 %f14, %f6, %f4, %f2 ; \
+ !aes_dround01 %f12, %f56, %f58, %f60 ; \
+ !aes_dround23 %f14, %f56, %f58, %f62 ; \
+ !aes_dround01 %f16, %f0, %f2, %f6 ; \
+ !aes_dround23 %f18, %f0, %f2, %f4 ; \
+ !aes_dround01 %f16, %f60, %f62, %f56 ; \
+ !aes_dround23 %f18, %f60, %f62, %f58 ; \
+ !aes_dround01 %f20, %f6, %f4, %f0 ; \
+ !aes_dround23 %f22, %f6, %f4, %f2 ; \
+ !aes_dround01 %f20, %f56, %f58, %f60 ; \
+ !aes_dround23 %f22, %f56, %f58, %f62 ; \
+ !aes_dround01 %f24, %f0, %f2, %f6 ; \
+ !aes_dround23 %f26, %f0, %f2, %f4 ; \
+ !aes_dround01 %f24, %f60, %f62, %f56 ; \
+ !aes_dround23 %f26, %f60, %f62, %f58 ; \
+ !aes_dround01 %f28, %f6, %f4, %f0 ; \
+ !aes_dround23 %f30, %f6, %f4, %f2 ; \
+ !aes_dround01 %f28, %f56, %f58, %f60 ; \
+ !aes_dround23 %f30, %f56, %f58, %f62 ; \
+ !aes_dround01 %f32, %f0, %f2, %f6 ; \
+ !aes_dround23 %f34, %f0, %f2, %f4 ; \
+ !aes_dround01 %f32, %f60, %f62, %f56 ; \
+ !aes_dround23 %f34, %f60, %f62, %f58 ; \
+ !aes_dround01 %f36, %f6, %f4, %f0 ; \
+ !aes_dround23 %f38, %f6, %f4, %f2 ; \
+ !aes_dround01 %f36, %f56, %f58, %f60 ; \
+ !aes_dround23 %f38, %f56, %f58, %f62 ; \
+ !aes_dround01 %f40, %f0, %f2, %f6 ; \
+ !aes_dround23 %f42, %f0, %f2, %f4 ; \
+ !aes_dround01 %f40, %f60, %f62, %f56 ; \
+ !aes_dround23 %f42, %f60, %f62, %f58 ; \
+ !aes_dround01 %f44, %f6, %f4, %f0 ; \
+ !aes_dround23 %f46, %f6, %f4, %f2 ; \
+ !aes_dround01 %f44, %f56, %f58, %f60 ; \
+ !aes_dround23 %f46, %f56, %f58, %f62 ; \
+ !aes_dround01 %f48, %f0, %f2, %f6 ; \
+ !aes_dround23 %f50, %f0, %f2, %f4 ; \
+ !ldd [%o0 + 0xd0], %f0 ; \
+ !aes_dround01 %f48, %f60, %f62, %f56 ; \
+ !ldd [%o0 + 0xd8], %f2 ; \
+ !aes_dround23 %f50, %f60, %f62, %f58 ; \
+ !aes_dround01_l %f52, %f6, %f4, %f20 ; \
+ !aes_dround23_l %f54, %f6, %f4, %f22 ; \
+ !ldd [%o0 + 0xc0], %f4 ; \
+ !aes_dround01_l %f52, %f56, %f58, %f60 ; \
+ !ldd [%o0 + 0xc8], %f6 ; \
+ !aes_dround23_l %f54, %f56, %f58, %f62
ENTRY(t4_aes128_load_keys_for_encrypt)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/components/openssl/openssl-1.0.0/engines/t4/t4_des.S Tue Nov 29 11:18:53 2011 -0800
@@ -0,0 +1,786 @@
+/*
+ * ====================================================================
+ * 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 */
--- a/components/openssl/openssl-1.0.0/engines/t4/t4_md5.S Tue Nov 29 05:42:26 2011 -0800
+++ b/components/openssl/openssl-1.0.0/engines/t4/t4_md5.S Tue Nov 29 11:18:53 2011 -0800
@@ -1,23 +1,53 @@
/*
- * CDDL HEADER START
+ * ====================================================================
+ * 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:
*
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
+ * 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/)"
*
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
+ * 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/)"
*
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
+ * 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.
*/
@@ -27,7 +57,7 @@
#if defined(lint) || defined(__lint)
#include <sys/types.h>
-#include <sys/md5.h>
+#include <openssl/md5.h>
/*ARGSUSED*/
void
@@ -63,6 +93,8 @@
ldd [%o1 + 0x30], %f20 !load 8 bytes of data
ldd [%o1 + 0x38], %f22 !load 8 bytes of data
+!perform crypto instruction here
+ !md5
.byte 0x81, 0xb0, 0x28, 0x00
dec %o2
@@ -99,6 +131,8 @@
faligndata %f20, %f22, %f20
faligndata %f22, %f24, %f22
+!perform crypto instruction here
+ !md5
.byte 0x81, 0xb0, 0x28, 0x00
dec %o2
--- a/components/openssl/openssl-1.0.0/engines/t4/t4_sha1.S Tue Nov 29 05:42:26 2011 -0800
+++ b/components/openssl/openssl-1.0.0/engines/t4/t4_sha1.S Tue Nov 29 11:18:53 2011 -0800
@@ -1,23 +1,53 @@
/*
- * CDDL HEADER START
+ * ====================================================================
+ * 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:
*
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
+ * 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/)"
*
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
+ * 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/)"
*
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
+ * 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.
*/
@@ -27,12 +57,11 @@
#if defined(lint) || defined(__lint)
#include <sys/types.h>
-#include <sys/sha1.h>
+#include <openssl/sha.h>
/*ARGSUSED*/
void
-t4_sha1_multiblock(SHA1_CTX *ctx, const uint8_t *input,
- size_t nr_blocks)
+t4_sha1_multiblock(SHA_CTX *ctx, const void *input, size_t num)
{ return; }
#else /* lint || __lint */
@@ -64,6 +93,8 @@
ldd [%o1 + 0x30], %f20 !load 8 bytes of data
ldd [%o1 + 0x38], %f22 !load 8 bytes of data
+!perform crypto instruction here
+ !sha1
.byte 0x81, 0xb0, 0x28, 0x20
dec %o2
@@ -101,6 +132,8 @@
faligndata %f20, %f22, %f20
faligndata %f22, %f24, %f22
+!perform crypto instruction here
+ !sha1
.byte 0x81, 0xb0, 0x28, 0x20
dec %o2
--- a/components/openssl/openssl-1.0.0/engines/t4/t4_sha2.S Tue Nov 29 05:42:26 2011 -0800
+++ b/components/openssl/openssl-1.0.0/engines/t4/t4_sha2.S Tue Nov 29 11:18:53 2011 -0800
@@ -1,23 +1,53 @@
/*
- * CDDL HEADER START
+ * ====================================================================
+ * 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:
*
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
+ * 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/)"
*
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
+ * 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/)"
*
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
+ * 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.
*/
@@ -27,18 +57,19 @@
#if defined(lint) || defined(__lint)
#include <sys/types.h>
-#include <sys/sha2.h>
+#include <openssl/sha.h>
+#include "../engine/eng_t4_sha2_asm.h"
/*ARGSUSED*/
void
-t4_sha256_multiblock(SHA2_CTX *ctx, const uint8_t *input,
- size_t nr_blocks)
+t4_sha256_multiblock(T4_SHA256_CTX *c, const void *input,
+ size_t num)
{ return; }
/*ARGSUSED*/
void
-t4_sha512_multiblock(SHA2_CTX *ctx, const uint8_t *input,
- size_t nr_blocks)
+t4_sha512_multiblock(T4_SHA512_CTX *c, const void *input,
+ size_t num)
{ return; }
#else /* lint || __lint */
@@ -75,6 +106,8 @@
ldd [%o1 + 0x30], %f20 !load 8 bytes of data
ldd [%o1 + 0x38], %f22 !load 8 bytes of data
+!perform crypto instruction here
+ !sha256
.byte 0x81, 0xb0, 0x28, 0x40
dec %o2
@@ -115,6 +148,8 @@
faligndata %f20, %f22, %f20
faligndata %f22, %f24, %f22
+!perform crypto instruction here
+ !sha256
.byte 0x81, 0xb0, 0x28, 0x40
dec %o2
@@ -181,6 +216,8 @@
ldd [%o1 + 0x70], %f44 !load 8 bytes of data
ldd [%o1 + 0x78], %f46 !load 8 bytes of data
+!perform crypto instruction here
+ !sha512
.byte 0x81, 0xb0, 0x28, 0x60
dec %o2
@@ -245,6 +282,8 @@
faligndata %f44, %f46, %f44
faligndata %f46, %f48, %f46
+!perform crypto instruction here
+ !sha512
.byte 0x81, 0xb0, 0x28, 0x60
dec %o2
--- a/components/openssl/openssl-1.0.0/patches/openssl-1.0.0d-t4-engine.sparc-patch Tue Nov 29 05:42:26 2011 -0800
+++ b/components/openssl/openssl-1.0.0/patches/openssl-1.0.0d-t4-engine.sparc-patch Tue Nov 29 11:18:53 2011 -0800
@@ -6,15 +6,15 @@
===================================================================
diff -ru openssl-1.0.0d/Configure openssl-1.0.0d/Configure
--- openssl-1.0.0d/Configure 2011-05-24 17:02:24.000000000 -0700
-+++ openssl-1.0.0d/Configure 2011-06-17 16:53:34.203229852 -0700
++++ openssl-1.0.0d/Configure 2011-07-27 10:48:17.817470000 -0700
@@ -134,8 +134,8 @@
my $x86_64_asm="x86_64cpuid.o:x86_64-gcc.o x86_64-mont.o::aes-x86_64.o::md5-x86_64.o:sha1-x86_64.o sha256-x86_64.o sha512-x86_64.o::rc4-x86_64.o:::wp-x86_64.o:cmll-x86_64.o cmll_misc.o";
my $ia64_asm="ia64cpuid.o:bn-ia64.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:::::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:::::::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:aes_core.o aes_cbc.o aes-sparcv9.o t4_aes.o::t4_md5.o:sha1-sparcv9.o sha256-sparcv9.o sha512-sparcv9.o t4_sha1.o t4_sha2.o:::::::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 $sparcv9_asm="sparcv9cap.o sparccpuid.o:bn-sparcv9.o sparcv9-mont.o sparcv9a-mont.o:des_enc-sparc.o fcrypt_b.o t4_des.o:aes_core.o aes_cbc.o aes-sparcv9.o t4_aes.o::t4_md5.o:sha1-sparcv9.o sha256-sparcv9.o sha512-sparcv9.o t4_sha1.o t4_sha2.o:::::::void";
++my $sparcv8_asm=":sparcv8.o:des_enc-sparc.o fcrypt_b.o t4_des.o:t4_aes.o::t4_md5.o:t4_sha1.o t4_sha2.o:::::::void";
my $alpha_asm="alphacpuid.o:bn_asm.o alpha-mont.o::::::::::::void";
my $mips3_asm=":bn-mips3.o::::::::::::void";
my $s390x_asm="s390xcap.o s390xcpuid.o:bn-s390x.o s390x-mont.o::aes-s390x.o:::sha1-s390x.o sha256-s390x.o sha512-s390x.o::rc4-s390x.o:::::void";
@@ -45,23 +45,52 @@
aes-ppc.s: asm/aes-ppc.pl
$(PERL) asm/aes-ppc.pl $(PERLASM_SCHEME) [email protected]
+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
[email protected]@ -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=
[email protected]@ -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 [email protected] asm/t4_des.S
++ elfedit -e 'cap:hw1 -and -cmp vis vis3' [email protected]
+
+ des-586.s: asm/des-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
+ $(PERL) asm/des-586.pl $(PERLASM_SCHEME) $(CFLAGS) > [email protected]
Index: crypto/engine/Makefile
===================================================================
diff -ru openssl-1.0.0d/crypto/engine/Makefile openssl-1.0.0d/crypto/engine/Makefile
--- openssl-1.0.0d/crypto/engine/Makefile 2011-05-24 17:04:12.000000000 -0700
-+++ openssl-1.0.0d/crypto/engine/Makefile 2011-06-17 16:55:13.074884424 -0700
[email protected]@ -22,12 +22,14 @@
++++ openssl-1.0.0d/crypto/engine/Makefile 2011-07-28 10:10:00.000000000 -0700
[email protected]@ -22,12 +22,16 @@
tb_rsa.c tb_dsa.c tb_ecdsa.c tb_dh.c tb_ecdh.c tb_rand.c tb_store.c \
tb_cipher.c tb_digest.c tb_pkmeth.c tb_asnmth.c \
eng_openssl.c eng_cnf.c eng_dyn.c eng_cryptodev.c \
-+ eng_t4.c eng_t4_digest.c \
++ eng_t4.c eng_t4_des.c eng_t4_md5.c \
++ eng_t4_sha1.c eng_t4_sha256.c eng_t4_sha512.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 \
eng_table.o eng_pkey.o eng_fat.o eng_all.o \
tb_rsa.o tb_dsa.o tb_ecdsa.o tb_dh.o tb_ecdh.o tb_rand.o tb_store.o \
tb_cipher.o tb_digest.o tb_pkmeth.o tb_asnmth.o \
eng_openssl.o eng_cnf.o eng_dyn.o eng_cryptodev.o \
-+ eng_t4.o eng_t4_digest.o \
++ eng_t4.o eng_t4_des.o eng_t4_md5.o \
++ eng_t4_sha1.o eng_t4_sha256.o eng_t4_sha512.o \
hw_pk11.o hw_pk11_pub.o hw_pk11_uri.o
SRC= $(LIBSRC)