security: Add KeyParams to support multiple types of keys.

Different types of keys may require different size options and default key size.
This commit also fixes the undefined behavior when processing the password of TPM.

Change-Id: I8fb95f28468be8299002f0d5146a4496ea1da25f
Refs: #1660
Refs: #1693
diff --git a/src/security/sec-tpm-osx.hpp b/src/security/sec-tpm-osx.hpp
index 306e417..fca8dda 100644
--- a/src/security/sec-tpm-osx.hpp
+++ b/src/security/sec-tpm-osx.hpp
@@ -53,9 +53,7 @@
   ~SecTpmOsx();
 
 
-  /******************************
-   * From TrustedPlatformModule *
-   ******************************/
+  // Following methods are inherited from SecTpm
 
   virtual void
   setTpmPassword(const uint8_t* password, size_t passwordLength);
@@ -76,9 +74,9 @@
   unlockTpm(const char* password, size_t passwordLength, bool usePassword);
 
   virtual void
-  generateKeyPairInTpm(const Name& keyName, KeyType keyType, int keySize)
+  generateKeyPairInTpm(const Name& keyName, const KeyParams& params)
   {
-    generateKeyPairInTpmInternal(keyName, keyType, keySize, false);
+    generateKeyPairInTpmInternal(keyName, params, false);
   }
 
   virtual void
@@ -104,7 +102,7 @@
   encryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric);
 
   virtual void
-  generateSymmetricKeyInTpm(const Name& keyName, KeyType keyType, int keySize);
+  generateSymmetricKeyInTpm(const Name& keyName, const KeyParams& params);
 
   virtual bool
   doesKeyExistInTpm(const Name& keyName, KeyClass keyClass);
@@ -116,9 +114,7 @@
   addAppToAcl(const Name& keyName, KeyClass keyClass, const std::string& appPath, AclType acl);
 
 protected:
-  /******************************
-   * From TrustedPlatformModule *
-   ******************************/
+  // Following methods are inherited from SecTpm
   virtual ConstBufferPtr
   exportPrivateKeyPkcs8FromTpm(const Name& keyName)
   {
@@ -134,11 +130,9 @@
   virtual bool
   importPublicKeyPkcs1IntoTpm(const Name& keyName, const uint8_t* buf, size_t size);
 
-  /******************************
-   *       OSX-specifics        *
-   ******************************/
+  // Following methods are OSX-specific
   void
-  generateKeyPairInTpmInternal(const Name& keyName, KeyType keyType, int keySize, bool needRetry);
+  generateKeyPairInTpmInternal(const Name& keyName, const KeyParams& params, bool needRetry);
 
   void
   deleteKeyPairInTpmInternal(const Name& keyName, bool needRetry);