27 #include "../encoding/oid.hpp" 28 #include "../util/crypto.hpp" 41 CryptoPP::StringSource src(keyDerBuf, keyDerSize,
true);
49 BOOST_THROW_EXCEPTION(
Error(
"Public key is empty"));
68 out.Put(m_key.
buf(), m_key.size());
87 BERSequenceDecoder decoder(in);
89 assert(decoder.IsDefiniteLength());
91 DERSequenceEncoder encoder(sink);
92 decoder.TransferTo(encoder, decoder.RemainingLength());
100 StringSource checkedSource(out,
true);
101 BERSequenceDecoder subjectPublicKeyInfo(checkedSource);
103 BERSequenceDecoder algorithmInfo(subjectPublicKeyInfo);
106 algorithm.
decode(algorithmInfo);
113 BOOST_THROW_EXCEPTION(
Error(
"Only RSA/ECDSA public keys are supported for now (" +
114 algorithm.
toString() +
" requested)"));
118 m_key.assign(out.begin(), out.end());
120 catch (CryptoPP::BERDecodeErr& err)
123 BOOST_THROW_EXCEPTION(
Error(
"PublicKey decoding error"));
145 CryptoPP::StringSource(key.
get().
buf(), key.
get().size(),
true,
146 new CryptoPP::Base64Encoder(
new CryptoPP::FileSink(os),
true, 64));
bool hasWire() const
Check if the Block has fully encoded wire.
Copyright (c) 2011-2015 Regents of the University of California.
Copyright (c) 2013-2014 Regents of the University of California.
std::ostream & operator<<(std::ostream &os, const Data &data)
PublicKey()
The default constructor.
void encode(CryptoPP::BufferedTransformation &out) const
Class representing a wire element of NDN-TLV packet format.
void decode(CryptoPP::BufferedTransformation &in)
const Block & computeDigest() const
void decode(CryptoPP::BufferedTransformation &in)
void encode()
Encode subblocks into wire buffer.
const Buffer & get() const
std::string toString() const
ConstBufferPtr sha256(const uint8_t *data, size_t dataLength)
Compute the sha-256 digest of data.
const OID ECDSA("1.2.840.10045.2.1")
const OID RSA("1.2.840.113549.1.1.1")