7101906 Need to add the digest support back to the OpenSSL T4 engine
authorMisaki Miyashita <Misaki.Miyashita@Oracle.COM>
Mon, 14 Nov 2011 08:53:46 -0800
changeset 580 abb7ba207fc9
parent 579 085a881269b8
child 581 ac0dbbad1d49
7101906 Need to add the digest support back to the OpenSSL T4 engine
components/openssl/openssl-1.0.0/engines/t4/eng_t4.c
components/openssl/openssl-1.0.0/engines/t4/eng_t4_digest.c
--- a/components/openssl/openssl-1.0.0/engines/t4/eng_t4.c	Fri Nov 11 05:39:11 2011 -0800
+++ b/components/openssl/openssl-1.0.0/engines/t4/eng_t4.c	Mon Nov 14 08:53:46 2011 -0800
@@ -909,15 +909,18 @@
 static int
 t4_bind(ENGINE *e)
 {
-	static int aes_engage = -1;
+	static int aes_engage = -1, digest_engage = -1;
 
 	if (aes_engage == -1) {
 		aes_engage = (t4_aes_instructions_present() != 0);
 	}
+	if (digest_engage == -1) {
+		digest_engage = (t4_digest_instructions_present() != 0);
+	}
 
 #ifdef DEBUG_T4
 	(void) fprintf(stderr,
-	    "t4_bind: engage aes=%d\n", aes_engage);
+	    "t4_bind: engage aes=%d, digest=%d\n", aes_engage, digest_engage);
 #endif
 
 #ifndef  SOLARIS_NO_AES_CTR
@@ -948,6 +951,7 @@
 	    aes_engage ? ENGINE_T4_NAME: ENGINE_NO_T4_NAME) ||
 	    !ENGINE_set_init_function(e, t4_init) ||
 	    (aes_engage && !ENGINE_set_ciphers(e, t4_get_all_ciphers)) ||
+	    (digest_engage && !ENGINE_set_digests(e, t4_get_all_digests)) ||
 	    !ENGINE_set_destroy_function(e, t4_destroy)) {
 		T4_FREE_AES_CTR_NIDS;
 		return (0);
--- a/components/openssl/openssl-1.0.0/engines/t4/eng_t4_digest.c	Fri Nov 11 05:39:11 2011 -0800
+++ b/components/openssl/openssl-1.0.0/engines/t4/eng_t4_digest.c	Mon Nov 14 08:53:46 2011 -0800
@@ -370,6 +370,9 @@
 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);
 }
@@ -506,6 +509,9 @@
 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);
 }
@@ -517,6 +523,9 @@
 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);
 }