Add PASSWORD_PROTECTION_DISABLE feature 15/52215/1
authorDongsun Lee <ds73.lee@samsung.com>
Fri, 20 Nov 2015 02:55:02 +0000 (11:55 +0900)
committerDongsun Lee <ds73.lee@samsung.com>
Fri, 20 Nov 2015 02:55:02 +0000 (11:55 +0900)
Change-Id: I58a8bde0e4424168a61590d6a5f12fb8e28f50b2
Signed-off-by: Dongsun Lee <ds73.lee@samsung.com>
CMakeLists.txt
packaging/key-manager.spec
src/manager/service/key-provider.cpp
src/manager/service/key-provider.h

index 73720b1..bc0aab1 100644 (file)
@@ -62,6 +62,11 @@ IF (DEFINED SYSTEMD_ENV_FILE)
     ADD_DEFINITIONS(-DSYSTEMD_ENV_FILE="${SYSTEMD_ENV_FILE}")
 ENDIF (DEFINED SYSTEMD_ENV_FILE)
 
+IF (DEFINED PASSWORD_PROTECTION_DISABLE)
+    MESSAGE("PASSWORD_PROTECTION_DISABLE ENABLED !")
+    ADD_DEFINITIONS("-DPASSWORD_PROTECTION_DISABLE")
+ENDIF (DEFINED PASSWORD_PROTECTION_DISABLE)
+
 SET(TARGET_KEY_MANAGER "key-manager")
 SET(TARGET_KEY_MANAGER_CLIENT "key-manager-client")
 SET(TARGET_KEY_MANAGER_CONTROL_CLIENT "key-manager-control-client")
index 23b89b0..6cdffd4 100644 (file)
@@ -113,6 +113,8 @@ cp -a %{SOURCE1005} .
     export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
 %endif
 
+# password protection enabled
+%define ckm_password_protection_disable 1
 
 export LDFLAGS+="-Wl,--rpath=%{_libdir},-Bsymbolic-functions "
 
@@ -121,6 +123,9 @@ export LDFLAGS+="-Wl,--rpath=%{_libdir},-Bsymbolic-functions "
         -DCMAKE_VERBOSE_MAKEFILE=ON \
         -DSYSTEMD_UNIT_DIR=%{_unitdir} \
         -DSYSTEMD_ENV_FILE="/etc/sysconfig/central-key-manager" \
+%if 0%{?ckm_password_protection_disable}
+        -DPASSWORD_PROTECTION_DISABLE=1 \
+%endif
         -DMOCKUP_SM=%{?mockup_sm:%mockup_sm}%{!?mockup_sm:OFF}
 
 make %{?jobs:-j%jobs}
index 23ca201..ce6e72b 100644 (file)
@@ -140,7 +140,7 @@ KeyProvider::KeyProvider(
 
     concat_user_pass = concat_password_user(
         wkmcDKEK.getWrappedKeyAndInfo().keyInfo.label,
-        password.c_str());
+        getConvertedStr(password));
 
     if (!PKCS5_PBKDF2_HMAC_SHA1(
         concat_user_pass,
@@ -223,7 +223,7 @@ RawBuffer KeyProvider::getWrappedDomainKEK(const Password &password)
 
     concat_user_pass = concat_password_user(
         m_kmcDKEK->getKeyAndInfo().keyInfo.label,
-        password.c_str());
+        getConvertedStr(password));
 
     if (!PKCS5_PBKDF2_HMAC_SHA1(
         concat_user_pass,
@@ -393,7 +393,7 @@ RawBuffer KeyProvider::reencrypt(
 
     concat_user_pass = concat_password_user(
         wkmcOldDKEK.getWrappedKeyAndInfo().keyInfo.label,
-        oldPass.c_str());
+        getConvertedStr(oldPass));
 
     if (!PKCS5_PBKDF2_HMAC_SHA1(
         concat_user_pass,
@@ -425,7 +425,7 @@ RawBuffer KeyProvider::reencrypt(
 
     concat_user_pass = concat_password_user(
         kmcDKEK.getKeyAndInfo().keyInfo.label,
-        newPass.c_str());
+        getConvertedStr(newPass));
 
     if (!PKCS5_PBKDF2_HMAC_SHA1(
         concat_user_pass,
@@ -477,7 +477,7 @@ RawBuffer KeyProvider::generateDomainKEK(
 
     int wrappedKeyLength;
     char *concat_user_pass = NULL;
-    concat_user_pass = concat_password_user(user.c_str(), userPassword.c_str());
+    concat_user_pass = concat_password_user(user.c_str(), getConvertedStr(userPassword));
     if (!PKCS5_PBKDF2_HMAC_SHA1(
         concat_user_pass,
         strlen(concat_user_pass),
@@ -645,3 +645,13 @@ char * KeyProvider::concat_password_user(const char *user, const char *password)
     delete[] resized_user;
     return concat_user_pass;
 }
+
+const char* KeyProvider::getConvertedStr(const Password &password)
+{
+#ifdef PASSWORD_PROTECTION_DISABLE
+    (void ) password;
+    return "";
+#else
+    return password.c_str();
+#endif
+}
index 918a622..dd22c32 100644 (file)
@@ -169,6 +169,7 @@ private:
         const char *user,
         const char *password);
 
+    static const char* getConvertedStr(const Password &password);
 };
 
 } // namespace CKM