swift
cryptodtochannel.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2019 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_CORE_AFV_CRYPTO_CRYPTODTOCHANNEL_H
7 #define SWIFT_CORE_AFV_CRYPTO_CRYPTODTOCHANNEL_H
8 
9 #include <QByteArray>
10 #include <QDateTime>
11 #include <QVector>
12 
14 #include "core/afv/dto.h"
15 
16 namespace swift::core::afv::crypto
17 {
20  {
21  public:
23  CCryptoDtoChannel(const CryptoDtoChannelConfigDto &channelConfig, int receiveSequenceHistorySize = 10);
24 
27  QByteArray getTransmitKey(CryptoDtoMode mode);
28  QByteArray getTransmitKey(CryptoDtoMode mode, uint &sequenceToSend);
30 
32  QString getChannelTag() const;
33 
35  QByteArray getReceiveKey(CryptoDtoMode mode);
36 
38  bool checkReceivedSequence(uint sequenceReceived);
39 
40  private:
41  bool contains(uint sequence) const;
42  uint getMin(int &minIndex) const;
43 
44  QByteArray m_aeadTransmitKey;
45  QByteArray m_aeadReceiveKey;
46 
47  uint m_transmitSequence = 0;
48  QVector<uint> m_receiveSequenceHistory;
49  int m_receiveSequenceHistoryDepth;
50  int m_receiveSequenceSizeMaxSize;
51 
52  QByteArray m_hmacKey;
53  QString m_channelTag;
54  QDateTime m_LastTransmitUtc;
55  QDateTime m_lastReceiveUtc;
56  };
57 } // namespace swift::core::afv::crypto
58 
59 #endif // SWIFT_CORE_AFV_CRYPTO_CRYPTODTOCHANNEL_H
QByteArray getReceiveKey(CryptoDtoMode mode)
Receiver key.
bool checkReceivedSequence(uint sequenceReceived)
check the received sequence
QByteArray getTransmitKey(CryptoDtoMode mode)
Transmit key.
CCryptoDtoChannel(const CryptoDtoChannelConfigDto &channelConfig, int receiveSequenceHistorySize=10)
Ctor.