From 9bfb6fadf71c46bf4cb5adabba0c96c32e84c1bc Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Sun, 20 Jan 2008 21:08:05 +0000 Subject: the whole library rewritten Signed-off-by: Michael Krelin --- (limited to 'lib/util.cc') diff --git a/lib/util.cc b/lib/util.cc index a9b9bed..54d6535 100644 --- a/lib/util.cc +++ b/lib/util.cc @@ -7,10 +7,16 @@ #include #include #include +#include #include #include "opkele/util.h" #include "opkele/exception.h" +#include +#ifdef HAVE_DEMANGLE +# include +#endif + namespace opkele { using namespace std; @@ -205,8 +211,7 @@ namespace opkele { else if(rv=="https:") s = true; else{ - /* TODO: support more schemes. - * e.g. xri. How do we normalize + /* TODO: support more schemes. e.g. xri. How do we normalize * xri? */ rv.append(uri,colon+1,ul-colon-1); @@ -311,6 +316,68 @@ namespace opkele { return rv; } + string& strip_uri_fragment_part(string& u) { + string::size_type q = u.find('?'), f = u.find('#'); + if(q==string::npos) { + if(f!=string::npos) + u.erase(f); + }else{ + if(f!=string::npos) { + if(fsecret(); + const EVP_MD *evpmd; + const string& at = assoc->assoc_type(); + if(at=="HMAC-SHA256") + evpmd = EVP_sha256(); + else if(at=="HMAC-SHA1") + evpmd = EVP_sha1(); + else + throw unsupported(OPKELE_CP_ "unknown association type"); + unsigned int md_len = 0; + unsigned char *md = HMAC(evpmd, + &(secret.front()),secret.size(), + (const unsigned char*)kv.data(),kv.length(), + 0,&md_len); + return encode_base64(md,md_len); + } + } } -- cgit v0.9.0.2