sim590 / dpaste

A simple pastebin for light values (max 64KB) using OpenDHT distributed hash table (with support for encryption).
GNU General Public License v3.0
15 stars 4 forks source link

Multiple cipher support: GPG, AES #5

Closed sim590 closed 6 years ago

sim590 commented 6 years ago

A new class Cipher has been introduced in order to capture the common interface on all different ciphers. The two following functions describe the interface of a cipher:

virtual std::vector<uint8_t> processPlainText(std::vector<uint8_t> plain_text, std::shared_ptr<Parameters>&& params);

virtual std::vector<uint8_t> processCipherText(std::vector<uint8_t> cipher_text, std::shared_ptr<Parameters>&& params);

The above is combined with two structures that are used to pass parameters depending on the cipher used.

struct GPGParameters;
struct AESParameters;
using Parameters = std::variant<GPGParameters, AESParameters>;

In each case, a cipher will process the (cipher/plain)text using the same functions which are implemented differently for each particular ciphers.

N.B: Since the new instruction std::variant is used, the program now depends on c++17.

sim590 commented 6 years ago
aberaud commented 6 years ago

Not tested but code looks good :-)

sim590 commented 6 years ago

@aberaud Thanks for your input! We'll see if tests pass after #9 is merged :smile_cat:

sim590 commented 6 years ago

Actually, they won't pass that's for sure. :wink: I will push new tests so that everything pass on this branch.