cryptolib: rename SHA* function to avoid openssl collision

When linking tools that need OpenSSL functions on the target, the
resolution of SHA* functions was being redirected to the firmware
cryptolib instead of the OpenSSL implementations, which was causing
OpenSSL calls to crash. This renames the internal implementations
to avoid the collision.

BUG=None
TEST=make runtests passes, mount-encrypted runs on target again.

Change-Id: Ica4fb04faf203ae3b4118c540f18d40239753810
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/23305
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
diff --git a/tests/sha_benchmark.c b/tests/sha_benchmark.c
index 9f4da36..a5bfc53 100644
--- a/tests/sha_benchmark.c
+++ b/tests/sha_benchmark.c
@@ -21,9 +21,9 @@
 } HashFxTable;
 
 HashFxTable hash_functions[NUM_HASH_ALGORITHMS] = {
-  {SHA1, "sha1"},
-  {SHA256, "sha256"},
-  {SHA512, "sha512"}
+  {internal_SHA1, "sha1"},
+  {internal_SHA256, "sha256"},
+  {internal_SHA512, "sha512"}
 };
 
 int main(int argc, char* argv[]) {
diff --git a/tests/sha_tests.c b/tests/sha_tests.c
index 65cbb46..6cc7e0f 100644
--- a/tests/sha_tests.c
+++ b/tests/sha_tests.c
@@ -21,7 +21,7 @@
   test_inputs[2] = (uint8_t *) long_msg;
 
   for (i = 0; i < 3; i++) {
-    SHA1(test_inputs[i], strlen((char *)test_inputs[i]),
+    internal_SHA1(test_inputs[i], strlen((char *)test_inputs[i]),
          sha1_digest);
     if (!memcmp(sha1_digest, sha1_results[i], SHA1_DIGEST_SIZE)) {
       fprintf(stderr, "Test vector %d PASSED for SHA-1\n", i+1);
@@ -43,7 +43,7 @@
   test_inputs[2] = (uint8_t *) long_msg;
 
   for (i = 0; i < 3; i++) {
-    SHA256(test_inputs[i], strlen((char *)test_inputs[i]),
+    internal_SHA256(test_inputs[i], strlen((char *)test_inputs[i]),
            sha256_digest);
     if (!memcmp(sha256_digest, sha256_results[i], SHA256_DIGEST_SIZE)) {
       fprintf(stderr, "Test vector %d PASSED for SHA-256\n", i+1);
@@ -65,7 +65,7 @@
   test_inputs[2] = (uint8_t *) long_msg;
 
   for (i = 0; i < 3; i++) {
-    SHA512(test_inputs[i], strlen((char *)test_inputs[i]),
+    internal_SHA512(test_inputs[i], strlen((char *)test_inputs[i]),
            sha512_digest);
     if (!memcmp(sha512_digest, sha512_results[i], SHA512_DIGEST_SIZE)) {
       fprintf(stderr, "Test vector %d PASSED for SHA-512\n", i+1);