#include "KeyCodeHelper.h" #include "lib/utils/datetime.h" #include "lib/utils/crypto/CryptoInit.h" #include "lib/utils/crypto/PrivateKey.h" #include "lib/utils/crypto/PublicKey.h" #include "lib/config/protos/keycode.pb.h" #include #include #include #include namespace bts { namespace crypto { bool decrypt_keycode(const bts::crypto::PublicKey& public_key, const bts::config::EncryptedKeyCode& kc, bts::config::KeyCode* dk) { std::stringstream kss, out; kss << kc.keycode(); if(public_key.decrypt(kss, out)) { bts::config::KeyCode kc; google::protobuf::io::IstreamInputStream kc_stream(&kss); google::protobuf::TextFormat::Parse(&kc_stream, &kc); if(dk) { *dk = kc; return true; } } return false; } }}