Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2013 Regents of the University of California. |
Jeff Thompson | 173fd43 | 2013-10-12 18:16:41 -0700 | [diff] [blame] | 4 | * @author: Yingdi Yu <yingdi@cs.ucla.edu> |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 5 | * @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 Afanasyev | 0ea6e08 | 2013-12-26 15:16:37 -0800 | [diff] [blame^] | 13 | #include "../../encoding/buffer.hpp" |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 14 | #include "../../encoding/oid.hpp" |
| 15 | |
Alexander Afanasyev | 0ea6e08 | 2013-12-26 15:16:37 -0800 | [diff] [blame^] | 16 | namespace CryptoPP { class BufferedTransformation; } |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 17 | |
Alexander Afanasyev | 0ea6e08 | 2013-12-26 15:16:37 -0800 | [diff] [blame^] | 18 | namespace ndn { |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 19 | |
| 20 | /** |
| 21 | * A CertificateExtension represents the Extension entry in a certificate. |
| 22 | */ |
| 23 | class CertificateExtension |
| 24 | { |
| 25 | public: |
Alexander Afanasyev | 0ea6e08 | 2013-12-26 15:16:37 -0800 | [diff] [blame^] | 26 | CertificateExtension(CryptoPP::BufferedTransformation &in) |
| 27 | { |
| 28 | decode(in); |
| 29 | } |
| 30 | |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 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 Thompson | 415da1e | 2013-10-17 16:52:59 -0700 | [diff] [blame] | 35 | * @param value The extension value. |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 36 | */ |
Alexander Afanasyev | 0ea6e08 | 2013-12-26 15:16:37 -0800 | [diff] [blame^] | 37 | CertificateExtension(const std::string& oid, const bool isCritical, const Buffer& value) |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 38 | : 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 Thompson | 415da1e | 2013-10-17 16:52:59 -0700 | [diff] [blame] | 46 | * @param value The extension value. |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 47 | */ |
Alexander Afanasyev | 0ea6e08 | 2013-12-26 15:16:37 -0800 | [diff] [blame^] | 48 | CertificateExtension(const OID& oid, const bool isCritical, const Buffer& value) |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 49 | : extensionId_(oid), isCritical_(isCritical), extensionValue_(value) |
| 50 | { |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * The virtual destructor. |
| 55 | */ |
| 56 | virtual |
| 57 | ~CertificateExtension() {} |
| 58 | |
Alexander Afanasyev | 0ea6e08 | 2013-12-26 15:16:37 -0800 | [diff] [blame^] | 59 | void |
| 60 | encode(CryptoPP::BufferedTransformation &out) const; |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 61 | |
Alexander Afanasyev | 0ea6e08 | 2013-12-26 15:16:37 -0800 | [diff] [blame^] | 62 | void |
| 63 | decode(CryptoPP::BufferedTransformation &in); |
| 64 | |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 65 | inline const OID& |
| 66 | getOid() const { return extensionId_; } |
| 67 | |
| 68 | inline const bool |
| 69 | getIsCritical() const { return isCritical_; } |
| 70 | |
Alexander Afanasyev | 0ea6e08 | 2013-12-26 15:16:37 -0800 | [diff] [blame^] | 71 | inline const Buffer& |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 72 | getValue() const { return extensionValue_; } |
| 73 | |
| 74 | protected: |
| 75 | OID extensionId_; |
| 76 | bool isCritical_; |
Alexander Afanasyev | 0ea6e08 | 2013-12-26 15:16:37 -0800 | [diff] [blame^] | 77 | Buffer extensionValue_; |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | } |
| 81 | |
| 82 | #endif |