Skip to content

Commit

Permalink
Support for crypto++7.0.0 is discarded as it is not supported in bion…
Browse files Browse the repository at this point in the history
…ic, see bug #40
  • Loading branch information
Pavel Kraynyukhov committed Oct 19, 2018
1 parent 03348a2 commit bb5b22e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
19 changes: 0 additions & 19 deletions include/ClientWebSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ namespace LAppS
static thread_local CryptoPP::AutoSeededRandomPool RNG(true);
static thread_local CryptoPP::Base64Encoder BASE64;
static thread_local CryptoPP::SHA1 SHA1;
static thread_local itc::sys::Nap NAP;

static thread_local std::vector<uint8_t> recvBuffer(8192,0);

Expand Down Expand Up @@ -397,13 +396,8 @@ namespace LAppS
{
std::string accept_key_src(mSecWebSocketKey+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");

#if __GNUC_PREREQ(7,0)
CryptoPP::byte digest[CryptoPP::SHA1::DIGESTSIZE];
SHA1.CalculateDigest(digest,(const CryptoPP::byte*)(accept_key_src.data()),accept_key_src.length());
#else
byte digest[CryptoPP::SHA1::DIGESTSIZE];
SHA1.CalculateDigest(digest,(const byte*)(accept_key_src.data()),accept_key_src.length());
#endif

BASE64.Initialize();
BASE64.Put(digest, CryptoPP::SHA1::DIGESTSIZE);
Expand All @@ -412,11 +406,7 @@ namespace LAppS
size_t accept_key_length=BASE64.MaxRetrievable()-1; // skip trailing \n

std::string required_accept_key(accept_key_length,'\0');
#if __GNUC_PREREQ(7,0)
BASE64.Get((CryptoPP::byte*)(required_accept_key.data()),accept_key_length);
#else
BASE64.Get((byte*)(required_accept_key.data()),accept_key_length);
#endif

return responseOK((const char*)(recvBuffer.data()),ret,required_accept_key);
}
Expand Down Expand Up @@ -550,11 +540,7 @@ namespace LAppS
size_t base64_str_size=BASE64.MaxRetrievable()-1; // remove trailing \n

mSecWebSocketKey.resize(base64_str_size,'\0');
#if __GNUC_PREREQ(7,0)
BASE64.Get((CryptoPP::byte*)(mSecWebSocketKey.data()),base64_str_size);
#else
BASE64.Get((byte*)(mSecWebSocketKey.data()),base64_str_size);
#endif

httpUpgradeRequest.append(mSecWebSocketKey);
httpUpgradeRequest.append("\r\n");
Expand Down Expand Up @@ -689,12 +675,7 @@ namespace LAppS
} double_mask;

uint32_t single_mask=0;
#if __GNUC_PREREQ(7,0)
RNG.GenerateBlock((CryptoPP::byte*)(&single_mask),sizeof(single_mask));
#else
RNG.GenerateBlock((byte*)(&single_mask),sizeof(single_mask));
#endif

double_mask.mask=(static_cast<uint64_t>(single_mask)<<32)|single_mask;

std::vector<uint8_t> out;
Expand Down
10 changes: 1 addition & 9 deletions include/Shakespeer.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,8 @@ namespace LAppS

std::string replykey(mHTTPRParser["Sec-WebSocket-Key"]+UID);

#if __GNUC_PREREQ(7,0)
CryptoPP::byte digest[CryptoPP::SHA1::DIGESTSIZE];
sha1.CalculateDigest( digest, (const CryptoPP::byte*)(replykey.c_str()),replykey.length());
#else
byte digest[CryptoPP::SHA1::DIGESTSIZE];
sha1.CalculateDigest( digest, (const byte*)(replykey.c_str()),replykey.length());
#endif

CryptoPP::Base64Encoder b64;
b64.Put(digest, CryptoPP::SHA1::DIGESTSIZE);
Expand All @@ -252,11 +247,8 @@ namespace LAppS

okResponse.resize(respsz+encoded_key_size-1);

#if __GNUC_PREREQ(7,0)
b64.Get((CryptoPP::byte*)(okResponse.data()+respsz),encoded_key_size-1);
#else
b64.Get((byte*)(okResponse.data()+respsz),encoded_key_size-1);
#endif

okResponse.append("\r\n\r\n");

response.resize(okResponse.size());
Expand Down

0 comments on commit bb5b22e

Please # to comment.