DescriptorSet::~DescriptorSet()
{
purge();
+
+ delete[] m_fds;
}
void DescriptorSet::purge()
close(it.first);
m_descriptors.clear();
+ m_dirty = true;
}
void DescriptorSet::add(int fd, short events, Callback &&callback)
const Password &pass,
Crypto::GObjShPtr &key)
{
- DB::Row row;
-
try {
// Key is for internal service use. It won't be exported to the client
Crypto::GObjUPtr obj;
const Password &password)
{
int retCode = CKM_API_SUCCESS;
- DB::Row row;
+ RawBuffer rowData;
DataType objDataType;
try {
objDataType);
if (retCode == CKM_API_SUCCESS)
- row.data = std::move(obj->getBinary());
+ rowData = obj->getBinary();
} catch (const Exc::Exception &e) {
retCode = e.error();
} catch (const CKM::Exception &e) {
retCode = CKM_API_ERROR_SERVER_ERROR;
}
- if (CKM_API_SUCCESS != retCode) {
- row.data.clear();
- row.dataType = dataType;
- }
+ if (CKM_API_SUCCESS != retCode)
+ rowData.clear();
auto response = MessageBuffer::Serialize(static_cast<int>(LogicCommand::GET),
commandId,
retCode,
static_cast<int>(objDataType),
- row.data);
+ rowData);
return response.Pop();
}
const LabelNameVector &labelNameVector,
CertificateImplVector &certVector)
{
- DB::Row row;
-
for (auto &i : labelNameVector) {
// certificates can't be protected with custom user password
Crypto::GObjUPtr obj;
CertificateImplVector untrustedCertVector;
CertificateImplVector trustedCertVector;
CertificateImplVector chainVector;
- DB::Row row;
if (cert.empty())
return CKM_API_ERROR_INPUT_PARAM;
const RawBuffer &message,
const CryptoAlgorithm &cryptoAlg)
{
- DB::Row row;
RawBuffer signature;
int retCode = CKM_API_SUCCESS;
int retCode = CKM_API_ERROR_VERIFICATION_FAILED;
try {
- DB::Row row;
-
// try certificate first - looking for a public key.
// in case of PKCS, pub key from certificate will be found first
// rather than private key from the same PKCS.
namespace DB {
struct Row : public Token {
- Row() = default;
+ Row() :
+ Token(),
+ exportable(0),
+ algorithmType(DBCMAlgType::NONE),
+ encryptionScheme(0),
+ dataSize(0) {}
Row(Token token, const Name &pName, const Label &pLabel, int pExportable) :
Token(std::move(token)),
char *KeyProvider::concat_password_user(const char *user, const char *password)
{
- char *concat_user_pass = NULL;
- char *resized_user = NULL;
- int concat_user_pass_len = 0;
-
- if (strlen(user) > MAX_LABEL_SIZE - 1) {
- resized_user = new char[MAX_LABEL_SIZE];
- memcpy(resized_user, user, MAX_LABEL_SIZE - 1);
- resized_user[MAX_LABEL_SIZE - 1] = '\0';
- } else {
- resized_user = new char[strlen(user) + 1];
- memcpy(resized_user, user, strlen(user));
- resized_user[strlen(user)] = '\0';
- }
-
- concat_user_pass_len = strlen(resized_user) + strlen(password) + 1;
- concat_user_pass = new char[concat_user_pass_len];
+ std::string result(password);
+ result += user;
- memset(concat_user_pass, '\0', concat_user_pass_len);
- memcpy(concat_user_pass, password, strlen(password));
- memcpy(&(concat_user_pass[strlen(password)]), resized_user,
- strlen(resized_user));
- concat_user_pass[strlen(resized_user) + strlen(password)] = '\0';
+ if (strlen(user) > MAX_LABEL_SIZE - 1)
+ result.resize(strlen(password) + MAX_LABEL_SIZE - 1);
- delete[] resized_user;
- return concat_user_pass;
+ char *ret = new char[result.size() + 1];
+ memcpy(ret, result.c_str(), result.size() + 1);
+ return ret;
}