diff options
Diffstat (limited to 'src/security/sasl')
-rw-r--r-- | src/security/sasl/SASLContext.cpp | 4 | ||||
-rw-r--r-- | src/security/sasl/SASLSession.cpp | 4 | ||||
-rw-r--r-- | src/security/sasl/SASLSocket.cpp | 50 | ||||
-rw-r--r-- | src/security/sasl/builtinSASLMechanism.cpp | 12 |
4 files changed, 37 insertions, 33 deletions
diff --git a/src/security/sasl/SASLContext.cpp b/src/security/sasl/SASLContext.cpp index c4d60bd9..3474cbeb 100644 --- a/src/security/sasl/SASLContext.cpp +++ b/src/security/sasl/SASLContext.cpp @@ -106,7 +106,7 @@ shared_ptr <SASLMechanism> SASLContext::suggestMechanism } -void SASLContext::decodeB64(const string& input, byte_t** output, long* outputLen) +void SASLContext::decodeB64(const string& input, byte_t** output, size_t* outputLen) { string res; @@ -127,7 +127,7 @@ void SASLContext::decodeB64(const string& input, byte_t** output, long* outputLe } -const string SASLContext::encodeB64(const byte_t* input, const long inputLen) +const string SASLContext::encodeB64(const byte_t* input, const size_t inputLen) { string res; diff --git a/src/security/sasl/SASLSession.cpp b/src/security/sasl/SASLSession.cpp index 1bdd0889..087ef27b 100644 --- a/src/security/sasl/SASLSession.cpp +++ b/src/security/sasl/SASLSession.cpp @@ -99,8 +99,8 @@ shared_ptr <SASLContext> SASLSession::getContext() bool SASLSession::evaluateChallenge - (const byte_t* challenge, const long challengeLen, - byte_t** response, long* responseLen) + (const byte_t* challenge, const size_t challengeLen, + byte_t** response, size_t* responseLen) { return m_mech->step(dynamicCast <SASLSession>(shared_from_this()), challenge, challengeLen, response, responseLen); diff --git a/src/security/sasl/SASLSocket.cpp b/src/security/sasl/SASLSocket.cpp index 37e297dc..12d634c2 100644 --- a/src/security/sasl/SASLSocket.cpp +++ b/src/security/sasl/SASLSocket.cpp @@ -30,9 +30,12 @@ #include "vmime/security/sasl/SASLSocket.hpp" #include "vmime/security/sasl/SASLSession.hpp" +#include "vmime/utility/stringUtils.hpp" + #include "vmime/exception.hpp" #include <algorithm> +#include <cstring> #include <gsasl.h> @@ -75,7 +78,7 @@ bool SASLSocket::isConnected() const } -SASLSocket::size_type SASLSocket::getBlockSize() const +size_t SASLSocket::getBlockSize() const { return m_wrapped->getBlockSize(); } @@ -95,17 +98,17 @@ const string SASLSocket::getPeerAddress() const void SASLSocket::receive(string& buffer) { - const size_type n = receiveRaw(m_recvBuffer, sizeof(m_recvBuffer)); + const size_t n = receiveRaw(m_recvBuffer, sizeof(m_recvBuffer)); - buffer = string(m_recvBuffer, n); + buffer = utility::stringUtils::makeStringFromBytes(m_recvBuffer, n); } -SASLSocket::size_type SASLSocket::receiveRaw(char* buffer, const size_type count) +size_t SASLSocket::receiveRaw(byte_t* buffer, const size_t count) { if (m_pendingLen != 0) { - const size_type copyLen = + const size_t copyLen = (count >= m_pendingLen ? m_pendingLen : count); std::copy(m_pendingBuffer + m_pendingPos, @@ -127,14 +130,13 @@ SASLSocket::size_type SASLSocket::receiveRaw(char* buffer, const size_type count return copyLen; } - const size_type n = m_wrapped->receiveRaw(buffer, count); + const size_t n = m_wrapped->receiveRaw(buffer, count); byte_t* output = 0; - long outputLen = 0; + size_t outputLen = 0; m_session->getMechanism()->decode - (m_session, reinterpret_cast <const byte_t*>(buffer), n, - &output, &outputLen); + (m_session, buffer, n, &output, &outputLen); // If we can not copy all decoded data into the output buffer, put // remaining data into a pending buffer for next calls to receive() @@ -161,23 +163,27 @@ SASLSocket::size_type SASLSocket::receiveRaw(char* buffer, const size_type count void SASLSocket::send(const string& buffer) { - sendRaw(buffer.data(), buffer.length()); + sendRaw(reinterpret_cast <const byte_t*>(buffer.data()), buffer.length()); +} + + +void SASLSocket::send(const char* str) +{ + sendRaw(reinterpret_cast <const byte_t*>(str), strlen(str)); } -void SASLSocket::sendRaw(const char* buffer, const size_type count) +void SASLSocket::sendRaw(const byte_t* buffer, const size_t count) { byte_t* output = 0; - long outputLen = 0; + size_t outputLen = 0; m_session->getMechanism()->encode - (m_session, reinterpret_cast <const byte_t*>(buffer), count, - &output, &outputLen); + (m_session, buffer, count, &output, &outputLen); try { - m_wrapped->sendRaw - (reinterpret_cast <const char*>(output), outputLen); + m_wrapped->sendRaw(output, outputLen); } catch (...) { @@ -189,21 +195,19 @@ void SASLSocket::sendRaw(const char* buffer, const size_type count) } -SASLSocket::size_type SASLSocket::sendRawNonBlocking(const char* buffer, const size_type count) +size_t SASLSocket::sendRawNonBlocking(const byte_t* buffer, const size_t count) { byte_t* output = 0; - long outputLen = 0; + size_t outputLen = 0; m_session->getMechanism()->encode - (m_session, reinterpret_cast <const byte_t*>(buffer), count, - &output, &outputLen); + (m_session, buffer, count, &output, &outputLen); - size_type bytesSent = 0; + size_t bytesSent = 0; try { - bytesSent = m_wrapped->sendRawNonBlocking - (reinterpret_cast <const char*>(output), outputLen); + bytesSent = m_wrapped->sendRawNonBlocking(output, outputLen); } catch (...) { diff --git a/src/security/sasl/builtinSASLMechanism.cpp b/src/security/sasl/builtinSASLMechanism.cpp index e7bd723e..e179e715 100644 --- a/src/security/sasl/builtinSASLMechanism.cpp +++ b/src/security/sasl/builtinSASLMechanism.cpp @@ -63,8 +63,8 @@ const string builtinSASLMechanism::getName() const bool builtinSASLMechanism::step - (shared_ptr <SASLSession> sess, const byte_t* challenge, const long challengeLen, - byte_t** response, long* responseLen) + (shared_ptr <SASLSession> sess, const byte_t* challenge, const size_t challengeLen, + byte_t** response, size_t* responseLen) { char* output = 0; size_t outputLen = 0; @@ -121,8 +121,8 @@ bool builtinSASLMechanism::isComplete() const void builtinSASLMechanism::encode - (shared_ptr <SASLSession> sess, const byte_t* input, const long inputLen, - byte_t** output, long* outputLen) + (shared_ptr <SASLSession> sess, const byte_t* input, const size_t inputLen, + byte_t** output, size_t* outputLen) { char* coutput = 0; size_t coutputLen = 0; @@ -154,8 +154,8 @@ void builtinSASLMechanism::encode void builtinSASLMechanism::decode - (shared_ptr <SASLSession> sess, const byte_t* input, const long inputLen, - byte_t** output, long* outputLen) + (shared_ptr <SASLSession> sess, const byte_t* input, const size_t inputLen, + byte_t** output, size_t* outputLen) { char* coutput = 0; size_t coutputLen = 0; |