blob: 0e56dfaa8a2dc38117ce0e662b9afe0b895ed062 [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 Afanasyeva4297a62014-06-19 13:29:34 -070044 explicit
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070045 CertificateSubjectDescription(CryptoPP::BufferedTransformation& in)
Jeff Thompson958bf9b2013-10-12 17:20:51 -070046 {
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080047 decode(in);
Jeff Thompson958bf9b2013-10-12 17:20:51 -070048 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070049
Jeff Thompson958bf9b2013-10-12 17:20:51 -070050 /**
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080051 * Create a new CertificateSubjectDescription.
52 * @param oid The oid of the subject description entry.
53 * @param value The value of the subject description entry.
Jeff Thompson958bf9b2013-10-12 17:20:51 -070054 */
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070055 CertificateSubjectDescription(const OID& oid, const std::string& value)
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070056 : m_oid(oid), m_value(value)
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080057 {
58 }
59
60 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070061 encode(CryptoPP::BufferedTransformation& out) const;
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080062
63 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070064 decode(CryptoPP::BufferedTransformation& in);
65
Jeff Thompson958bf9b2013-10-12 17:20:51 -070066 std::string
Jeff Thompson61a25ff2013-12-20 10:40:04 -080067 getOidString() const
Jeff Thompson958bf9b2013-10-12 17:20:51 -070068 {
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070069 return m_oid.toString();
Jeff Thompson958bf9b2013-10-12 17:20:51 -070070 }
71
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070072 const std::string&
Jeff Thompson958bf9b2013-10-12 17:20:51 -070073 getValue() const
74 {
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070075 return m_value;
Jeff Thompson958bf9b2013-10-12 17:20:51 -070076 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070077
Jeff Thompson958bf9b2013-10-12 17:20:51 -070078private:
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070079 OID m_oid;
80 std::string m_value;
Jeff Thompson958bf9b2013-10-12 17:20:51 -070081};
82
Yingdi Yufc40d872014-02-18 12:56:04 -080083} // namespace ndn
Jeff Thompson958bf9b2013-10-12 17:20:51 -070084
Yingdi Yufc40d872014-02-18 12:56:04 -080085#endif //NDN_SECURITY_CERTIFICATE_SUBJECT_DESCRIPTION_HPP