diff --git a/interfaces/innerkits/syspara/param_comm.c b/interfaces/innerkits/syspara/param_comm.c index 477483178d1ad9f1056687816550950bdc9ef81a..fa9d7962002f2a76026c111909514e4d4df1d924 100644 --- a/interfaces/innerkits/syspara/param_comm.c +++ b/interfaces/innerkits/syspara/param_comm.c @@ -26,9 +26,8 @@ #include "sysparam_errno.h" #ifdef USE_MBEDTLS #include "mbedtls/sha256.h" -#elif !(defined OHOS_LITE) -#include "openssl/sha.h" #endif + #include "securec.h" #include "beget_ext.h" @@ -152,27 +151,6 @@ static int GetSha256Value(const char *input, char *udid, int udidSize) } return EC_SUCCESS; } -#elif !(defined OHOS_LITE) -static int GetSha256Value(const char *input, char *udid, int udidSize) -{ - char buf[DEV_BUF_LENGTH] = { 0 }; - unsigned char hash[SHA256_DIGEST_LENGTH] = { 0 }; - SHA256_CTX sha256; - if ((SHA256_Init(&sha256) == 0) || (SHA256_Update(&sha256, input, strlen(input)) == 0) || - (SHA256_Final(hash, &sha256) == 0)) { - return -1; - } - - for (size_t i = 0; i < SHA256_DIGEST_LENGTH; i++) { - unsigned char value = hash[i]; - (void)memset_s(buf, DEV_BUF_LENGTH, 0, DEV_BUF_LENGTH); - int len = sprintf_s(buf, sizeof(buf), "%02X", value); - if (len > 0 && strcat_s(udid, udidSize, buf) != 0) { - return -1; - } - } - return 0; -} #else static int GetSha256Value(const char *input, char *udid, int udidSize) { @@ -204,6 +182,11 @@ INIT_LOCAL_API int GetDevUdid_(char *udid, int size) if (size < UDID_LEN || udid == NULL) { return EC_FAILURE; } + + uint32_t len = size; + int ret = SystemGetParameter("const.product.udid", udid, &len); + BEGET_CHECK(ret != 0, return ret); + const char *manufacture = GetManufacture_(); const char *model = GetProductModel_(); const char *sn = GetSerial_(); @@ -224,7 +207,7 @@ INIT_LOCAL_API int GetDevUdid_(char *udid, int size) return -1; } - int ret = GetSha256Value(tmp, udid, size); + ret = GetSha256Value(tmp, udid, size); free(tmp); return ret; } diff --git a/services/etc/param/ohos.para.dac b/services/etc/param/ohos.para.dac index 34b58bbf81361151e5c1df2209fcc1fc3f8562c2..fb3df12466c3525c515d848b25817d8b8d6a4aad 100755 --- a/services/etc/param/ohos.para.dac +++ b/services/etc/param/ohos.para.dac @@ -32,6 +32,7 @@ persist.appspawn. = root:root:0775 #udid and sn, only read ohos.boot.sn = root:deviceprivate:0750 +const.product.udid = root:deviceprivate:0750 const.actionable_compatible_property.enabled = root:root:0777 const.postinstall.fstab.prefix = root:root:0777