class GStore {
public:
- virtual GKeyShPtr getKey(const Token &) { ThrowErr(Exc::Crypto::OperationNotSupported); }
+ virtual GKeyUPtr getKey(const Token &) { ThrowErr(Exc::Crypto::OperationNotSupported); }
virtual TokenPair generateAKey(const CryptoAlgorithm &) { ThrowErr(Exc::Crypto::OperationNotSupported); }
virtual Token generateSKey(const CryptoAlgorithm &) { ThrowErr(Exc::Crypto::OperationNotSupported); }
virtual Token import(DataType, const RawBuffer &) { ThrowErr(Exc::Crypto::OperationNotSupported); }
#include <sw-backend/store.h>
#include <sw-backend/internals.h>
+namespace {
+
+template <typename T, typename ...Args>
+std::unique_ptr<T> make_unique(Args&& ...args) {
+ return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
+}
+
+} // namespace anonymous
+
namespace CKM {
namespace Crypto {
namespace SW {
Internals::initialize();
}
-GKeyShPtr Store::getKey(const Token &token) {
+GKeyUPtr Store::getKey(const Token &token) {
if (token.backendId != m_backendId) {
ThrowErr(Exc::Crypto::WrongBackend, "Decider choose wrong backend!");
}
if (token.dataType.isKeyPrivate() || token.dataType.isKeyPublic()) {
- return std::make_shared<AKey>(token.data, token.dataType);
+ return make_unique<AKey>(token.data, token.dataType);
}
if (token.dataType == DataType(DataType::KEY_AES)) {
- return std::make_shared<SKey>(token.data, token.dataType);
+ return make_unique<SKey>(token.data, token.dataType);
}
if (token.dataType.isCertificate()) {
- return std::make_shared<Cert>(token.data, token.dataType);
+ return make_unique<Cert>(token.data, token.dataType);
}
ThrowErr(Exc::Crypto::KeyNotSupported,
public:
explicit Store(CryptoBackend backendId);
- virtual GKeyShPtr getKey(const Token &token);
+ virtual GKeyUPtr getKey(const Token &token);
virtual TokenPair generateAKey(const CryptoAlgorithm &);
virtual Token generateSKey(const CryptoAlgorithm &);
virtual Token import(DataType dataType, const RawBuffer &buffer);
public:
explicit Store(CryptoBackend backendId);
- virtual GKeyShPtr getKey(const Token &token);
+ virtual GKeyUPtr getKey(const Token &token);
virtual TokenPair generateAKey(const CryptoAlgorithm &);
virtual Token import(DataType dataType, const RawBuffer &buffer);
virtual void destroy(const Token &){}