Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions plugins/experimental/ssl_session_reuse/src/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,21 @@

#include "common.h"

const unsigned char salt[] = {115, 97, 108, 117, 0, 85, 137, 229};
const unsigned char salt[] = {115, 97, 108, 117, 0, 85, 137, 229};
const unsigned char hex_chars[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};

std::string
hex_str(std::string str)
hex_str(std::string const &str)
{
std::string hex_str = "";
for (char &c : str) {
std::stringstream stream;
stream << std::hex << std::setfill('0') << std::setw(2) << (0xFF & static_cast<unsigned int>(c));
hex_str += stream.str();
}
return hex_str;
size_t len = str.size() * 2 + 1;
char hex_str[len];
for (unsigned long int i = 0; i < str.size(); ++i) {
unsigned char c = str.at(i);
hex_str[i * 2] = hex_chars[(c & 0xF0) >> 4];
hex_str[i * 2 + 1] = hex_chars[(c & 0x0F)];
}
hex_str[len] = '\0';
return std::string(hex_str, len);
}

int
Expand Down
3 changes: 1 addition & 2 deletions plugins/experimental/ssl_session_reuse/src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#pragma once

#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <cstring>
Expand Down Expand Up @@ -70,7 +69,7 @@ class PluginThreads
std::mutex threads_mutex;
};

std::string hex_str(std::string str);
std::string hex_str(std::string const &str);

int encrypt_encode64(const unsigned char *key, int key_length, const unsigned char *in_data, int in_data_len, char *out_data,
size_t out_data_size, size_t *out_data_len);
Expand Down