您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CKeyingMaterial函数代码示例

51自学网 2021-06-01 20:01:50
  C++
这篇教程C++ CKeyingMaterial函数代码示例写得很实用,希望能帮到您。

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

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

示例1: TestEncrypt

static void TestEncrypt(const CCrypter& crypt, const std::vector<unsigned char>& vchPlaintextIn, /                       const std::vector<unsigned char>& vchCiphertextCorrect = std::vector<unsigned char>()){    TestEncryptSingle(crypt, CKeyingMaterial(vchPlaintextIn.begin(), vchPlaintextIn.end()), vchCiphertextCorrect);    for(std::vector<unsigned char>::const_iterator i(vchPlaintextIn.begin()); i != vchPlaintextIn.end(); ++i)        TestEncryptSingle(crypt, CKeyingMaterial(i, vchPlaintextIn.end()));}
开发者ID:brianmcmichael,项目名称:bitcoin,代码行数:7,


示例2: assert

bool CHDSeed::Encrypt(CKeyingMaterial& vMasterKeyIn){    assert(sizeof(m_UUID) == WALLET_CRYPTO_IV_SIZE);    encryptedMnemonic.clear();    if (!EncryptSecret(vMasterKeyIn, CKeyingMaterial(unencryptedMnemonic.begin(), unencryptedMnemonic.end()), std::vector<unsigned char>(m_UUID.begin(), m_UUID.end()), encryptedMnemonic))        return false;    SecureUnsignedCharVector masterKeyPrivEncoded(BIP32_EXTKEY_SIZE);    masterKeyPriv.Encode(masterKeyPrivEncoded.data());    if (!EncryptSecret(vMasterKeyIn, CKeyingMaterial(masterKeyPrivEncoded.begin(), masterKeyPrivEncoded.end()), masterKeyPub.pubkey.GetHash(), masterKeyPrivEncrypted))        return false;    SecureUnsignedCharVector purposeKeyPrivEncoded(BIP32_EXTKEY_SIZE);    purposeKeyPriv.Encode(purposeKeyPrivEncoded.data());    if (!EncryptSecret(vMasterKeyIn, CKeyingMaterial(purposeKeyPrivEncoded.begin(), purposeKeyPrivEncoded.end()), purposeKeyPub.pubkey.GetHash(), purposeKeyPrivEncrypted))        return false;    SecureUnsignedCharVector cointypeKeyPrivEncoded(BIP32_EXTKEY_SIZE);    cointypeKeyPriv.Encode(cointypeKeyPrivEncoded.data());    if (!EncryptSecret(vMasterKeyIn, CKeyingMaterial(cointypeKeyPrivEncoded.begin(), cointypeKeyPrivEncoded.end()), cointypeKeyPub.pubkey.GetHash(), cointypeKeyPrivEncrypted))        return false;    encrypted = true;    vMasterKey = vMasterKeyIn;    return true;}
开发者ID:Gulden,项目名称:gulden-official,代码行数:28,


示例3: assert

