Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Jeff Thompson | 4147191 | 2013-09-12 16:21:50 -0700 | [diff] [blame] | 2 | /** |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 3 | * Copyright (C) 2013 Regents of the University of California. |
Jeff Thompson | 06e787d | 2013-09-12 19:00:55 -0700 | [diff] [blame] | 4 | * @author: Yingdi Yu <yingdi@cs.ucla.edu> |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 5 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
Jeff Thompson | 4147191 | 2013-09-12 16:21:50 -0700 | [diff] [blame] | 6 | * See COPYING for copyright and distribution information. |
| 7 | */ |
| 8 | |
| 9 | #ifndef NDN_IDENTITY_MANAGER_HPP |
Jeff Thompson | c69163b | 2013-10-12 13:49:50 -0700 | [diff] [blame] | 10 | #define NDN_IDENTITY_MANAGER_HPP |
Jeff Thompson | 4147191 | 2013-09-12 16:21:50 -0700 | [diff] [blame] | 11 | |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 12 | #include "identity-storage.hpp" |
Jeff Thompson | 86e1d75 | 2013-09-17 17:22:38 -0700 | [diff] [blame] | 13 | #include "private-key-storage.hpp" |
Alexander Afanasyev | bf1a67a | 2014-01-05 23:36:13 -0800 | [diff] [blame^] | 14 | #include "../certificate/public-key.hpp" |
Jeff Thompson | 4147191 | 2013-09-12 16:21:50 -0700 | [diff] [blame] | 15 | |
Alexander Afanasyev | 64a3d81 | 2014-01-05 23:35:05 -0800 | [diff] [blame] | 16 | #include "../../data.hpp" |
| 17 | |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 18 | namespace ndn { |
| 19 | |
Alexander Afanasyev | 64a3d81 | 2014-01-05 23:35:05 -0800 | [diff] [blame] | 20 | class IdentityCertificate; |
| 21 | |
Jeff Thompson | ffa36f9 | 2013-09-20 08:42:41 -0700 | [diff] [blame] | 22 | /** |
| 23 | * An IdentityManager is the interface of operations related to identity, keys, and certificates. |
| 24 | */ |
Jeff Thompson | 4147191 | 2013-09-12 16:21:50 -0700 | [diff] [blame] | 25 | class IdentityManager { |
| 26 | public: |
Alexander Afanasyev | 64a3d81 | 2014-01-05 23:35:05 -0800 | [diff] [blame] | 27 | struct Error : public std::runtime_error { Error(const std::string &what) : std::runtime_error(what) {} }; |
| 28 | |
Alexander Afanasyev | bf1a67a | 2014-01-05 23:36:13 -0800 | [diff] [blame^] | 29 | IdentityManager(const ptr_lib::shared_ptr<IdentityStorage> &identityStorage = DefaultIdentityStorage, |
| 30 | const ptr_lib::shared_ptr<PrivateKeyStorage> &privateKeyStorage = DefaultPrivateKeyStorage); |
| 31 | |
| 32 | inline IdentityStorage& |
| 33 | info(); |
| 34 | |
| 35 | inline const IdentityStorage& |
| 36 | info() const; |
| 37 | |
| 38 | inline PrivateKeyStorage& |
| 39 | tpm(); |
| 40 | |
| 41 | inline const PrivateKeyStorage& |
| 42 | tpm() const; |
Jeff Thompson | 86e1d75 | 2013-09-17 17:22:38 -0700 | [diff] [blame] | 43 | |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 44 | /** |
Jeff Thompson | e7e069b | 2013-09-27 15:48:48 -0700 | [diff] [blame] | 45 | * Create an identity by creating a pair of Key-Signing-Key (KSK) for this identity and a self-signed certificate of the KSK. |
| 46 | * @param identityName The name of the identity. |
| 47 | * @return The key name of the auto-generated KSK of the identity. |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 48 | */ |
| 49 | Name |
| 50 | createIdentity(const Name& identityName); |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 51 | |
| 52 | /** |
| 53 | * Get the default identity. |
| 54 | * @return The default identity name. |
| 55 | */ |
| 56 | Name |
| 57 | getDefaultIdentity() |
| 58 | { |
Alexander Afanasyev | bf1a67a | 2014-01-05 23:36:13 -0800 | [diff] [blame^] | 59 | return info().getDefaultIdentity(); |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 60 | } |
| 61 | |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 62 | /** |
Jeff Thompson | e7e069b | 2013-09-27 15:48:48 -0700 | [diff] [blame] | 63 | * Generate a pair of RSA keys for the specified identity. |
| 64 | * @param identityName The name of the identity. |
| 65 | * @param isKsk true for generating a Key-Signing-Key (KSK), false for a Data-Signing-Key (KSK). |
| 66 | * @param keySize The size of the key. |
| 67 | * @return The generated key name. |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 68 | */ |
| 69 | Name |
Jeff Thompson | e7e069b | 2013-09-27 15:48:48 -0700 | [diff] [blame] | 70 | generateRSAKeyPair(const Name& identityName, bool isKsk = false, int keySize = 2048); |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 71 | |
| 72 | /** |
Jeff Thompson | e7e069b | 2013-09-27 15:48:48 -0700 | [diff] [blame] | 73 | * Set a key as the default key of an identity. |
| 74 | * @param keyName The name of the key. |
| 75 | * @param identityName the name of the identity. If not specified, the identity name is inferred from the keyName. |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 76 | */ |
| 77 | void |
Jeff Thompson | e7e069b | 2013-09-27 15:48:48 -0700 | [diff] [blame] | 78 | setDefaultKeyForIdentity(const Name& keyName, const Name& identityName = Name()) |
| 79 | { |
Alexander Afanasyev | bf1a67a | 2014-01-05 23:36:13 -0800 | [diff] [blame^] | 80 | info().setDefaultKeyNameForIdentity(keyName, identityName); |
Jeff Thompson | e7e069b | 2013-09-27 15:48:48 -0700 | [diff] [blame] | 81 | } |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 82 | |
| 83 | /** |
Jeff Thompson | 18bf631 | 2013-10-04 11:23:55 -0700 | [diff] [blame] | 84 | * Get the default key for an identity. |
| 85 | * @param identityName the name of the identity. If omitted, the identity name is inferred from the keyName. |
| 86 | * @return The default key name. |
| 87 | */ |
| 88 | Name |
| 89 | getDefaultKeyNameForIdentity(const Name& identityName = Name()) |
| 90 | { |
Alexander Afanasyev | bf1a67a | 2014-01-05 23:36:13 -0800 | [diff] [blame^] | 91 | return info().getDefaultKeyNameForIdentity(identityName); |
Jeff Thompson | 18bf631 | 2013-10-04 11:23:55 -0700 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | /** |
Jeff Thompson | e7e069b | 2013-09-27 15:48:48 -0700 | [diff] [blame] | 95 | * Generate a pair of RSA keys for the specified identity and set it as default key for the identity. |
| 96 | * @param identityName The name of the identity. |
| 97 | * @param isKsk true for generating a Key-Signing-Key (KSK), false for a Data-Signing-Key (KSK). |
| 98 | * @param keySize The size of the key. |
| 99 | * @return The generated key name. |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 100 | */ |
| 101 | Name |
Jeff Thompson | e7e069b | 2013-09-27 15:48:48 -0700 | [diff] [blame] | 102 | generateRSAKeyPairAsDefault(const Name& identityName, bool isKsk = false, int keySize = 2048); |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 103 | |
| 104 | /** |
Jeff Thompson | e7e069b | 2013-09-27 15:48:48 -0700 | [diff] [blame] | 105 | * Get the public key with the specified name. |
| 106 | * @param keyName The name of the key. |
| 107 | * @return The public key. |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 108 | */ |
Alexander Afanasyev | bf1a67a | 2014-01-05 23:36:13 -0800 | [diff] [blame^] | 109 | ptr_lib::shared_ptr<PublicKey> |
| 110 | getPublicKey(const Name& keyName) |
| 111 | { |
| 112 | return info().getKey(keyName); |
| 113 | } |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 114 | |
| 115 | /** |
Jeff Thompson | c69163b | 2013-10-12 13:49:50 -0700 | [diff] [blame] | 116 | * Create an identity certificate for a public key managed by this IdentityManager. |
Jeff Thompson | 418b05a | 2013-10-22 17:48:54 -0700 | [diff] [blame] | 117 | * @param certificatePrefix The name of public key to be signed. |
Jeff Thompson | c69163b | 2013-10-12 13:49:50 -0700 | [diff] [blame] | 118 | * @param signerCertificateName The name of signing certificate. |
| 119 | * @param notBefore The notBefore value in the validity field of the generated certificate. |
| 120 | * @param notAfter The notAfter vallue in validity field of the generated certificate. |
| 121 | * @return The name of generated identity certificate. |
| 122 | */ |
Alexander Afanasyev | bf1a67a | 2014-01-05 23:36:13 -0800 | [diff] [blame^] | 123 | ptr_lib::shared_ptr<IdentityCertificate> |
Jeff Thompson | 418b05a | 2013-10-22 17:48:54 -0700 | [diff] [blame] | 124 | createIdentityCertificate |
Alexander Afanasyev | bf1a67a | 2014-01-05 23:36:13 -0800 | [diff] [blame^] | 125 | (const Name& certificatePrefix, |
| 126 | const Name& signerCertificateName, |
| 127 | const MillisecondsSince1970& notBefore, |
Jeff Thompson | 418b05a | 2013-10-22 17:48:54 -0700 | [diff] [blame] | 128 | const MillisecondsSince1970& notAfter); |
Jeff Thompson | c69163b | 2013-10-12 13:49:50 -0700 | [diff] [blame] | 129 | |
| 130 | /** |
| 131 | * Create an identity certificate for a public key supplied by the caller. |
Jeff Thompson | 418b05a | 2013-10-22 17:48:54 -0700 | [diff] [blame] | 132 | * @param certificatePrefix The name of public key to be signed. |
Jeff Thompson | c69163b | 2013-10-12 13:49:50 -0700 | [diff] [blame] | 133 | * @param publickey The public key to be signed. |
| 134 | * @param signerCertificateName The name of signing certificate. |
| 135 | * @param notBefore The notBefore value in the validity field of the generated certificate. |
| 136 | * @param notAfter The notAfter vallue in validity field of the generated certificate. |
| 137 | * @return The generated identity certificate. |
| 138 | */ |
| 139 | ptr_lib::shared_ptr<IdentityCertificate> |
| 140 | createIdentityCertificate |
Alexander Afanasyev | bf1a67a | 2014-01-05 23:36:13 -0800 | [diff] [blame^] | 141 | (const Name& certificatePrefix, |
| 142 | const PublicKey& publickey, |
| 143 | const Name& signerCertificateName, |
| 144 | const MillisecondsSince1970& notBefore, |
| 145 | const MillisecondsSince1970& notAfter); |
Jeff Thompson | c69163b | 2013-10-12 13:49:50 -0700 | [diff] [blame] | 146 | |
| 147 | /** |
Jeff Thompson | e7e069b | 2013-09-27 15:48:48 -0700 | [diff] [blame] | 148 | * Add a certificate into the public key identity storage. |
Jeff Thompson | c69163b | 2013-10-12 13:49:50 -0700 | [diff] [blame] | 149 | * @param certificate The certificate to to added. This makes a copy of the certificate. |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 150 | */ |
| 151 | void |
Jeff Thompson | c69163b | 2013-10-12 13:49:50 -0700 | [diff] [blame] | 152 | addCertificate(const IdentityCertificate& certificate) |
Jeff Thompson | e7e069b | 2013-09-27 15:48:48 -0700 | [diff] [blame] | 153 | { |
Alexander Afanasyev | bf1a67a | 2014-01-05 23:36:13 -0800 | [diff] [blame^] | 154 | info().addCertificate(certificate); |
Jeff Thompson | e7e069b | 2013-09-27 15:48:48 -0700 | [diff] [blame] | 155 | } |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 156 | |
| 157 | /** |
Jeff Thompson | e7e069b | 2013-09-27 15:48:48 -0700 | [diff] [blame] | 158 | * Set the certificate as the default for its corresponding key. |
Jeff Thompson | 418b05a | 2013-10-22 17:48:54 -0700 | [diff] [blame] | 159 | * @param certificateName The certificate. |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 160 | */ |
| 161 | void |
Jeff Thompson | 418b05a | 2013-10-22 17:48:54 -0700 | [diff] [blame] | 162 | setDefaultCertificateForKey(const IdentityCertificate& certificate); |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 163 | |
| 164 | /** |
Jeff Thompson | e7e069b | 2013-09-27 15:48:48 -0700 | [diff] [blame] | 165 | * Add a certificate into the public key identity storage and set the certificate as the default for its corresponding identity. |
Jeff Thompson | c69163b | 2013-10-12 13:49:50 -0700 | [diff] [blame] | 166 | * @param certificate The certificate to be added. This makes a copy of the certificate. |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 167 | */ |
| 168 | void |
Jeff Thompson | c69163b | 2013-10-12 13:49:50 -0700 | [diff] [blame] | 169 | addCertificateAsIdentityDefault(const IdentityCertificate& certificate); |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 170 | |
| 171 | /** |
Jeff Thompson | e7e069b | 2013-09-27 15:48:48 -0700 | [diff] [blame] | 172 | * Add a certificate into the public key identity storage and set the certificate as the default of its corresponding key. |
Jeff Thompson | c69163b | 2013-10-12 13:49:50 -0700 | [diff] [blame] | 173 | * @param certificate The certificate to be added. This makes a copy of the certificate. |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 174 | */ |
| 175 | void |
Jeff Thompson | c69163b | 2013-10-12 13:49:50 -0700 | [diff] [blame] | 176 | addCertificateAsDefault(const IdentityCertificate& certificate); |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 177 | |
| 178 | /** |
Jeff Thompson | e7e069b | 2013-09-27 15:48:48 -0700 | [diff] [blame] | 179 | * Get a certificate with the specified name. |
| 180 | * @param certificateName The name of the requested certificate. |
| 181 | * @return the requested certificate which is valid. |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 182 | */ |
Alexander Afanasyev | bf1a67a | 2014-01-05 23:36:13 -0800 | [diff] [blame^] | 183 | ptr_lib::shared_ptr<IdentityCertificate> |
| 184 | getCertificate(const Name& certificateName) |
| 185 | { |
| 186 | return info().getCertificate(certificateName, false); |
| 187 | } |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 188 | |
| 189 | /** |
Jeff Thompson | e7e069b | 2013-09-27 15:48:48 -0700 | [diff] [blame] | 190 | * Get a certificate even if the certificate is not valid anymore. |
| 191 | * @param certificateName The name of the requested certificate. |
| 192 | * @return the requested certificate. |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 193 | */ |
Alexander Afanasyev | bf1a67a | 2014-01-05 23:36:13 -0800 | [diff] [blame^] | 194 | ptr_lib::shared_ptr<IdentityCertificate> |
| 195 | getAnyCertificate(const Name& certificateName) |
| 196 | { |
| 197 | return info().getCertificate(certificateName, true); |
| 198 | } |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 199 | |
| 200 | /** |
| 201 | * Get the default certificate name for the specified identity, which will be used when signing is performed based on identity. |
| 202 | * @param identityName The name of the specified identity. |
| 203 | * @return The requested certificate name. |
| 204 | */ |
| 205 | Name |
| 206 | getDefaultCertificateNameForIdentity(const Name& identityName) |
| 207 | { |
Alexander Afanasyev | bf1a67a | 2014-01-05 23:36:13 -0800 | [diff] [blame^] | 208 | return info().getDefaultCertificateNameForIdentity(identityName); |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | /** |
| 212 | * Get the default certificate name of the default identity, which will be used when signing is based on identity and |
| 213 | * the identity is not specified. |
| 214 | * @return The requested certificate name. |
| 215 | */ |
| 216 | Name |
| 217 | getDefaultCertificateName() |
| 218 | { |
Alexander Afanasyev | bf1a67a | 2014-01-05 23:36:13 -0800 | [diff] [blame^] | 219 | return info().getDefaultCertificateNameForIdentity(getDefaultIdentity()); |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 220 | } |
| 221 | |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 222 | /** |
Jeff Thompson | c69163b | 2013-10-12 13:49:50 -0700 | [diff] [blame] | 223 | * Sign the byte array data based on the certificate name. |
Jeff Thompson | c01e178 | 2013-10-21 14:08:42 -0700 | [diff] [blame] | 224 | * @param buffer The byte array to be signed. |
| 225 | * @param bufferLength the length of buffer. |
Jeff Thompson | c69163b | 2013-10-12 13:49:50 -0700 | [diff] [blame] | 226 | * @param certificateName The signing certificate name. |
| 227 | * @return The generated signature. |
Jeff Thompson | 9296f0c | 2013-09-23 18:10:27 -0700 | [diff] [blame] | 228 | */ |
Alexander Afanasyev | 64a3d81 | 2014-01-05 23:35:05 -0800 | [diff] [blame] | 229 | Signature |
Jeff Thompson | c01e178 | 2013-10-21 14:08:42 -0700 | [diff] [blame] | 230 | signByCertificate(const uint8_t* buffer, size_t bufferLength, const Name& certificateName); |
| 231 | |
| 232 | /** |
Jeff Thompson | 86e1d75 | 2013-09-17 17:22:38 -0700 | [diff] [blame] | 233 | * Sign data packet based on the certificate name. |
Jeff Thompson | 4147191 | 2013-09-12 16:21:50 -0700 | [diff] [blame] | 234 | * Note: the caller must make sure the timestamp in data is correct, for example with |
| 235 | * data.getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0). |
| 236 | * @param data The Data object to sign and update its signature. |
| 237 | * @param certificateName The Name identifying the certificate which identifies the signing key. |
| 238 | * @param wireFormat The WireFormat for calling encodeData, or WireFormat::getDefaultWireFormat() if omitted. |
| 239 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 240 | void |
Alexander Afanasyev | 64a3d81 | 2014-01-05 23:35:05 -0800 | [diff] [blame] | 241 | signByCertificate(Data& data, const Name& certificateName); |
Jeff Thompson | 418b05a | 2013-10-22 17:48:54 -0700 | [diff] [blame] | 242 | |
| 243 | /** |
| 244 | * Generate a self-signed certificate for a public key. |
| 245 | * @param keyName The name of the public key. |
| 246 | * @return The generated certificate. |
| 247 | */ |
| 248 | ptr_lib::shared_ptr<IdentityCertificate> |
| 249 | selfSign(const Name& keyName); |
Alexander Afanasyev | bf1a67a | 2014-01-05 23:36:13 -0800 | [diff] [blame^] | 250 | |
| 251 | /** |
| 252 | * @brief Self-sign the supplied identity certificate |
| 253 | */ |
| 254 | void |
| 255 | selfSign (IdentityCertificate& cert); |
| 256 | |
| 257 | public: |
| 258 | static const ptr_lib::shared_ptr<IdentityStorage> DefaultIdentityStorage; |
| 259 | static const ptr_lib::shared_ptr<PrivateKeyStorage> DefaultPrivateKeyStorage; |
Jeff Thompson | 86e1d75 | 2013-09-17 17:22:38 -0700 | [diff] [blame] | 260 | |
| 261 | private: |
Jeff Thompson | e7e069b | 2013-09-27 15:48:48 -0700 | [diff] [blame] | 262 | /** |
| 263 | * Generate a key pair for the specified identity. |
| 264 | * @param identityName The name of the specified identity. |
| 265 | * @param isKsk true for generating a Key-Signing-Key (KSK), false for a Data-Signing-Key (KSK). |
| 266 | * @param keyType The type of the key pair, e.g. KEY_TYPE_RSA. |
| 267 | * @param keySize The size of the key pair. |
| 268 | * @return The name of the generated key. |
| 269 | */ |
| 270 | Name |
| 271 | generateKeyPair(const Name& identityName, bool isKsk = false, KeyType keyType = KEY_TYPE_RSA, int keySize = 2048); |
| 272 | |
Jeff Thompson | 418b05a | 2013-10-22 17:48:54 -0700 | [diff] [blame] | 273 | static Name |
| 274 | getKeyNameFromCertificatePrefix(const Name& certificatePrefix); |
Alexander Afanasyev | bf1a67a | 2014-01-05 23:36:13 -0800 | [diff] [blame^] | 275 | |
| 276 | private: |
| 277 | ptr_lib::shared_ptr<IdentityStorage> identityStorage_; |
Jeff Thompson | 86e1d75 | 2013-09-17 17:22:38 -0700 | [diff] [blame] | 278 | ptr_lib::shared_ptr<PrivateKeyStorage> privateKeyStorage_; |
Jeff Thompson | 4147191 | 2013-09-12 16:21:50 -0700 | [diff] [blame] | 279 | }; |
| 280 | |
Alexander Afanasyev | bf1a67a | 2014-01-05 23:36:13 -0800 | [diff] [blame^] | 281 | inline IdentityStorage& |
| 282 | IdentityManager::info() |
| 283 | { |
| 284 | if (!identityStorage_) |
| 285 | throw Error("IdentityStorage is not assigned to IdentityManager"); |
| 286 | |
| 287 | return *identityStorage_; |
| 288 | } |
| 289 | |
| 290 | inline const IdentityStorage& |
| 291 | IdentityManager::info() const |
| 292 | { |
| 293 | if (!identityStorage_) |
| 294 | throw Error("IdentityStorage is not assigned to IdentityManager"); |
| 295 | |
| 296 | return *identityStorage_; |
| 297 | } |
| 298 | |
| 299 | inline PrivateKeyStorage& |
| 300 | IdentityManager::tpm() |
| 301 | { |
| 302 | if (!identityStorage_) |
| 303 | throw Error("PrivateKeyStorage is not assigned to IdentityManager"); |
| 304 | |
| 305 | return *privateKeyStorage_; |
| 306 | } |
| 307 | |
| 308 | inline const PrivateKeyStorage& |
| 309 | IdentityManager::tpm() const |
| 310 | { |
| 311 | if (!identityStorage_) |
| 312 | throw Error("PrivateKeyStorage is not assigned to IdentityManager"); |
| 313 | return *privateKeyStorage_; |
| 314 | } |
| 315 | |
| 316 | |
| 317 | |
Jeff Thompson | 4147191 | 2013-09-12 16:21:50 -0700 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | #endif |