1 #pragma once 2 3 #include "file_io_by_type.hpp" 4 5 #include <tuple> 6 7 namespace pldm 8 { 9 namespace responder 10 { 11 using Fd = int; 12 using RemainingSize = uint64_t; 13 using CertDetails = std::tuple<Fd, RemainingSize>; 14 using CertType = uint16_t; 15 using CertMap = std::map<CertType, CertDetails>; 16 17 /** @class CertHandler 18 * 19 * @brief Inherits and implements FileHandler. This class is used 20 * to read/write certificates and certificate signing requests 21 */ 22 class CertHandler : public FileHandler 23 { 24 public: 25 /** @brief CertHandler constructor 26 */ CertHandler(uint32_t fileHandle,uint16_t fileType)27 CertHandler(uint32_t fileHandle, uint16_t fileType) : 28 FileHandler(fileHandle), certType(fileType) 29 {} 30 31 virtual int writeFromMemory(uint32_t offset, uint32_t length, 32 uint64_t address, 33 oem_platform::Handler* /*oemPlatformHandler*/); 34 virtual int readIntoMemory(uint32_t offset, uint32_t length, 35 uint64_t address, 36 oem_platform::Handler* /*oemPlatformHandler*/); 37 virtual int read(uint32_t offset, uint32_t& length, Response& response, 38 oem_platform::Handler* /*oemPlatformHandler*/); 39 40 virtual int write(const char* buffer, uint32_t offset, uint32_t& length, 41 oem_platform::Handler* /*oemPlatformHandler*/); 42 fileAck(uint8_t)43 virtual int fileAck(uint8_t /*fileStatus*/) 44 { 45 return PLDM_ERROR_UNSUPPORTED_PLDM_CMD; 46 } 47 48 virtual int newFileAvailable(uint64_t length); 49 50 virtual int fileAckWithMetaData( 51 uint8_t /*fileStatus*/, uint32_t /*metaDataValue1*/, 52 uint32_t /*metaDataValue2*/, uint32_t /*metaDataValue3*/, 53 uint32_t /*metaDataValue4*/); 54 55 virtual int newFileAvailableWithMetaData( 56 uint64_t length, uint32_t metaDataValue1, uint32_t /*metaDataValue2*/, 57 uint32_t /*metaDataValue3*/, uint32_t /*metaDataValue4*/); 58 59 /** @brief CertHandler destructor 60 */ ~CertHandler()61 ~CertHandler() {} 62 63 private: 64 uint16_t certType; //!< type of the certificate 65 static CertMap certMap; //!< holds the fd and remaining read/write size for 66 //!< each certificate 67 enum SignedCertStatus 68 { 69 PLDM_INVALID_CERT_DATA = 0X03 70 }; 71 }; 72 } // namespace responder 73 } // namespace pldm 74