blob: d979d443b4373df0f0469b537af9329cc11ecf9c [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 }
Jeff Thompson958bf9b2013-10-12 17:20:51 -070030
31 /**
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 OID& oid, const bool isCritical, const Buffer& value)
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080038 : extensionId_(oid), isCritical_(isCritical), extensionValue_(value)
Jeff Thompson958bf9b2013-10-12 17:20:51 -070039 {
40 }
41
Alexander Afanasyev049f8f72013-12-26 19:07:15 -080042 CertificateExtension(const OID& oid, const bool isCritical, const uint8_t* value, size_t valueSize)
43 : extensionId_(oid), isCritical_(isCritical), extensionValue_(value, valueSize)
44 {
45 }
46
Jeff Thompson958bf9b2013-10-12 17:20:51 -070047 /**
48 * The virtual destructor.
49 */
50 virtual
51 ~CertificateExtension() {}
52
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080053 void
54 encode(CryptoPP::BufferedTransformation &out) const;
Jeff Thompson958bf9b2013-10-12 17:20:51 -070055
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080056 void
57 decode(CryptoPP::BufferedTransformation &in);
58
Jeff Thompson958bf9b2013-10-12 17:20:51 -070059 inline const OID&
60 getOid() const { return extensionId_; }
61
62 inline const bool
63 getIsCritical() const { return isCritical_; }
64
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080065 inline const Buffer&
Jeff Thompson958bf9b2013-10-12 17:20:51 -070066 getValue() const { return extensionValue_; }
67
68protected:
69 OID extensionId_;
70 bool isCritical_;
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080071 Buffer extensionValue_;
Jeff Thompson958bf9b2013-10-12 17:20:51 -070072};
73
74}
75
76#endif