summaryrefslogtreecommitdiffabout
path: root/lib/secret.cc
authorMichael Krelin <hacker@klever.net>2007-12-16 22:52:51 (UTC)
committer Michael Krelin <hacker@klever.net>2007-12-17 12:09:16 (UTC)
commit24a6f9e3525b76ed1aa787f66b003b01b767af39 (patch) (unidiff)
tree87741582a2a673205b11ac0386725c0b9d8377f9 /lib/secret.cc
parentd4e05a6fe00ebd64546637e5873759d4e8d1b010 (diff)
downloadlibopkele-24a6f9e3525b76ed1aa787f66b003b01b767af39.zip
libopkele-24a6f9e3525b76ed1aa787f66b003b01b767af39.tar.gz
libopkele-24a6f9e3525b76ed1aa787f66b003b01b767af39.tar.bz2
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 <hacker@klever.net>
Diffstat (limited to 'lib/secret.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/secret.cc12
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/secret.cc b/lib/secret.cc
index 632a2ca..d538890 100644
--- a/lib/secret.cc
+++ b/lib/secret.cc
@@ -15,11 +15,9 @@ namespace opkele {
15 }; 15 };
16 16
17 void secret_t::enxor_to_base64(const unsigned char *key_sha1,string& rv) const { 17 void secret_t::enxor_to_base64(const unsigned char *key_d,string& rv) const {
18 if(size()!=20)
19 throw bad_input(OPKELE_CP_ "wrong secret size");
20 vector<unsigned char> tmp; 18 vector<unsigned char> tmp;
21 transform( 19 transform(
22 begin(), end(), 20 begin(), end(),
23 key_sha1, 21 key_d,
24 back_insert_iterator<vector<unsigned char> >(tmp), 22 back_insert_iterator<vector<unsigned char> >(tmp),
25 bitwise_xor<unsigned char,unsigned char,unsigned char>() ); 23 bitwise_xor<unsigned char,unsigned char,unsigned char>() );
@@ -27,10 +25,10 @@ namespace opkele {
27 } 25 }
28 26
29 void secret_t::enxor_from_base64(const unsigned char *key_sha1,const string& b64) { 27 void secret_t::enxor_from_base64(const unsigned char *key_d,const string& b64) {
30 clear(); 28 clear();
31 util::decode_base64(b64,*this); 29 util::decode_base64(b64,*this);
32 transform( 30 transform(
33 begin(), end(), 31 begin(), end(),
34 key_sha1, 32 key_d,
35 begin(), 33 begin(),
36 bitwise_xor<unsigned char,unsigned char,unsigned char>() ); 34 bitwise_xor<unsigned char,unsigned char,unsigned char>() );
@@ -38,6 +36,4 @@ namespace opkele {
38 36
39 void secret_t::to_base64(string& rv) const { 37 void secret_t::to_base64(string& rv) const {
40 if(size()!=20)
41 throw bad_input(OPKELE_CP_ "wrong secret size");
42 rv = util::encode_base64(&(front()),size()); 38 rv = util::encode_base64(&(front()),size());
43 } 39 }