本文整理汇总了C++中OID::decode方法的典型用法代码示例。如果您正苦于以下问题:C++ OID::decode方法的具体用法?C++ OID::decode怎么用?C++ OID::decode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OID
的用法示例。
在下文中一共展示了OID::decode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sink
void
PublicKey::decode(CryptoPP::BufferedTransformation& in)
{
// SubjectPublicKeyInfo ::= SEQUENCE {
// algorithm AlgorithmIdentifier
// keybits BIT STRING }
using namespace CryptoPP;
try
{
std::string out;
StringSink sink(out);
////////////////////////
// part 1: copy as is //
////////////////////////
BERSequenceDecoder decoder(in);
{
assert(decoder.IsDefiniteLength());
DERSequenceEncoder encoder(sink);
decoder.TransferTo(encoder, decoder.RemainingLength());
encoder.MessageEnd();
}
decoder.MessageEnd();
////////////////////////
// part 2: check if the key is RSA (since it is the only supported for now)
////////////////////////
StringSource checkedSource(out, true);
BERSequenceDecoder subjectPublicKeyInfo(checkedSource);
{
BERSequenceDecoder algorithmInfo(subjectPublicKeyInfo);
{
OID algorithm;
algorithm.decode(algorithmInfo);
if (algorithm == oid::RSA)
m_type = KEY_TYPE_RSA;
else if (algorithm == oid::ECDSA)
m_type = KEY_TYPE_ECDSA;
else
BOOST_THROW_EXCEPTION(Error("Only RSA/ECDSA public keys are supported for now (" +
algorithm.toString() + " requested)"));
}
}
m_key.assign(out.begin(), out.end());
}
catch (CryptoPP::BERDecodeErr& err)
{
m_type = KEY_TYPE_NULL;
BOOST_THROW_EXCEPTION(Error("PublicKey decoding error"));
}
m_digest.reset();
}