Virgil Security Crypto library  2.4.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
VirgilPFS.h
1 
37 #ifndef VIRGIL_CRYPTO_PFS_VIRGIL_PFS_H
38 #define VIRGIL_CRYPTO_PFS_VIRGIL_PFS_H
39 
40 #include "../VirgilByteArray.h"
41 
42 #include "VirgilPFSSession.h"
43 #include "VirgilPFSEncryptedMessage.h"
44 #include "VirgilPFSInitiatorPublicInfo.h"
45 #include "VirgilPFSInitiatorPrivateInfo.h"
46 #include "VirgilPFSResponderPublicInfo.h"
47 #include "VirgilPFSResponderPrivateInfo.h"
48 
49 #include "../primitive/VirgilOperationRandom.h"
50 #include "../primitive/VirgilOperationHash.h"
51 #include "../primitive/VirgilOperationDH.h"
52 #include "../primitive/VirgilOperationKDF.h"
53 #include "../primitive/VirgilOperationCipher.h"
54 
55 namespace virgil { namespace crypto { namespace pfs {
56 
62 class VirgilPFS {
63 public:
69  VirgilPFS();
70 
80  const VirgilPFSInitiatorPrivateInfo& initiatorPrivateInfo,
81  const VirgilPFSResponderPublicInfo& responderPublicInfo,
82  const VirgilByteArray& additionalData = VirgilByteArray());
83 
93  const VirgilPFSResponderPrivateInfo& responderPrivateInfo,
94  const VirgilPFSInitiatorPublicInfo& initiatorPublicInfo,
95  const VirgilByteArray& additionalData = VirgilByteArray());
96 
105 
112  VirgilByteArray decrypt(const VirgilPFSEncryptedMessage& encryptedMessage) const;
113 
118  void setRandom(VirgilOperationRandom random);
119 
124  void setDH(VirgilOperationDH dh);
125 
130  void setKDF(VirgilOperationKDF kdf);
131 
136  void setCipher(VirgilOperationCipher cipher);
137 
143 
148  void setSession(VirgilPFSSession session);
149 
150 private:
151  VirgilByteArray calculateSharedKey(
152  const VirgilPFSInitiatorPrivateInfo& initiatorPrivateInfo,
153  const VirgilPFSResponderPublicInfo& responderPublicInfo) const;
154 
155  VirgilByteArray calculateSharedKey(
156  const VirgilPFSResponderPrivateInfo& responderPrivateInfo,
157  const VirgilPFSInitiatorPublicInfo& initiatorPublicInfo) const;
158 
159  VirgilByteArray calculateSecretKey(const VirgilByteArray& keyMaterial, size_t size);
160 
161  VirgilByteArray calculateAdditionalData(
162  const VirgilByteArray& adSecretKey, const VirgilByteArray& additionalDataMaterial) const;
163 
164  VirgilByteArray calculateSessionIdentifier(
165  const VirgilByteArray& idSecretKey, const VirgilByteArray& additionalData) const;
166 
167 private:
168  VirgilOperationRandom random_;
169  VirgilOperationDH dh_;
170  VirgilOperationKDF kdf_;
171  VirgilOperationCipher cipher_;
172  VirgilPFSSession session_;
173 };
174 
175 }}}
176 
177 #endif //VIRGIL_CRYPTO_PFS_VIRGIL_PFS_H
This is model object that represent session in PFS communication.
Definition: VirgilPFSSession.h:56
This is model object that represent private information of a PFS Initiator.
Definition: VirgilPFSInitiatorPrivateInfo.h:53
This is model object that represent public information of a PFS Initiator.
Definition: VirgilPFSInitiatorPublicInfo.h:53
std::vector< unsigned char > VirgilByteArray
This type represents a sequence of bytes.
Definition: VirgilByteArray.h:50
void setSession(VirgilPFSSession session)
Set new session.
VirgilPFSSession startInitiatorSession(const VirgilPFSInitiatorPrivateInfo &initiatorPrivateInfo, const VirgilPFSResponderPublicInfo &responderPublicInfo, const VirgilByteArray &additionalData=VirgilByteArray())
Start session from the Initiator side.
VirgilPFSSession startResponderSession(const VirgilPFSResponderPrivateInfo &responderPrivateInfo, const VirgilPFSInitiatorPublicInfo &initiatorPublicInfo, const VirgilByteArray &additionalData=VirgilByteArray())
Start session from the Responder side.
void setCipher(VirgilOperationCipher cipher)
Set custom implementation for algorithm: Symmetric Cipher.
VirgilPFSEncryptedMessage encrypt(const VirgilByteArray &data)
Encrypt given data.
void setRandom(VirgilOperationRandom random)
Set custom implementation for algorithm: random.
VirgilByteArray decrypt(const VirgilPFSEncryptedMessage &encryptedMessage) const
Decrypt given message.
This is the main entry for the all Perfect Forward Secrecy (PFS) Modules.
Definition: VirgilPFS.h:62
VirgilPFSSession getSession() const
Return current session.
This is model object that represent encrypted message produced by VirgilPFS.
Definition: VirgilPFSEncryptedMessage.h:50
This is model object that represent private information of a PFS Responder.
Definition: VirgilPFSResponderPrivateInfo.h:53
void setKDF(VirgilOperationKDF kdf)
Set custom implementation for algorithm: Key Dervation Function.
VirgilPFS()
Configures PFS module with default underlying algorithms.
This is model object that represent public information of a PFS Responder.
Definition: VirgilPFSResponderPublicInfo.h:53
void setDH(VirgilOperationDH dh)
Set custom implementation for algorithm: Diffie–Hellman.