class BData : public GObj {
public:
- BData(int scheme, RawBuffer buffer, Pwd pwd, DataType keyType):
- m_scheme(scheme), m_raw(std::move(buffer)), m_password(std::move(pwd)),
- m_type(keyType) {}
+ explicit BData(RawBuffer buffer) : m_raw(std::move(buffer)) {}
virtual RawBuffer getBinary() const override
{
return m_raw;
}
+protected:
+ RawBuffer m_raw;
+};
+
+class Key : public BData {
+public:
+ Key(int scheme, RawBuffer buffer, Pwd pwd, DataType dataType) :
+ BData(std::move(buffer)),
+ m_scheme(scheme),
+ m_password(std::move(pwd)),
+ m_type(dataType) {}
+
virtual int getScheme() const
{
return m_scheme;
protected:
int m_scheme;
- RawBuffer m_raw;
Pwd m_password;
DataType m_type;
};
-class SKey : public BData {
+class SKey : public Key {
public:
- SKey(int scheme, RawBuffer buffer, Pwd pwd, DataType keyType) :
- BData(scheme, std::move(buffer), std::move(pwd), keyType) {}
+ SKey(int scheme, RawBuffer buffer, Pwd pwd, DataType dataType) :
+ Key(scheme, std::move(buffer), std::move(pwd), dataType) {}
virtual RawBuffer encrypt(const CryptoAlgorithm &, const RawBuffer &);
virtual RawBuffer decrypt(const CryptoAlgorithm &, const RawBuffer &);
};
-class AKey : public BData {
+class AKey : public Key {
public:
AKey(int scheme, RawBuffer buffer, Pwd pwd, DataType dataType) :
- BData(scheme, std::move(buffer), std::move(pwd), dataType) {}
+ Key(scheme, std::move(buffer), std::move(pwd), dataType) {}
virtual RawBuffer sign(const CryptoAlgorithm &alg, const RawBuffer &message);
virtual int verify(const CryptoAlgorithm &alg, const RawBuffer &message,
if (token.dataType.isBinaryData()) {
RawBuffer exported_data = Internals::getData(id, Pwd(pass, iv, tag));
- return make_unique<BData>(scheme, exported_data, Pwd(pass, iv, tag), token.dataType);
+ return make_unique<BData>(std::move(exported_data));
}
ThrowErr(Exc::Crypto::DataTypeNotSupported,