author | Michael Krelin <hacker@klever.net> | 2007-11-21 14:01:36 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-11-21 14:01:36 (UTC) |
commit | 8e397698d6a224e36f2b4a188380ec04400aac66 (patch) (unidiff) | |
tree | da7aa7d75f6dd74b8d7260b7ab9c39241726ca88 | |
parent | 10916ef2b15b91badb17af5404acd9981b8a2087 (diff) | |
download | libopkele-8e397698d6a224e36f2b4a188380ec04400aac66.zip libopkele-8e397698d6a224e36f2b4a188380ec04400aac66.tar.gz libopkele-8e397698d6a224e36f2b4a188380ec04400aac66.tar.bz2 |
added some missing includes for gcc 4.3
According to Marcus Rueckert gcc 4.3 wants these. Thanks, Marcus!
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | lib/consumer.cc | 1 | ||||
-rw-r--r-- | lib/server.cc | 1 | ||||
-rw-r--r-- | lib/util.cc | 1 |
3 files changed, 3 insertions, 0 deletions
diff --git a/lib/consumer.cc b/lib/consumer.cc index f9212ea..d578546 100644 --- a/lib/consumer.cc +++ b/lib/consumer.cc | |||
@@ -1,50 +1,51 @@ | |||
1 | #include <algorithm> | 1 | #include <algorithm> |
2 | #include <cassert> | 2 | #include <cassert> |
3 | #include <cstring> | ||
3 | #include <opkele/util.h> | 4 | #include <opkele/util.h> |
4 | #include <opkele/exception.h> | 5 | #include <opkele/exception.h> |
5 | #include <opkele/data.h> | 6 | #include <opkele/data.h> |
6 | #include <opkele/consumer.h> | 7 | #include <opkele/consumer.h> |
7 | #include <openssl/sha.h> | 8 | #include <openssl/sha.h> |
8 | #include <openssl/hmac.h> | 9 | #include <openssl/hmac.h> |
9 | #include <curl/curl.h> | 10 | #include <curl/curl.h> |
10 | 11 | ||
11 | #include <iostream> | 12 | #include <iostream> |
12 | 13 | ||
13 | #include "config.h" | 14 | #include "config.h" |
14 | 15 | ||
15 | #include <pcre.h> | 16 | #include <pcre.h> |
16 | 17 | ||
17 | namespace opkele { | 18 | namespace opkele { |
18 | using namespace std; | 19 | using namespace std; |
19 | 20 | ||
20 | class pcre_matches_t { | 21 | class pcre_matches_t { |
21 | public: | 22 | public: |
22 | int *_ov; | 23 | int *_ov; |
23 | int _s; | 24 | int _s; |
24 | 25 | ||
25 | pcre_matches_t() : _ov(0), _s(0) { } | 26 | pcre_matches_t() : _ov(0), _s(0) { } |
26 | pcre_matches_t(int s) : _ov(0), _s(s) { | 27 | pcre_matches_t(int s) : _ov(0), _s(s) { |
27 | if(_s&1) ++_s; | 28 | if(_s&1) ++_s; |
28 | _s += _s>>1; | 29 | _s += _s>>1; |
29 | _ov = new int[_s]; | 30 | _ov = new int[_s]; |
30 | } | 31 | } |
31 | ~pcre_matches_t() throw() { if(_ov) delete[] _ov; } | 32 | ~pcre_matches_t() throw() { if(_ov) delete[] _ov; } |
32 | 33 | ||
33 | int begin(int i) const { return _ov[i<<1]; } | 34 | int begin(int i) const { return _ov[i<<1]; } |
34 | int end(int i) const { return _ov[(i<<1)+1]; } | 35 | int end(int i) const { return _ov[(i<<1)+1]; } |
35 | int length(int i) const { int t=i<<1; return _ov[t+1]-_ov[t]; } | 36 | int length(int i) const { int t=i<<1; return _ov[t+1]-_ov[t]; } |
36 | }; | 37 | }; |
37 | 38 | ||
38 | class pcre_t { | 39 | class pcre_t { |
39 | public: | 40 | public: |
40 | pcre *_p; | 41 | pcre *_p; |
41 | 42 | ||
42 | pcre_t() : _p(0) { } | 43 | pcre_t() : _p(0) { } |
43 | pcre_t(pcre *p) : _p(p) { } | 44 | pcre_t(pcre *p) : _p(p) { } |
44 | pcre_t(const char *re,int opts) : _p(0) { | 45 | pcre_t(const char *re,int opts) : _p(0) { |
45 | static const char *errptr; static int erroffset; | 46 | static const char *errptr; static int erroffset; |
46 | _p = pcre_compile(re,opts,&errptr,&erroffset,NULL); | 47 | _p = pcre_compile(re,opts,&errptr,&erroffset,NULL); |
47 | if(!_p) | 48 | if(!_p) |
48 | throw internal_error(OPKELE_CP_ string("Failed to compile regexp: ")+errptr); | 49 | throw internal_error(OPKELE_CP_ string("Failed to compile regexp: ")+errptr); |
49 | } | 50 | } |
50 | ~pcre_t() throw() { if(_p) (*pcre_free)(_p); } | 51 | ~pcre_t() throw() { if(_p) (*pcre_free)(_p); } |
diff --git a/lib/server.cc b/lib/server.cc index b1c5c3a..aa61035 100644 --- a/lib/server.cc +++ b/lib/server.cc | |||
@@ -1,48 +1,49 @@ | |||
1 | #include <cstring> | ||
1 | #include <vector> | 2 | #include <vector> |
2 | #include <openssl/sha.h> | 3 | #include <openssl/sha.h> |
3 | #include <openssl/hmac.h> | 4 | #include <openssl/hmac.h> |
4 | #include <opkele/util.h> | 5 | #include <opkele/util.h> |
5 | #include <opkele/exception.h> | 6 | #include <opkele/exception.h> |
6 | #include <opkele/server.h> | 7 | #include <opkele/server.h> |
7 | #include <opkele/data.h> | 8 | #include <opkele/data.h> |
8 | 9 | ||
9 | namespace opkele { | 10 | namespace opkele { |
10 | using namespace std; | 11 | using namespace std; |
11 | 12 | ||
12 | void server_t::associate(const params_t& pin,params_t& pout) { | 13 | void server_t::associate(const params_t& pin,params_t& pout) { |
13 | util::dh_t dh; | 14 | util::dh_t dh; |
14 | util::bignum_t c_pub; | 15 | util::bignum_t c_pub; |
15 | unsigned char key_sha1[SHA_DIGEST_LENGTH]; | 16 | unsigned char key_sha1[SHA_DIGEST_LENGTH]; |
16 | enum { | 17 | enum { |
17 | sess_cleartext, | 18 | sess_cleartext, |
18 | sess_dh_sha1 | 19 | sess_dh_sha1 |
19 | } st = sess_cleartext; | 20 | } st = sess_cleartext; |
20 | if( | 21 | if( |
21 | pin.has_param("openid.session_type") | 22 | pin.has_param("openid.session_type") |
22 | && pin.get_param("openid.session_type")=="DH-SHA1" ) { | 23 | && pin.get_param("openid.session_type")=="DH-SHA1" ) { |
23 | /* TODO: fallback to cleartext in case of exceptions here? */ | 24 | /* TODO: fallback to cleartext in case of exceptions here? */ |
24 | if(!(dh = DH_new())) | 25 | if(!(dh = DH_new())) |
25 | throw exception_openssl(OPKELE_CP_ "failed to DH_new()"); | 26 | throw exception_openssl(OPKELE_CP_ "failed to DH_new()"); |
26 | c_pub = util::base64_to_bignum(pin.get_param("openid.dh_consumer_public")); | 27 | c_pub = util::base64_to_bignum(pin.get_param("openid.dh_consumer_public")); |
27 | if(pin.has_param("openid.dh_modulus")) | 28 | if(pin.has_param("openid.dh_modulus")) |
28 | dh->p = util::base64_to_bignum(pin.get_param("openid.dh_modulus")); | 29 | dh->p = util::base64_to_bignum(pin.get_param("openid.dh_modulus")); |
29 | else | 30 | else |
30 | dh->p = util::dec_to_bignum(data::_default_p); | 31 | dh->p = util::dec_to_bignum(data::_default_p); |
31 | if(pin.has_param("openid.dh_gen")) | 32 | if(pin.has_param("openid.dh_gen")) |
32 | dh->g = util::base64_to_bignum(pin.get_param("openid.dh_gen")); | 33 | dh->g = util::base64_to_bignum(pin.get_param("openid.dh_gen")); |
33 | else | 34 | else |
34 | dh->g = util::dec_to_bignum(data::_default_g); | 35 | dh->g = util::dec_to_bignum(data::_default_g); |
35 | if(!DH_generate_key(dh)) | 36 | if(!DH_generate_key(dh)) |
36 | throw exception_openssl(OPKELE_CP_ "failed to DH_generate_key()"); | 37 | throw exception_openssl(OPKELE_CP_ "failed to DH_generate_key()"); |
37 | vector<unsigned char> ck(DH_size(dh)+1); | 38 | vector<unsigned char> ck(DH_size(dh)+1); |
38 | unsigned char *ckptr = &(ck.front())+1; | 39 | unsigned char *ckptr = &(ck.front())+1; |
39 | int cklen = DH_compute_key(ckptr,c_pub,dh); | 40 | int cklen = DH_compute_key(ckptr,c_pub,dh); |
40 | if(cklen<0) | 41 | if(cklen<0) |
41 | throw exception_openssl(OPKELE_CP_ "failed to DH_compute_key()"); | 42 | throw exception_openssl(OPKELE_CP_ "failed to DH_compute_key()"); |
42 | if(cklen && (*ckptr)&0x80) { | 43 | if(cklen && (*ckptr)&0x80) { |
43 | (*(--ckptr)) = 0; ++cklen; | 44 | (*(--ckptr)) = 0; ++cklen; |
44 | } | 45 | } |
45 | SHA1(ckptr,cklen,key_sha1); | 46 | SHA1(ckptr,cklen,key_sha1); |
46 | st = sess_dh_sha1; | 47 | st = sess_dh_sha1; |
47 | } | 48 | } |
48 | assoc_t assoc = alloc_assoc(mode_associate); | 49 | assoc_t assoc = alloc_assoc(mode_associate); |
diff --git a/lib/util.cc b/lib/util.cc index 94e09ed..26be66a 100644 --- a/lib/util.cc +++ b/lib/util.cc | |||
@@ -1,50 +1,51 @@ | |||
1 | #include <errno.h> | 1 | #include <errno.h> |
2 | #include <cassert> | 2 | #include <cassert> |
3 | #include <cstring> | ||
3 | #include <vector> | 4 | #include <vector> |
4 | #include <string> | 5 | #include <string> |
5 | #include <openssl/bio.h> | 6 | #include <openssl/bio.h> |
6 | #include <openssl/evp.h> | 7 | #include <openssl/evp.h> |
7 | #include <curl/curl.h> | 8 | #include <curl/curl.h> |
8 | #include "opkele/util.h" | 9 | #include "opkele/util.h" |
9 | #include "opkele/exception.h" | 10 | #include "opkele/exception.h" |
10 | 11 | ||
11 | namespace opkele { | 12 | namespace opkele { |
12 | using namespace std; | 13 | using namespace std; |
13 | 14 | ||
14 | namespace util { | 15 | namespace util { |
15 | 16 | ||
16 | /* | 17 | /* |
17 | * base64 | 18 | * base64 |
18 | */ | 19 | */ |
19 | string encode_base64(const void *data,size_t length) { | 20 | string encode_base64(const void *data,size_t length) { |
20 | BIO *b64 = 0, *bmem = 0; | 21 | BIO *b64 = 0, *bmem = 0; |
21 | try { | 22 | try { |
22 | b64 = BIO_new(BIO_f_base64()); | 23 | b64 = BIO_new(BIO_f_base64()); |
23 | if(!b64) | 24 | if(!b64) |
24 | throw exception_openssl(OPKELE_CP_ "failed to BIO_new() base64 encoder"); | 25 | throw exception_openssl(OPKELE_CP_ "failed to BIO_new() base64 encoder"); |
25 | BIO_set_flags(b64,BIO_FLAGS_BASE64_NO_NL); | 26 | BIO_set_flags(b64,BIO_FLAGS_BASE64_NO_NL); |
26 | bmem = BIO_new(BIO_s_mem()); | 27 | bmem = BIO_new(BIO_s_mem()); |
27 | BIO_set_flags(b64,BIO_CLOSE); | 28 | BIO_set_flags(b64,BIO_CLOSE); |
28 | if(!bmem) | 29 | if(!bmem) |
29 | throw exception_openssl(OPKELE_CP_ "failed to BIO_new() memory buffer"); | 30 | throw exception_openssl(OPKELE_CP_ "failed to BIO_new() memory buffer"); |
30 | BIO_push(b64,bmem); | 31 | BIO_push(b64,bmem); |
31 | if(((size_t)BIO_write(b64,data,length))!=length) | 32 | if(((size_t)BIO_write(b64,data,length))!=length) |
32 | throw exception_openssl(OPKELE_CP_ "failed to BIO_write()"); | 33 | throw exception_openssl(OPKELE_CP_ "failed to BIO_write()"); |
33 | if(BIO_flush(b64)!=1) | 34 | if(BIO_flush(b64)!=1) |
34 | throw exception_openssl(OPKELE_CP_ "failed to BIO_flush()"); | 35 | throw exception_openssl(OPKELE_CP_ "failed to BIO_flush()"); |
35 | char *rvd; | 36 | char *rvd; |
36 | long rvl = BIO_get_mem_data(bmem,&rvd); | 37 | long rvl = BIO_get_mem_data(bmem,&rvd); |
37 | string rv(rvd,rvl); | 38 | string rv(rvd,rvl); |
38 | BIO_free_all(b64); | 39 | BIO_free_all(b64); |
39 | return rv; | 40 | return rv; |
40 | }catch(...) { | 41 | }catch(...) { |
41 | if(b64) BIO_free_all(b64); | 42 | if(b64) BIO_free_all(b64); |
42 | throw; | 43 | throw; |
43 | } | 44 | } |
44 | } | 45 | } |
45 | 46 | ||
46 | void decode_base64(const string& data,vector<unsigned char>& rv) { | 47 | void decode_base64(const string& data,vector<unsigned char>& rv) { |
47 | BIO *b64 = 0, *bmem = 0; | 48 | BIO *b64 = 0, *bmem = 0; |
48 | rv.clear(); | 49 | rv.clear(); |
49 | try { | 50 | try { |
50 | bmem = BIO_new_mem_buf((void*)data.data(),data.size()); | 51 | bmem = BIO_new_mem_buf((void*)data.data(),data.size()); |