1 /*! 2 * \brief Implementation of ChipAuthenticationInfo 3 * 4 * \copyright Copyright (c) 2015-2021 Governikus GmbH & Co. KG, Germany 5 */ 6 7 #pragma once 8 9 10 #include "SecurityInfo.h" 11 12 13 namespace governikus 14 { 15 16 /** 17 * ChipAuthenticationInfo ::= SEQUENCE { 18 * protocol OBJECT IDENTIFIER( id-CA-DH-3DES-CBC-CBC | id-CA-DH-AES-CBC-CMAC-128 | id-CA-DH-AES-CBC-CMAC-192 | 19 * id-CA-DH-AES-CBC-CMAC-256 | id-CA-ECDH-3DES-CBC-CBC | id-CA-ECDH-AES-CBC-CMAC-128 | 20 * id-CA-ECDH-AES-CBC-CMAC-192 | id-CA-ECDH-AES-CBC-CMAC-256), 21 * version INTEGER, -- MUST be 1 for CAv1 or 2 for CAv2 22 * keyId INTEGER OPTIONAL 23 * } 24 * 25 * defined in TR 3110 Part 3 26 */ 27 struct chipauthenticationinfo_st 28 { 29 ASN1_OBJECT* mProtocol; 30 ASN1_INTEGER* mVersion; 31 ASN1_INTEGER* mKeyId; 32 }; DECLARE_ASN1_FUNCTIONS(chipauthenticationinfo_st)33DECLARE_ASN1_FUNCTIONS(chipauthenticationinfo_st) 34 35 36 /* 37 * Wrapper for structure chipauthenticationinfo_st. 38 */ 39 class ChipAuthenticationInfo 40 : public SecurityInfo 41 { 42 friend class QSharedPointer<ChipAuthenticationInfo>; 43 44 const QSharedPointer<const chipauthenticationinfo_st> mDelegate; 45 46 explicit ChipAuthenticationInfo(const QSharedPointer<const chipauthenticationinfo_st>& pDelegate); 47 [[nodiscard]] ASN1_OBJECT* getProtocolObjectIdentifier() const override; 48 static bool acceptsProtocol(const ASN1_OBJECT* pObjectIdentifier); 49 50 public: 51 static QSharedPointer<ChipAuthenticationInfo> decode(const QByteArray& pBytes) 52 { 53 if (const auto& delegate = decodeObject<chipauthenticationinfo_st>(pBytes, false)) 54 { 55 if (ChipAuthenticationInfo::acceptsProtocol(delegate->mProtocol)) 56 { 57 return QSharedPointer<ChipAuthenticationInfo>::create(delegate); 58 } 59 } 60 return QSharedPointer<ChipAuthenticationInfo>(); 61 } 62 63 64 [[nodiscard]] QByteArray getVersion() const; 65 [[nodiscard]] QByteArray getKeyId() const; 66 }; 67 68 69 template<> 70 chipauthenticationinfo_st* decodeAsn1Object<chipauthenticationinfo_st>(chipauthenticationinfo_st** pObject, const unsigned char** pData, long pDataLen); 71 72 73 template<> 74 void freeAsn1Object<chipauthenticationinfo_st>(chipauthenticationinfo_st* pObject); 75 76 77 } // namespace governikus 78