AusweisApp2
SecureMessaging.h
gehe zur Dokumentation dieser Datei
1 
7 #pragma once
8 
10 #include "CommandApdu.h"
11 #include "pace/CipherMac.h"
12 #include "pace/SymmetricCipher.h"
13 #include "ResponseApdu.h"
14 
15 #include <QByteArray>
16 
17 
18 namespace governikus
19 {
20 
26  : public ASN1_OCTET_STRING {};
28 
29 
30 class SecureMessaging final
31 {
32  private:
33  SymmetricCipher mCipher;
34  CipherMac mCipherMac;
35  quint32 mSendSequenceCounter;
36 
37  QByteArray padToCipherBlockSize(const QByteArray& pData) const;
38  QByteArray unpadFromCipherBlockSize(const QByteArray& pData) const;
39  QByteArray createSecuredHeader(const CommandApdu& pCommandApdu) const;
40  QByteArray createMac(const QByteArray& pSecuredHeader, const QByteArray& pFormattedEncryptedData, const QByteArray& pSecuredLe);
41  int createNewLe(const QByteArray& pSecuredData, int pOldLe) const;
42  QByteArray getSendSequenceCounter() const;
43  QByteArray getEncryptedIv();
44 
45  QByteArray createSecuredLe(int pLe);
46 
47  public:
48  SecureMessaging(const QByteArray& pPaceAlgorithm, const QByteArray& pEncKey, const QByteArray& pMacKey);
49  ~SecureMessaging() = default;
50 
54  bool isInitialized();
55 
56  CommandApdu encrypt(const CommandApdu& pCommandApdu);
57 
63  ResponseApdu decrypt(const ResponseApdu& pEncryptedResponseApdu);
64 };
65 
66 } // namespace governikus
Definition: CipherMac.h:15
Implementation of ActivationContext for Intent based activation on Android systems.
Definition: ActivationContext.h:14
Message part of the Secure Messaging command APDU containing the expected length.
Definition: SecureMessaging.h:25
Definition: CommandApdu.h:14
Definition: SymmetricCipher.h:15
#define DECLARE_ASN1_OBJECT(name)
Definition: ASN1TemplateUtil.h:169
Definition: SecureMessaging.h:30
Definition: ResponseApdu.h:82