本文整理汇总了C++中botan::SecureVector::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ SecureVector::empty方法的具体用法?C++ SecureVector::empty怎么用?C++ SecureVector::empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类botan::SecureVector
的用法示例。
在下文中一共展示了SecureVector::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: source
// Decode from PKCS#8 BER
bool BotanECDHPrivateKey::PKCS8Decode(const ByteString& ber)
{
Botan::DataSource_Memory source(ber.const_byte_str(), ber.size());
if (source.end_of_data()) return false;
Botan::SecureVector<Botan::byte> keydata;
Botan::AlgorithmIdentifier alg_id;
const Botan::OID oid("1.2.840.10045.2.1");
Botan::ECDH_PrivateKey* key = NULL;
try
{
Botan::BER_Decoder(source)
.start_cons(Botan::SEQUENCE)
.decode_and_check<size_t>(0, "Unknown PKCS #8 version number")
.decode(alg_id)
.decode(keydata, Botan::OCTET_STRING)
.discard_remaining()
.end_cons();
if (keydata.empty())
throw Botan::Decoding_Error("PKCS #8 private key decoding failed");
// Botan defines == but not != ?!
if (!(alg_id.oid == oid))
{
ERROR_MSG("Decoded private key not ECDH");
return false;
}
key = new Botan::ECDH_PrivateKey(alg_id, keydata);
if (key == NULL) return false;
setFromBotan(key);
delete key;
}
catch (std::exception& e)
{
ERROR_MSG("Decode failed on %s", e.what());
return false;
}
return true;
}
示例2: source
// Decode from PKCS#8 BER
bool BotanDSAPrivateKey::PKCS8Decode(const ByteString& ber)
{
Botan::DataSource_Memory source(ber.const_byte_str(), ber.size());
if (source.end_of_data()) return false;
Botan::SecureVector<Botan::byte> keydata;
Botan::AlgorithmIdentifier alg_id;
Botan::DSA_PrivateKey* key = NULL;
try
{
Botan::BER_Decoder(source)
.start_cons(Botan::SEQUENCE)
.decode_and_check<size_t>(0, "Unknown PKCS #8 version number")
.decode(alg_id)
.decode(keydata, Botan::OCTET_STRING)
.discard_remaining()
.end_cons();
if (keydata.empty())
throw Botan::Decoding_Error("PKCS #8 private key decoding failed");
if (Botan::OIDS::lookup(alg_id.oid).compare("DSA"))
{
ERROR_MSG("Decoded private key not DSA");
return false;
}
BotanRNG* rng = (BotanRNG*)BotanCryptoFactory::i()->getRNG();
key = new Botan::DSA_PrivateKey(alg_id, keydata, *rng->getRNG());
if (key == NULL) return false;
setFromBotan(key);
delete key;
}
catch (std::exception& e)
{
ERROR_MSG("Decode failed on %s", e.what());
return false;
}
return true;
}