Use cryptsvc for derive key from platform key 02/58602/1 accepted/tizen/ivi/20160218.023747 accepted/tizen/mobile/20160203.050936 accepted/tizen/tv/20160203.050949 accepted/tizen/wearable/20160203.051012 submit/tizen/20160202.104355 submit/tizen_common/20160218.142243 submit/tizen_ivi/20160217.000000 submit/tizen_ivi/20160217.000003
authorKyungwook Tak <k.tak@samsung.com>
Tue, 2 Feb 2016 07:08:08 +0000 (16:08 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Tue, 2 Feb 2016 07:08:24 +0000 (16:08 +0900)
Dukgenerator API integrated to cryptsvc

Change-Id: I7165467996fbd8b046b10d67013b89224fc7afd8
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
CMakeLists.txt
packaging/drm-service-core-tizen.spec
tappsd/src/util/DTapps2HMAC.cpp
test/CMakeLists.txt

index d59040b..7cc97ff 100644 (file)
@@ -44,7 +44,6 @@ pkg_check_modules(DRM_SERVICE_CORE_DEP
        dlog
        db-util
        openssl
-    dukgenerator
     cryptsvc
     libtzplatform-config
 )
@@ -98,7 +97,6 @@ pkg_check_modules(DRM_INITIALIZE_DEP
        dlog
        db-util
        openssl
-    dukgenerator
 #    cryptsvc
 )
 
index 24e0aa2..4fb6dc2 100755 (executable)
@@ -12,7 +12,6 @@ BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(db-util)
 BuildRequires:  pkgconfig(openssl)
 BuildRequires:  pkgconfig(cryptsvc)
-BuildRequires:  pkgconfig(dukgenerator)
 BuildRequires:  pkgconfig(libtzplatform-config)
 
 %description
index 9848de5..b454092 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-
 /**
  * @file       DTapps2HMAC.cpp
  * @brief      This file includes functions relating to HMAC.
  * @author     Harsha Shekar (h.shekar@samsung.com)
  */
-#include <dukgen.h>
+#include "DTapps2HMAC.h"
+
 #include <openssl/evp.h>
 #include <openssl/hmac.h>
 
-#include "DTapps2HMAC.h"
+#include <SecCryptoSvc.h>
 
 void DTappsCalHMACSHA1(unsigned char* key,int key_len,unsigned char* msg,size_t msglen,unsigned char *md,unsigned int *md_len)
 {
        HMAC(EVP_sha1(),(void*)key,key_len,msg,msglen,md,md_len);
 }
 
-int DTappsGetDeviceKey(unsigned char **pDevKey,unsigned int *DevKeyLen)
+int DTappsGetDeviceKey(unsigned char **pDevKey, unsigned int *pDevKeyLen)
 {
-       int                             ret = 0;
-       char                    passwd[30] = {0,};
-       unsigned int    LocalKeyLen = 16;
-
-       char* pDuk = GetDeviceUniqueKey(passwd, strlen(passwd), 16);
-
-       if (!pDuk || !pDevKey || !DevKeyLen)
-       {
-               DRM_TAPPS_EXCEPTION("pDevKey = %p, DevKeyLen = %p",pDevKey,DevKeyLen);
-               goto DTApps_ERR;
+       if (pDevKey == NULL || pDevKeyLen == NULL) {
+               DRM_TAPPS_EXCEPTION("Invalid parameters on DTappsGetDeviceKey.");
+               return 0;
        }
 
-       DRM_TAPPS_LOG("LocalKeyLen = %u", LocalKeyLen);
-
-       *pDevKey = (unsigned char*)DTAPPS_MALLOC(LocalKeyLen + 1);
-
-       if(NULL == *pDevKey)
-       {
-               DRM_TAPPS_EXCEPTION("Malloc Failed");
-
-               goto DTApps_ERR;
+       constexpr int KeyLen = 16;
+       char passwd[30] = {0,};
+       unsigned char *key = NULL;
+       int ret = cs_derive_key_with_pass(passwd, strlen(passwd), KeyLen, &key);
+       if (ret != CS_ERROR_NONE || key == NULL) {
+               DRM_TAPPS_EXCEPTION("cs_derive_key_with_pass ret[%d]", ret);
+               free(key);
+               return 0;
        }
 
-       DTAPPS_MEMSET(*pDevKey, 0x0, LocalKeyLen + 1);
-       DTAPPS_MEMCPY(*pDevKey, pDuk, LocalKeyLen);
-
-       *DevKeyLen = LocalKeyLen;
-       ret = 1;
-
-DTApps_ERR:
+       *pDevKey = key;
+       *pDevKeyLen = static_cast<unsigned int>(KeyLen);
 
-       if (ret == 1)
-               DRM_TAPPS_LOG("SUCCESS:ret=%d", ret);
-       else
-               DRM_TAPPS_EXCEPTION("FAILED:ret=%d", ret);
-
-       free(pDuk);
-
-       return ret;
+       return 1;
 }
 
 void DTappsFreeDeviceKey(unsigned char **pDevKey)
 {
-       if(pDevKey == NULL)
-       {
-               DRM_TAPPS_EXCEPTION("pDevKey = %p", pDevKey);
-
+       if (pDevKey == NULL)
                return;
-       }
 
        DTAPPS_FREE(*pDevKey);
        *pDevKey = NULL;
index 4e44c2c..a15bd00 100644 (file)
@@ -3,7 +3,6 @@ pkg_check_modules(DRM_TEST_DEP
        dlog
        db-util
        openssl
-    dukgenerator
     cryptsvc
     libtzplatform-config
 )