bool CAccountHD::Encrypt(const CKeyingMaterial& vMasterKeyIn){    assert(sizeof(accountUUID) == WALLET_CRYPTO_IV_SIZE);    if (IsReadOnly())    {        return true;    }    // NB! We don't encrypt the keystores for HD accounts - as they only contain public keys.    // Encrypt account key    SecureUnsignedCharVector accountKeyPrivEncoded(BIP32_EXTKEY_SIZE);    accountKeyPriv.Encode(accountKeyPrivEncoded.data());    if (!EncryptSecret(vMasterKeyIn, CKeyingMaterial(accountKeyPrivEncoded.begin(), accountKeyPrivEncoded.end()), std::vector<unsigned char>(accountUUID.begin(), accountUUID.end()), accountKeyPrivEncrypted))        return false;    // Encrypt primary chain key    SecureUnsignedCharVector primaryChainKeyPrivEncoded(BIP32_EXTKEY_SIZE);    primaryChainKeyPriv.Encode(primaryChainKeyPrivEncoded.data());    if (!EncryptSecret(vMasterKeyIn, CKeyingMaterial(primaryChainKeyPrivEncoded.begin(), primaryChainKeyPrivEncoded.end()), primaryChainKeyPub.pubkey.GetHash(), primaryChainKeyEncrypted))        return false;    // Encrypt change chain key    SecureUnsignedCharVector changeChainKeyPrivEncoded(BIP32_EXTKEY_SIZE);    changeChainKeyPriv.Encode(changeChainKeyPrivEncoded.data());    if (!EncryptSecret(vMasterKeyIn, CKeyingMaterial(changeChainKeyPrivEncoded.begin(), changeChainKeyPrivEncoded.end()), changeChainKeyPub.pubkey.GetHash(), changeChainKeyEncrypted))        return false;    encrypted = true;    return true;}
开发者ID:ALEX196969,项目名称:gulden-official,代码行数:33,


示例4: OldDecrypt

bool OldDecrypt(const std::vector<unsigned char>& vchCiphertext, CKeyingMaterial& vchPlaintext, const unsigned char chKey[32], const unsigned char chIV[16]){    // plaintext will always be equal to or lesser than length of ciphertext    int nLen = vchCiphertext.size();    int nPLen = nLen, nFLen = 0;    vchPlaintext = CKeyingMaterial(nPLen);    EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();    if (!ctx) return false;    bool fOk = true;    EVP_CIPHER_CTX_init(ctx);    if (fOk) fOk = EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, chKey, chIV) != 0;    if (fOk) fOk = EVP_DecryptUpdate(ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen) != 0;    if (fOk) fOk = EVP_DecryptFinal_ex(ctx, (&vchPlaintext[0]) + nPLen, &nFLen) != 0;    EVP_CIPHER_CTX_cleanup(ctx);    EVP_CIPHER_CTX_free(ctx);    if (!fOk) return false;    vchPlaintext.resize(nPLen + nFLen);    return true;}
开发者ID:brianmcmichael,项目名称:bitcoin,代码行数:27,


示例5: CKeyingMaterial

bool CCrypter::Decrypt(const std::vector<unsigned char>& vchCiphertext, CKeyingMaterial& vchPlaintext){    if (!fKeySet)        return false;    // plaintext will always be equal to or lesser than length of ciphertext    int nLen = vchCiphertext.size();    int nPLen = nLen, nFLen = 0;    vchPlaintext = CKeyingMaterial(nPLen);    EVP_CIPHER_CTX ctx;    bool fOk = true;    EVP_CIPHER_CTX_init(&ctx);    if (fOk) fOk = EVP_DecryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, chKey, chIV);    if (fOk) fOk = EVP_DecryptUpdate(&ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen);    if (fOk) fOk = EVP_DecryptFinal_ex(&ctx, (&vchPlaintext[0])+nPLen, &nFLen);    EVP_CIPHER_CTX_cleanup(&ctx);    if (!fOk) return false;    vchPlaintext.resize(nPLen + nFLen);    return true;}
开发者ID:oracul,项目名称:bullycoin,代码行数:26,


示例6: CKeyingMaterial

bool CCrypter::Decrypt(const std::vector<unsigned char>& vchCiphertext, CKeyingMaterial& vchPlaintext){    if (!fKeySet)        return false;    // plaintext will always be equal to or lesser than length of ciphertext    int nLen = vchCiphertext.size();    int nPLen = nLen, nFLen = 0;    vchPlaintext = CKeyingMaterial(nPLen);    bool fOk = true;    EVP_CIPHER_CTX *ctx= EVP_CIPHER_CTX_new();    if(!ctx)        throw std::runtime_error("Error allocating cipher context");    if (fOk) fOk = EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, chKey, chIV);    if (fOk) fOk = EVP_DecryptUpdate(ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen);    if (fOk) fOk = EVP_DecryptFinal_ex(ctx, (&vchPlaintext[0])+nPLen, &nFLen);    EVP_CIPHER_CTX_free(ctx);    if (!fOk) return false;    vchPlaintext.resize(nPLen + nFLen);    return true;}
开发者ID:gridcoin,项目名称:Gridcoin-Research,代码行数:27,


示例7: TestDecrypt

static void TestDecrypt(const CCrypter& crypt, const std::vector<unsigned char>& vchCiphertext, /                        const std::vector<unsigned char>& vchPlaintext = std::vector<unsigned char>()){    CKeyingMaterial vchDecrypted;    crypt.Decrypt(vchCiphertext, vchDecrypted);    if (vchPlaintext.size())        BOOST_CHECK(CKeyingMaterial(vchPlaintext.begin(), vchPlaintext.end()) == vchDecrypted);}
开发者ID:Xekyo,项目名称:bitcoin,代码行数:8,


示例8: TestDecrypt

static void TestDecrypt(const CCrypter& crypt, const std::vector<unsigned char>& vchCiphertext, /                        const std::vector<unsigned char>& vchPlaintext = std::vector<unsigned char>()){    CKeyingMaterial vchDecrypted1;    CKeyingMaterial vchDecrypted2;    int result1, result2;    result1 = crypt.Decrypt(vchCiphertext, vchDecrypted1);    result2 = OldDecrypt(vchCiphertext, vchDecrypted2, crypt.vchKey.data(), crypt.vchIV.data());    BOOST_CHECK(result1 == result2);    // These two should be equal. However, OpenSSL 1.0.1j introduced a change    // that would zero all padding except for the last byte for failed decrypts.    // This behavior was reverted for 1.0.1k.    if (vchDecrypted1 != vchDecrypted2 && vchDecrypted1.size() >= AES_BLOCK_SIZE && SSLeay() == 0x100010afL)    {        for(CKeyingMaterial::iterator it = vchDecrypted1.end() - AES_BLOCK_SIZE; it != vchDecrypted1.end() - 1; it++)            *it = 0;    }    BOOST_CHECK_MESSAGE(vchDecrypted1 == vchDecrypted2, HexStr(vchDecrypted1.begin(), vchDecrypted1.end()) + " != " + HexStr(vchDecrypted2.begin(), vchDecrypted2.end()));    if (vchPlaintext.size())        BOOST_CHECK(CKeyingMaterial(vchPlaintext.begin(), vchPlaintext.end()) == vchDecrypted2);}
开发者ID:brianmcmichael,项目名称:bitcoin,代码行数:24,



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


C++ CLAMPIS函数代码示例
C++ CKSEG1ADDR函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。