Untitled

mail@pastecode.io avatar
unknown
plain_text
4 months ago
1.2 kB
3
Indexable
int32_t openSecureObject(const uint8_t *inData, const uint32_t inDataLen,
        uint8_t *outData, uint32_t *outDataLen, const uint8_t *targetUid, const uint32_t targetUidLen)
{
    char srcTaName[MAX_TID_SIZE];
    int32_t ret = NOT_ERROR;


    if(inData == NULL || inDataLen == 0 || outData == NULL || outDataLen == NULL || targetUid == NULL)
    {
        LOGE("%s : Invalid argument.", __func__);
        return ERR_TA_INVALID_ARGUMENT;
    }

    memset(srcTaName, 0, sizeof(srcTaName));

    if((ret = qsee_decapsulate_inter_app_message(srcTaName, (uint8_t *)inData, inDataLen,
                    outData, (qc_uint32_t *)outDataLen)) != NOT_ERROR)
    {
        LOGE("Failed to open secure object with error 0x%X.", ret);
        return ERR_TA_QSEE_BASE - (ret & 0x0000FFF);
    }

    if(strncmp(srcTaName, (const char *)targetUid, (strlen(srcTaName) < targetUidLen) ? strlen(srcTaName) : targetUidLen)) // <- check can be bypassed, because according to comparison "s" == "skm", "skm.not_skm" == "skm"
    {
        LOGE("Unsupported source TA : %s.", srcTaName);
        ret = ERR_TA_INVALID_BLOB;
    }

    return ret;
}
Leave a Comment