Virgil Security Crypto library  1.8.2
VirgilPBE.h
1 
37 #ifndef VIRGIL_CRYPTO_VIRGIL_PBE_H
38 #define VIRGIL_CRYPTO_VIRGIL_PBE_H
39 
40 #include <cstddef>
41 
42 #include <virgil/crypto/VirgilByteArray.h>
43 #include <virgil/crypto/foundation/asn1/VirgilAsn1Compatible.h>
44 
45 namespace virgil { namespace crypto { namespace foundation {
46 
50 class VirgilPBEImpl;
53 
58 public:
62  enum {
64  kIterationCountMin = 1024
65  };
67 public:
72 
77  static VirgilPBE pkcs5(const virgil::crypto::VirgilByteArray& salt, size_t iterationCount = kIterationCountMin);
78 
83  static VirgilPBE pkcs12(const virgil::crypto::VirgilByteArray& salt, size_t iterationCount = kIterationCountMin);
85 
88 
94  VirgilPBE();
95 
99  virtual ~VirgilPBE() throw();
101 
104 
111  virgil::crypto::VirgilByteArray encrypt(
112  const virgil::crypto::VirgilByteArray& data,
113  const virgil::crypto::VirgilByteArray& pwd) const;
114 
121  virgil::crypto::VirgilByteArray decrypt(
122  const virgil::crypto::VirgilByteArray& data,
123  const virgil::crypto::VirgilByteArray& pwd) const;
125 
131  VirgilPBE(const VirgilPBE& other);
133 
134  VirgilPBE& operator=(const VirgilPBE& rhs);
136 
147  virtual size_t asn1Write(
150  size_t childWrittenBytes = 0) const;
151 
154 private:
159  explicit VirgilPBE(int type, const virgil::crypto::VirgilByteArray& salt, size_t iterationCount);
160 
164  void checkState() const;
165 
169  virgil::crypto::VirgilByteArray process(
170  const virgil::crypto::VirgilByteArray& data,
171  const virgil::crypto::VirgilByteArray& pwd, int mode) const;
172 
173 private:
174  VirgilPBEImpl* impl_;
175 };
176 
177 }}}
178 
179 #endif /* VIRGIL_CRYPTO_VIRGIL_PBE_H */
static VirgilPBE pkcs5(const virgil::crypto::VirgilByteArray &salt, size_t iterationCount=kIterationCountMin)
Create object with PKCS#5 parameters for PBE encryption or decryption.
This class provides methods for reading ASN.1 data structure.
Definition: VirgilAsn1Reader.h:53
Provides Password-Based Cryptography. Now PKCS#5 and PKCS#12 are partially supported.
Definition: VirgilPBE.h:57
This class provides interface that allow to save and restore object state in the ASN.1 structure.
Definition: VirgilAsn1Compatible.h:59
This class provides methods for writing ASN.1 data structure.
Definition: VirgilAsn1Writer.h:54
Definition: VirgilAsn1Compatible.h:46
VirgilPBE()
Create object with undefined algorithm.
virtual void asn1Read(virgil::crypto::foundation::asn1::VirgilAsn1Reader &asn1Reader)
Read object state from the reader.
virgil::crypto::VirgilByteArray encrypt(const virgil::crypto::VirgilByteArray &data, const virgil::crypto::VirgilByteArray &pwd) const
Encrypt data with given password.
virgil::crypto::VirgilByteArray decrypt(const virgil::crypto::VirgilByteArray &data, const virgil::crypto::VirgilByteArray &pwd) const
Decrypt data with given password.
static VirgilPBE pkcs12(const virgil::crypto::VirgilByteArray &salt, size_t iterationCount=kIterationCountMin)
Create object with PKCS#12 parameters for PBE encryption or decryption.
virtual ~VirgilPBE()
Polymorphic destructor.
virtual size_t asn1Write(virgil::crypto::foundation::asn1::VirgilAsn1Writer &asn1Writer, size_t childWrittenBytes=0) const
Write object state to the writer.