blob: 054caf32a834650875da916116ceaf825d8b8a7c [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Jeff Thompson958bf9b2013-10-12 17:20:51 -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.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070020 *
21 * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
22 * @author Jeff Thompson <jefft0@remap.ucla.edu>
23 * @author Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html>
Jeff Thompson958bf9b2013-10-12 17:20:51 -070024 */
25
Yingdi Yufc40d872014-02-18 12:56:04 -080026#ifndef NDN_SECURITY_CERTIFICATE_SUBJECT_DESCRIPTION_HPP
27#define NDN_SECURITY_CERTIFICATE_SUBJECT_DESCRIPTION_HPP
Jeff Thompson958bf9b2013-10-12 17:20:51 -070028
Yingdi Yu4f324632014-01-15 18:10:03 -080029#include "../common.hpp"
30#include "../encoding/oid.hpp"
Jeff Thompson958bf9b2013-10-12 17:20:51 -070031
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070032namespace CryptoPP {
33class BufferedTransformation;
34}
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080035
Jeff Thompson958bf9b2013-10-12 17:20:51 -070036namespace ndn {
37
Jeff Thompson958bf9b2013-10-12 17:20:51 -070038/**
39 * A CertificateSubjectDescription represents the SubjectDescription entry in a Certificate.
40 */
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070041class CertificateSubjectDescription
42{
Jeff Thompson958bf9b2013-10-12 17:20:51 -070043public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070044 CertificateSubjectDescription(CryptoPP::BufferedTransformation& in)
Jeff Thompson958bf9b2013-10-12 17:20:51 -070045 {
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080046 decode(in);
Jeff Thompson958bf9b2013-10-12 17:20:51 -070047 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070048
Jeff Thompson958bf9b2013-10-12 17:20:51 -070049 /**
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080050 * Create a new CertificateSubjectDescription.
51 * @param oid The oid of the subject description entry.
52 * @param value The value of the subject description entry.
Jeff Thompson958bf9b2013-10-12 17:20:51 -070053 */
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070054 CertificateSubjectDescription(const OID& oid, const std::string& value)
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070055 : m_oid(oid), m_value(value)
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080056 {
57 }
58
59 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070060 encode(CryptoPP::BufferedTransformation& out) const;
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080061
62 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070063 decode(CryptoPP::BufferedTransformation& in);
64
Jeff Thompson958bf9b2013-10-12 17:20:51 -070065 std::string
Jeff Thompson61a25ff2013-12-20 10:40:04 -080066 getOidString() const
Jeff Thompson958bf9b2013-10-12 17:20:51 -070067 {
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070068 return m_oid.toString();
Jeff Thompson958bf9b2013-10-12 17:20:51 -070069 }
70
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070071 const std::string&
Jeff Thompson958bf9b2013-10-12 17:20:51 -070072 getValue() const
73 {
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070074 return m_value;
Jeff Thompson958bf9b2013-10-12 17:20:51 -070075 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070076
Jeff Thompson958bf9b2013-10-12 17:20:51 -070077private:
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070078 OID m_oid;
79 std::string m_value;
Jeff Thompson958bf9b2013-10-12 17:20:51 -070080};
81
Yingdi Yufc40d872014-02-18 12:56:04 -080082} // namespace ndn
Jeff Thompson958bf9b2013-10-12 17:20:51 -070083
Yingdi Yufc40d872014-02-18 12:56:04 -080084#endif //NDN_SECURITY_CERTIFICATE_SUBJECT_DESCRIPTION_HPP