27 #include "../security/cryptopp.hpp" 49 OID::construct(
const std::string& oid)
51 string str = oid +
".";
56 while (string::npos != pos) {
59 pos = str.find_first_of(
'.', pos);
60 if (pos == string::npos)
63 m_oid.push_back(atoi(str.substr(ppos, pos - ppos).c_str()));
72 std::ostringstream convert;
74 for (vector<int>::const_iterator it = m_oid.begin(); it != m_oid.end(); ++it) {
75 if (it != m_oid.begin())
84 OID::equal(
const OID& oid)
const 86 vector<int>::const_iterator i = m_oid.begin();
87 vector<int>::const_iterator j = oid.m_oid.begin();
89 for (; i != m_oid.end() && j != oid.m_oid.end(); i++, j++) {
94 return (i == m_oid.end() && j == oid.m_oid.end());
98 encodeValue(CryptoPP::BufferedTransformation& bt, CryptoPP::word32 v)
102 for (
unsigned int i = RoundUpToMultipleOf(STDMAX(7U, BitPrecision(v)), 7U) - 7; i != 0; i -= 7)
103 bt.Put(static_cast<byte>(0x80 | ((v >> i) & 0x7f)));
104 bt.Put(static_cast<byte>(v & 0x7f));
108 decodeValue(CryptoPP::BufferedTransformation& bt, CryptoPP::word32& v)
120 if (v >> (8 *
sizeof(v) - 7))
134 BOOST_ASSERT(m_oid.size() >= 2);
137 temp.Put(byte(m_oid[0] * OID_MAGIC_NUMBER + m_oid[1]));
138 for (
size_t i = 2; i < m_oid.size(); i++)
141 out.Put(OBJECT_IDENTIFIER);
142 DERLengthEncode(out, temp.CurrentSize());
143 temp.TransferTo(out);
152 if (!in.Get(b) || b != OBJECT_IDENTIFIER)
156 if (!BERLengthDecode(in, length) || length < 1)
171 if (valueLen > length)
179 const OID RSA(
"1.2.840.113549.1.1.1");
180 const OID ECDSA(
"1.2.840.10045.2.1");
void encodeValue(CryptoPP::BufferedTransformation &bt, CryptoPP::word32 v)
Copyright (c) 2011-2015 Regents of the University of California.
Copyright (c) 2013-2014 Regents of the University of California.
void encode(CryptoPP::BufferedTransformation &out) const
const OID ATTRIBUTE_NAME("2.5.4.41")
void decode(CryptoPP::BufferedTransformation &in)
size_t decodeValue(CryptoPP::BufferedTransformation &bt, CryptoPP::word32 &v)
std::string toString() const
const OID ECDSA("1.2.840.10045.2.1")
const OID RSA("1.2.840.113549.1.1.1")
static const int OID_MAGIC_NUMBER