blob: d5f99caa77589ec3766bfd9d039516c41f66b041 [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 Afanasyevc169a812014-05-20 20:37:29 -04003 * Copyright (c) 2013-2014 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;
31}
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080032
Jeff Thompsonc0573432013-09-19 17:41:36 -070033namespace ndn {
34
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070035class OID
36{
Jeff Thompsonc0573432013-09-19 17:41:36 -070037public:
Yingdi Yu9d9d5992014-06-25 12:25:16 -070038 OID()
Jeff Thompsonc0573432013-09-19 17:41:36 -070039 {
40 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070041
Yingdi Yu9d9d5992014-06-25 12:25:16 -070042 explicit
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070043 OID(const char* oid);
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080044
Yingdi Yu9d9d5992014-06-25 12:25:16 -070045 explicit
Jeff Thompsonc0573432013-09-19 17:41:36 -070046 OID(const std::string& oid);
47
Yingdi Yu9d9d5992014-06-25 12:25:16 -070048 explicit
Jeff Thompsonc0573432013-09-19 17:41:36 -070049 OID(const std::vector<int>& oid)
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070050 : m_oid(oid)
Jeff Thompsonc0573432013-09-19 17:41:36 -070051 {
52 }
53
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070054 const std::vector<int>&
Jeff Thompsonc0573432013-09-19 17:41:36 -070055 getIntegerList() const
56 {
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070057 return m_oid;
Jeff Thompsonc0573432013-09-19 17:41:36 -070058 }
59
60 void
Yingdi Yu9d9d5992014-06-25 12:25:16 -070061 setIntegerList(const std::vector<int>& value)
62 {
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070063 m_oid = value;
Jeff Thompsonc0573432013-09-19 17:41:36 -070064 }
65
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070066 std::string
Jeff Thompson6c729a22013-12-20 10:37:59 -080067 toString() const;
Jeff Thompsonc0573432013-09-19 17:41:36 -070068
Yingdi Yu9d9d5992014-06-25 12:25:16 -070069 bool
70 operator==(const OID& oid) const
Jeff Thompsonc0573432013-09-19 17:41:36 -070071 {
72 return equal(oid);
73 }
74
Yingdi Yu9d9d5992014-06-25 12:25:16 -070075 bool
76 operator!=(const OID& oid) const
Jeff Thompsonc0573432013-09-19 17:41:36 -070077 {
78 return !equal(oid);
79 }
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080080
81 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070082 encode(CryptoPP::BufferedTransformation& out) const;
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080083
84 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070085 decode(CryptoPP::BufferedTransformation& in);
Jeff Thompsonc0573432013-09-19 17:41:36 -070086
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080087
88private:
89 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070090 construct(const std::string& value);
91
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080092 bool
93 equal(const OID& oid) const;
94
95private:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070096 std::vector<int> m_oid;
Jeff Thompsonc0573432013-09-19 17:41:36 -070097};
98
Yingdi Yu9d9d5992014-06-25 12:25:16 -070099namespace oid {
100//crypto algorithm
101extern const OID RSA;
102extern const OID ECDSA;
103
104//certificate entries
105extern const OID ATTRIBUTE_NAME;
106}
107
Jeff Thompsonc0573432013-09-19 17:41:36 -0700108}
109
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -0700110#endif // NDN_ENCODING_OID_HPP