Lines Matching refs:certChain

41 bool ConstructDataToCertChain(struct HksCertChain **certChain, int certsCount)

43 *certChain = static_cast<struct HksCertChain *>(malloc(sizeof(struct HksCertChain)));
44 if (*certChain == nullptr) {
48 (*certChain)->certsCount = CERT_COUNT;
50 (*certChain)->certs = static_cast<struct HksBlob *>(malloc(sizeof(struct HksBlob) *
51 ((*certChain)->certsCount)));
52 if ((*certChain)->certs == nullptr) {
53 free(*certChain);
54 *certChain = nullptr;
57 for (uint32_t i = 0; i < (*certChain)->certsCount; i++) {
58 (*certChain)->certs[i].size = CERT_DATA_SIZE;
59 (*certChain)->certs[i].data = static_cast<uint8_t *>(malloc((*certChain)->certs[i].size));
60 if ((*certChain)->certs[i].data == nullptr) {
62 FreeCertChain(certChain, i);
69 void FreeCertChain(struct HksCertChain **certChain, const uint32_t pos)
71 if (*certChain == nullptr) {
74 if ((*certChain)->certs == nullptr) {
75 free(*certChain);
76 *certChain = nullptr;
80 if ((*certChain)->certs[j].data != nullptr) {
81 free((*certChain)->certs[j].data);
82 (*certChain)->certs[j].data = nullptr;
85 free((*certChain)->certs);
86 (*certChain)->certs = nullptr;
87 free(*certChain);
88 *certChain = nullptr;
91 bool FormattedCertChain(const HksCertChain *certChain, ByteBuffer &buffer)
93 uint32_t certsCount = certChain->certsCount;
96 totalLen += sizeof(uint32_t) + certChain->certs[i].size;
105 if (!buffer.PutData(pos, CastToUint8Ptr(&certChain->certs[i].size), sizeof(uint32_t))) {
109 if (!buffer.PutData(pos, certChain->certs[i].data, certChain->certs[i].size)) {
112 pos += certChain->certs[i].size;