예제 #1
0
파일: ckm_db_tool.cpp 프로젝트: Samsung/ckm
int DbWrapper::unlock()
{
    // no unlock for system db
    if (m_uid < 5000)
        return CKM_API_SUCCESS;

    int retCode;
    RawBuffer ret = m_logic.unlockUserKey(m_uid, m_pw);
    MessageBuffer buff;
    buff.Push(ret);
    buff.Deserialize(retCode);
    return retCode;
}
예제 #2
0
void MuddComm::HandleReadBody(const error_code& error)
{
    if (!error)
    {
        MessageBuffer msgs;
        msgs.Deserialize(_readMsg.data());

        ProcessMessageBuffer(msgs);

        // Reserve space for the header, then read it in
        _readMsg.resize(MessageBuffer::HEADER_LENGTH, '\0');
        async_read(_socket, buffer(_readMsg.data(), MessageBuffer::HEADER_LENGTH), bind(&MuddComm::HandleReadHeader, shared_from_this(), _1));
    }
    else
    {
        _room.Leave(shared_from_this());
    }
}
예제 #3
0
int getCertChain(
    ServiceConnection & serviceConnection,
    LogicCommand command,
    int counter,
    const CertificateShPtr &certificate,
    const T &untrustedVector,
    const T &trustedVector,
    bool useTrustedSystemCertificates,
    CertificateShPtrVector &certificateChainVector)
{
    return try_catch([&] {
        MessageBuffer recv;
        auto send = MessageBuffer::Serialize(static_cast<int>(command),
                                             counter,
                                             certificate->getDER(),
                                             untrustedVector,
                                             trustedVector,
                                             useTrustedSystemCertificates);

        int retCode = serviceConnection.processRequest(send.Pop(), recv);
        if (CKM_API_SUCCESS != retCode)
            return retCode;

        int retCommand;
        int retCounter;
        RawBufferVector rawBufferVector;
        recv.Deserialize(retCommand, retCounter, retCode, rawBufferVector);

        if ((counter != retCounter) || (static_cast<int>(command) != retCommand))
            return CKM_API_ERROR_UNKNOWN;

        if (retCode != CKM_API_SUCCESS)
            return retCode;

        for (auto &e: rawBufferVector) {
            CertificateShPtr cert(new CertificateImpl(e, DataFormat::FORM_DER));
            if (cert->empty())
                return CKM_API_ERROR_BAD_RESPONSE;
            certificateChainVector.push_back(cert);
        }

        return retCode;
    });
}