当前位置: 首页>>代码示例>>C++>>正文


C++ upse::Buffer类代码示例

本文整理汇总了C++中upse::Buffer的典型用法代码示例。如果您正苦于以下问题:C++ Buffer类的具体用法?C++ Buffer怎么用?C++ Buffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Buffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: aesCMAC

ae_error_t CertificateProvisioningProtocol::aesCMAC(const upse::Buffer& key, const upse::Buffer& message, upse::Buffer& cmac)
{
    ae_error_t status = AE_FAILURE;

    do
    {
        if (key.getSize() != sizeof(sgx_aes_gcm_128bit_key_t))
            break;

        status = cmac.Alloc(sizeof(sgx_cmac_128bit_tag_t));
        if (AE_FAILED(status))
            break;

        uint8_t* pCMAC;
        status = upse::BufferWriter(cmac).reserve(cmac.getSize(), &pCMAC);
        if (AE_FAILED(status))
            break;

        sgx_status_t sgx_status;
        sgx_status = sgx_rijndael128_cmac_msg(reinterpret_cast<const sgx_aes_gcm_128bit_key_t *>(key.getData()),
            message.getData(), message.getSize(), reinterpret_cast<sgx_cmac_128bit_tag_t *>(pCMAC));
        if (SGX_SUCCESS != sgx_status)
        {
            status = AE_FAILURE;
            break;
        }

        status = AE_SUCCESS;

    } while (0);

    return status;
}
开发者ID:01org,项目名称:linux-sgx,代码行数:33,代码来源:pse_crypto_helper.cpp

示例2: sizeof

ae_error_t CertificateProvisioningProtocol::msg3_create_header(const upse::Buffer& transactionID, uint32_t nonceSize, uint32_t quoteSize, uint32_t epidSigSize, uint32_t csrSize, provision_request_header_t& header)
{
    ae_error_t status = AESM_PSE_PR_INTERNAL_ERROR;

    do
    {
        uint32_t seq2_0_tlv_block_cipher_text_size = BLOCK_CIPHER_TEXT_TLV_SIZE(quoteSize + epidSigSize + csrSize);
        uint32_t seq3_0_tlv_nonce_size = nonceSize;
        uint32_t seq4_0_tlv_mac_size = MAC_TLV_SIZE(MAC_SIZE);

        header.protocol = PSE_PROVISIONING;
        header.version = TLV_VERSION_1;
        header.type = static_cast<uint8_t>(TYPE_PSE_MSG3);

        if (XID_SIZE != transactionID.getSize())
            break;

        if (memcpy_s(header.xid, sizeof(header.xid), transactionID.getData(), transactionID.getSize()) != 0)
            break;

        uint32_t totalSize = seq2_0_tlv_block_cipher_text_size + seq3_0_tlv_nonce_size + seq4_0_tlv_mac_size;

        uint32_t serializedSize = _htonl(totalSize);
        se_static_assert(sizeof(serializedSize) == sizeof(header.size));

        if (memcpy_s(header.size, sizeof(header.size), &serializedSize, sizeof(serializedSize)) != 0)
            break;

        status = AE_SUCCESS;
    } while (0);

    return status;
}
开发者ID:01org,项目名称:linux-sgx,代码行数:33,代码来源:pse_provisioning_msg3.cpp

示例3: while

ae_error_t CertificateProvisioningProtocol::msg3_seq3_2_create_quote_signature_tlv(const upse::Buffer& quote, TLVsMsg& seq3_2_tlv_quote_signature)
{
    ae_error_t status = AESM_PSE_PR_INTERNAL_ERROR;
    tlv_status_t tlv_status;

    do
    {
	    if (sizeof(sgx_quote_t) > quote.getSize())
            break;

	    const sgx_quote_t* pQuote = (const sgx_quote_t*)quote.getData();

	    /* the QUOTE SIGNATURE TLV doesn't include Quote.signature_len */
        uint32_t SigLen = pQuote->signature_len;
  
        if (sizeof(sgx_quote_t) + SigLen > quote.getSize())
            break;

        const uint8_t *pSig = pQuote->signature;

        tlv_status = seq3_2_tlv_quote_signature.add_quote_signature(pSig, SigLen);
		status = tlv_error_2_pve_error(tlv_status);
        if (AE_FAILED(status))
            break;

        status = AE_SUCCESS;

    } while (0);

    return status;
}
开发者ID:01org,项目名称:linux-sgx,代码行数:31,代码来源:pse_provisioning_msg3.cpp

