27 #include "../../encoding/oid.hpp" 28 #include "../../util/crypto.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/ECDSA public keys are supported for now (" +
116 algorithm.
toString() +
" requested)"));
120 m_key.assign(out.begin(), out.end());
122 catch (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")
bool hasWire() const
Check if the Block has fully encoded wire.
Copyright (c) 2011-2015 Regents of the University of California.
const Buffer & get() const
Copyright (c) 2013-2016 Regents of the University of California.
std::ostream & operator<<(std::ostream &os, const Certificate &cert)
Class representing a wire element of NDN-TLV packet format.
PublicKey()
The default constructor.
const Oid RSA("1.2.840.113549.1.1.1")
std::string toString() const
const Block & computeDigest() const
void encode()
Encode subblocks into wire buffer.
ConstBufferPtr computeSha256Digest(const uint8_t *data, size_t dataLength)
Compute the sha-256 digest of data.
void decode(CryptoPP::BufferedTransformation &in)
void encode(CryptoPP::BufferedTransformation &out) const