Virgil Security Crypto library  2.4.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
VirgilPBKDF.h
1 
37 #ifndef VIRGIL_CRYPTO_PBKDF_H
38 #define VIRGIL_CRYPTO_PBKDF_H
39 
40 #include <string>
41 #include <memory>
42 
43 #include "../VirgilByteArray.h"
44 #include "asn1/VirgilAsn1Compatible.h"
45 #include "VirgilHash.h"
46 
47 namespace virgil { namespace crypto { namespace foundation {
48 
53 public:
58  static constexpr unsigned int kIterationCount_Default = 2048;
59 public:
63  enum class Algorithm {
64  PBKDF2
65  };
69 
75  VirgilPBKDF();
76 
83  VirgilPBKDF(const virgil::crypto::VirgilByteArray& salt, unsigned int iterationCount = kIterationCount_Default);
85 
89 
93  VirgilByteArray getSalt() const;
94 
98  unsigned int getIterationCount() const;
99 
104 
109 
114 
119 
125 
132 
135 
145 
167  size_t asn1Write(asn1::VirgilAsn1Writer& asn1Writer, size_t childWrittenBytes = 0) const override;
169 
170  void asn1Read(asn1::VirgilAsn1Reader& asn1Reader) override;
172 public:
174  VirgilPBKDF(VirgilPBKDF&& rhs) noexcept;
175 
176  VirgilPBKDF& operator=(VirgilPBKDF&& rhs) noexcept;
177 
178  virtual ~VirgilPBKDF() noexcept;
180 
181 private:
185  void checkRecommendations(const VirgilByteArray& pwd) const;
186 
187 private:
188  class Impl;
189 
190  std::unique_ptr<Impl> impl_;
191 };
192 
193 }}}
194 
195 #endif /* VIRGIL_CRYPTO_PBKDF_H */
Algorithm
Defines specific password based key derivation function algorithm.
Definition: VirgilPBKDF.h:63
unsigned int getIterationCount() const
Return iteration count.
Algorithm
Enumerates possible Hash algorithms.
Definition: VirgilHash.h:57
virgil::crypto::VirgilByteArray derive(const virgil::crypto::VirgilByteArray &pwd, size_t outSize=0)
Derive key from the given key material.
This class provides methods for reading ASN.1 data structure.
Definition: VirgilAsn1Reader.h:53
VirgilByteArray getSalt() const
Return salt.
void disableRecommendationsCheck()
Ignore security check for used parameters.
static constexpr unsigned int kIterationCount_Default
Default iteration count.
Definition: VirgilPBKDF.h:58
This class provides interface that allow to save and restore object state in the ASN.1 structure.
Definition: VirgilAsn1Compatible.h:59
void asn1Read(asn1::VirgilAsn1Reader &asn1Reader) override
Read object state from the reader.
void setHashAlgorithm(VirgilHash::Algorithm hash)
Set underlying digest algorithm.
This class provides methods for writing ASN.1 data structure.
Definition: VirgilAsn1Writer.h:54
std::vector< unsigned char > VirgilByteArray
This type represents a sequence of bytes.
Definition: VirgilByteArray.h:50
VirgilPBKDF::Algorithm getAlgorithm() const
Return current algorithm of the password based key derivation function.
void setAlgorithm(VirgilPBKDF::Algorithm alg)
Set specific algorithm of the password based key derivation function.
VirgilPBKDF()
Create object with undefined algorithms.
Defines PBKDF2 algorithm (https://www.ietf.org/rfc/rfc2898.txt)
void enableRecommendationsCheck()
Involve security check for used parameters.
VirgilHash::Algorithm getHashAlgorithm() const
Returns underlying digest algorithm.
Provides password based key derivation function.
Definition: VirgilPBKDF.h:52
size_t asn1Write(asn1::VirgilAsn1Writer &asn1Writer, size_t childWrittenBytes=0) const override
Write object state to the writer.