summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Lidén Borell <samuel@slbdata.se>2010-02-05 16:57:41 +0100
committerSamuel Lidén Borell <samuel@slbdata.se>2010-02-05 16:57:41 +0100
commit60e6069a52a761e33db81349652eaff48bd5d83c (patch)
treedcc654f26b7881f9a7641ff0b985110f5fc5011f
parentac9da9a356949ce5e115544c6fe955568eabccaa (diff)
downloadfribid-60e6069a52a761e33db81349652eaff48bd5d83c.tar.gz
fribid-60e6069a52a761e33db81349652eaff48bd5d83c.tar.bz2
fribid-60e6069a52a761e33db81349652eaff48bd5d83c.zip
Refactoring: Moved the sha_base64 function to misc.c
-rw-r--r--client/misc.c8
-rw-r--r--client/misc.h1
-rw-r--r--client/xmldsig.c10
3 files changed, 10 insertions, 9 deletions
diff --git a/client/misc.c b/client/misc.c
index 3494f79..509e08b 100644
--- a/client/misc.c
+++ b/client/misc.c
@@ -27,6 +27,7 @@
#include <base64.h>
#include <glib.h>
#include <stdarg.h>
+#include <sechash.h>
#include "misc.h"
@@ -100,6 +101,13 @@ bool is_canonical_base64(const char *encoded) {
return equal;
}
+char *sha_base64(const char *str) {
+ char shasum[SHA256_LENGTH];
+
+ HASH_HashBuf(HASH_AlgSHA256, (unsigned char*)shasum, (unsigned char*)str, strlen(str));
+ return base64_encode(shasum, sizeof(shasum));
+}
+
bool is_valid_domain_name(const char *domain) {
static const char allowed[] = "abcdefghijklmnopqrstuvwxyz0123456789-.";
return (strspn(domain, allowed) == strlen(domain));
diff --git a/client/misc.h b/client/misc.h
index f391904..3943577 100644
--- a/client/misc.h
+++ b/client/misc.h
@@ -32,6 +32,7 @@ char *rasprintf(const char *format, ...);
char *base64_encode(const char *data, const int length);
char *base64_decode(const char *encoded);
bool is_canonical_base64(const char *encoded);
+char *sha_base64(const char *str);
bool is_valid_domain_name(const char *domain);
bool is_valid_ip_address(const char *ip);
diff --git a/client/xmldsig.c b/client/xmldsig.c
index e650d1e..d0a34a3 100644
--- a/client/xmldsig.c
+++ b/client/xmldsig.c
@@ -26,8 +26,7 @@
#include <string.h>
#include <stdlib.h>
-
-#include <sechash.h>
+#include <stdio.h>
#include "keyfile.h"
#include "xmldsig.h"
@@ -73,13 +72,6 @@ static const char keyinfo_template[] =
static const char cert_template[] =
"<X509Certificate>%s</X509Certificate>";
-static char *sha_base64(const char *str) {
- char shasum[SHA256_LENGTH];
-
- HASH_HashBuf(HASH_AlgSHA256, (unsigned char*)shasum, (unsigned char*)str, strlen(str));
- return base64_encode(shasum, sizeof(shasum));
-}
-
/**
* Creates a xmldsig signature. See the sign function in bankid.c.
*/