std::vector<uint8_t> cert;
int result = context->connection->get_certificate_chain(cert);
if(result == DCM_ERROR_NONE) {
- if(!(*cert_chain = strdup(reinterpret_cast<const char*>(cert.data()))))
+ *cert_chain = (char*)malloc(sizeof(uint8_t) * cert.size());
+ if(*cert_chain == NULL)
return DCM_ERROR_OUT_OF_MEMORY;
+ memcpy(*cert_chain, cert.data(), cert.size());
*cert_chain_len = cert.size();
}
reinterpret_cast<const dcm_key_context_internal *>(key_ctx);
std::string type = context->connection->key_type();
- if(!(*key_type = strdup(type.c_str())))
+ *key_type = (char*)malloc(sizeof(char) * (type.length() + 1));
+ if(*key_type == NULL)
return DCM_ERROR_OUT_OF_MEMORY;
+ memcpy(*key_type, type.c_str(), type.length() + 1);
return DCM_ERROR_NONE;
}
if(digest.size() > MBEDTLS_MPI_MAX_SIZE)
return DCM_ERROR_INVALID_PARAMETER;
- if(!(*signature = strdup(reinterpret_cast<const char*>(digest.data()))))
+ *signature = (char*)malloc(sizeof(uint8_t) * digest.size());
+ if(*signature == NULL)
return DCM_ERROR_OUT_OF_MEMORY;
+ memcpy(*signature, digest.data(), digest.size());
*signature_len = digest.size();
}