msm_shared: prepare crypto for next revision

Minor changes to prepare for clean merge of next
crypto engine driver.

Change-Id: Ia62b40daa9e2d5a61593e85ea8fecf693a5be8b0
diff --git a/platform/msm_shared/crypto4_eng.c b/platform/msm_shared/crypto4_eng.c
index 1a9bc0a..2d34470 100644
--- a/platform/msm_shared/crypto4_eng.c
+++ b/platform/msm_shared/crypto4_eng.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -382,3 +382,9 @@
 	    rd_ce(CRYPTO_AUTH_BYTECNTn(1));
 	return;
 }
+
+/* Returns the max authentication block size */
+uint32_t crypto_get_max_auth_blk_size()
+{
+	return 0xFA00;
+}
diff --git a/platform/msm_shared/crypto_eng.c b/platform/msm_shared/crypto_eng.c
index 4ab34b3..2bf96ac 100644
--- a/platform/msm_shared/crypto_eng.c
+++ b/platform/msm_shared/crypto_eng.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
+/* Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -9,7 +9,7 @@
  *     copyright notice, this list of conditions and the following
  *     disclaimer in the documentation and/or other materials provided
  *     with the distribution.
- *   * Neither the name of Code Aurora Forum, Inc. nor the names of its
+ *   * Neither the name of The Linux Foundation nor the names of its
  *     contributors may be used to endorse or promote products derived
  *     from this software without specific prior written permission.
  *
@@ -341,3 +341,9 @@
 	    rd_ce(CRYPTO3_AUTH_BYTECNTn(1));
 	return;
 }
+
+/* Returns the max authentication block size */
+uint32_t crypto_get_max_auth_blk_size()
+{
+	return 0xFA00;
+}
diff --git a/platform/msm_shared/crypto_hash.c b/platform/msm_shared/crypto_hash.c
index afd33b3..1568243 100644
--- a/platform/msm_shared/crypto_hash.c
+++ b/platform/msm_shared/crypto_hash.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
+/* Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -9,7 +9,7 @@
  *     copyright notice, this list of conditions and the following
  *     disclaimer in the documentation and/or other materials provided
  *     with the distribution.
- *   * Neither the name of Code Aurora Forum, Inc. nor the names of its
+ *   * Neither the name of The Linux Foundation nor the names of its
  *     contributors may be used to endorse or promote products derived
  *     from this software without specific prior written permission.
  *
@@ -293,9 +293,9 @@
 
 	do {
 		if ((bytes_to_write - bytes_written) >
-		    CRYPTO_MAX_AUTH_BLOCK_SIZE) {
+		    crypto_get_max_auth_blk_size()) {
 			/* Write CRYPTO_MAX_AUTH_BLOCK_SIZE bytes at a time to the CE */
-			tmp_bytes = CRYPTO_MAX_AUTH_BLOCK_SIZE;
+			tmp_bytes = crypto_get_max_auth_blk_size();
 			tmp_last = FALSE;
 
 			if (sha1_ctx->saved_buff_indx != 0) {
diff --git a/platform/msm_shared/include/crypto_hash.h b/platform/msm_shared/include/crypto_hash.h
index ea53b3e..03dccbc 100644
--- a/platform/msm_shared/include/crypto_hash.h
+++ b/platform/msm_shared/include/crypto_hash.h
@@ -1,17 +1,17 @@
-/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
-
+/* Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
  * met:
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * 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.
- *   * Neither the name of Code Aurora Forum, Inc. nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of The Linux Foundation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
@@ -40,12 +40,16 @@
 #define SHA1_INIT_VECTOR_SIZE		5
 
 #define CRYPTO_SHA_BLOCK_SIZE		64
-#define CRYPTO_MAX_AUTH_BLOCK_SIZE	0xFA00
 
 #define CRYPTO_ERR_NONE				0x01
 #define CRYPTO_ERR_FAIL				0x02
 
 typedef enum {
+	CRYPTO_FIRST_CHUNK = 1,
+	CRYPTO_LAST_CHUNK  = 2,
+} crypto_flag_type;
+
+typedef enum {
 	CRYPTO_SHA_ERR_NONE,
 	CRYPTO_SHA_ERR_BUSY,
 	CRYPTO_SHA_ERR_FAIL,
@@ -68,7 +72,7 @@
 	unsigned char saved_buff[64];
 	unsigned char saved_buff_indx;
 	unsigned int auth_iv[5];
-	unsigned char flags;
+	uint32_t flags;
 } crypto_SHA1_ctx;
 
 typedef struct {
@@ -76,7 +80,8 @@
 	unsigned char saved_buff[64];
 	unsigned char saved_buff_indx;
 	unsigned int auth_iv[8];
-	unsigned char flags;
+	uint32_t bytes_to_write;
+	uint32_t flags;
 } crypto_SHA256_ctx;
 
 extern void crypto_eng_reset(void);
@@ -99,6 +104,8 @@
 
 extern void crypto_get_ctx(void *ctx_ptr);
 
+extern uint32_t crypto_get_max_auth_blk_size();
+
 static void crypto_init(void);
 
 static crypto_result_type do_sha(unsigned char *buff_ptr,