From 24a6f9e3525b76ed1aa787f66b003b01b767af39 Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Sun, 16 Dec 2007 22:52:51 +0000 Subject: made secret_t non-constant size and added params_t::query_string function 1. removed checking that secret_t is exactly 20 bytes, because its size is not so constant anymore. 2. added a query_string function that produces a query string suitable for use in GET and POST requests. I'm making use of it when performing direct request when establishing associations. Signed-off-by: Michael Krelin --- (limited to 'lib/secret.cc') diff --git a/lib/secret.cc b/lib/secret.cc index 632a2ca..d538890 100644 --- a/lib/secret.cc +++ b/lib/secret.cc @@ -14,31 +14,27 @@ namespace opkele { } }; - void secret_t::enxor_to_base64(const unsigned char *key_sha1,string& rv) const { - if(size()!=20) - throw bad_input(OPKELE_CP_ "wrong secret size"); + void secret_t::enxor_to_base64(const unsigned char *key_d,string& rv) const { vector tmp; transform( begin(), end(), - key_sha1, + key_d, back_insert_iterator >(tmp), bitwise_xor() ); rv = util::encode_base64(&(tmp.front()),tmp.size()); } - void secret_t::enxor_from_base64(const unsigned char *key_sha1,const string& b64) { + void secret_t::enxor_from_base64(const unsigned char *key_d,const string& b64) { clear(); util::decode_base64(b64,*this); transform( begin(), end(), - key_sha1, + key_d, begin(), bitwise_xor() ); } void secret_t::to_base64(string& rv) const { - if(size()!=20) - throw bad_input(OPKELE_CP_ "wrong secret size"); rv = util::encode_base64(&(front()),size()); } -- cgit v0.9.0.2