summaryrefslogtreecommitdiffabout
path: root/lib/secret.cc
authorMichael Krelin <hacker@klever.net>2007-01-12 12:58:25 (UTC)
committer Michael Krelin <hacker@klever.net>2007-01-12 12:58:25 (UTC)
commite79687a3d9a1631613de02d8e12bae36302b46ab (patch) (unidiff)
tree4238c0d8d61f5e70ed1e98debb01315babb21686 /lib/secret.cc
parent4cc2e58186e8cd9b96a3573c92f6664064cf11fe (diff)
downloadlibopkele-e79687a3d9a1631613de02d8e12bae36302b46ab.zip
libopkele-e79687a3d9a1631613de02d8e12bae36302b46ab.tar.gz
libopkele-e79687a3d9a1631613de02d8e12bae36302b46ab.tar.bz2
eliminated mimetic dependency and made use of openssl base64 encoder instead
Diffstat (limited to 'lib/secret.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/secret.cc22
1 files changed, 5 insertions, 17 deletions
diff --git a/lib/secret.cc b/lib/secret.cc
index ae8a3c5..632a2ca 100644
--- a/lib/secret.cc
+++ b/lib/secret.cc
@@ -2,7 +2,7 @@
2#include <functional> 2#include <functional>
3#include <opkele/types.h> 3#include <opkele/types.h>
4#include <opkele/exception.h> 4#include <opkele/exception.h>
5#include <mimetic/mimetic.h> 5#include <opkele/util.h>
6 6
7namespace opkele { 7namespace opkele {
8 using namespace std; 8 using namespace std;
@@ -23,18 +23,12 @@ namespace opkele {
23 key_sha1, 23 key_sha1,
24 back_insert_iterator<vector<unsigned char> >(tmp), 24 back_insert_iterator<vector<unsigned char> >(tmp),
25 bitwise_xor<unsigned char,unsigned char,unsigned char>() ); 25 bitwise_xor<unsigned char,unsigned char,unsigned char>() );
26 mimetic::Base64::Encoder b(0); 26 rv = util::encode_base64(&(tmp.front()),tmp.size());
27 mimetic::encode(
28 tmp.begin(),tmp.end(), b,
29 back_insert_iterator<string>(rv) );
30 } 27 }
31 28
32 void secret_t::enxor_from_base64(const unsigned char *key_sha1,const string& b64) { 29 void secret_t::enxor_from_base64(const unsigned char *key_sha1,const string& b64) {
33 mimetic::Base64::Decoder b;
34 clear(); 30 clear();
35 mimetic::decode( 31 util::decode_base64(b64,*this);
36 b64.begin(),b64.end(), b,
37 back_insert_iterator<secret_t>(*this) );
38 transform( 32 transform(
39 begin(), end(), 33 begin(), end(),
40 key_sha1, 34 key_sha1,
@@ -45,17 +39,11 @@ namespace opkele {
45 void secret_t::to_base64(string& rv) const { 39 void secret_t::to_base64(string& rv) const {
46 if(size()!=20) 40 if(size()!=20)
47 throw bad_input(OPKELE_CP_ "wrong secret size"); 41 throw bad_input(OPKELE_CP_ "wrong secret size");
48 mimetic::Base64::Encoder b(0); 42 rv = util::encode_base64(&(front()),size());
49 mimetic::encode(
50 begin(),end(), b,
51 back_insert_iterator<string>(rv) );
52 } 43 }
53 44
54 void secret_t::from_base64(const string& b64) { 45 void secret_t::from_base64(const string& b64) {
55 mimetic::Base64::Decoder b; 46 util::decode_base64(b64,*this);
56 mimetic::decode(
57 b64.begin(),b64.end(), b,
58 back_insert_iterator<secret_t>(*this) );
59 } 47 }
60 48
61} 49}