security: Add doxygen comments
Change-Id: Ieafe4d13513e626d84ef9e621694f69844785018
diff --git a/src/security/certificate-cache-ttl.cpp b/src/security/certificate-cache-ttl.cpp
index 9538d95..0892789 100644
--- a/src/security/certificate-cache-ttl.cpp
+++ b/src/security/certificate-cache-ttl.cpp
@@ -15,8 +15,8 @@
using namespace std;
-namespace ndn
-{
+namespace ndn {
+
CertificateCacheTtl::CertificateCacheTtl(shared_ptr<boost::asio::io_service> io, int defaultTtl)
: m_defaultTtl(defaultTtl)
, m_scheduler(*io)
@@ -66,6 +66,6 @@
return ptr_lib::shared_ptr<IdentityCertificate>();
}
-}//ndn
+} // namespace ndn
diff --git a/src/security/certificate-cache-ttl.hpp b/src/security/certificate-cache-ttl.hpp
index 8702c3a..9ac91d5 100644
--- a/src/security/certificate-cache-ttl.hpp
+++ b/src/security/certificate-cache-ttl.hpp
@@ -5,8 +5,8 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_CERTIFICATE_CACHE_TTL_HPP
-#define NDN_CERTIFICATE_CACHE_TTL_HPP
+#ifndef NDN_SECURITY_CERTIFICATE_CACHE_TTL_HPP
+#define NDN_SECURITY_CERTIFICATE_CACHE_TTL_HPP
#include "../common.hpp"
#include "certificate-cache.hpp"
@@ -46,6 +46,6 @@
Scheduler m_scheduler;
};
-}//ndn
+} // namespace ndn
-#endif
+#endif //NDN_SECURITY_CERTIFICATE_CACHE_TTL_HPP
diff --git a/src/security/certificate-cache.hpp b/src/security/certificate-cache.hpp
index 14c42d1..9d99dcc 100644
--- a/src/security/certificate-cache.hpp
+++ b/src/security/certificate-cache.hpp
@@ -5,14 +5,13 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_CERTIFICATE_CACHE_HPP
-#define NDN_CERTIFICATE_CACHE_HPP
+#ifndef NDN_SECURITY_CERTIFICATE_CACHE_HPP
+#define NDN_SECURITY_CERTIFICATE_CACHE_HPP
#include "../name.hpp"
#include "identity-certificate.hpp"
-namespace ndn
-{
+namespace ndn {
class CertificateCache
{
@@ -27,6 +26,6 @@
getCertificate(const Name& certificateNameWithoutVersion) = 0;
};
-}//ndn
+} // namespace ndn
-#endif
+#endif //NDN_SECURITY_CERTIFICATE_CACHE_HPP
diff --git a/src/security/certificate-extension.cpp b/src/security/certificate-extension.cpp
index e3ceff6..69a2d10 100644
--- a/src/security/certificate-extension.cpp
+++ b/src/security/certificate-extension.cpp
@@ -55,4 +55,4 @@
extension.MessageEnd();
}
-}
+} // namespace ndn
diff --git a/src/security/certificate-extension.hpp b/src/security/certificate-extension.hpp
index 61f7dd2..4eba4f2 100644
--- a/src/security/certificate-extension.hpp
+++ b/src/security/certificate-extension.hpp
@@ -6,8 +6,8 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_CERTIFICATE_EXTENSION_HPP
-#define NDN_CERTIFICATE_EXTENSION_HPP
+#ifndef NDN_SECURITY_CERTIFICATE_EXTENSION_HPP
+#define NDN_SECURITY_CERTIFICATE_EXTENSION_HPP
#include "../common.hpp"
#include "../encoding/buffer.hpp"
@@ -73,6 +73,6 @@
Buffer extensionValue_;
};
-}
+} // namespace ndn
-#endif
+#endif //NDN_SECURITY_CERTIFICATE_EXTENSION_HPP
diff --git a/src/security/certificate-subject-description.cpp b/src/security/certificate-subject-description.cpp
index 63e7b0b..ccf6778 100644
--- a/src/security/certificate-subject-description.cpp
+++ b/src/security/certificate-subject-description.cpp
@@ -63,4 +63,4 @@
attributeTypeAndValue.MessageEnd();
}
-}
+} // namespace ndn
diff --git a/src/security/certificate-subject-description.hpp b/src/security/certificate-subject-description.hpp
index fc26d37..5510f6e 100644
--- a/src/security/certificate-subject-description.hpp
+++ b/src/security/certificate-subject-description.hpp
@@ -6,8 +6,8 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_CERTIFICATE_SUBJECT_DESCRIPTION_HPP
-#define NDN_CERTIFICATE_SUBJECT_DESCRIPTION_HPP
+#ifndef NDN_SECURITY_CERTIFICATE_SUBJECT_DESCRIPTION_HPP
+#define NDN_SECURITY_CERTIFICATE_SUBJECT_DESCRIPTION_HPP
#include "../common.hpp"
#include "../encoding/oid.hpp"
@@ -59,6 +59,6 @@
std::string value_;
};
-}
+} // namespace ndn
-#endif
+#endif //NDN_SECURITY_CERTIFICATE_SUBJECT_DESCRIPTION_HPP
diff --git a/src/security/certificate.cpp b/src/security/certificate.cpp
index 3778a80..f0dfdf2 100644
--- a/src/security/certificate.cpp
+++ b/src/security/certificate.cpp
@@ -265,4 +265,4 @@
// keyRoot->accept(printVisitor, string(""));
}
-}
+} // namespace ndn
diff --git a/src/security/certificate.hpp b/src/security/certificate.hpp
index 260638a..35934d0 100644
--- a/src/security/certificate.hpp
+++ b/src/security/certificate.hpp
@@ -6,8 +6,8 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_CERTIFICATE_HPP
-#define NDN_CERTIFICATE_HPP
+#ifndef NDN_SECURITY_CERTIFICATE_HPP
+#define NDN_SECURITY_CERTIFICATE_HPP
#include "../common.hpp"
#include "../data.hpp"
@@ -153,4 +153,4 @@
} // namespace ndn
-#endif
+#endif //NDN_SECURITY_CERTIFICATE_HPP
diff --git a/src/security/identity-certificate.cpp b/src/security/identity-certificate.cpp
index 44d6588..5fddbfc 100644
--- a/src/security/identity-certificate.cpp
+++ b/src/security/identity-certificate.cpp
@@ -90,4 +90,4 @@
return tmpName.getSubName(0, i).append(tmpName.getSubName(i + 1, tmpName.size() - i - 1));
}
-}
+} // namespace ndn
diff --git a/src/security/identity-certificate.hpp b/src/security/identity-certificate.hpp
index fa31966..6d6d334 100644
--- a/src/security/identity-certificate.hpp
+++ b/src/security/identity-certificate.hpp
@@ -6,8 +6,8 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_IDENTITY_CERTIFICATE_HPP
-#define NDN_IDENTITY_CERTIFICATE_HPP
+#ifndef NDN_SECURITY_IDENTITY_CERTIFICATE_HPP
+#define NDN_SECURITY_IDENTITY_CERTIFICATE_HPP
#include "../common.hpp"
#include "certificate.hpp"
@@ -108,6 +108,6 @@
return publicKeyName_;
}
-}
+} // namespace ndn
-#endif
+#endif //NDN_SECURITY_IDENTITY_CERTIFICATE_HPP
diff --git a/src/security/key-chain.hpp b/src/security/key-chain.hpp
index 981dfce..7a3ff42 100644
--- a/src/security/key-chain.hpp
+++ b/src/security/key-chain.hpp
@@ -6,8 +6,8 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_KEY_CHAIN_HPP
-#define NDN_KEY_CHAIN_HPP
+#ifndef NDN_SECURITY_KEY_CHAIN_HPP
+#define NDN_SECURITY_KEY_CHAIN_HPP
#include "identity-certificate.hpp"
#include "public-key.hpp"
@@ -539,7 +539,7 @@
};
-}
+} // namespace ndn
@@ -559,4 +559,4 @@
#endif //NDN_CPP_HAVE_OSX_SECURITY
-#endif
+#endif //NDN_SECURITY_KEY_CHAIN_HPP
diff --git a/src/security/public-key.cpp b/src/security/public-key.cpp
index 09222a4..c8362af 100644
--- a/src/security/public-key.cpp
+++ b/src/security/public-key.cpp
@@ -115,4 +115,4 @@
return os;
}
-}
+} // namespace ndn
diff --git a/src/security/public-key.hpp b/src/security/public-key.hpp
index 8fc5dab..a332f02 100644
--- a/src/security/public-key.hpp
+++ b/src/security/public-key.hpp
@@ -6,8 +6,8 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_PUBLIC_KEY_HPP
-#define NDN_PUBLIC_KEY_HPP
+#ifndef NDN_SECURITY_PUBLIC_KEY_HPP
+#define NDN_SECURITY_PUBLIC_KEY_HPP
#include "../common.hpp"
@@ -80,6 +80,6 @@
std::ostream &
operator <<(std::ostream &os, const PublicKey &key);
-}
+} // namespace ndn
-#endif
+#endif //NDN_SECURITY_PUBLIC_KEY_HPP
diff --git a/src/security/sec-public-info-memory.cpp b/src/security/sec-public-info-memory.cpp
index e9f93f2..1e41df1 100644
--- a/src/security/sec-public-info-memory.cpp
+++ b/src/security/sec-public-info-memory.cpp
@@ -219,6 +219,4 @@
throw runtime_error("SecPublicInfoMemory::deleteIdentityInfo not implemented");
}
-
-
-}
+} // namespace ndn
diff --git a/src/security/sec-public-info-memory.hpp b/src/security/sec-public-info-memory.hpp
index e598ebf..04104ea 100644
--- a/src/security/sec-public-info-memory.hpp
+++ b/src/security/sec-public-info-memory.hpp
@@ -5,8 +5,8 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_SEC_PUBLIC_INFO_MEMORY_HPP
-#define NDN_SEC_PUBLIC_INFO_MEMORY_HPP
+#ifndef NDN_SECURITY_SEC_PUBLIC_INFO_MEMORY_HPP
+#define NDN_SECURITY_SEC_PUBLIC_INFO_MEMORY_HPP
#include "../common.hpp"
#include "sec-public-info.hpp"
@@ -232,6 +232,6 @@
CertificateStore certificateStore_;
};
-}
+} // namespace ndn
-#endif
+#endif //NDN_SECURITY_SEC_PUBLIC_INFO_MEMORY_HPP
diff --git a/src/security/sec-public-info-sqlite3.cpp b/src/security/sec-public-info-sqlite3.cpp
index bc16d9d..fbef713 100644
--- a/src/security/sec-public-info-sqlite3.cpp
+++ b/src/security/sec-public-info-sqlite3.cpp
@@ -30,8 +30,7 @@
using namespace std;
-namespace ndn
-{
+namespace ndn {
static const string INIT_ID_TABLE = "\
CREATE TABLE IF NOT EXISTS \n \
diff --git a/src/security/sec-public-info-sqlite3.hpp b/src/security/sec-public-info-sqlite3.hpp
index 94dc0fa..2cecb04 100644
--- a/src/security/sec-public-info-sqlite3.hpp
+++ b/src/security/sec-public-info-sqlite3.hpp
@@ -6,16 +6,15 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_SEC_PUBLIC_INFO_SQLITE3_HPP
-#define NDN_SEC_PUBLIC_INFO_SQLITE3_HPP
+#ifndef NDN_SECURITY_SEC_PUBLIC_INFO_SQLITE3_HPP
+#define NDN_SECURITY_SEC_PUBLIC_INFO_SQLITE3_HPP
#include "../common.hpp"
#include "sec-public-info.hpp"
struct sqlite3;
-namespace ndn
-{
+namespace ndn {
/**
* BasicIdentityStorage extends IdentityStorage to implement a basic storage of identity, public keys and certificates
@@ -234,6 +233,6 @@
updateKeyStatus(keyName, false);
}
-}
+} // namespace ndn
-#endif
+#endif //NDN_SECURITY_SEC_PUBLIC_INFO_SQLITE3_HPP
diff --git a/src/security/sec-public-info.hpp b/src/security/sec-public-info.hpp
index aa35ff9..b68875b 100644
--- a/src/security/sec-public-info.hpp
+++ b/src/security/sec-public-info.hpp
@@ -6,8 +6,8 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_SEC_PUBLIC_INFO_HPP
-#define NDN_SEC_PUBLIC_INFO_HPP
+#ifndef NDN_SECURITY_SEC_PUBLIC_INFO_HPP
+#define NDN_SECURITY_SEC_PUBLIC_INFO_HPP
#include "../name.hpp"
#include "security-common.hpp"
@@ -399,6 +399,6 @@
defaultCertificate_ = getCertificate(certName);
}
-}
+} // namespace ndn
-#endif
+#endif //NDN_SECURITY_SEC_PUBLIC_INFO_HPP
diff --git a/src/security/sec-rule-relative.cpp b/src/security/sec-rule-relative.cpp
index cdfdeac..db3e653 100644
--- a/src/security/sec-rule-relative.cpp
+++ b/src/security/sec-rule-relative.cpp
@@ -18,8 +18,7 @@
using namespace std;
-namespace ndn
-{
+namespace ndn {
SecRuleRelative::SecRuleRelative (const string& dataRegex, const string& signerRegex, const string& op,
const string& dataExpand, const string& signerExpand, bool isPositive)
@@ -111,4 +110,4 @@
return true;
}
-}//ndn
+} // namespace ndn
diff --git a/src/security/sec-rule-relative.hpp b/src/security/sec-rule-relative.hpp
index 1d763de..59c8f09 100644
--- a/src/security/sec-rule-relative.hpp
+++ b/src/security/sec-rule-relative.hpp
@@ -6,14 +6,13 @@
*/
-#ifndef NDN_SEC_RULE_RELATIVE_HPP
-#define NDN_SEC_RULE_RELATIVE_HPP
+#ifndef NDN_SECURITY_SEC_RULE_RELATIVE_HPP
+#define NDN_SECURITY_SEC_RULE_RELATIVE_HPP
#include "sec-rule.hpp"
#include "../util/regex.hpp"
-namespace ndn
-{
+namespace ndn {
class SecRuleRelative : public SecRule
{
@@ -53,6 +52,6 @@
Regex m_signerNameRegex;
};
-}//ndn
+} // namespace ndn
-#endif
+#endif //NDN_SECURITY_SEC_RULE_RELATIVE_HPP
diff --git a/src/security/sec-rule-specific.cpp b/src/security/sec-rule-specific.cpp
index b1973de..484a08e 100644
--- a/src/security/sec-rule-specific.cpp
+++ b/src/security/sec-rule-specific.cpp
@@ -10,10 +10,9 @@
#include "sec-rule-specific.hpp"
#include "signature-sha256-with-rsa.hpp"
-using namespace ndn;
using namespace std;
-namespace ndn{
+namespace ndn {
SecRuleSpecific::SecRuleSpecific(shared_ptr<Regex> dataRegex,
shared_ptr<Regex> signerRegex)
@@ -48,10 +47,14 @@
bool
SecRuleSpecific::satisfy(const Data & data)
-{ return (matchDataName(data) && matchSignerName(data)) ? true : false ; }
+{
+ return (matchDataName(data) && matchSignerName(data)) ? true : false ;
+}
bool
SecRuleSpecific::satisfy(const Name & dataName, const Name & signerName)
-{ return (m_dataRegex->match(dataName) && m_signerRegex->match(signerName)); }
-
+{
+ return (m_dataRegex->match(dataName) && m_signerRegex->match(signerName));
}
+
+} // namespace ndn
diff --git a/src/security/sec-rule-specific.hpp b/src/security/sec-rule-specific.hpp
index 2b7b355..1e961a0 100644
--- a/src/security/sec-rule-specific.hpp
+++ b/src/security/sec-rule-specific.hpp
@@ -5,14 +5,14 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_SEC_RULE_SPECIFIC_H
-#define NDN_SEC_RULE_SPECIFIC_H
+#ifndef NDN_SECURITY_SEC_RULE_SPECIFIC_H
+#define NDN_SECURITY_SEC_RULE_SPECIFIC_H
#include "../common.hpp"
#include "sec-rule.hpp"
#include "../util/regex.hpp"
-namespace ndn{
+namespace ndn {
class SecRuleSpecific : public ndn::SecRule
{
@@ -43,6 +43,6 @@
ndn::shared_ptr<ndn::Regex> m_signerRegex;
};
-}
+} // namespace ndn
-#endif
+#endif //NDN_SECURITY_SEC_RULE_SPECIFIC_H
diff --git a/src/security/sec-rule.hpp b/src/security/sec-rule.hpp
index c175863..496b33d 100644
--- a/src/security/sec-rule.hpp
+++ b/src/security/sec-rule.hpp
@@ -5,14 +5,13 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_SEC_RULE_HPP
-#define NDN_SEC_RULE_HPP
+#ifndef NDN_SECURITY_SEC_RULE_HPP
+#define NDN_SECURITY_SEC_RULE_HPP
#include "../common.hpp"
#include "../data.hpp"
-namespace ndn
-{
+namespace ndn {
class SecRule
{
@@ -52,6 +51,6 @@
return m_isPositive;
}
-}
+} // namespace ndn
-#endif
+#endif //NDN_SECURITY_SEC_RULE_HPP
diff --git a/src/security/sec-tpm-file.cpp b/src/security/sec-tpm-file.cpp
index 78d7ef7..ecb8237 100644
--- a/src/security/sec-tpm-file.cpp
+++ b/src/security/sec-tpm-file.cpp
@@ -33,8 +33,7 @@
using namespace std;
-namespace ndn
-{
+namespace ndn {
class SecTpmFile::Impl {
public:
@@ -243,7 +242,7 @@
ConstBufferPtr
-SecTpmFile::decryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric)
+SecTpmFile::decryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric)
{
string keyURI = keyName.toUri();
if (!isSymmetric)
@@ -303,7 +302,7 @@
}
ConstBufferPtr
-SecTpmFile::encryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric)
+SecTpmFile::encryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric)
{
string keyURI = keyName.toUri();
@@ -437,4 +436,4 @@
}
}
-} //ndn
+} // namespace ndn
diff --git a/src/security/sec-tpm-file.hpp b/src/security/sec-tpm-file.hpp
index f1e6fa8..5f40200 100644
--- a/src/security/sec-tpm-file.hpp
+++ b/src/security/sec-tpm-file.hpp
@@ -6,15 +6,14 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_SEC_TPM_FILE_HPP
-#define NDN_SEC_TPM_FILE_HPP
+#ifndef NDN_SECURITY_SEC_TPM_FILE_HPP
+#define NDN_SECURITY_SEC_TPM_FILE_HPP
#include "../common.hpp"
#include "sec-tpm.hpp"
-namespace ndn
-{
+namespace ndn {
class SecTpmFile : public SecTpm
{
@@ -23,9 +22,6 @@
SecTpmFile(const std::string & dir = "");
- /**
- * @brief destructor
- */
virtual
~SecTpmFile() {};
@@ -38,71 +34,24 @@
virtual void
generateKeyPairInTpm(const Name & keyName, KeyType keyType, int keySize);
- /**
- * Delete a key pair of asymmetric keys.
- * @param keyName The name of the key pair.
- */
virtual void
deleteKeyPairInTpm(const Name &keyName);
- /**
- * Get the public key
- * @param keyName The name of public key.
- * @return The public key.
- */
- virtual ptr_lib::shared_ptr<PublicKey>
+ virtual shared_ptr<PublicKey>
getPublicKeyFromTpm(const Name & keyName);
- /**
- * Fetch the private key for keyName and sign the data, returning a signature block.
- * Throw Error if signing fails.
- * @param data Pointer to the input byte array.
- * @param dataLength The length of data.
- * @param keyName The name of the signing key.
- * @param digestAlgorithm the digest algorithm.
- * @return The signature block.
- */
virtual Block
signInTpm(const uint8_t *data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm);
- /**
- * Decrypt data.
- * @param keyName The name of the decrypting key.
- * @param data The byte to be decrypted.
- * @param dataLength the length of data.
- * @param isSymmetric If true symmetric encryption is used, otherwise asymmetric encryption is used.
- * @return The decrypted data.
- */
virtual ConstBufferPtr
- decryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric);
+ decryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric);
- /**
- * Encrypt data.
- * @param keyName The name of the encrypting key.
- * @param data The byte to be encrypted.
- * @param dataLength the length of data.
- * @param isSymmetric If true symmetric encryption is used, otherwise asymmetric decryption is used.
- * @return The encrypted data.
- */
virtual ConstBufferPtr
- encryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric);
+ encryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric);
-
- /**
- * Generate a symmetric key.
- * @param keyName The name of the key.
- * @param keyType The type of the key, e.g. KEY_TYPE_AES.
- * @param keySize The size of the key.
- */
virtual void
generateSymmetricKeyInTpm(const Name& keyName, KeyType keyType, int keySize);
- /**
- * Check if a particular key exists.
- * @param keyName The name of the key.
- * @param keyClass The class of the key, e.g. KEY_CLASS_PUBLIC, KEY_CLASS_PRIVATE, or KEY_CLASS_SYMMETRIC.
- * @return True if the key exists, otherwise false.
- */
virtual bool
doesKeyExistInTpm(const Name& keyName, KeyClass keyClass);
@@ -127,6 +76,6 @@
shared_ptr<Impl> m_impl;
};
-}//ndn
+} // namespace ndn
-#endif
+#endif //NDN_SECURITY_SEC_TPM_FILE_HPP
diff --git a/src/security/sec-tpm-memory.cpp b/src/security/sec-tpm-memory.cpp
index 231a195..638a174 100644
--- a/src/security/sec-tpm-memory.cpp
+++ b/src/security/sec-tpm-memory.cpp
@@ -138,7 +138,7 @@
}
ConstBufferPtr
-SecTpmMemory::decryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric)
+SecTpmMemory::decryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric)
{
#if 1
throw Error("MemoryPrivateKeyStorage::decrypt not implemented");
@@ -146,7 +146,7 @@
}
ConstBufferPtr
-SecTpmMemory::encryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric)
+SecTpmMemory::encryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric)
{
#if 1
throw Error("MemoryPrivateKeyStorage::encrypt not implemented");
@@ -185,4 +185,4 @@
}
}
-}
+} // namespace ndn
diff --git a/src/security/sec-tpm-memory.hpp b/src/security/sec-tpm-memory.hpp
index b24246b..01860e2 100644
--- a/src/security/sec-tpm-memory.hpp
+++ b/src/security/sec-tpm-memory.hpp
@@ -5,8 +5,8 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_SEC_TPM_MEMORY_HPP
-#define NDN_SEC_TPM_MEMORY_HPP
+#ifndef NDN_SECURITY_SEC_TPM_MEMORY_HPP
+#define NDN_SECURITY_SEC_TPM_MEMORY_HPP
#include "../common.hpp"
#include "sec-tpm.hpp"
@@ -23,9 +23,6 @@
public:
struct Error : public SecTpm::Error { Error(const std::string &what) : SecTpm::Error(what) {} };
- /**
- * The virtual destructor
- */
virtual
~SecTpmMemory();
@@ -36,60 +33,21 @@
virtual void
generateKeyPairInTpm(const Name& keyName, KeyType keyType, int keySize);
- /**
- * Get the public key
- * @param keyName The name of public key.
- * @return The public key.
- */
virtual ptr_lib::shared_ptr<PublicKey>
getPublicKeyFromTpm(const Name& keyName);
- /**
- * Delete a key pair of asymmetric keys.
- * @param keyName The name of the key pair.
- */
virtual void
deleteKeyPairInTpm(const Name &keyName);
-
- /**
- * Fetch the private key for keyName and sign the data, returning a signature Blob.
- * @param data Pointer to the input byte array.
- * @param dataLength The length of data.
- * @param keyName The name of the signing key.
- * @param digestAlgorithm the digest algorithm.
- * @return The signature, or a null pointer if signing fails.
- */
+
virtual Block
signInTpm(const uint8_t *data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm);
- /**
- * Decrypt data.
- * @param keyName The name of the decrypting key.
- * @param data The byte to be decrypted.
- * @param dataLength the length of data.
- * @param isSymmetric If true symmetric encryption is used, otherwise asymmetric decryption is used.
- * @return The decrypted data.
- */
virtual ConstBufferPtr
- decryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric);
+ decryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric);
- /**
- * Encrypt data.
- * @param keyName The name of the encrypting key.
- * @param data The byte to be encrypted.
- * @param dataLength the length of data.
- * @param isSymmetric If true symmetric encryption is used, otherwise asymmetric decryption is used.
- * @return The encrypted data.
- */
virtual ConstBufferPtr
- encryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric);
+ encryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric);
- /**
- * @brief Generate a symmetric key.
- * @param keyName The name of the key.
- * @param keyType The type of the key, e.g. KEY_TYPE_AES.
- * @param keySize The size of the key.
- */
virtual void
generateSymmetricKeyInTpm(const Name& keyName, KeyType keyType, int keySize);
@@ -140,6 +98,6 @@
PrivateKeyStore privateKeyStore_; /**< The map key is the keyName.toUri() */
};
-}
+} // namespace ndn
-#endif
+#endif //NDN_SECURITY_SEC_TPM_MEMORY_HPP
diff --git a/src/security/sec-tpm-osx.cpp b/src/security/sec-tpm-osx.cpp
index d85636d..94d3bfe 100644
--- a/src/security/sec-tpm-osx.cpp
+++ b/src/security/sec-tpm-osx.cpp
@@ -28,8 +28,8 @@
INIT_LOGGER("SecTpmOsx");
-namespace ndn
-{
+namespace ndn {
+
class SecTpmOsx::Impl {
public:
Impl()
@@ -38,8 +38,8 @@
/**
* @brief Convert NDN name of a key to internal name of the key.
*
- * @param keyName the NDN name of the key
- * @param keyClass the class of the key
+ * @param keyName
+ * @param keyClass
* @return the internal key name
*/
std::string
@@ -47,15 +47,17 @@
/**
* @brief Get key.
- * @param keyName the name of the key
- * @param keyClass the class of the key
+ *
+ * @param keyName
+ * @param keyClass
* @returns pointer to the key
*/
SecKeychainItemRef
getKey(const Name & keyName, KeyClass keyClass);
/**
- * convert keyType to MAC OS symmetric key key type
+ * @brief Convert keyType to MAC OS symmetric key key type
+ *
* @param keyType
* @returns MAC OS key type
*/
@@ -63,7 +65,8 @@
getSymKeyType(KeyType keyType);
/**
- * convert keyType to MAC OS asymmetirc key type
+ * @brief Convert keyType to MAC OS asymmetirc key type
+ *
* @param keyType
* @returns MAC OS key type
*/
@@ -71,7 +74,8 @@
getAsymKeyType(KeyType keyType);
/**
- * convert keyClass to MAC OS key class
+ * @brief Convert keyClass to MAC OS key class
+ *
* @param keyClass
* @returns MAC OS key class
*/
@@ -79,7 +83,8 @@
getKeyClass(KeyClass keyClass);
/**
- * convert digestAlgo to MAC OS algorithm id
+ * @brief Convert digestAlgo to MAC OS algorithm id
+ *
* @param digestAlgo
* @returns MAC OS algorithm id
*/
@@ -87,8 +92,9 @@
getDigestAlgorithm(DigestAlgorithm digestAlgo);
/**
- * get the digest size of the corresponding algorithm
- * @param digestAlgo the digest algorithm
+ * @brief Get the digest size of the corresponding algorithm
+ *
+ * @param digestAlgo
* @return digest size
*/
long
@@ -522,7 +528,7 @@
}
ConstBufferPtr
-SecTpmOsx::decryptInTpm(const Name & keyName, const uint8_t* data, size_t dataLength, bool sym)
+SecTpmOsx::decryptInTpm(const uint8_t* data, size_t dataLength, const Name & keyName, bool sym)
{
_LOG_TRACE("OSXPrivateKeyStorage::Decrypt");
@@ -614,55 +620,8 @@
return true;
}
-// bool
-// OSXPrivateKeyStorage::verifyData(const Name & keyName, const Blob & pData, const Blob & pSig, DigestAlgorithm digestAlgo)
-// {
-// _LOG_TRACE("OSXPrivateKeyStorage::Verify");
-
-// CFDataRef dataRef = CFDataCreate(NULL,
-// reinterpret_cast<const unsigned char*>(pData.buf()),
-// pData.size());
-
-// CFDataRef sigRef = CFDataCreate(NULL,
-// reinterpret_cast<const unsigned char*>(pSig.buf()),
-// pSig.size());
-
-// SecKeyRef publicKey = (SecKeyRef)m_impl->getKey(keyName, KEY_CLASS_PUBLIC);
-
-// CFErrorRef error;
-// SecTransformRef verifier = SecVerifyTransformCreate(publicKey, sigRef, &error);
-// if (error) throw Error("Fail to create verifier");
-
-// Boolean set_res = SecTransformSetAttribute(verifier,
-// kSecTransformInputAttributeName,
-// dataRef,
-// &error);
-// if (error) throw Error("Fail to configure input of verifier");
-
-// set_res = SecTransformSetAttribute(verifier,
-// kSecDigestTypeAttribute,
-// m_impl->getDigestAlgorithm(digestAlgo),
-// &error);
-// if (error) throw Error("Fail to configure digest algorithm of verifier");
-
-// long digestSize = m_impl->getDigestSize(digestAlgo);
-// set_res = SecTransformSetAttribute(verifier,
-// kSecDigestLengthAttribute,
-// CFNumberCreate(NULL, kCFNumberLongType, &digestSize),
-// &error);
-// if (error) throw Error("Fail to configure digest size of verifier");
-
-// CFBooleanRef result = (CFBooleanRef) SecTransformExecute(verifier, &error);
-// if (error) throw Error("Fail to verify data");
-
-// if (result == kCFBooleanTrue)
-// return true;
-// else
-// return false;
-// }
-
ConstBufferPtr
-SecTpmOsx::encryptInTpm(const Name & keyName, const uint8_t* data, size_t dataLength, bool sym)
+SecTpmOsx::encryptInTpm(const uint8_t* data, size_t dataLength, const Name & keyName, bool sym)
{
_LOG_TRACE("OSXPrivateKeyStorage::Encrypt");
@@ -854,4 +813,4 @@
}
}
-}// ndn
+} // namespace ndn
diff --git a/src/security/sec-tpm-osx.hpp b/src/security/sec-tpm-osx.hpp
index 251df24..d10ce7d 100644
--- a/src/security/sec-tpm-osx.hpp
+++ b/src/security/sec-tpm-osx.hpp
@@ -5,28 +5,20 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_SEC_TPM_OSX_HPP
-#define NDN_SEC_TPM_OSX_HPP
+#ifndef NDN_SECURITY_SEC_TPM_OSX_HPP
+#define NDN_SECURITY_SEC_TPM_OSX_HPP
#include "../common.hpp"
#include "sec-tpm.hpp"
-namespace ndn
-{
+namespace ndn {
class SecTpmOsx : public SecTpm {
public:
struct Error : public SecTpm::Error { Error(const std::string& what) : SecTpm::Error(what) {} };
- /**
- * constructor of OSXKeyChainTpm
- * @param keychainName the name of keychain
- */
SecTpmOsx();
- /**
- * destructor of OSXKeyChainTpm
- */
virtual
~SecTpmOsx();
@@ -35,10 +27,6 @@
virtual void
generateKeyPairInTpm(const Name& keyName, KeyType keyType, int keySize);
- /**
- * Delete a key pair of asymmetric keys.
- * @param keyName The name of the key pair.
- */
virtual void
deleteKeyPairInTpm(const Name& keyName);
@@ -47,44 +35,16 @@
virtual Block
signInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm);
-
- /**
- * Decrypt data.
- * @param keyName The name of the decrypting key.
- * @param data The byte to be decrypted.
- * @param dataLength the length of data.
- * @param isSymmetric If true symmetric encryption is used, otherwise asymmetric decryption is used.
- * @return The decrypted data.
- */
+
virtual ConstBufferPtr
- decryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric);
+ decryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric);
- /**
- * Encrypt data.
- * @param keyName The name of the encrypting key.
- * @param data The byte to be encrypted.
- * @param dataLength the length of data.
- * @param isSymmetric If true symmetric encryption is used, otherwise asymmetric decryption is used.
- * @return The encrypted data.
- */
virtual ConstBufferPtr
- encryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric);
+ encryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric);
- /**
- * Generate a symmetric key.
- * @param keyName The name of the key.
- * @param keyType The type of the key, e.g. KEY_TYPE_AES.
- * @param keySize The size of the key.
- */
virtual void
generateSymmetricKeyInTpm(const Name& keyName, KeyType keyType, int keySize);
- /**
- * Check if a particular key exists.
- * @param keyName The name of the key.
- * @param keyClass The class of the key, e.g. KEY_CLASS_PUBLIC, KEY_CLASS_PRIVATE, or KEY_CLASS_SYMMETRIC.
- * @return True if the key exists, otherwise false.
- */
virtual bool
doesKeyExistInTpm(const Name& keyName, KeyClass keyClass);
@@ -97,7 +57,8 @@
////////////////////////////////////////////////////////////////////////////////////
/**
- * configure ACL of a particular key
+ * @brief Configure ACL of a particular key.
+ *
* @param keyName the name of key
* @param keyClass the class of key, e.g. Private Key
* @param acl the new acl of the key
@@ -127,4 +88,4 @@
} // namespace ndn
-#endif // NDN_SEC_TPM_OSX_HPP
+#endif // NDN_SECURITY_SEC_TPM_OSX_HPP
diff --git a/src/security/sec-tpm.cpp b/src/security/sec-tpm.cpp
index 13b04a8..a52d839 100644
--- a/src/security/sec-tpm.cpp
+++ b/src/security/sec-tpm.cpp
@@ -284,4 +284,4 @@
}
-}//ndn
+} // namespace ndn
diff --git a/src/security/sec-tpm.hpp b/src/security/sec-tpm.hpp
index dcdea95..f49518d 100644
--- a/src/security/sec-tpm.hpp
+++ b/src/security/sec-tpm.hpp
@@ -6,8 +6,8 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_SEC_TPM_HPP
-#define NDN_SEC_TPM_HPP
+#ifndef NDN_SECURITY_SEC_TPM_HPP
+#define NDN_SECURITY_SEC_TPM_HPP
#include "../common.hpp"
#include "security-common.hpp"
@@ -17,6 +17,11 @@
namespace ndn {
+/**
+ * @brief SecTpm is the base class of the TPM classes.
+ *
+ * It specifies the interfaces of private/secret key related operations.
+ */
class SecTpm {
public:
struct Error : public std::runtime_error { Error(const std::string &what) : std::runtime_error(what) {} };
@@ -28,65 +33,75 @@
~SecTpm() {}
/**
- * Generate a pair of asymmetric keys.
+ * @brief Generate a pair of asymmetric keys.
+ *
* @param keyName The name of the key pair.
* @param keyType The type of the key pair, e.g. KEY_TYPE_RSA.
* @param keySize The size of the key pair.
+ * @throws SecTpm::Error if fails.
*/
virtual void
generateKeyPairInTpm(const Name& keyName, KeyType keyType, int keySize) = 0;
/**
- * Delete a key pair of asymmetric keys.
+ * @brief Delete a key pair of asymmetric keys.
+ *
* @param keyName The name of the key pair.
*/
virtual void
deleteKeyPairInTpm(const Name &keyName) = 0;
/**
- * Get the public key
- * @param keyName The name of public key.
- * @return The public key.
+ * @brief Get a public key.
+ *
+ * @param keyName The public key name.
+ * @return The public key if exists, otherwise a NULL pointer.
*/
- virtual ptr_lib::shared_ptr<PublicKey>
+ virtual shared_ptr<PublicKey>
getPublicKeyFromTpm(const Name& keyName) = 0;
/**
- * Fetch the private key for keyName and sign the data, returning a signature block.
- * @param data Pointer to the input byte array.
+ * @brief Sign data.
+ *
+ * @param data Pointer to the byte array to be signed.
* @param dataLength The length of data.
* @param keyName The name of the signing key.
* @param digestAlgorithm the digest algorithm.
* @return The signature block.
- * @throws SecTpm::Error
+ * @throws SecTpm::Error if signing fails.
*/
virtual Block
signInTpm(const uint8_t *data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm) = 0;
/**
- * Decrypt data.
+ * @brief Decrypt data.
+ *
+ * @param data Pointer to the byte arry to be decrypted.
+ * @param dataLength The length of data.
* @param keyName The name of the decrypting key.
- * @param data The byte to be decrypted.
- * @param dataLength the length of data.
- * @param isSymmetric If true symmetric encryption is used, otherwise asymmetric encryption is used.
+ * @param isSymmetric If true symmetric encryption is used, otherwise asymmetric encryption.
* @return The decrypted data.
+ * @throws SecTpm::Error if decryption fails.
*/
virtual ConstBufferPtr
- decryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric) = 0;
+ decryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric) = 0;
/**
- * Encrypt data.
+ * @brief Encrypt data.
+ *
+ * @param data Pointer to the byte arry to be decrypted.
+ * @param dataLength The length of data.
* @param keyName The name of the encrypting key.
- * @param data The byte to be encrypted.
- * @param dataLength the length of data.
- * @param isSymmetric If true symmetric encryption is used, otherwise asymmetric encryption is used.
+ * @param isSymmetric If true symmetric encryption is used, otherwise asymmetric encryption.
* @return The encrypted data.
+ * @throws SecTpm::Error if encryption fails.
*/
virtual ConstBufferPtr
- encryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric) = 0;
+ encryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric) = 0;
/**
* @brief Generate a symmetric key.
+ *
* @param keyName The name of the key.
* @param keyType The type of the key, e.g. KEY_TYPE_AES.
* @param keySize The size of the key.
@@ -95,7 +110,8 @@
generateSymmetricKeyInTpm(const Name& keyName, KeyType keyType, int keySize) = 0;
/**
- * Check if a particular key exists.
+ * @brief Check if a particular key exists.
+ *
* @param keyName The name of the key.
* @param keyClass The class of the key, e.g. KEY_CLASS_PUBLIC, KEY_CLASS_PRIVATE, or KEY_CLASS_SYMMETRIC.
* @return True if the key exists, otherwise false.
@@ -213,6 +229,6 @@
return result;
}
-}
+} // namespace ndn
-#endif
+#endif //NDN_SECURITY_SEC_TPM_HPP
diff --git a/src/security/signature-sha256-with-rsa.hpp b/src/security/signature-sha256-with-rsa.hpp
index b1dd6e1..c9db4a3 100644
--- a/src/security/signature-sha256-with-rsa.hpp
+++ b/src/security/signature-sha256-with-rsa.hpp
@@ -5,8 +5,8 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_SIGNATURE_SHA256_WITH_RSA_HPP
-#define NDN_SIGNATURE_SHA256_WITH_RSA_HPP
+#ifndef NDN_SECURITY_SIGNATURE_SHA256_WITH_RSA_HPP
+#define NDN_SECURITY_SIGNATURE_SHA256_WITH_RSA_HPP
#include "../data.hpp"
#include "../encoding/tlv.hpp"
@@ -62,4 +62,4 @@
} // namespace ndn
-#endif
+#endif //NDN_SECURITY_SIGNATURE_SHA256_WITH_RSA_HPP
diff --git a/src/security/validator-null.hpp b/src/security/validator-null.hpp
index d1d8faa..eb186c6 100644
--- a/src/security/validator-null.hpp
+++ b/src/security/validator-null.hpp
@@ -6,8 +6,8 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_VALIDATOR_NULL_HPP
-#define NDN_VALIDATOR_NULL_HPP
+#ifndef NDN_SECURITY_VALIDATOR_NULL_HPP
+#define NDN_SECURITY_VALIDATOR_NULL_HPP
#include "validator.hpp"
@@ -37,6 +37,6 @@
{ onValidated(interest.shared_from_this()); }
};
-}
+} // namespace ndn
-#endif
+#endif //NDN_SECURITY_VALIDATOR_NULL_HPP
diff --git a/src/security/validator-regex.cpp b/src/security/validator-regex.cpp
index b85bad2..6569b58 100644
--- a/src/security/validator-regex.cpp
+++ b/src/security/validator-regex.cpp
@@ -17,8 +17,7 @@
using namespace std;
-namespace ndn
-{
+namespace ndn {
const shared_ptr<CertificateCache> ValidatorRegex::DefaultCertificateCache = shared_ptr<CertificateCache>();
@@ -62,7 +61,7 @@
}
else
{
- _LOG_DEBUG("Wrong Invalidity:");
+ _LOG_DEBUG("Wrong validity:");
onValidationFailed(data);
return;
}
@@ -150,4 +149,4 @@
return;
}
-}//ndn
+} // namespace ndn
diff --git a/src/security/validator-regex.hpp b/src/security/validator-regex.hpp
index d6b9b1d..f57d128 100644
--- a/src/security/validator-regex.hpp
+++ b/src/security/validator-regex.hpp
@@ -5,8 +5,8 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_VALIDATOR_REGEX_HPP
-#define NDN_VALIDATOR_REGEX_HPP
+#ifndef NDN_SECURITY_VALIDATOR_REGEX_HPP
+#define NDN_SECURITY_VALIDATOR_REGEX_HPP
#include "validator.hpp"
#include "identity-certificate.hpp"
@@ -92,6 +92,6 @@
ValidatorRegex::addTrustAnchor(shared_ptr<IdentityCertificate> certificate)
{ m_trustAnchors[certificate->getName().getPrefix(-1)] = certificate; }
-}//ndn
+} // namespace ndn
-#endif
+#endif //NDN_SECURITY_VALIDATOR_REGEX_HPP
diff --git a/src/security/validator.cpp b/src/security/validator.cpp
index 6eec2d0..d0c808b 100644
--- a/src/security/validator.cpp
+++ b/src/security/validator.cpp
@@ -256,4 +256,4 @@
return result;
}
-}
+} // namespace ndn
diff --git a/src/security/validator.hpp b/src/security/validator.hpp
index 5a1062d..7a75f70 100644
--- a/src/security/validator.hpp
+++ b/src/security/validator.hpp
@@ -6,8 +6,8 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_VALIDATOR_HPP
-#define NDN_VALIDATOR_HPP
+#ifndef NDN_SECURITY_VALIDATOR_HPP
+#define NDN_SECURITY_VALIDATOR_HPP
#include "../common.hpp"
@@ -152,6 +152,6 @@
shared_ptr<Face> m_face;
};
-}
+} // namespace ndn
-#endif
+#endif //NDN_SECURITY_VALIDATOR_HPP