summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorberkeviktor@aol.com <berkeviktor@aol.com>2010-10-20 20:58:08 +0200
committerberkeviktor@aol.com <berkeviktor@aol.com>2010-10-20 20:58:08 +0200
commit676718594338b84812e0c6cbf1b28bf7589f3167 (patch)
treefff705df192ed9973306fdbf418ca57309aa0788 /src
parent48045bdf6aa3b2fe9f4da96fafe98b146933d932 (diff)
convert sha256sum to checksum plugin
Diffstat (limited to 'src')
-rw-r--r--src/common/checksum.c74
-rw-r--r--src/common/checksum.h6
2 files changed, 0 insertions, 80 deletions
diff --git a/src/common/checksum.c b/src/common/checksum.c
deleted file mode 100644
index a0f2cdef..00000000
--- a/src/common/checksum.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* this is a cleaned-up version of
- * http://adamlamers.com/?p=5
- */
-
-#include <stdio.h>
-#include <malloc.h>
-#include <errno.h>
-
-#include "checksum.h"
-
-void
-sha256_hash_string (unsigned char hash[SHA256_DIGEST_LENGTH], char outputBuffer[65])
-{
-	int i = 0;
-	for (i = 0; i < SHA256_DIGEST_LENGTH; i++)
-	{
-		sprintf(outputBuffer + (i * 2), "%02x", hash[i]);
-	}
-	outputBuffer[64] = 0;
-}
-
-void
-sha256 (char *string, char outputBuffer[65])
-{
-	int i;
-	unsigned char hash[SHA256_DIGEST_LENGTH];
-	SHA256_CTX sha256;
-
-	SHA256_Init (&sha256);
-	SHA256_Update (&sha256, string, strlen(string));
-	SHA256_Final (hash, &sha256);
-
-	for (i = 0; i < SHA256_DIGEST_LENGTH; i++)
-	{
-		sprintf (outputBuffer + (i * 2), "%02x", hash[i]);
-	}
-	outputBuffer[64] = 0;
-}
-
-int
-sha256_file (char *path, char outputBuffer[65])
-{
-	int bytesRead;
-	unsigned char *buffer;
-	unsigned char hash[SHA256_DIGEST_LENGTH];
-	SHA256_CTX sha256;
-
-	FILE *file = fopen (path, "rb");
-	if (!file)
-	{
-		return -534;
-	}
-
-	SHA256_Init (&sha256);
-	buffer = malloc (BUFSIZE);
-	bytesRead = 0;
-
-	if (!buffer)
-	{
-		return ENOMEM;
-	}
-
-	while ((bytesRead = fread (buffer, 1, BUFSIZE, file)))
-	{
-		SHA256_Update (&sha256, buffer, bytesRead);
-    }
-
-    SHA256_Final (hash, &sha256);
-    sha256_hash_string (hash, outputBuffer);
-
-	fclose (file);
-    free (buffer);
-    return 0;
-}
diff --git a/src/common/checksum.h b/src/common/checksum.h
deleted file mode 100644
index 1d5d62e3..00000000
--- a/src/common/checksum.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <openssl/sha.h>
-#define BUFSIZE 32768
-
-void sha256_hash_string (unsigned char hash[SHA256_DIGEST_LENGTH], char outputBuffer[65]);
-void sha256 (char *string, char outputBuffer[65]);
-int sha256_file (char *path, char outputBuffer[65]);