blob: 2f89484599b5642b4c03601adc1d62619c0f7f81 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Jeff Thompsonc0573432013-09-19 17:41:36 -07002/**
Alexander Afanasyev2fa59392016-07-29 17:24:23 -07003 * Copyright (c) 2013-2016 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
Jeff Thompsonc0573432013-09-19 17:41:36 -070020 */
21
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070022#ifndef NDN_ENCODING_OID_HPP
23#define NDN_ENCODING_OID_HPP
Jeff Thompsonc0573432013-09-19 17:41:36 -070024
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080025#include "../common.hpp"
Jeff Thompsonc0573432013-09-19 17:41:36 -070026
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070027#include <vector>
28
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070029namespace CryptoPP {
30class BufferedTransformation;
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070031} // namespace CryptoPP
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080032
Jeff Thompsonc0573432013-09-19 17:41:36 -070033namespace ndn {
34
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070035class Oid
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070036{
Jeff Thompsonc0573432013-09-19 17:41:36 -070037public:
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070038 Oid() = default;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070039
Yingdi Yu9d9d5992014-06-25 12:25:16 -070040 explicit
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070041 Oid(const char* oid);
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080042
Yingdi Yu9d9d5992014-06-25 12:25:16 -070043 explicit
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070044 Oid(const std::string& oid);
Jeff Thompsonc0573432013-09-19 17:41:36 -070045
Yingdi Yu9d9d5992014-06-25 12:25:16 -070046 explicit
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070047 Oid(const std::vector<int>& oid)
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070048 : m_oid(oid)
Jeff Thompsonc0573432013-09-19 17:41:36 -070049 {
50 }
51
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070052 const std::vector<int>&
Jeff Thompsonc0573432013-09-19 17:41:36 -070053 getIntegerList() const
54 {
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070055 return m_oid;
Jeff Thompsonc0573432013-09-19 17:41:36 -070056 }
57
58 void
Yingdi Yu9d9d5992014-06-25 12:25:16 -070059 setIntegerList(const std::vector<int>& value)
60 {
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070061 m_oid = value;
Jeff Thompsonc0573432013-09-19 17:41:36 -070062 }
63
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070064 std::string
Jeff Thompson6c729a22013-12-20 10:37:59 -080065 toString() const;
Jeff Thompsonc0573432013-09-19 17:41:36 -070066
Yingdi Yu9d9d5992014-06-25 12:25:16 -070067 bool
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070068 operator==(const Oid& oid) const
Jeff Thompsonc0573432013-09-19 17:41:36 -070069 {
70 return equal(oid);
71 }
72
Yingdi Yu9d9d5992014-06-25 12:25:16 -070073 bool
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070074 operator!=(const Oid& oid) const
Jeff Thompsonc0573432013-09-19 17:41:36 -070075 {
76 return !equal(oid);
77 }
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080078
79 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070080 encode(CryptoPP::BufferedTransformation& out) const;
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080081
82 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070083 decode(CryptoPP::BufferedTransformation& in);
Jeff Thompsonc0573432013-09-19 17:41:36 -070084
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080085
86private:
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080087 bool
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070088 equal(const Oid& oid) const;
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080089
90private:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070091 std::vector<int> m_oid;
Jeff Thompsonc0573432013-09-19 17:41:36 -070092};
93
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070094/**
95 * @deprecated Use Oid type instead
96 */
97typedef Oid OID;
98
Yingdi Yu9d9d5992014-06-25 12:25:16 -070099namespace oid {
Alexander Afanasyev2fa59392016-07-29 17:24:23 -0700100// crypto algorithm
101extern const Oid RSA;
102extern const Oid ECDSA;
Yingdi Yu9d9d5992014-06-25 12:25:16 -0700103
Alexander Afanasyev2fa59392016-07-29 17:24:23 -0700104// certificate entries
105extern const Oid ATTRIBUTE_NAME;
106} // namespace oid
Yingdi Yu9d9d5992014-06-25 12:25:16 -0700107
Alexander Afanasyev2fa59392016-07-29 17:24:23 -0700108} // namespace ndn
Jeff Thompsonc0573432013-09-19 17:41:36 -0700109
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -0700110#endif // NDN_ENCODING_OID_HPP