示例4: aesGCMDecrypt

ae_error_t CertificateProvisioningProtocol::aesGCMDecrypt(const upse::Buffer& iv, const upse::Buffer& key, const upse::Buffer& cipherText,
                            const upse::Buffer& aad, const upse::Buffer& mac, upse::Buffer& plainText)
{
    ae_error_t status = AE_FAILURE;

    do
    {
        if (key.getSize() != sizeof(sgx_aes_gcm_128bit_key_t))
            break;

        status = plainText.Alloc(cipherText.getSize());
        if (AE_FAILED(status))
            break;

        uint8_t* pPlainText = NULL;
        status = upse::BufferWriter(plainText).reserve(plainText.getSize(), &pPlainText);
        if (AE_FAILED(status))
            break;

        sgx_status_t sgx_status;
        sgx_status = sgx_rijndael128GCM_decrypt(reinterpret_cast<const sgx_aes_gcm_128bit_key_t *>(key.getData()),
                        cipherText.getData(), cipherText.getSize(), pPlainText, iv.getData(), IV_SIZE, aad.getData(), aad.getSize(),
                        reinterpret_cast<const sgx_aes_gcm_128bit_tag_t *>(mac.getData()));
        if (SGX_SUCCESS != sgx_status)
        {
            AESM_LOG_ERROR("%s", g_event_string_table[SGX_EVENT_PSE_CERT_PROV_INTEGRITY_ERROR]);
            status = AE_FAILURE;
            break;
        }

        status = AE_SUCCESS;
    } while (0);

    return status;
}
开发者ID:01org,项目名称:linux-sgx,代码行数:35,代码来源:pse_crypto_helper.cpp

示例5: AESM_DBG_INFO

ae_error_t CertificateProvisioningProtocol::sendReceive(const upse::Buffer& sendSerialized, upse::Buffer& recvSerialized)
{
    ae_error_t status = AE_FAILURE;

    uint8_t* recv = NULL;
    uint32_t recv_size = 0;

    do
    {
        AESM_DBG_INFO("start send msg");
	    status = AESMNetworkEncoding::aesm_send_recv_msg_encoding(m_url.c_str(), const_cast<uint8_t *>(sendSerialized.getData()), sendSerialized.getSize(), recv, recv_size);
	    if (AE_FAILED(status))
            break;
        AESM_DBG_INFO("msg received with size %u", recv_size);

        status = recvSerialized.Alloc(recv_size);
        if (AE_FAILED(status))
            break;
        AESM_DBG_INFO("buffer alloced");
        status = upse::BufferWriter(recvSerialized).writeRaw(recv, recv_size);
        if (AE_FAILED(status))
            break;
        AESM_DBG_INFO("buffer written");
        status = AE_SUCCESS;

    } while (0);

    if (NULL != recv)
        AESMNetworkEncoding::aesm_free_response_msg(recv);

    return status;
}
开发者ID:axelexic,项目名称:linux-sgx,代码行数:32,代码来源:CertificateProvisioningProtocol.cpp

示例6: get_intel_pek_cipher_text_size

ae_error_t CertificateProvisioningProtocol::encryptRSA_OAEP_SHA256(const public_key_t& publicKey, upse::BufferReader& plainTextReader, upse::Buffer& cipherText)
{
    ae_error_t status = AE_FAILURE;

    void* rsa_pub_key = NULL;
    size_t dst_len = 0;

    do
    {
        if(SGX_SUCCESS != get_intel_rsa_pub_key(publicKey, &rsa_pub_key))
            break;
	
        int plainTextSize = plainTextReader.getRemainingSize();
        const uint8_t* pPlainText = NULL;
        if (AE_FAILED(plainTextReader.readRaw(&pPlainText)))
            break;

        int cipherTextSize = get_intel_pek_cipher_text_size();
        if (AE_FAILED(cipherText.Alloc(cipherTextSize)))
            break;

        upse::BufferWriter cipherTextWriter(cipherText);
        uint8_t* pCipherText;
        if (AE_FAILED(cipherTextWriter.reserve(cipherText.getSize(), &pCipherText)))
            break;

        // Check the encrypt output length
        sgx_status_t res = sgx_rsa_pub_encrypt_sha256(rsa_pub_key, NULL, &dst_len, pPlainText, plainTextSize);
        if(res != SGX_SUCCESS || dst_len != cipherText.getSize())
            break;

        res = sgx_rsa_pub_encrypt_sha256(rsa_pub_key, pCipherText, &dst_len, pPlainText, plainTextSize);
        if(res != SGX_SUCCESS)
            break;
        
        status = AE_SUCCESS;

    } while (0);

    free_intel_rsa_pub_key(rsa_pub_key);

    return status;
}
开发者ID:01org,项目名称:linux-sgx,代码行数:43,代码来源:pse_crypto_helper.cpp

