blob: 2eea3106d098c0586d5d50ae2462c655ca0759c4 [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 Afanasyeve6835fe2017-01-19 20:05:01 -08003 * Copyright (c) 2013-2017 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 -080085private:
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080086 bool
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070087 equal(const Oid& oid) const;
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080088
89private:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070090 std::vector<int> m_oid;
Jeff Thompsonc0573432013-09-19 17:41:36 -070091};
92
Yingdi Yu9d9d5992014-06-25 12:25:16 -070093namespace oid {
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070094// crypto algorithm
95extern const Oid RSA;
96extern const Oid ECDSA;
Yingdi Yu9d9d5992014-06-25 12:25:16 -070097
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070098// certificate entries
99extern const Oid ATTRIBUTE_NAME;
100} // namespace oid
Yingdi Yu9d9d5992014-06-25 12:25:16 -0700101
Alexander Afanasyev2fa59392016-07-29 17:24:23 -0700102} // namespace ndn
Jeff Thompsonc0573432013-09-19 17:41:36 -0700103
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -0700104#endif // NDN_ENCODING_OID_HPP