本文整理汇总了C++中CKeyingMaterial::end方法的典型用法代码示例。如果您正苦于以下问题:C++ CKeyingMaterial::end方法的具体用法?C++ CKeyingMaterial::end怎么用?C++ CKeyingMaterial::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKeyingMaterial
的用法示例。
在下文中一共展示了CKeyingMaterial::end方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Unlock
bool CHDSeed::Unlock(const CKeyingMaterial& vMasterKeyIn)
{
assert(sizeof(m_UUID) == WALLET_CRYPTO_IV_SIZE);
CKeyingMaterial vchMnemonic;
if (!DecryptSecret(vMasterKeyIn, encryptedMnemonic, std::vector<unsigned char>(m_UUID.begin(), m_UUID.end()), vchMnemonic))
return false;
unencryptedMnemonic = SecureString(vchMnemonic.begin(), vchMnemonic.end());
CKeyingMaterial vchMasterKeyPrivEncoded;
if (!DecryptSecret(vMasterKeyIn, masterKeyPrivEncrypted, masterKeyPub.pubkey.GetHash(), vchMasterKeyPrivEncoded))
return false;
masterKeyPriv.Decode(vchMasterKeyPrivEncoded.data());
CKeyingMaterial vchPurposeKeyPrivEncoded;
if (!DecryptSecret(vMasterKeyIn, purposeKeyPrivEncrypted, purposeKeyPub.pubkey.GetHash(), vchPurposeKeyPrivEncoded))
return false;
purposeKeyPriv.Decode(vchPurposeKeyPrivEncoded.data());
CKeyingMaterial vchCoinTypeKeyPrivEncoded;
if (!DecryptSecret(vMasterKeyIn, cointypeKeyPrivEncrypted, cointypeKeyPub.pubkey.GetHash(), vchCoinTypeKeyPrivEncoded))
return false;
cointypeKeyPriv.Decode(vchCoinTypeKeyPrivEncoded.data());
vMasterKey = vMasterKeyIn;
return true;
}
示例2: Unlock
bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn)
{
{
LOCK(cs_KeyStore);
if (!SetCrypted())
return false;
CryptedKeyMap::const_iterator mi = mapCryptedKeys.begin();
for (; mi != mapCryptedKeys.end(); ++mi)
{
const CPubKey &vchPubKey = (*mi).second.first;
const std::vector<unsigned char> &vchCryptedSecret = (*mi).second.second;
CKeyingMaterial vchSecret;
if(!DecryptSecret(vMasterKeyIn, vchCryptedSecret, vchPubKey.GetHash(), vchSecret))
return false;
if (vchSecret.size() != 32)
return false;
CKey key;
key.Set(vchSecret.begin(), vchSecret.end(), vchPubKey.IsCompressed());
if (key.GetPubKey() == vchPubKey)
break;
return false;
}
vMasterKey = vMasterKeyIn;
}
NotifyStatusChanged(this);
return true;
}
示例3: DecryptData
// LogTrace("spark", "the vEncrypted:%s\n", VectorToString(vEncrypted));
return true;
}
bool CLotData::DecryptData(const CLottoFileKey &key, const vector<unsigned char>& vInput,
vector<unsigned char>& vDecrypted) {
CLottoFileKey nkey = key;
vector<uint256> keydata = nkey.getKey();
if (keydata.size() == 1) {
int ii = 0;
vector<unsigned char> tmpdata = vInput;
// LogTrace("spark", "read out from file:%s\n", VectorToString(tmpdata));
while (ii >= 0) {
CKeyingMaterial tmpkey(keydata[ii].begin(), keydata[ii].end());
CKeyingMaterial tmpout;
// LogTrace("spark", "the tmp:%s\n", VectorToString(vector<unsigned char>(tmpkey.begin(), tmpkey.end())));
if (!sDecryptData(tmpkey, tmpdata, uint256(100), tmpout)) {
return false;
}
tmpdata.assign(tmpout.begin(), tmpout.end());
// LogTrace("spark", "the tmpout:%s\n", VectorToString(tmpdata));
ii--;
}
vDecrypted = tmpdata;
} else {
示例4: DecryptKey
static bool DecryptKey(const CKeyingMaterial& vMasterKey, const std::vector<unsigned char>& vchCryptedSecret, const CPubKey& vchPubKey, CKey& key)
{
CKeyingMaterial vchSecret;
if(!DecryptSecret(vMasterKey, vchCryptedSecret, vchPubKey.GetHash(), vchSecret))
return false;
if (vchSecret.size() != 32)
return false;
key.Set(vchSecret.begin(), vchSecret.end(), vchPubKey.IsCompressed());
return key.VerifyPubKey(vchPubKey);
}
示例5: DecryptKey
bool WalletUtilityDB::DecryptKey(const std::vector<unsigned char>& vchCryptedSecret, const CPubKey& vchPubKey, CKey& key)
{
CKeyingMaterial vchSecret;
if(!DecryptSecret(vchCryptedSecret, vchPubKey.GetHash(), vchSecret))
return false;
if (vchSecret.size() != 32)
return false;
key.Set(vchSecret.begin(), vchSecret.end(), vchPubKey.IsCompressed());
return true;
}
示例6: TestEncryptSingle
static void TestEncryptSingle(const CCrypter& crypt, const CKeyingMaterial& vchPlaintext,
const std::vector<unsigned char>& vchCiphertextCorrect = std::vector<unsigned char>())
{
std::vector<unsigned char> vchCiphertext;
crypt.Encrypt(vchPlaintext, vchCiphertext);
if (!vchCiphertextCorrect.empty())
BOOST_CHECK(vchCiphertext == vchCiphertextCorrect);
const std::vector<unsigned char> vchPlaintext2(vchPlaintext.begin(), vchPlaintext.end());
TestDecrypt(crypt, vchCiphertext, vchPlaintext2);
}
示例7: Unlock
bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn)
{
{
LOCK(cs_KeyStore);
if (!SetCrypted())
return false;
bool keyPass = false;
bool keyFail = false;
CryptedKeyMap::const_iterator mi = mapCryptedKeys.begin();
for (; mi != mapCryptedKeys.end(); ++mi)
{
const CPubKey &vchPubKey = (*mi).second.first;
const std::vector<unsigned char> &vchCryptedSecret = (*mi).second.second;
CKeyingMaterial vchSecret;
if(!DecryptSecret(vMasterKeyIn, vchCryptedSecret, vchPubKey.GetHash(), vchSecret))
{
keyFail = true;
break;
}
if (vchSecret.size() != 32)
{
keyFail = true;
break;
}
CKey key;
key.Set(vchSecret.begin(), vchSecret.end(), vchPubKey.IsCompressed());
if (key.GetPubKey() != vchPubKey)
{
keyFail = true;
break;
}
keyPass = true;
if (fDecryptionThoroughlyChecked)
break;
}
if (keyPass && keyFail)
{
LogPrintf("The wallet is probably corrupted: Some keys decrypt but not all.");
assert(false);
}
if (keyFail || !keyPass)
return false;
vMasterKey = vMasterKeyIn;
fDecryptionThoroughlyChecked = true;
}
NotifyStatusChanged(this);
return true;
}
示例8: DecryptKey
/* The old namecoind encrypted not the 32-byte secret, but the full 279-byte
serialised keys. Thus, we need to handle both formats. This is done
by the following utility routine: It decrypts a secret and initialises
a CKey object from it. */
static bool DecryptKey(const CKeyingMaterial& vMasterKey, const std::vector<unsigned char>& vchCryptedSecret, const CPubKey& vchPubKey, CKey& key)
{
CKeyingMaterial vchSecret;
if(!DecryptSecret(vMasterKey, vchCryptedSecret, vchPubKey.GetHash(), vchSecret))
return false;
//LogPrintf("%s : decrypted %u-byte key\n", __func__, vchSecret.size());
if (vchSecret.size() == 32)
{
key.Set(vchSecret.begin(), vchSecret.end(), vchPubKey.IsCompressed());
return true;
}
return key.SetPrivKey(vchSecret, vchPubKey.IsCompressed());
}
示例9: TestEncryptSingle
static void TestEncryptSingle(const CCrypter& crypt, const CKeyingMaterial& vchPlaintext,
const std::vector<unsigned char>& vchCiphertextCorrect = std::vector<unsigned char>())
{
std::vector<unsigned char> vchCiphertext1;
std::vector<unsigned char> vchCiphertext2;
int result1 = crypt.Encrypt(vchPlaintext, vchCiphertext1);
int result2 = OldEncrypt(vchPlaintext, vchCiphertext2, crypt.vchKey.data(), crypt.vchIV.data());
BOOST_CHECK(result1 == result2);
BOOST_CHECK(vchCiphertext1 == vchCiphertext2);
if (!vchCiphertextCorrect.empty())
BOOST_CHECK(vchCiphertext2 == vchCiphertextCorrect);
const std::vector<unsigned char> vchPlaintext2(vchPlaintext.begin(), vchPlaintext.end());
if(vchCiphertext1 == vchCiphertext2)
TestDecrypt(crypt, vchCiphertext1, vchPlaintext2);
}
示例10: GetKey
bool CCryptoKeyStore::GetKey(const CKeyID &address, CKey& keyOut) const
{
{
LOCK(cs_KeyStore);
if (!IsCrypted())
return CBasicKeyStore::GetKey(address, keyOut);
CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(address);
if (mi != mapCryptedKeys.end())
{
const CPubKey &vchPubKey = (*mi).second.first;
const std::vector<unsigned char> &vchCryptedSecret = (*mi).second.second;
CKeyingMaterial vchSecret;
if (!DecryptSecret(vMasterKey, vchCryptedSecret, vchPubKey.GetHash(), vchSecret))
return false;
if (vchSecret.size() != 32)
return false;
keyOut.Set(vchSecret.begin(), vchSecret.end(), vchPubKey.IsCompressed());
return true;
}
}
return false;
}