示例7: aesGCMEncrypt

ae_error_t CertificateProvisioningProtocol::aesGCMEncrypt(const upse::Buffer& iv, const upse::Buffer& key, const upse::Buffer& plainText,
                            const upse::Buffer& aad, upse::Buffer& encryptedText, upse::Buffer& mac)
{
    ae_error_t status = AE_FAILURE;

    do
    {
        if (key.getSize() != sizeof(sgx_aes_gcm_128bit_key_t))
            break;

        status = encryptedText.Alloc(plainText.getSize());
        if (AE_FAILED(status))
            break;

        uint8_t* pEncryptedText;
        status = upse::BufferWriter(encryptedText).reserve(encryptedText.getSize(), &pEncryptedText);
        if (AE_FAILED(status))
            break;

        status = mac.Alloc(sizeof(sgx_aes_gcm_128bit_tag_t));
        if (AE_FAILED(status))
            break;

        uint8_t* pMAC;
        status = upse::BufferWriter(mac).reserve(mac.getSize(), &pMAC);
        if (AE_FAILED(status))
            break;

        sgx_status_t sgx_status;
        sgx_status = sgx_rijndael128GCM_encrypt(reinterpret_cast<const sgx_aes_gcm_128bit_key_t *>(key.getData()),
                        plainText.getData(), plainText.getSize(), pEncryptedText, iv.getData(), IV_SIZE, aad.getData(), aad.getSize(),
                        reinterpret_cast<sgx_aes_gcm_128bit_tag_t *>(pMAC));
        if (SGX_SUCCESS != sgx_status)
        {
            status = AE_FAILURE;
            break;
        }

        status = AE_SUCCESS;
    } while (0);

    return status;
}
开发者ID:01org,项目名称:linux-sgx,代码行数:43,代码来源:pse_crypto_helper.cpp

示例8: Write

ae_error_t upsePersistentStorage::Write(aesm_data_id_t data_id, upse::Buffer& data)
{
    ae_error_t status = AESM_PSE_PR_PERSISTENT_STORAGE_WRITE_ERROR;

    do
    {
        if (AE_FAILED(aesm_write_data(FT_PERSISTENT_STORAGE, data_id, data.getData(), data.getSize())))
            break;

        status = AE_SUCCESS;

    } while (0);

    return status;
}
开发者ID:daveti,项目名称:linux-sgx,代码行数:15,代码来源:helper.cpp

示例9: bw

ae_error_t CertificateProvisioningProtocol::get_random_value(uint32_t size, upse::Buffer& randomValue)
{
    ae_error_t status = AE_FAILURE;

    do
    {
        status = randomValue.Alloc(size);
        if (AE_FAILED(status))
            break;

        uint8_t* p;
        upse::BufferWriter bw(randomValue);
        status = bw.reserve(size, &p);
        if (AE_FAILED(status))
            break;

        status = aesm_read_rand(p, size);

    } while (0);

    return status;
}
开发者ID:01org,项目名称:linux-sgx,代码行数:22,代码来源:pse_crypto_helper.cpp

示例10: aesm_query_data_size

