24 #include "../security/v1/cryptopp.hpp" 39 std::string str = oid +
".";
44 while (std::string::npos != pos) {
47 pos = str.find_first_of(
'.', pos);
48 if (pos == std::string::npos)
51 m_oid.push_back(atoi(str.substr(ppos, pos - ppos).c_str()));
60 std::ostringstream convert;
62 for (std::vector<int>::const_iterator it = m_oid.begin(); it != m_oid.end(); ++it) {
63 if (it != m_oid.begin())
72 Oid::equal(
const Oid& oid)
const 74 std::vector<int>::const_iterator i = m_oid.begin();
75 std::vector<int>::const_iterator j = oid.m_oid.begin();
77 for (; i != m_oid.end() && j != oid.m_oid.end(); i++, j++) {
82 return (i == m_oid.end() && j == oid.m_oid.end());
86 encodeValue(CryptoPP::BufferedTransformation& bt, CryptoPP::word32 v)
90 for (
unsigned int i = RoundUpToMultipleOf(STDMAX(7U, BitPrecision(v)), 7U) - 7; i != 0; i -= 7)
91 bt.Put(static_cast<byte>(0x80 | ((v >> i) & 0x7f)));
92 bt.Put(static_cast<byte>(v & 0x7f));
96 decodeValue(CryptoPP::BufferedTransformation& bt, CryptoPP::word32& v)
108 if (v >> (8 *
sizeof(v) - 7))
122 BOOST_ASSERT(m_oid.size() >= 2);
125 temp.Put(byte(m_oid[0] * OID_MAGIC_NUMBER + m_oid[1]));
126 for (
size_t i = 2; i < m_oid.size(); i++)
129 out.Put(OBJECT_IDENTIFIER);
130 DERLengthEncode(out, temp.CurrentSize());
131 temp.TransferTo(out);
140 if (!in.Get(b) || b != OBJECT_IDENTIFIER)
144 if (!BERLengthDecode(in, length) || length < 1)
159 if (valueLen > length)
167 const Oid RSA(
"1.2.840.113549.1.1.1");
168 const Oid ECDSA(
"1.2.840.10045.2.1");
void encode(CryptoPP::BufferedTransformation &out) const
void decode(CryptoPP::BufferedTransformation &in)
void encodeValue(CryptoPP::BufferedTransformation &bt, CryptoPP::word32 v)
const Oid ECDSA("1.2.840.10045.2.1")
Copyright (c) 2011-2015 Regents of the University of California.
Copyright (c) 2013-2016 Regents of the University of California.
const Oid ATTRIBUTE_NAME("2.5.4.41")
std::string toString() const
size_t decodeValue(CryptoPP::BufferedTransformation &bt, CryptoPP::word32 &v)
static const int OID_MAGIC_NUMBER