AusweisApp2
KeyAgreement.h
gehe zur Dokumentation dieser Datei
1 
7 #pragma once
8 
9 #include "CardConnectionWorker.h"
12 
13 #include <QSharedPointer>
14 
15 namespace governikus
16 {
17 
19 {
20  SUCCESS,
23  FAILED,
25 };
26 
28 {
29  protected:
30  struct CardResult
31  {
32  CardReturnCode mReturnCode = CardReturnCode::UNDEFINED;
33  QByteArray mData = QByteArray();
34  };
35 
36  private:
37  const QSharedPointer<CardConnectionWorker> mCardConnectionWorker;
38  QByteArray mEncryptionKey;
39  QByteArray mMacKey;
40  QByteArray mCarCurr, mCarPrev;
41 
42 
43  CardResult createTransmitResult(CardReturnCode pReturnCode,
44  StatusCode pResponseReturnCode,
45  const QByteArray& pResultData,
46  const char* pLogMessage);
47 
54  CardResult determineNonce(const QString& pPin);
55 
62  virtual CardResult determineSharedSecret(const QByteArray& pNonce) = 0;
63 
69  virtual QByteArray getUncompressedTerminalPublicKey() = 0;
70 
75  CardResult transmitGAEncryptedNonce();
76 
82  KeyAgreementStatus performMutualAuthenticate();
83 
84  protected:
85  const QSharedPointer<const PaceInfo> mPaceInfo;
87 
88  KeyAgreement(const QSharedPointer<const PaceInfo>& pPaceInfo, const QSharedPointer<CardConnectionWorker>& pCardConnectionWorker);
89 
95  CardResult transmitGAMappingData(const QByteArray& pMappingData);
96 
102  CardResult transmitGAEphemeralPublicKey(const QByteArray& pEphemeralPublicKey);
103 
109  GAMutualAuthenticationResponse transmitGAMutualAuthentication(const QByteArray& pMutualAuthenticationData);
110 
111  public:
117  virtual QByteArray getUncompressedCardPublicKey() = 0;
118 
124  virtual QByteArray getCompressedCardPublicKey() = 0;
125 
132  static QSharedPointer<KeyAgreement> create(const QSharedPointer<const PaceInfo>& pPaceInfo,
133  QSharedPointer<CardConnectionWorker> pCardConnectionWorker);
134  virtual ~KeyAgreement();
135 
141  KeyAgreementStatus perform(const QString& pPin);
142 
148  const QByteArray& getEncryptionKey() const;
149 
155  const QByteArray& getMacKey() const;
156 
161  const QByteArray& getCarCurr() const;
162 
167  const QByteArray& getCarPrev() const;
168 };
169 
170 } // namespace governikus
Definition: KeyAgreement.h:27
CardResult transmitGAEphemeralPublicKey(const QByteArray &pEphemeralPublicKey)
Transmit the General Authenticate (Ephemeral Public Key) command to the card.
Definition: KeyAgreement.cpp:196
virtual QByteArray getCompressedCardPublicKey()=0
Returns the compressed card&#39;s ephemeral public key calculated during key agreement.
Definition: GeneralAuthenticateResponse.h:124
Definition: KeyDerivationFunction.h:16
KeyAgreementStatus
Definition: KeyAgreement.h:18
KeyDerivationFunction mKeyDerivationFunction
Definition: KeyAgreement.h:86
Implementation of ActivationContext for Intent based activation on Android systems.
Definition: ActivationContext.h:14
const QByteArray & getCarPrev() const
Subsequent to the key agreement a certificate authority reference (CAR) may be determined.
Definition: KeyAgreement.cpp:245
QByteArray mData
Definition: KeyAgreement.h:33
const QSharedPointer< const PaceInfo > mPaceInfo
Definition: KeyAgreement.h:85
KeyAgreementStatus perform(const QString &pPin)
Perform the key agreement.
Definition: KeyAgreement.cpp:88
const QByteArray & getMacKey() const
Subsequent to the key agreement a MAC key is determined.
Definition: KeyAgreement.cpp:251
KeyAgreement(const QSharedPointer< const PaceInfo > &pPaceInfo, const QSharedPointer< CardConnectionWorker > &pCardConnectionWorker)
Definition: KeyAgreement.cpp:71
virtual QByteArray getUncompressedCardPublicKey()=0
Returns the uncompressed card&#39;s ephemeral public key calculated during key agreement.
GAMutualAuthenticationResponse transmitGAMutualAuthentication(const QByteArray &pMutualAuthenticationData)
Transmit the General Authenticate (Mutual Authentication) command to the card.
Definition: KeyAgreement.cpp:219
static QSharedPointer< KeyAgreement > create(const QSharedPointer< const PaceInfo > &pPaceInfo, QSharedPointer< CardConnectionWorker > pCardConnectionWorker)
Factory method to create an instance of KeyAgreement.
Definition: KeyAgreement.cpp:56
const QByteArray & getCarCurr() const
Subsequent to the key agreement a certificate authority reference (CAR) may be determined.
Definition: KeyAgreement.cpp:239
Definition: KeyAgreement.h:30
CardReturnCode mReturnCode
Definition: KeyAgreement.h:32
const QByteArray & getEncryptionKey() const
Subsequent to the key agreement an encryption key is determined.
Definition: KeyAgreement.cpp:233
CardResult transmitGAMappingData(const QByteArray &pMappingData)
Transmit the General Authenticate (Mapping Data) command to the card.
Definition: KeyAgreement.cpp:207
virtual ~KeyAgreement()
Definition: KeyAgreement.cpp:83