blob: c76a920a4a4bf5cc70dea430844d5f9e74e017a1 [file] [log] [blame]
Jeff Thompson958bf9b2013-10-12 17:20:51 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07003 * Copyright (c) 2013-2014, Regents of the University of California.
4 * All rights reserved.
5 *
6 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
7 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
8 *
9 * This file licensed under New BSD License. See COPYING for detailed information about
10 * ndn-cxx library copyright, permissions, and redistribution restrictions.
11 *
12 * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
13 * @author Jeff Thompson <jefft0@remap.ucla.edu>
14 * @author Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html>
Jeff Thompson958bf9b2013-10-12 17:20:51 -070015 */
16
Yingdi Yufc40d872014-02-18 12:56:04 -080017#ifndef NDN_SECURITY_CERTIFICATE_SUBJECT_DESCRIPTION_HPP
18#define NDN_SECURITY_CERTIFICATE_SUBJECT_DESCRIPTION_HPP
Jeff Thompson958bf9b2013-10-12 17:20:51 -070019
Yingdi Yu4f324632014-01-15 18:10:03 -080020#include "../common.hpp"
21#include "../encoding/oid.hpp"
Jeff Thompson958bf9b2013-10-12 17:20:51 -070022
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070023namespace CryptoPP {
24class BufferedTransformation;
25}
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080026
Jeff Thompson958bf9b2013-10-12 17:20:51 -070027namespace ndn {
28
Jeff Thompson958bf9b2013-10-12 17:20:51 -070029/**
30 * A CertificateSubjectDescription represents the SubjectDescription entry in a Certificate.
31 */
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070032class CertificateSubjectDescription
33{
Jeff Thompson958bf9b2013-10-12 17:20:51 -070034public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070035 CertificateSubjectDescription(CryptoPP::BufferedTransformation& in)
Jeff Thompson958bf9b2013-10-12 17:20:51 -070036 {
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080037 decode(in);
Jeff Thompson958bf9b2013-10-12 17:20:51 -070038 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070039
Jeff Thompson958bf9b2013-10-12 17:20:51 -070040 /**
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080041 * Create a new CertificateSubjectDescription.
42 * @param oid The oid of the subject description entry.
43 * @param value The value of the subject description entry.
Jeff Thompson958bf9b2013-10-12 17:20:51 -070044 */
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070045 CertificateSubjectDescription(const OID& oid, const std::string& value)
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070046 : m_oid(oid), m_value(value)
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080047 {
48 }
49
50 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070051 encode(CryptoPP::BufferedTransformation& out) const;
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080052
53 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070054 decode(CryptoPP::BufferedTransformation& in);
55
Jeff Thompson958bf9b2013-10-12 17:20:51 -070056 std::string
Jeff Thompson61a25ff2013-12-20 10:40:04 -080057 getOidString() const
Jeff Thompson958bf9b2013-10-12 17:20:51 -070058 {
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070059 return m_oid.toString();
Jeff Thompson958bf9b2013-10-12 17:20:51 -070060 }
61
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070062 const std::string&
Jeff Thompson958bf9b2013-10-12 17:20:51 -070063 getValue() const
64 {
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070065 return m_value;
Jeff Thompson958bf9b2013-10-12 17:20:51 -070066 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070067
Jeff Thompson958bf9b2013-10-12 17:20:51 -070068private:
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070069 OID m_oid;
70 std::string m_value;
Jeff Thompson958bf9b2013-10-12 17:20:51 -070071};
72
Yingdi Yufc40d872014-02-18 12:56:04 -080073} // namespace ndn
Jeff Thompson958bf9b2013-10-12 17:20:51 -070074
Yingdi Yufc40d872014-02-18 12:56:04 -080075#endif //NDN_SECURITY_CERTIFICATE_SUBJECT_DESCRIPTION_HPP