Migrate to openssl 1.1 71/206971/1 accepted/tizen_5.5_unified accepted/tizen_5.5_unified_mobile_hotfix accepted/tizen_5.5_unified_wearable_hotfix tizen_5.5 tizen_5.5_mobile_hotfix tizen_5.5_tv tizen_5.5_wearable_hotfix accepted/tizen/5.5/unified/20191031.021457 accepted/tizen/5.5/unified/mobile/hotfix/20201027.085738 accepted/tizen/5.5/unified/wearable/hotfix/20201027.112405 accepted/tizen/unified/20190723.053603 submit/tizen/20190708.112222 submit/tizen/20190708.115723 submit/tizen/20190718.131607 submit/tizen/20190722.094101 submit/tizen_5.5/20191031.000004 submit/tizen_5.5_mobile_hotfix/20201026.185104 submit/tizen_5.5_wearable_hotfix/20201026.184304 tizen_5.5.m2_release
authorKonrad Lipinski <k.lipinski2@partner.samsung.com>
Tue, 28 May 2019 14:34:31 +0000 (16:34 +0200)
committerKonrad Lipinski <k.lipinski2@partner.samsung.com>
Wed, 29 May 2019 13:29:48 +0000 (15:29 +0200)
Change-Id: I75f690f2142159ec8a9fc4ec84425fc06f617171

CMakeLists.txt
initializer/CMakeLists.txt
packaging/drm-service-core-tizen.spec
tadcore/TADCInterface/TADC_IF.cpp
test/CMakeLists.txt
test/drm_testutil.cpp

index 36ada8d..139d098 100644 (file)
@@ -37,7 +37,7 @@ PKG_CHECK_MODULES(DRM_SERVICE_CORE_DEP
     sqlite3
     glib-2.0
     dlog
-    openssl
+    openssl1.1
 )
 
 INCLUDE_DIRECTORIES(
index e36c571..95f6281 100644 (file)
@@ -4,7 +4,7 @@ PKG_CHECK_MODULES(DRM_INITIALIZE_DEP
     sqlite3
     glib-2.0
     dlog
-    openssl
+    openssl1.1
 )
 
 INCLUDE_DIRECTORIES(${DRM_INITIALIZE_DEP_INCLUDE_DIRS})
index fbd7a56..94c6e54 100755 (executable)
@@ -11,7 +11,7 @@ BuildRequires:  cmake
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(sqlite3)
 BuildRequires:  pkgconfig(glib-2.0)
-BuildRequires:  pkgconfig(openssl)
+BuildRequires:  pkgconfig(openssl1.1)
 BuildRequires:  pkgconfig(cryptsvc)
 BuildRequires:  pkgconfig(libtzplatform-config)
 
index 7784ca1..6dd8504 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2000-2019 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Flora License, Version 1.1 (the License);
  * you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 #include <openssl/sha.h>
 #include <openssl/dh.h>
 #include <openssl/bn.h>
+#include <openssl/modes.h>
 
 //2011.03.08 to verify signature
 #include <openssl/x509.h>
@@ -93,11 +94,11 @@ int TADC_IF_GetDHKey(T_DH_INFO *t_dhinfo)
        };
        BYTE generator[1] = {DH_GENERATOR_5};
 
-       pDH->p = BN_bin2bn(prime64, 64, NULL);
-       pDH->g = BN_bin2bn(generator, 1, NULL);
+       DH_set0_pqg(pDH, BN_bin2bn(prime64, 64, NULL), nullptr,
+                       BN_bin2bn(generator, 1, NULL));
 
        /* Set a to run with normal modexp and b to use constant time */
-       pDH->flags &= ~DH_FLAG_NO_EXP_CONSTTIME;
+       DH_clear_flags(pDH, DH_FLAG_NO_EXP_CONSTTIME);
 
        // Debug
        DRM_TAPPS_LOG("After Set the Prime and Generator Value");
@@ -115,8 +116,8 @@ int TADC_IF_GetDHKey(T_DH_INFO *t_dhinfo)
        TADC_IF_MemCpy(t_dhinfo->p, prime64, 64);
        t_dhinfo->pSize = 64;
        t_dhinfo->g = DH_GENERATOR_5;
-       t_dhinfo->ASize = BN_bn2bin(pDH->pub_key, t_dhinfo->A);
-       t_dhinfo->aSize = BN_bn2bin(pDH->priv_key, t_dhinfo->a);
+       t_dhinfo->ASize = BN_bn2bin(DH_get0_pub_key(pDH), t_dhinfo->A);
+       t_dhinfo->aSize = BN_bn2bin(DH_get0_priv_key(pDH), t_dhinfo->a);
 
        //5. DH Free
        DH_free(pDH);
@@ -146,12 +147,12 @@ int TADC_IF_GetDHKey_K(T_DH_INFO *t_dhinfo)
        }
 
        //2.Set DH Info to pDH
