27 #include "../../encoding/oid.hpp" 28 #include "../../util/sha256.hpp" 43 CryptoPP::StringSource src(keyDerBuf, keyDerSize,
true);
51 BOOST_THROW_EXCEPTION(
Error(
"Public key is empty"));
70 out.Put(m_key.
buf(), m_key.size());
89 BERSequenceDecoder decoder(in);
91 assert(decoder.IsDefiniteLength());
93 DERSequenceEncoder encoder(sink);
94 decoder.TransferTo(encoder, decoder.RemainingLength());
102 StringSource checkedSource(out,
true);
103 BERSequenceDecoder subjectPublicKeyInfo(checkedSource);
105 BERSequenceDecoder algorithmInfo(subjectPublicKeyInfo);
108 algorithm.
decode(algorithmInfo);
115 BOOST_THROW_EXCEPTION(
Error(
"Only RSA/EC public keys are supported for now (" +
116 algorithm.
toString() +
" requested)"));
120 m_key.assign(out.begin(), out.end());
122 catch (
const CryptoPP::BERDecodeErr& err)
125 BOOST_THROW_EXCEPTION(
Error(
"PublicKey decoding error"));
147 CryptoPP::StringSource(key.
get().
buf(), key.
get().size(),
true,
148 new CryptoPP::Base64Encoder(
new CryptoPP::FileSink(os),
true, 64));
void decode(CryptoPP::BufferedTransformation &in)
const Oid ECDSA("1.2.840.10045.2.1")
Copyright (c) 2013-2017 Regents of the University of California.
const Buffer & get() const
const Block & computeDigest() const
Copyright (c) 2013-2017 Regents of the University of California.
std::ostream & operator<<(std::ostream &os, const Certificate &cert)
Represents a TLV element of NDN packet format.
void encode(CryptoPP::BufferedTransformation &out) const
PublicKey()
The default constructor.
const Oid RSA("1.2.840.113549.1.1.1")
void encode()
Encode sub elements into TLV-VALUE.
bool hasWire() const
Check if the Block has fully encoded wire.
ConstBufferPtr computeDigest()
Finalize and return the digest based on all previously supplied inputs.
void decode(CryptoPP::BufferedTransformation &in)
std::string toString() const