blob: 00eab76009808296d01ea12f499bfcde21ead002 [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 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.
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
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070026#ifndef NDN_SECURITY_V1_CERTIFICATE_SUBJECT_DESCRIPTION_HPP
27#define NDN_SECURITY_V1_CERTIFICATE_SUBJECT_DESCRIPTION_HPP
Jeff Thompson958bf9b2013-10-12 17:20:51 -070028
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070029#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;
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070034} // namespace CryptoPP
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080035
Jeff Thompson958bf9b2013-10-12 17:20:51 -070036namespace ndn {
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070037namespace security {
38namespace v1 {
Jeff Thompson958bf9b2013-10-12 17:20:51 -070039
Jeff Thompson958bf9b2013-10-12 17:20:51 -070040/**
41 * A CertificateSubjectDescription represents the SubjectDescription entry in a Certificate.
42 */
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070043class CertificateSubjectDescription
44{
Jeff Thompson958bf9b2013-10-12 17:20:51 -070045public:
Alexander Afanasyeva4297a62014-06-19 13:29:34 -070046 explicit
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070047 CertificateSubjectDescription(CryptoPP::BufferedTransformation& in)
Jeff Thompson958bf9b2013-10-12 17:20:51 -070048 {
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080049 decode(in);
Jeff Thompson958bf9b2013-10-12 17:20:51 -070050 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070051
Jeff Thompson958bf9b2013-10-12 17:20:51 -070052 /**
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080053 * Create a new CertificateSubjectDescription.
54 * @param oid The oid of the subject description entry.
55 * @param value The value of the subject description entry.
Jeff Thompson958bf9b2013-10-12 17:20:51 -070056 */
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070057 CertificateSubjectDescription(const Oid& oid, const std::string& value)
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070058 : m_oid(oid), m_value(value)
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080059 {
60 }
61
62 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070063 encode(CryptoPP::BufferedTransformation& out) const;
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080064
65 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070066 decode(CryptoPP::BufferedTransformation& in);
67
Jeff Thompson958bf9b2013-10-12 17:20:51 -070068 std::string
Jeff Thompson61a25ff2013-12-20 10:40:04 -080069 getOidString() const
Jeff Thompson958bf9b2013-10-12 17:20:51 -070070 {
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070071 return m_oid.toString();
Jeff Thompson958bf9b2013-10-12 17:20:51 -070072 }
73
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070074 const std::string&
Jeff Thompson958bf9b2013-10-12 17:20:51 -070075 getValue() const
76 {
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070077 return m_value;
Jeff Thompson958bf9b2013-10-12 17:20:51 -070078 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070079
Jeff Thompson958bf9b2013-10-12 17:20:51 -070080private:
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070081 Oid m_oid;
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070082 std::string m_value;
Jeff Thompson958bf9b2013-10-12 17:20:51 -070083};
84
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070085} // namespace v1
86} // namespace security
87
88#ifdef NDN_CXX_KEEP_SECURITY_V1_ALIASES
89/// @deprecated When needed, use explicit namespace
90using security::v1::CertificateSubjectDescription;
91#endif // NDN_CXX_KEEP_SECURITY_V1_ALIASES
92
Yingdi Yufc40d872014-02-18 12:56:04 -080093} // namespace ndn
Jeff Thompson958bf9b2013-10-12 17:20:51 -070094
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070095#endif // NDN_SECURITY_V1_CERTIFICATE_SUBJECT_DESCRIPTION_HPP