Virgil Security Crypto library  2.6.3
VirgilOperationKDF.h
1 
37 #ifndef VIRGIL_CRYPTO_VIRGIL_KDF_H
38 #define VIRGIL_CRYPTO_VIRGIL_KDF_H
39 
40 #include "../VirgilByteArray.h"
41 
42 #include <memory>
43 
44 namespace virgil { namespace crypto { inline namespace primitive {
45 
52 private:
53  template<class Impl>
54  struct Model;
55 
56 public:
62  template<class Impl>
63  VirgilOperationKDF(Impl impl):self_(std::make_shared<Model<Impl>>(std::move(impl))) {}
64 
75  const VirgilByteArray& keyMaterial, const VirgilByteArray& salt,
76  const VirgilByteArray& info, size_t size) const {
77  return self_->doDerive(keyMaterial, salt, info, size);
78  }
79 
84 
85 private:
86  struct Concept {
87  virtual VirgilByteArray doDerive(
88  const VirgilByteArray& keyMaterial, const VirgilByteArray& salt,
89  const VirgilByteArray& info, size_t size) const = 0;
90 
91  virtual ~Concept() noexcept = default;
92  };
93 
94  template<class Impl>
95  struct Model : Concept {
96 
97  explicit Model(Impl impl) : impl_(std::move(impl)) {}
98 
99  VirgilByteArray doDerive(
100  const VirgilByteArray& keyMaterial, const VirgilByteArray& salt,
101  const VirgilByteArray& info, size_t size) const override {
102 
103  return impl_.derive(keyMaterial, salt, info, size);
104  }
105 
106  private:
107  Impl impl_;
108  };
109 
110 private:
111  std::shared_ptr<const Concept> self_;
112 };
113 
114 }}}
115 
116 #endif //VIRGIL_CRYPTO_VIRGIL_KDF_H
VirgilOperationKDF(Impl impl)
Captures implementation object.
Definition: VirgilOperationKDF.h:63
Definition: VirgilHash.h:265
static VirgilOperationKDF getDefault()
Return default implementation.
Root namespace for all Virgil Security libraries.
Definition: VirgilAsn1Compatible.h:46
std::vector< unsigned char > VirgilByteArray
This type represents a sequence of bytes.
Definition: VirgilByteArray.h:50
VirgilByteArray derive(const VirgilByteArray &keyMaterial, const VirgilByteArray &salt, const VirgilByteArray &info, size_t size) const
Derive key from the given key material and additional options.
Definition: VirgilOperationKDF.h:74
Define proxy interface for the Key Derivation Function functionality.
Definition: VirgilOperationKDF.h:51