-       pDH->p = BN_bin2bn(t_dhinfo->p, t_dhinfo->pSize, NULL);
        tempG[0] = t_dhinfo->g;
-       pDH->g = BN_bin2bn(tempG, 1, NULL);
-       pDH->flags &= ~DH_FLAG_NO_EXP_CONSTTIME;
-       pDH->pub_key = BN_bin2bn(t_dhinfo->A, t_dhinfo->ASize, NULL);
-       pDH->priv_key = BN_bin2bn(t_dhinfo->a, t_dhinfo->aSize, NULL);
+       DH_set0_pqg(pDH, BN_bin2bn(t_dhinfo->p, t_dhinfo->pSize, NULL), nullptr,
+                       BN_bin2bn(tempG, 1, NULL));
+       DH_clear_flags(pDH, DH_FLAG_NO_EXP_CONSTTIME);
+       DH_set0_key(pDH, BN_bin2bn(t_dhinfo->A, t_dhinfo->ASize, NULL),
+                       BN_bin2bn(t_dhinfo->a, t_dhinfo->aSize, NULL));
 
        //3. Set Public Key of Server
        pPubKey = BN_bin2bn(t_dhinfo->B, t_dhinfo->BSize, NULL);
@@ -190,7 +191,7 @@ int TADC_IF_AES_CTR(unsigned char *pKey, int ivLen, unsigned char *pIV,
        TADC_IF_MemSet(chain, 0, sizeof(chain));
        TADC_IF_MemCpy(chain, pIV, ivLen);
 
-       AES_ctr128_encrypt(in, out, inLen, &stKey, chain, ecount, &num);
+       CRYPTO_ctr128_encrypt(in, out, inLen, &stKey, chain, ecount, &num, (block128_f)AES_encrypt);
 
        *pOutLen = inLen;
 
@@ -396,8 +397,6 @@ error:
 int TADC_IF_VerifyCertChain(unsigned char *rica, int ricaLen,
                                                        unsigned char *cert, int certLen)
 {
-       OpenSSL_add_all_algorithms();
-
        X509_STORE *pstStore = X509_STORE_new();
 
        if (pstStore == NULL)
index 79b416d..4304f8a 100644 (file)
@@ -4,7 +4,7 @@ pkg_check_modules(DRM_TEST_DEP
     sqlite3
     glib-2.0
     dlog
-    openssl
+    openssl1.1
 )
 
 SET(DRMTESTUTIL_SRCS
index c235c09..5b25fed 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2000-2019 Samsung Electronics Co., Ltd. All rights reserved
  *
  * Licensed under the Flora License, Version 1.1 (the License);
  * you may not use this file except in compliance with the License.
@@ -52,17 +52,6 @@ static unsigned char g_baAESKey[32] = {
 };
 
 
-int __initialized = _UNINITIALIZED;
-
-void __init_crypto()
-{
-       if (__initialized != _INITIALIZED) {
-               ERR_load_crypto_strings();
-               OpenSSL_add_all_algorithms();
-               __initialized = _INITIALIZED;
-       }
-}
-
 int __get_random_bytes(char *output, int random_len)
 {
        FILE *fp = fopen("/dev/urandom", "r");
@@ -201,6 +190,7 @@ int _create_dh_key(const char *dh_key_p_hex, const char *dh_key_g_hex,
 {
        int ret = DRMTEST_SUCCESS;
        DH *pDH = NULL;
+       BIGNUM *p = NULL, *g = NULL;
 
        if ((pDH = DH_new()) == NULL) {
                printf("...FAIL: DH_new() error");
@@ -208,11 +198,12 @@ int _create_dh_key(const char *dh_key_p_hex, const char *dh_key_g_hex,
                goto error;
        }
 
-       BN_hex2bn(&(pDH->p), dh_key_p_hex);
-       BN_hex2bn(&(pDH->g), dh_key_g_hex);
+       BN_hex2bn(&p, dh_key_p_hex);
+       BN_hex2bn(&g, dh_key_g_hex);
+       DH_set0_pqg(pDH, p, nullptr, g);
 
        /* Set a to run with normal modexp and b to use constant time */
-       pDH->flags &= ~DH_FLAG_NO_EXP_CONSTTIME;
+       DH_clear_flags(pDH, DH_FLAG_NO_EXP_CONSTTIME);
 
        // Generate DH Key
        if (!DH_generate_key(pDH)) {
@@ -241,7 +232,7 @@ int _free_dh_key(DH *pkey)
 
 int _get_dh_hex_pubkey(const DH *pkey, char **dh_pubkey)
 {
-       *dh_pubkey = BN_bn2hex(pkey->pub_key);
+       *dh_pubkey = BN_bn2hex(DH_get0_pub_key(pkey));
        return DRMTEST_SUCCESS;
 }