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 12 using Fd = int; 13 using RemainingSize = uint64_t; 14 using CertDetails = std::tuple<Fd, RemainingSize>; 15 using CertType = uint16_t; 16 using CertMap = std::map<CertType, CertDetails>; 17 18 /** @class CertHandler 19 * 20 * @brief Inherits and implements FileHandler. This class is used 21 * to read/write certificates and certificate signing requests 22 */ 23 class CertHandler : public FileHandler 24 { 25 public: 26 /** @brief CertHandler constructor 27 */ 28 CertHandler(uint32_t fileHandle, uint16_t fileType) : 29 FileHandler(fileHandle), certType(fileType) 30 {} 31 32 virtual int writeFromMemory(uint32_t offset, uint32_t length, 33 uint64_t address, 34 oem_platform::Handler* /*oemPlatformHandler*/); 35 virtual int readIntoMemory(uint32_t offset, uint32_t& length, 36 uint64_t address, 37 oem_platform::Handler* /*oemPlatformHandler*/); 38 virtual int read(uint32_t offset, uint32_t& length, Response& response, 39 oem_platform::Handler* /*oemPlatformHandler*/); 40 41 virtual int write(const char* buffer, uint32_t offset, uint32_t& length, 42 oem_platform::Handler* /*oemPlatformHandler*/); 43 44 virtual int fileAck(uint8_t /*fileStatus*/) 45 { 46 return PLDM_ERROR_UNSUPPORTED_PLDM_CMD; 47 } 48 49 virtual int newFileAvailable(uint64_t length); 50 51 /** @brief CertHandler destructor 52 */ 53 ~CertHandler() 54 {} 55 56 private: 57 uint16_t certType; //!< type of the certificate 58 static CertMap certMap; //!< holds the fd and remaining read/write size for 59 //!< each certificate 60 }; 61 } // namespace responder 62 } // namespace pldm 63