blob: 778732b170fb03c880e124603a78c848234f2c29 [file] [log] [blame]
Jeff Thompson25b4e612013-10-10 16:03:24 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Jeff Thompson47c93cf2013-08-09 00:38:48 -07002/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07003 * Copyright (C) 2013 Regents of the University of California.
Jeff Thompsonba16b8f2013-12-16 13:11:47 -08004 * @author: Yingdi Yu <yingdi@cs.ucla.edu>
Jeff Thompson7687dc02013-09-13 11:54:07 -07005 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompson47c93cf2013-08-09 00:38:48 -07006 * See COPYING for copyright and distribution information.
7 */
8
9#ifndef NDN_KEY_CHAIN_HPP
Jeff Thompson2d27e2f2013-08-09 12:55:00 -070010#define NDN_KEY_CHAIN_HPP
Jeff Thompson47c93cf2013-08-09 00:38:48 -070011
Yingdi Yu4f324632014-01-15 18:10:03 -080012#include "identity-certificate.hpp"
13#include "public-key.hpp"
14#include "signature-sha256-with-rsa.hpp"
Yingdi Yu4270f202014-01-28 14:19:16 -080015#include "../interest.hpp"
Yingdi Yu31b4af22014-01-14 14:13:00 -080016
Yingdi Yu04020922014-01-22 12:46:53 -080017//PublicInfo
Yingdi Yu4f324632014-01-15 18:10:03 -080018#include "sec-public-info-sqlite3.hpp"
19#include "sec-public-info-memory.hpp"
Yingdi Yu04020922014-01-22 12:46:53 -080020//TPM
21#include "sec-tpm-file.hpp"
Yingdi Yu4f324632014-01-15 18:10:03 -080022#include "sec-tpm-memory.hpp"
Yingdi Yu2abd73f2014-01-08 23:34:11 -080023
Yingdi Yu04020922014-01-22 12:46:53 -080024#ifdef NDN_CPP_HAVE_OSX_SECURITY
25#include "sec-tpm-osx.hpp"
26#endif
27
Jeff Thompson47c93cf2013-08-09 00:38:48 -070028
29namespace ndn {
30
Jeff Thompson2ce8f492013-09-17 18:01:25 -070031/**
Yingdi Yu2abd73f2014-01-08 23:34:11 -080032 * KeyChain is one of the main classes of the security library.
Jeff Thompsonffa36f92013-09-20 08:42:41 -070033 *
Yingdi Yu2abd73f2014-01-08 23:34:11 -080034 * The KeyChain class provides a set of interfaces of identity management and private key related operations.
Jeff Thompsonffa36f92013-09-20 08:42:41 -070035 */
Yingdi Yu31b4af22014-01-14 14:13:00 -080036template<class Info, class Tpm>
37class KeyChainImpl : public Info, public Tpm
38{
Yingdi Yu4270f202014-01-28 14:19:16 -080039 typedef typename Info::Error InfoError;
Jeff Thompson47c93cf2013-08-09 00:38:48 -070040public:
Yingdi Yu2abd73f2014-01-08 23:34:11 -080041
42 /**
43 * Create an identity by creating a pair of Key-Signing-Key (KSK) for this identity and a self-signed certificate of the KSK.
44 * @param identityName The name of the identity.
45 * @return The key name of the auto-generated KSK of the identity.
46 */
47 Name
Yingdi Yu31b4af22014-01-14 14:13:00 -080048 createIdentity(const Name& identityName)
49 {
50 if (!Info::doesIdentityExist(identityName)) {
51 Info::addIdentity(identityName);
52
53 Name keyName = generateRSAKeyPairAsDefault(identityName, true);
54
55 ptr_lib::shared_ptr<IdentityCertificate> selfCert = selfSign(keyName);
56
Yingdi Yu4270f202014-01-28 14:19:16 -080057 Info::addCertificateAsIdentityDefault(*selfCert);
Yingdi Yu31b4af22014-01-14 14:13:00 -080058
59 return keyName;
60 }
61 else
62 return Name();
63 }
Yingdi Yu2abd73f2014-01-08 23:34:11 -080064
65 /**
Yingdi Yu2abd73f2014-01-08 23:34:11 -080066 * Generate a pair of RSA keys for the specified identity.
67 * @param identityName The name of the identity.
68 * @param isKsk true for generating a Key-Signing-Key (KSK), false for a Data-Signing-Key (KSK).
69 * @param keySize The size of the key.
70 * @return The generated key name.
71 */
72 Name
Yingdi Yu31b4af22014-01-14 14:13:00 -080073 generateRSAKeyPair(const Name& identityName, bool isKsk = false, int keySize = 2048)
Yingdi Yu2abd73f2014-01-08 23:34:11 -080074 {
Yingdi Yu31b4af22014-01-14 14:13:00 -080075 return generateKeyPair(identityName, isKsk, KEY_TYPE_RSA, keySize);
Yingdi Yu2abd73f2014-01-08 23:34:11 -080076 }
Alexander Afanasyev64a3d812014-01-05 23:35:05 -080077
Yingdi Yu2abd73f2014-01-08 23:34:11 -080078 /**
79 * Generate a pair of RSA keys for the specified identity and set it as default key for the identity.
80 * @param identityName The name of the identity.
81 * @param isKsk true for generating a Key-Signing-Key (KSK), false for a Data-Signing-Key (KSK).
82 * @param keySize The size of the key.
83 * @return The generated key name.
84 */
85 Name
Yingdi Yu31b4af22014-01-14 14:13:00 -080086 generateRSAKeyPairAsDefault(const Name& identityName, bool isKsk = false, int keySize = 2048)
87 {
88 Name keyName = generateKeyPair(identityName, isKsk, KEY_TYPE_RSA, keySize);
89
90 Info::setDefaultKeyNameForIdentity(keyName);
Yingdi Yu31b4af22014-01-14 14:13:00 -080091
92 return keyName;
93 }
Jeff Thompson79a2d5d2013-09-27 14:32:23 -070094
Yingdi Yu2abd73f2014-01-08 23:34:11 -080095 /**
Yingdi Yu2abd73f2014-01-08 23:34:11 -080096 * Create an identity certificate for a public key managed by this IdentityManager.
97 * @param certificatePrefix The name of public key to be signed.
98 * @param signerCertificateName The name of signing certificate.
99 * @param notBefore The notBefore value in the validity field of the generated certificate.
100 * @param notAfter The notAfter vallue in validity field of the generated certificate.
101 * @return The name of generated identity certificate.
102 */
103 ptr_lib::shared_ptr<IdentityCertificate>
104 createIdentityCertificate
105 (const Name& certificatePrefix,
106 const Name& signerCertificateName,
107 const MillisecondsSince1970& notBefore,
Yingdi Yu31b4af22014-01-14 14:13:00 -0800108 const MillisecondsSince1970& notAfter)
109 {
110 Name keyName = getKeyNameFromCertificatePrefix(certificatePrefix);
111
112 ptr_lib::shared_ptr<PublicKey> pubKey = Info::getPublicKey(keyName);
113 if (!pubKey)
Yingdi Yu4270f202014-01-28 14:19:16 -0800114 throw InfoError("Requested public key [" + keyName.toUri() + "] doesn't exist");
Yingdi Yu31b4af22014-01-14 14:13:00 -0800115
116 ptr_lib::shared_ptr<IdentityCertificate> certificate =
117 createIdentityCertificate(certificatePrefix,
118 *pubKey,
119 signerCertificateName,
120 notBefore, notAfter);
121
122 Info::addCertificate(*certificate);
123
124 return certificate;
125 }
126
Jeff Thompson79a2d5d2013-09-27 14:32:23 -0700127
Yingdi Yu2abd73f2014-01-08 23:34:11 -0800128 /**
129 * Create an identity certificate for a public key supplied by the caller.
130 * @param certificatePrefix The name of public key to be signed.
131 * @param publickey The public key to be signed.
132 * @param signerCertificateName The name of signing certificate.
133 * @param notBefore The notBefore value in the validity field of the generated certificate.
134 * @param notAfter The notAfter vallue in validity field of the generated certificate.
135 * @return The generated identity certificate.
136 */
137 ptr_lib::shared_ptr<IdentityCertificate>
138 createIdentityCertificate
139 (const Name& certificatePrefix,
Yingdi Yu31b4af22014-01-14 14:13:00 -0800140 const PublicKey& publicKey,
Yingdi Yu2abd73f2014-01-08 23:34:11 -0800141 const Name& signerCertificateName,
142 const MillisecondsSince1970& notBefore,
Yingdi Yu31b4af22014-01-14 14:13:00 -0800143 const MillisecondsSince1970& notAfter)
Yingdi Yu2abd73f2014-01-08 23:34:11 -0800144 {
Yingdi Yu31b4af22014-01-14 14:13:00 -0800145 ptr_lib::shared_ptr<IdentityCertificate> certificate (new IdentityCertificate());
146 Name keyName = getKeyNameFromCertificatePrefix(certificatePrefix);
147
148 Name certificateName = certificatePrefix;
149 certificateName.append("ID-CERT").appendVersion();
150
151 certificate->setName(certificateName);
152 certificate->setNotBefore(notBefore);
153 certificate->setNotAfter(notAfter);
154 certificate->setPublicKeyInfo(publicKey);
155 certificate->addSubjectDescription(CertificateSubjectDescription("2.5.4.41", keyName.toUri()));
156 certificate->encode();
157
158 sign(*certificate, signerCertificateName);
159
160 return certificate;
Alexander Afanasyevbf1a67a2014-01-05 23:36:13 -0800161 }
162
Yingdi Yu2abd73f2014-01-08 23:34:11 -0800163 void
Yingdi Yu31b4af22014-01-14 14:13:00 -0800164 sign(Data &data)
165 {
166 if (!Info::defaultCertificate())
167 {
168 Info::refreshDefaultCertificate();
169
170 if(!Info::defaultCertificate())
Yingdi Yu4270f202014-01-28 14:19:16 -0800171 throw InfoError("Default IdentityCertificate cannot be determined");
Yingdi Yu31b4af22014-01-14 14:13:00 -0800172 }
173
174 sign(data, *Info::defaultCertificate());
175 }
Yingdi Yu4270f202014-01-28 14:19:16 -0800176
177 void
178 sign(Interest &interest)
179 {
180 if (!Info::defaultCertificate())
181 {
182 Info::refreshDefaultCertificate();
183
184 if(!Info::defaultCertificate())
185 throw InfoError("Default IdentityCertificate cannot be determined");
186 }
187
188 sign(interest, *Info::defaultCertificate());
189 }
Alexander Afanasyeve64788e2014-01-05 22:38:21 -0800190
Jeff Thompson47c93cf2013-08-09 00:38:48 -0700191 /**
Jeff Thompson2ce8f492013-09-17 18:01:25 -0700192 * Wire encode the Data object, sign it and set its signature.
Jeff Thompson2ce8f492013-09-17 18:01:25 -0700193 * @param data The Data object to be signed. This updates its signature and key locator field and wireEncoding.
Jeff Thompson9296f0c2013-09-23 18:10:27 -0700194 * @param certificateName The certificate name of the key to use for signing. If omitted, infer the signing identity from the data packet name.
Jeff Thompson3c73da42013-08-12 11:19:05 -0700195 */
Yingdi Yu2abd73f2014-01-08 23:34:11 -0800196 void
Yingdi Yu31b4af22014-01-14 14:13:00 -0800197 sign(Data& data, const Name& certificateName)
198 {
199 ptr_lib::shared_ptr<IdentityCertificate> cert = Info::getCertificate(certificateName);
200 if (!cert)
Yingdi Yu4270f202014-01-28 14:19:16 -0800201 throw InfoError("Requested certificate [" + certificateName.toUri() + "] doesn't exist");
Yingdi Yu31b4af22014-01-14 14:13:00 -0800202
203 SignatureSha256WithRsa signature;
204 signature.setKeyLocator(certificateName.getPrefix(-1)); // implicit conversion should take care
205 data.setSignature(signature);
206
207 // For temporary usage, we support RSA + SHA256 only, but will support more.
Yingdi Yu8726f652014-01-23 10:35:12 -0800208 signDataInTpm(data, cert->getPublicKeyName(), DIGEST_ALGORITHM_SHA256);
Yingdi Yu31b4af22014-01-14 14:13:00 -0800209 }
Yingdi Yu2abd73f2014-01-08 23:34:11 -0800210
211 void
Yingdi Yu4270f202014-01-28 14:19:16 -0800212 sign(Interest &interest, const Name &certificateName)
213 {
214 ptr_lib::shared_ptr<IdentityCertificate> cert = Info::getCertificate(certificateName);
215 if(!static_cast<bool>(cert))
216 throw InfoError("Requested certificate [" + certificateName.toUri() + "] doesn't exist");
217
218 SignatureSha256WithRsa signature;
219 signature.setKeyLocator(certificateName.getPrefix(-1)); // implicit conversion should take care
220
221 Name interestName = interest.getName().append(Name::Component::fromNumber(getNow())).append(signature.getInfo());
222
223 signature.setValue(Tpm::signInTpm(interestName.wireEncode().value(),
224 interestName.wireEncode().value_size(),
225 cert->getPublicKeyName(),
226 DIGEST_ALGORITHM_SHA256));
227
228 interest.getName().append(signature.getValue());
229 }
230
231 void
232 sign(Data &data, const IdentityCertificate& certificate)
Yingdi Yu31b4af22014-01-14 14:13:00 -0800233 {
234 SignatureSha256WithRsa signature;
235 signature.setKeyLocator(certificate.getName().getPrefix(-1));
236 data.setSignature(signature);
237
238 // For temporary usage, we support RSA + SHA256 only, but will support more.
Yingdi Yu8726f652014-01-23 10:35:12 -0800239 signDataInTpm(data, certificate.getPublicKeyName(), DIGEST_ALGORITHM_SHA256);
Yingdi Yu31b4af22014-01-14 14:13:00 -0800240 }
Yingdi Yu4270f202014-01-28 14:19:16 -0800241
242 void
243 sign(Interest &interest, const IdentityCertificate& certificate)
244 {
245 SignatureSha256WithRsa signature;
246 signature.setKeyLocator(certificate.getName().getPrefix(-1)); // implicit conversion should take care
247
248 Name &interestName = interest.getName();
249 interestName.append(Name::Component::fromNumber(getNow())).append(signature.getInfo());
250
251 signature.setValue(Tpm::signInTpm(interestName.wireEncode().value(),
252 interestName.wireEncode().value_size(),
253 certificate.getPublicKeyName(),
254 DIGEST_ALGORITHM_SHA256));
255
256 interestName.append(signature.getValue());
257 }
Jeff Thompson79a2d5d2013-09-27 14:32:23 -0700258
Jeff Thompson29ce3102013-09-27 11:47:48 -0700259 /**
Jeff Thompsonc01e1782013-10-21 14:08:42 -0700260 * Sign the byte array using a certificate name and return a Signature object.
261 * @param buffer The byte array to be signed.
262 * @param bufferLength the length of buffer.
263 * @param certificateName The certificate name used to get the signing key and which will be put into KeyLocator.
264 * @return The Signature.
265 */
Yingdi Yu2abd73f2014-01-08 23:34:11 -0800266 Signature
Yingdi Yu31b4af22014-01-14 14:13:00 -0800267 sign(const uint8_t* buffer, size_t bufferLength, const Name& certificateName)
268 {
269 ptr_lib::shared_ptr<IdentityCertificate> cert = Info::getCertificate(certificateName);
Yingdi Yu4270f202014-01-28 14:19:16 -0800270 if (!static_cast<bool>(cert))
271 throw InfoError("Requested certificate [" + certificateName.toUri() + "] doesn't exist");
Yingdi Yu31b4af22014-01-14 14:13:00 -0800272
273 SignatureSha256WithRsa signature;
274 signature.setKeyLocator(certificateName.getPrefix(-1)); // implicit conversion should take care
275
276 // For temporary usage, we support RSA + SHA256 only, but will support more.
Yingdi Yub4bb85a2014-01-16 10:11:04 -0800277 signature.setValue(Tpm::signInTpm(buffer, bufferLength, cert->getPublicKeyName(), DIGEST_ALGORITHM_SHA256));
Yingdi Yu31b4af22014-01-14 14:13:00 -0800278 return signature;
279 }
Jeff Thompsonc01e1782013-10-21 14:08:42 -0700280
281 /**
Jeff Thompson29ce3102013-09-27 11:47:48 -0700282 * Wire encode the Data object, sign it and set its signature.
Jeff Thompson29ce3102013-09-27 11:47:48 -0700283 * @param data The Data object to be signed. This updates its signature and key locator field and wireEncoding.
284 * @param identityName The identity name for the key to use for signing. If omitted, infer the signing identity from the data packet name.
Jeff Thompson29ce3102013-09-27 11:47:48 -0700285 */
286 void
Yingdi Yu4270f202014-01-28 14:19:16 -0800287 signByIdentity(Data& data, const Name& identityName)
Yingdi Yu31b4af22014-01-14 14:13:00 -0800288 {
289 Name signingCertificateName = Info::getDefaultCertificateNameForIdentity(identityName);
290
291 if (signingCertificateName.getComponentCount() == 0)
292 throw std::runtime_error("No qualified certificate name found!");
293
294 sign(data, signingCertificateName);
295 }
Jeff Thompson3c73da42013-08-12 11:19:05 -0700296
Yingdi Yu4270f202014-01-28 14:19:16 -0800297 void
298 signByIdentity(Interest& interest, const Name& identityName)
299 {
300 Name signingCertificateName = Info::getDefaultCertificateNameForIdentity(identityName);
301
302 if (signingCertificateName.getComponentCount() == 0)
303 throw std::runtime_error("No qualified certificate name found!");
304
305 sign(interest, signingCertificateName);
306 }
307
308
Jeff Thompson3c73da42013-08-12 11:19:05 -0700309 /**
Jeff Thompsonc01e1782013-10-21 14:08:42 -0700310 * Sign the byte array using an identity name and return a Signature object.
311 * @param buffer The byte array to be signed.
312 * @param bufferLength the length of buffer.
313 * @param identityName The identity name.
314 * @return The Signature.
315 */
Alexander Afanasyev64a3d812014-01-05 23:35:05 -0800316 Signature
Yingdi Yu31b4af22014-01-14 14:13:00 -0800317 signByIdentity(const uint8_t* buffer, size_t bufferLength, const Name& identityName = Name())
318 {
319 Name signingCertificateName = Info::getDefaultCertificateNameForIdentity(identityName);
320
321 if (signingCertificateName.size() == 0)
322 throw std::runtime_error("No qualified certificate name found!");
323
324 return sign(buffer, bufferLength, signingCertificateName);
325 }
Jeff Thompsonc01e1782013-10-21 14:08:42 -0700326
327 /**
Yingdi Yu2abd73f2014-01-08 23:34:11 -0800328 * Generate a self-signed certificate for a public key.
329 * @param keyName The name of the public key.
330 * @return The generated certificate.
331 */
332 ptr_lib::shared_ptr<IdentityCertificate>
Yingdi Yu31b4af22014-01-14 14:13:00 -0800333 selfSign(const Name& keyName)
334 {
Yingdi Yu7ea69502014-01-15 17:21:29 -0800335 if(keyName.empty())
Yingdi Yu4270f202014-01-28 14:19:16 -0800336 throw InfoError("Incorrect key name: " + keyName.toUri());
Yingdi Yu7ea69502014-01-15 17:21:29 -0800337
Yingdi Yu31b4af22014-01-14 14:13:00 -0800338 ptr_lib::shared_ptr<IdentityCertificate> certificate = ptr_lib::make_shared<IdentityCertificate>();
339
340 Name certificateName = keyName.getPrefix(-1);
341 certificateName.append("KEY").append(keyName.get(-1)).append("ID-CERT").appendVersion();
342
343 ptr_lib::shared_ptr<PublicKey> pubKey = Info::getPublicKey(keyName);
344 if (!pubKey)
Yingdi Yu4270f202014-01-28 14:19:16 -0800345 throw InfoError("Requested public key [" + keyName.toUri() + "] doesn't exist");
Yingdi Yu31b4af22014-01-14 14:13:00 -0800346
347 certificate->setName(certificateName);
348 certificate->setNotBefore(getNow());
349 certificate->setNotAfter(getNow() + 630720000 /* 20 years*/);
350 certificate->setPublicKeyInfo(*pubKey);
351 certificate->addSubjectDescription(CertificateSubjectDescription("2.5.4.41", keyName.toUri()));
352 certificate->encode();
353
354 selfSign(*certificate);
355 return certificate;
356 }
Yingdi Yu2abd73f2014-01-08 23:34:11 -0800357
358 /**
359 * @brief Self-sign the supplied identity certificate
Jeff Thompson8efe5ad2013-08-20 17:36:38 -0700360 */
Jeff Thompson2ce8f492013-09-17 18:01:25 -0700361 void
Yingdi Yu31b4af22014-01-14 14:13:00 -0800362 selfSign (IdentityCertificate& cert)
363 {
364 SignatureSha256WithRsa signature;
365 signature.setKeyLocator(cert.getName().getPrefix(-1)); // implicit conversion should take care
366 cert.setSignature(signature);
367
368 // For temporary usage, we support RSA + SHA256 only, but will support more.
Yingdi Yu8726f652014-01-23 10:35:12 -0800369 signDataInTpm(cert, cert.getPublicKeyName(), DIGEST_ALGORITHM_SHA256);
Yingdi Yu31b4af22014-01-14 14:13:00 -0800370 }
371
Jeff Thompson8efe5ad2013-08-20 17:36:38 -0700372
Yingdi Yu2abd73f2014-01-08 23:34:11 -0800373private:
374 /**
375 * Generate a key pair for the specified identity.
376 * @param identityName The name of the specified identity.
377 * @param isKsk true for generating a Key-Signing-Key (KSK), false for a Data-Signing-Key (KSK).
378 * @param keyType The type of the key pair, e.g. KEY_TYPE_RSA.
379 * @param keySize The size of the key pair.
380 * @return The name of the generated key.
381 */
382 Name
Yingdi Yu31b4af22014-01-14 14:13:00 -0800383 generateKeyPair(const Name& identityName, bool isKsk = false, KeyType keyType = KEY_TYPE_RSA, int keySize = 2048)
384 {
385 Name keyName = Info::getNewKeyName(identityName, isKsk);
386
387 Tpm::generateKeyPairInTpm(keyName.toUri(), keyType, keySize);
388
389 ptr_lib::shared_ptr<PublicKey> pubKey = Tpm::getPublicKeyFromTpm(keyName.toUri());
Yingdi Yuef26ee32014-01-15 16:41:14 -0800390 Info::addPublicKey(keyName, keyType, *pubKey);
Yingdi Yu31b4af22014-01-14 14:13:00 -0800391
392 return keyName;
393 }
Yingdi Yu2abd73f2014-01-08 23:34:11 -0800394
395 static Name
Yingdi Yu31b4af22014-01-14 14:13:00 -0800396 getKeyNameFromCertificatePrefix(const Name& certificatePrefix)
397 {
398 Name result;
Alexander Afanasyevbf1a67a2014-01-05 23:36:13 -0800399
Yingdi Yu31b4af22014-01-14 14:13:00 -0800400 std::string keyString("KEY");
401 int i = 0;
402 for(; i < certificatePrefix.size(); i++) {
403 if (certificatePrefix.get(i).toEscapedString() == keyString)
404 break;
405 }
Alexander Afanasyevbf1a67a2014-01-05 23:36:13 -0800406
Yingdi Yu31b4af22014-01-14 14:13:00 -0800407 if (i >= certificatePrefix.size())
Yingdi Yu4270f202014-01-28 14:19:16 -0800408 throw InfoError("Identity Certificate Prefix does not have a KEY component");
Alexander Afanasyevbd5ba402014-01-05 22:41:09 -0800409
Yingdi Yu31b4af22014-01-14 14:13:00 -0800410 result.append(certificatePrefix.getSubName(0, i));
411 result.append(certificatePrefix.getSubName(i + 1, certificatePrefix.size()-i-1));
412
413 return result;
414 }
415
Yingdi Yu8726f652014-01-23 10:35:12 -0800416 /**
417 * Fetch the private key for keyName and sign the data, and set the signature block of the data packet.
418 * @param data Reference to the input data packet.
419 * @param keyName The name of the signing key.
420 * @param digestAlgorithm the digest algorithm.
421 * @throws Tpm::Error
422 */
423 void
424 signDataInTpm(Data &data, const Name& keyName, DigestAlgorithm digestAlgorithm)
425 {
426 data.setSignatureValue
427 (Tpm::signInTpm(data.wireEncode().value(),
428 data.wireEncode().value_size() - data.getSignature().getValue().size(),
429 keyName, digestAlgorithm));
430 }
431
Jeff Thompson47c93cf2013-08-09 00:38:48 -0700432};
433
Yingdi Yu31b4af22014-01-14 14:13:00 -0800434}
Yingdi Yu2abd73f2014-01-08 23:34:11 -0800435
Yingdi Yu04020922014-01-22 12:46:53 -0800436
437
Yingdi Yu31b4af22014-01-14 14:13:00 -0800438#ifdef NDN_CPP_HAVE_OSX_SECURITY
439
440namespace ndn
Alexander Afanasyeve64788e2014-01-05 22:38:21 -0800441{
Yingdi Yu31b4af22014-01-14 14:13:00 -0800442typedef KeyChainImpl<SecPublicInfoSqlite3, SecTpmOsx> KeyChain;
443};
Yingdi Yu2abd73f2014-01-08 23:34:11 -0800444
Yingdi Yu31b4af22014-01-14 14:13:00 -0800445#else
Alexander Afanasyeve64788e2014-01-05 22:38:21 -0800446
Yingdi Yu31b4af22014-01-14 14:13:00 -0800447namespace ndn
Alexander Afanasyeve64788e2014-01-05 22:38:21 -0800448{
Yingdi Yu04020922014-01-22 12:46:53 -0800449typedef KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> KeyChain;
Yingdi Yu31b4af22014-01-14 14:13:00 -0800450};
Alexander Afanasyeve64788e2014-01-05 22:38:21 -0800451
Yingdi Yu31b4af22014-01-14 14:13:00 -0800452#endif //NDN_CPP_HAVE_OSX_SECURITY
Jeff Thompson47c93cf2013-08-09 00:38:48 -0700453
454#endif