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 */ 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 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(uint8_t /*fileStatus*/, 51 uint32_t /*metaDataValue1*/, 52 uint32_t /*metaDataValue2*/, 53 uint32_t /*metaDataValue3*/, 54 uint32_t /*metaDataValue4*/); 55 56 virtual int newFileAvailableWithMetaData(uint64_t length, 57 uint32_t metaDataValue1, 58 uint32_t /*metaDataValue2*/, 59 uint32_t /*metaDataValue3*/, 60 uint32_t /*metaDataValue4*/); 61 62 /** @brief CertHandler destructor 63 */ 64 ~CertHandler() {} 65 66 private: 67 uint16_t certType; //!< type of the certificate 68 static CertMap certMap; //!< holds the fd and remaining read/write size for 69 //!< each certificate 70 enum SignedCertStatus 71 { 72 PLDM_INVALID_CERT_DATA = 0X03 73 }; 74 }; 75 } // namespace responder 76 } // namespace pldm 77