12 #include "../security/cryptopp.hpp"
15 using namespace CryptoPP;
19 OID::OID(
const char* oid)
24 OID::OID(
const string& oid)
30 OID::construct(
const std::string& oid)
32 string str = oid +
".";
37 while (string::npos != pos) {
40 pos = str.find_first_of(
'.', pos);
41 if (pos == string::npos)
44 m_oid.push_back(atoi(str.substr(ppos, pos - ppos).c_str()));
52 ostringstream convert;
54 for (vector<int>::const_iterator it = m_oid.begin(); it != m_oid.end(); ++it) {
55 if (it != m_oid.begin())
64 OID::equal(
const OID& oid)
const
66 vector<int>::const_iterator i = m_oid.begin();
67 vector<int>::const_iterator j = oid.m_oid.begin();
69 for (; i != m_oid.end () && j != oid.m_oid.end (); i++, j++) {
74 if (i == m_oid.end () && j == oid.m_oid.end ())
83 for (
unsigned int i = RoundUpToMultipleOf(STDMAX(7U,BitPrecision(v)), 7U) - 7; i != 0; i -= 7)
84 bt.Put((byte)(0x80 | ((v >> i) & 0x7f)));
85 bt.Put((byte)(v & 0x7f));
99 if (v >> (8*
sizeof(v) - 7))
109 OID::encode(CryptoPP::BufferedTransformation& out)
const
111 BOOST_ASSERT(m_oid.size() >= 2);
114 temp.Put(byte(m_oid[0] * 40 + m_oid[1]));
115 for (
size_t i = 2; i < m_oid.size(); i++)
118 out.Put(OBJECT_IDENTIFIER);
119 DERLengthEncode(out, temp.CurrentSize());
120 temp.TransferTo(out);
124 OID::decode(CryptoPP::BufferedTransformation& in)
127 if (!in.Get(b) || b != OBJECT_IDENTIFIER)
131 if (!BERLengthDecode(in, length) || length < 1)
146 if (valueLen > length)
size_t DecodeValue(BufferedTransformation &bt, word32 &v)
std::string toString(const system_clock::TimePoint &timePoint, const std::string &format="%Y-%m-%d %H:%M:%S", const std::locale &locale=std::locale("C"))
Convert time point to string with specified format.
void EncodeValue(BufferedTransformation &bt, word32 v)