blob: 697993ca4172fefd8e1938663a960d667803f836 [file] [log] [blame]
Jeff Thompson958bf9b2013-10-12 17:20:51 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
3 * Copyright (C) 2013 Regents of the University of California.
Jeff Thompson173fd432013-10-12 18:16:41 -07004 * @author: Yingdi Yu <yingdi@cs.ucla.edu>
Jeff Thompson958bf9b2013-10-12 17:20:51 -07005 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
6 * See COPYING for copyright and distribution information.
7 */
8
9#ifndef NDN_CERTIFICATE_EXTENSION_HPP
10#define NDN_CERTIFICATE_EXTENSION_HPP
11
12#include "../../common.hpp"
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080013#include "../../encoding/buffer.hpp"
Jeff Thompson958bf9b2013-10-12 17:20:51 -070014#include "../../encoding/oid.hpp"
15
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080016namespace CryptoPP { class BufferedTransformation; }
Jeff Thompson958bf9b2013-10-12 17:20:51 -070017
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080018namespace ndn {
Jeff Thompson958bf9b2013-10-12 17:20:51 -070019
20/**
21 * A CertificateExtension represents the Extension entry in a certificate.
22 */
23class CertificateExtension
24{
25public:
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080026 CertificateExtension(CryptoPP::BufferedTransformation &in)
27 {
28 decode(in);
29 }
30
Jeff Thompson958bf9b2013-10-12 17:20:51 -070031 /**
32 * Create a new CertificateExtension.
33 * @param oid The oid of subject description entry.
34 * @param isCritical If true, the extension must be handled.
Jeff Thompson415da1e2013-10-17 16:52:59 -070035 * @param value The extension value.
Jeff Thompson958bf9b2013-10-12 17:20:51 -070036 */
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080037 CertificateExtension(const std::string& oid, const bool isCritical, const Buffer& value)
Jeff Thompson958bf9b2013-10-12 17:20:51 -070038 : extensionId_(oid), isCritical_(isCritical), extensionValue_(value)
39 {
40 }
41
42 /**
43 * Create a new CertificateExtension.
44 * @param oid The oid of subject description entry.
45 * @param isCritical If true, the extension must be handled.
Jeff Thompson415da1e2013-10-17 16:52:59 -070046 * @param value The extension value.
Jeff Thompson958bf9b2013-10-12 17:20:51 -070047 */
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080048 CertificateExtension(const OID& oid, const bool isCritical, const Buffer& value)
Jeff Thompson958bf9b2013-10-12 17:20:51 -070049 : extensionId_(oid), isCritical_(isCritical), extensionValue_(value)
50 {
51 }
52
53 /**
54 * The virtual destructor.
55 */
56 virtual
57 ~CertificateExtension() {}
58
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080059 void
60 encode(CryptoPP::BufferedTransformation &out) const;
Jeff Thompson958bf9b2013-10-12 17:20:51 -070061
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080062 void
63 decode(CryptoPP::BufferedTransformation &in);
64
Jeff Thompson958bf9b2013-10-12 17:20:51 -070065 inline const OID&
66 getOid() const { return extensionId_; }
67
68 inline const bool
69 getIsCritical() const { return isCritical_; }
70
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080071 inline const Buffer&
Jeff Thompson958bf9b2013-10-12 17:20:51 -070072 getValue() const { return extensionValue_; }
73
74protected:
75 OID extensionId_;
76 bool isCritical_;
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080077 Buffer extensionValue_;
Jeff Thompson958bf9b2013-10-12 17:20:51 -070078};
79
80}
81
82#endif