Jeff Thompson | fa30664 | 2013-06-17 15:06:57 -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 |
| 4 | * Alexander Afanasyev |
| 5 | * |
| 6 | * BSD license, See the LICENSE file for more information |
| 7 | * |
| 8 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 9 | */ |
| 10 | |
| 11 | #ifndef NDN_SIGNATURE_SHA256_WITH_RSA_H |
| 12 | #define NDN_SIGNATURE_SHA256_WITH_RSA_H |
| 13 | |
| 14 | #include "signature.h" |
| 15 | |
| 16 | #include "ndn-cpp/fields/blob.h" |
| 17 | #include "ndn-cpp/fields/key-locator.h" |
| 18 | |
| 19 | #include <string> |
| 20 | |
| 21 | namespace ndn { |
| 22 | |
| 23 | namespace signature { |
| 24 | |
| 25 | /** |
| 26 | * @brief Class providing operations to work with SHA256withRSA (OID: "2.16.840.1.101.3.4.2.1") |
| 27 | */ |
| 28 | class Sha256WithRsa : public virtual Signature |
| 29 | { |
| 30 | public: |
| 31 | /** |
| 32 | * @brief Virtual destructor |
| 33 | */ |
| 34 | virtual |
| 35 | ~Sha256WithRsa (); |
| 36 | |
| 37 | /** |
| 38 | * @brief Get OID of the signature algorithm |
| 39 | */ |
| 40 | inline const std::string & |
| 41 | getDigestAlgorithm () const; |
| 42 | |
| 43 | /** |
| 44 | * @brief Get reference to signature bits |
| 45 | */ |
| 46 | inline Blob & |
| 47 | getSignatureBits (); |
| 48 | |
| 49 | /** |
| 50 | * @brief Get const reference to signature bits |
| 51 | */ |
| 52 | inline const Blob & |
| 53 | getSignatureBits () const; |
| 54 | |
| 55 | /** |
| 56 | * @brief Set signature bits |
| 57 | */ |
| 58 | inline void |
| 59 | setSignatureBits (const Blob &signatureBits); |
| 60 | |
| 61 | /** |
| 62 | * @brief Get reference to publisher key digest bits |
| 63 | */ |
| 64 | inline Blob & |
| 65 | getPublisherKeyDigest (); |
| 66 | |
| 67 | /** |
| 68 | * @brief Get const reference to publisher key digest bits |
| 69 | */ |
| 70 | inline const Blob & |
| 71 | getPublisherKeyDigest () const; |
| 72 | |
| 73 | /** |
| 74 | * @brief Set publisher key digest bits |
| 75 | */ |
| 76 | inline void |
| 77 | setPublisherKeyDigest (const Blob &publisherKeyDigest); |
| 78 | |
| 79 | /** |
| 80 | * @brief Get reference to key locator object |
| 81 | */ |
| 82 | inline KeyLocator & |
| 83 | getKeyLocator (); |
| 84 | |
| 85 | /** |
| 86 | * @brief Get const reference to key locator object |
| 87 | */ |
| 88 | inline const KeyLocator & |
| 89 | getKeyLocator () const; |
| 90 | |
| 91 | /** |
| 92 | * @brief Set key locator object |
| 93 | */ |
| 94 | inline void |
| 95 | setKeyLocator (const KeyLocator &keyLocator); |
| 96 | |
| 97 | // from Signature |
| 98 | virtual void |
| 99 | doubleDispatch (std::ostream &os, wire::Base &wire, void *userData) const; |
| 100 | |
| 101 | private: |
| 102 | static const std::string s_oid; |
| 103 | |
| 104 | Blob m_signatureBits; |
| 105 | Blob m_publisherKeyDigest; |
| 106 | KeyLocator m_keyLocator; |
| 107 | }; |
| 108 | |
| 109 | const std::string & |
| 110 | Sha256WithRsa::getDigestAlgorithm () const |
| 111 | { |
| 112 | return s_oid; |
| 113 | } |
| 114 | |
| 115 | inline Blob & |
| 116 | Sha256WithRsa::getSignatureBits () |
| 117 | { |
| 118 | return m_signatureBits; |
| 119 | } |
| 120 | |
| 121 | inline const Blob & |
| 122 | Sha256WithRsa::getSignatureBits () const |
| 123 | { |
| 124 | return m_signatureBits; |
| 125 | } |
| 126 | |
| 127 | inline void |
| 128 | Sha256WithRsa::setSignatureBits (const Blob &signatureBits) |
| 129 | { |
| 130 | m_signatureBits = signatureBits; |
| 131 | } |
| 132 | |
| 133 | inline Blob & |
| 134 | Sha256WithRsa::getPublisherKeyDigest () |
| 135 | { |
| 136 | return m_publisherKeyDigest; |
| 137 | } |
| 138 | |
| 139 | inline const Blob & |
| 140 | Sha256WithRsa::getPublisherKeyDigest () const |
| 141 | { |
| 142 | return m_publisherKeyDigest; |
| 143 | } |
| 144 | |
| 145 | inline void |
| 146 | Sha256WithRsa::setPublisherKeyDigest (const Blob &publisherKeyDigest) |
| 147 | { |
| 148 | m_publisherKeyDigest = publisherKeyDigest; |
| 149 | } |
| 150 | |
| 151 | inline KeyLocator & |
| 152 | Sha256WithRsa::getKeyLocator () |
| 153 | { |
| 154 | return m_keyLocator; |
| 155 | } |
| 156 | |
| 157 | inline const KeyLocator & |
| 158 | Sha256WithRsa::getKeyLocator () const |
| 159 | { |
| 160 | return m_keyLocator; |
| 161 | } |
| 162 | |
| 163 | inline void |
| 164 | Sha256WithRsa::setKeyLocator (const KeyLocator &keyLocator) |
| 165 | { |
| 166 | m_keyLocator = keyLocator; |
| 167 | } |
| 168 | |
| 169 | } // signature |
| 170 | } // ndn |
| 171 | |
| 172 | #endif // NDN_EXCLUDE_H |