ae_error_t upsePersistentStorage::Read(aesm_data_id_t data_id, upse::Buffer& data)
{
    ae_error_t status = AESM_PSE_PR_PERSISTENT_STORAGE_READ_ERROR;

    uint8_t* tempData = NULL;

    do {
        ae_error_t readError;
        uint32_t sizeInout;
        readError = aesm_query_data_size(FT_PERSISTENT_STORAGE, data_id, &sizeInout);
        if ((readError != AE_SUCCESS) || (sizeInout == 0))
        {
            break;
        }
        tempData = (uint8_t*) malloc(sizeInout);
        if (tempData == NULL)
        {
            break;
        }
        readError = aesm_read_data(FT_PERSISTENT_STORAGE, data_id, tempData, &sizeInout);
        if (AE_SUCCESS != readError)
        {
            break;
        }
        data.Alloc(sizeInout);
        upse::BufferWriter bw(data);
        bw.writeRaw(tempData, sizeInout);

        status = AE_SUCCESS;
    } while (0);

    if (NULL != tempData)
        free(tempData);

    return status;
}
开发者ID:daveti,项目名称:linux-sgx,代码行数:36,代码来源:helper.cpp

示例11: memset

//*********************************************************************
// Call quoting enclave to convert report to name-based quote
//*********************************************************************
static ae_error_t do_get_quote
    (
    /*in */ upse::Buffer& reportBuffer,
    /*in */ upse::Buffer& sigRLBuffer,
    /*out*/ upse::Buffer& quoteBuffer
    )
{
    // Call QE to convert REPORT to a name-based QUOTE
    ae_error_t status = AE_FAILURE;
    ae_error_t tmp_status = AE_SUCCESS;

    do
    {
#ifndef FAKE_QUOTE
        uint32_t nQuote;                                 // in     - Quote buffer size

        sgx_report_t enclaveReport;                      // in
        sgx_quote_sign_type_t quote_type;                // in
        sgx_spid_t spid = {{0}};                           // in
        uint8_t* pSigRL = NULL;                          // in
        uint32_t nSigRL = 0;                               // in     - Sig RL buffer size

        memset(&enclaveReport, 0, sizeof(enclaveReport));

        nSigRL = sigRLBuffer.getSize();

        if (0 != nSigRL)
            pSigRL = const_cast<uint8_t*>(sigRLBuffer.getData());

        if (SGX_SUCCESS != sgx_calc_quote_size(pSigRL, nSigRL, &nQuote))
            break;

        tmp_status = quoteBuffer.Alloc(nQuote);
        if (AE_FAILED(tmp_status))
            break;
        upse::BufferWriter bwQuote(quoteBuffer);
        uint8_t* pQuote;
        tmp_status = bwQuote.reserve(nQuote, &pQuote);      // out
        if (AE_FAILED(tmp_status))
            break;

        quote_type = SGX_UNLINKABLE_SIGNATURE; // or SGX_LINKABLE_SIGNATURE

        // LSB16(SHA256("SGX PSE PROVISIONING SERVER"))
        // const char* SPID_VALUE = "SGX PSE PROVISIONING SERVER";
        // sgx_sha256_hash_t spid_hash;
        // sgx_sha256_msg((const uint8_t*)SPID_VALUE, strlen(SPID_VALUE), &spid_hash);
        // memcpy_s(spid.id, sizeof(spid.id), &spid_hash[0], 16);
        static uint8_t spid_hash[] = { 0x32, 0x81, 0xE5, 0x9E, 0xB1, 0x23, 0xFA, 0xCD,
            0x56, 0xDB, 0x62, 0x1E, 0x3B, 0x37, 0xFB, 0xE2 };
        memcpy_s(spid.id, sizeof(spid.id), spid_hash, sizeof(spid_hash));

        if (reportBuffer.getSize() != sizeof(enclaveReport))
            break;

        memcpy_s(&enclaveReport, reportBuffer.getSize(), reportBuffer.getData(), reportBuffer.getSize());
        aesm_error_t result;
        result = AESMLogic::get_quote(
            (uint8_t*)&enclaveReport, sizeof(enclaveReport),
            quote_type,
            (uint8_t*)&spid, sizeof(spid),
            NULL, 0,
            pSigRL, nSigRL,
            NULL, 0,
            (uint8_t*)pQuote, nQuote);
        if (result == AESM_BUSY)
        {
            //EPID_PROVISION triggered, make sure previous EPID provision has finished
            ae_error_t temp_ret = wait_pve_thread();
            BREAK_IF_TRUE(AE_SUCCESS != temp_ret , status, PSE_PR_PCH_EPID_UNKNOWN_ERROR);
            //redo get_quote
            result = AESMLogic::get_quote(
                (uint8_t*)&enclaveReport, sizeof(enclaveReport),
                quote_type,
                (uint8_t*)&spid, sizeof(spid),
                NULL, 0,
                pSigRL, nSigRL,
                NULL, 0,
                (uint8_t*)pQuote, nQuote);
        }
        BREAK_IF_TRUE(AESM_OUT_OF_EPC == result, status, AESM_AE_OUT_OF_EPC);
        BREAK_IF_TRUE(AESM_SUCCESS != result, status, AESM_PSE_PR_GET_QUOTE_ERROR);
#else
        const uint16_t SIGNATURE_LENGTH = 32;

        tmp_status = quoteBuffer.Alloc(sizeof(sgx_quote_t) + SIGNATURE_LENGTH);
        if (AE_FAILED(tmp_status))
            break;

        sgx_quote_t* pQuote;
        tmp_status = upse::BufferWriter(quoteBuffer).reserve(quoteBuffer.getSize(), (uint8_t**)&pQuote);
        if (AE_FAILED(tmp_status))
            break;

        uint16_t CPUSVN = 1;
        pQuote->version = 1;
        memcpy_s(pQuote->epid_group_id, sizeof(pQuote->epid_group_id), &GID_TO_USE, sizeof(GID_TO_USE));
//.........这里部分代码省略.........
开发者ID:hyjiang,项目名称:linux-sgx,代码行数:101,代码来源:u_certificate_provisioning.cpp

示例12: BREAK_IF_TRUE

//*********************************************************************
// Call quoting enclave to get target info
//*********************************************************************
static ae_error_t do_quote_initialization
    (
    /*out */ upse::Buffer& targetInfo,
    /*out */ GroupId* pGID
    )
{
    ae_error_t status = AE_FAILURE;


    do
    {
        BREAK_IF_TRUE( (NULL == pGID), status, PSE_PR_BAD_POINTER_ERROR);

#ifndef FAKE_QUOTE
        if (AE_FAILED(targetInfo.Alloc(sizeof(sgx_target_info_t))))
            break;
        upse::BufferWriter bwTargetInfo(targetInfo);
        uint8_t* p;
        status = bwTargetInfo.reserve(sizeof(sgx_target_info_t), &p);
        if (AE_FAILED(status))
            break;
        sgx_target_info_t* pTargetInfo = (sgx_target_info_t*)p;

        aesm_error_t result;
        SGX_DBGPRINT_PRINT_ANSI_STRING("aesmLogic.init_quote?");

        result = AESMLogic::init_quote(
            (uint8_t*)pTargetInfo, sizeof(sgx_target_info_t),
            (uint8_t*)pGID, sizeof(*pGID));
        if (result == AESM_BUSY)
        {
            //EPID_PROVISION triggered, make sure previous EPID provision has finished
            ae_error_t temp_ret = wait_pve_thread();
            BREAK_IF_TRUE(AE_SUCCESS != temp_ret , status, PSE_PR_PCH_EPID_UNKNOWN_ERROR);
            //redo init_quote
            result = AESMLogic::init_quote(
                (uint8_t*)pTargetInfo, sizeof(sgx_target_info_t),
                (uint8_t*)pGID, sizeof(*pGID));
        }
        BREAK_IF_TRUE(AESM_UPDATE_AVAILABLE == result, status, PSW_UPDATE_REQUIRED);
        BREAK_IF_TRUE(AESM_OUT_OF_EPC == result, status, AESM_AE_OUT_OF_EPC);
        BREAK_IF_TRUE(AESM_SUCCESS != result, status, AESM_PSE_PR_INIT_QUOTE_ERROR);
#else

        //NRG: m_tmpGID = 0;
        upse::Buffer m_tmpGID;
        if (AE_FAILED(m_tmpGID.Alloc(GID_TO_USE, sizeof(GID_TO_USE))))
            break;

        //      m_tmpGID = 1244;
        //      upse::BufferWriter(m_tmpGID).writeRaw(GID_TO_USE, sizeof(GID_TO_USE));
        SigmaData::SetGID(m_tmpGID);
        memcpy_s(pGID, sizeof(GroupId), m_tmpGID.getData(), sizeof(GroupId));
        if (AE_FAILED(targetInfo.Alloc(sizeof(sgx_target_info_t))))
            break;
#endif

        SGX_DBGPRINT_PRINT_ANSI_STRING("aesmLogic.init_quote success");
        status = AE_SUCCESS;

    } while (0);

    SGX_DBGPRINT_PRINT_FUNCTION_AND_RETURNVAL(__FUNCTION__, status);

    return status;
}
开发者ID:hyjiang,项目名称:linux-sgx,代码行数:69,代码来源:u_certificate_provisioning.cpp

示例13: SGX_DBGPRINT_PRINT_STRING_LTP

ae_error_t Helper::PrepareCertificateChainVLR( /*in*/ std::list<upse::Buffer>& certChain, /*out*/ upse::Buffer& certChainVLR)
{
    ae_error_t status = AESM_PSE_PR_LOAD_VERIFIER_CERT_ERROR;

    try
    {
        do
        {
            int nPaddedBytes = 0;
            int nCertChain = 0;

#if !defined(LEAFTOROOT)
#error LEAFTOROOT not #defined
#endif

            //
            // spec'd behavior is to receive certs in leaft to root order
            // then, it only makes sense to store them leaf to root
            // but sigma wants them root to leaf
            // we'll leave the #if here since, cumulatively, it shows how to traverse
            // in both directions
            //
#if !LEAFTOROOT
            SGX_DBGPRINT_PRINT_STRING_LTP("leaf cert to root cert direction, padding");

            std::list<upse::Buffer>::reverse_iterator it;
            for (it = certChain.rbegin(); it != certChain.rend(); ++it)
            {
                int nSize = (*it).getSize();
                nPaddedBytes += REQUIRED_PADDING_DWORD_ALIGNMENT(nSize);
                nCertChain += nSize;
            }
#else
            SGX_DBGPRINT_PRINT_STRING_LTP("root cert to leaf cert direction, padding");
            std::list<upse::Buffer>::iterator it;
            for (it = certChain.begin(); it != certChain.end(); ++it)
            {
                int nSize = (*it).getSize();
                nPaddedBytes += REQUIRED_PADDING_DWORD_ALIGNMENT(nSize);
                nCertChain += nSize;
            }
#endif

            SGX_DBGPRINT_PRINT_STRING_LTP("less cert padding");
            //NRG: This doesn't work, but should. It should replace the previous
            nPaddedBytes = REQUIRED_PADDING_DWORD_ALIGNMENT(nCertChain);

            if(UINT16_MAX - ((int)sizeof(SIGMA_VLR_HEADER) + nPaddedBytes) < nCertChain){
                break;
            }
            int nLength = static_cast<int>(sizeof(SIGMA_VLR_HEADER)) + nPaddedBytes + nCertChain;

            certChainVLR.Alloc(nLength);

            upse::BufferWriter bw(certChainVLR);
            VERIFIER_CERT_CHAIN_VLR* pVLR;
            uint8_t* p;
            if (AE_FAILED(bw.reserve(nLength, &p)))
                break;
            pVLR = (VERIFIER_CERT_CHAIN_VLR*)p;

            pVLR->VlrHeader.ID = VERIFIER_CERTIFICATE_CHAIN_VLR_ID;
            pVLR->VlrHeader.PaddedBytes = (UINT8)nPaddedBytes;
            pVLR->VlrHeader.Length = (UINT16)nLength;

            memset(pVLR->VerifierCertificateChain, 0, nPaddedBytes + nCertChain);
            int ndx = 0;

            //
            // see above 
            //
#if (!LEAFTOROOT)
            SGX_DBGPRINT_PRINT_STRING_LTP("leaf cert to root cert direction");
            for (it = certChain.rbegin(); it != certChain.rend(); ++it)
            {
                memcpy_s(pVLR->VerifierCertificateChain + ndx, (*it).getSize(), (*it).getData(), (*it).getSize());
                ndx += (*it).getSize();
            }
#else
            SGX_DBGPRINT_PRINT_STRING_LTP("root cert to leaf cert direction");
            for (it = certChain.begin(); it != certChain.end(); ++it)
            {
                memcpy_s(pVLR->VerifierCertificateChain + ndx, (*it).getSize(), (*it).getData(), (*it).getSize());
                ndx += (*it).getSize();
            }
#endif

            status = AE_SUCCESS;

        } while (0);
    } catch(...)
    {
    }

    SGX_DBGPRINT_PRINT_FUNCTION_AND_RETURNVAL(__FUNCTION__, status);
    return status;
}
开发者ID:daveti,项目名称:linux-sgx,代码行数:97,代码来源:helper.cpp

示例14: BREAK_IF_TRUE

ae_error_t pse_pr_interface_psda::ExchangeS2AndS3(/*in*/  const uint8_t* pse_instance_id,
                                                  /*in */ const upse::Buffer& s2, 
                                                  /*out*/ upse::Buffer& s3)
{
    ae_error_t status = AE_FAILURE;

    lt_session_m7_t* pLt_session_m7 = NULL;
    lt_session_m8_t* pLt_session_m8 = NULL;

    uint32_t lt_session_m7_size = static_cast<uint32_t>(sizeof(lt_session_m7_t) + s2.getSize());
    uint32_t lt_session_m8_size = 10000;

    do
    {
        pLt_session_m7 = (lt_session_m7_t*)malloc(lt_session_m7_size);
        BREAK_IF_TRUE( (NULL == pLt_session_m7), status, AESM_PSE_PR_INSUFFICIENT_MEMORY_ERROR);

        pLt_session_m8 = (lt_session_m8_t*)malloc(lt_session_m8_size);
        BREAK_IF_TRUE( (NULL == pLt_session_m8), status, AESM_PSE_PR_INSUFFICIENT_MEMORY_ERROR);
        memset(pLt_session_m8, 0, lt_session_m8_size);

        memcpy_s(pLt_session_m7->msg_hdr.pse_instance_id, SW_INSTANCE_ID_SIZE, pse_instance_id, SW_INSTANCE_ID_SIZE);
        pLt_session_m7->msg_hdr.msg_type = _htonl(PSDA_MSG_TYPE_LT_M7);
        pLt_session_m7->msg_hdr.msg_len  = _htonl(s2.getSize());

        memcpy_s(&pLt_session_m7->msg7, s2.getSize(), s2.getData(), s2.getSize());

        commBuf_s3.TxBuf->buffer = pLt_session_m7;
        commBuf_s3.TxBuf->length = lt_session_m7_size;
        commBuf_s3.RxBuf->buffer = pLt_session_m8;
        commBuf_s3.RxBuf->length = lt_session_m8_size;

        status = PSDAService::instance().send_and_recv( 
            PSDA_COMMAND_LT, 
            &commBuf_s3, 
            &responseCode,
            NO_RETRY_ON_SESSION_LOSS);
        AESM_DBG_INFO("JHI_SendAndRecv2 response_code is %d", responseCode);

        if (status != AE_SUCCESS) {
            AESM_LOG_ERROR("%s", g_event_string_table[SGX_EVENT_DAL_COMM_FAILURE]);
            break;
        }
        if (PSDA_SUCCESS != responseCode) {
            AESM_LOG_ERROR("%s", g_event_string_table[SGX_EVENT_DAL_SIGMA_ERROR]);
            BREAK_IF_TRUE( (responseCode == PSDA_INTEGRITY_ERROR), status, AESM_PSDA_LT_SESSION_INTEGRITY_ERROR);
            BREAK_IF_TRUE( (responseCode == PSDA_INTERNAL_ERROR) , status, AESM_PSDA_INTERNAL_ERROR);
            BREAK_IF_TRUE( (responseCode == PSDA_PLATFORM_KEYS_REVOKED) , status, AESM_PSDA_PLATFORM_KEYS_REVOKED);
            BREAK_IF_TRUE( (responseCode == PSDA_PERSISTENT_DATA_WRITE_THROTTLED) , status, AESM_PSDA_WRITE_THROTTLED);
            BREAK_IF_TRUE( (responseCode != PSDA_SUCCESS)        , status, AESM_PSDA_INTERNAL_ERROR);
        }

        uint32_t msg_len  = _ntohl(pLt_session_m8->msg_hdr.msg_len);
        uint32_t msg_type = _ntohl(pLt_session_m8->msg_hdr.msg_type);

        if (msg_type != PSDA_MSG_TYPE_LT_M8)
        {
            status = AE_FAILURE;
            break;
        }

        if (commBuf_s3.RxBuf->length <= sizeof(pLt_session_m8->msg_hdr) 
        || msg_len != commBuf_s3.RxBuf->length - sizeof(pLt_session_m8->msg_hdr))
        {
            AESM_DBG_INFO("Received invalid S3 message from PSDA!");
            status = AE_FAILURE;
            break;
        }

        status = s3.Alloc(msg_len);
        BREAK_IF_FAILED(status);
        upse::BufferWriter bw(s3);
        status = bw.writeRaw((UINT8*)&pLt_session_m8->msg8, msg_len);
        BREAK_IF_FAILED(status);

        status = AE_SUCCESS;

    } while (0);

    if (NULL != pLt_session_m7)
        free(pLt_session_m7);
    if (NULL != pLt_session_m8)
        free(pLt_session_m8);

    return status;
}
开发者ID:axelexic,项目名称:linux-sgx,代码行数:86,代码来源:interface_psda.cpp

示例15: memcpy_s

ae_error_t pse_pr_interface_psda::GetS1(/*in*/const uint8_t* pse_instance_id, /*out*/ upse::Buffer& s1)
{
    ae_error_t status = AE_FAILURE;

    lt_session_m1_t lt_session_m1;
    lt_session_m2_t lt_session_m2;

    do
    {
        // endian-ness doesn't matter for these two; they're 0
        memcpy_s(lt_session_m1.msg_hdr.pse_instance_id, SW_INSTANCE_ID_SIZE, pse_instance_id, SW_INSTANCE_ID_SIZE);
        lt_session_m1.msg_hdr.msg_type = PSDA_MSG_TYPE_LT_M1;
        lt_session_m1.msg_hdr.msg_len = 0;

        memset(&lt_session_m2, 0, sizeof(lt_session_m2));
        commBuf_s1.TxBuf->buffer = &lt_session_m1;
        commBuf_s1.TxBuf->length = sizeof(lt_session_m1_t);
        commBuf_s1.RxBuf->buffer = &lt_session_m2;
        commBuf_s1.RxBuf->length = sizeof(lt_session_m2_t);

        status = PSDAService::instance().send_and_recv( 
            PSDA_COMMAND_LT, 
            &commBuf_s1, 
            &responseCode,
            AUTO_RETRY_ON_SESSION_LOSS);
        AESM_DBG_INFO("JHI_SendAndRecv2 response_code is %d", responseCode);

        if (status != AE_SUCCESS) {
            AESM_LOG_ERROR("%s", g_event_string_table[SGX_EVENT_DAL_COMM_FAILURE]);
            break;
        }
        if (PSDA_SUCCESS != responseCode) {
            AESM_LOG_ERROR("%s", g_event_string_table[SGX_EVENT_DAL_SIGMA_ERROR]);
            BREAK_IF_TRUE( (responseCode == PSDA_NOT_PROVISIONED), status, AESM_PSDA_NOT_PROVISONED_ERROR);
            BREAK_IF_TRUE( (responseCode == PSDA_PROTOCOL_NOT_SUPPORTED), status, AESM_PSDA_PROTOCOL_NOT_SUPPORTED);
            BREAK_IF_TRUE( (responseCode == PSDA_INTERNAL_ERROR) , status, AESM_PSDA_INTERNAL_ERROR);
            BREAK_IF_TRUE( (responseCode == PSDA_PERSISTENT_DATA_WRITE_THROTTLED) , status, AESM_PSDA_WRITE_THROTTLED);
        }

        uint32_t msg_len  = _ntohl(lt_session_m2.msg_hdr.msg_len);
        uint32_t msg_type = _ntohl(lt_session_m2.msg_hdr.msg_type);

        if (responseCode != PSDA_SUCCESS || msg_type != PSDA_MSG_TYPE_LT_M2 || msg_len != sizeof(pse_cse_lt_msg2_t))
        {
            status = AE_FAILURE;
            break;
        }

        if (commBuf_s1.RxBuf->length <= sizeof(lt_session_m2.msg_hdr)
            || msg_len != commBuf_s1.RxBuf->length - sizeof(lt_session_m2.msg_hdr))
        {
            AESM_DBG_INFO("Received invalid S1 message from PSDA!");
            status = AE_FAILURE;
            break;
        }

        status = s1.Alloc(msg_len);
        BREAK_IF_FAILED(status);

        upse::BufferWriter bw(s1);
        status = bw.writeRaw((UINT8*)&lt_session_m2.msg2, msg_len);
        BREAK_IF_FAILED(status);

    } while (0);

    return status;
}
开发者ID:axelexic,项目名称:linux-sgx,代码行数:67,代码来源:interface_psda.cpp


注:本文中的upse::Buffer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。