summaryrefslogtreecommitdiffstats
path: root/lib/Plugins/CCpp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Plugins/CCpp.cpp')
-rw-r--r--lib/Plugins/CCpp.cpp39
1 files changed, 32 insertions, 7 deletions
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp
index 8b0c2b89..6c200d01 100644
--- a/lib/Plugins/CCpp.cpp
+++ b/lib/Plugins/CCpp.cpp
@@ -24,9 +24,8 @@
#include <sstream>
#include <set>
#include <iomanip>
-#include <nss.h>
-#include <sechash.h>
-#include <sysexits.h>
+//#include <nss.h>
+//#include <sechash.h>
#include "abrtlib.h"
#include "CCpp.h"
#include "ABRTException.h"
@@ -34,6 +33,8 @@
#include "CommLayerInner.h"
#include "Polkit.h"
+#include "CCpp_sha1.h"
+
using namespace std;
#define CORE_PATTERN_IFACE "/proc/sys/kernel/core_pattern"
@@ -54,11 +55,13 @@ CAnalyzerCCpp::CAnalyzerCCpp() :
static string CreateHash(const char *pInput)
{
- string ret;
- HASHContext* hc;
- unsigned char hash[SHA1_LENGTH];
unsigned int len;
+#if 0
+{
+ char hash_str[SHA1_LENGTH*2 + 1];
+ unsigned char hash[SHA1_LENGTH];
+ HASHContext *hc;
hc = HASH_Create(HASH_AlgSHA1);
if (!hc)
{
@@ -69,7 +72,6 @@ static string CreateHash(const char *pInput)
HASH_End(hc, hash, &len, sizeof(hash));
HASH_Destroy(hc);
- char hash_str[SHA1_LENGTH*2 + 1];
char *d = hash_str;
unsigned char *s = hash;
while (len)
@@ -80,6 +82,29 @@ static string CreateHash(const char *pInput)
len--;
}
*d = '\0';
+//log("hash1:%s str:'%s'", hash_str, pInput);
+}
+#endif
+
+ char hash_str[SHA1_RESULT_LEN*2 + 1];
+ unsigned char hash2[SHA1_RESULT_LEN];
+ sha1_ctx_t sha1ctx;
+ sha1_begin(&sha1ctx);
+ sha1_hash(pInput, strlen(pInput), &sha1ctx);
+ sha1_end(hash2, &sha1ctx);
+ len = SHA1_RESULT_LEN;
+
+ char *d = hash_str;
+ unsigned char *s = hash2;
+ while (len)
+ {
+ *d++ = "0123456789abcdef"[*s >> 4];
+ *d++ = "0123456789abcdef"[*s & 0xf];
+ s++;
+ len--;
+ }
+ *d = '\0';
+//log("hash2:%s str:'%s'", hash_str, pInput);
return hash_str;
}