/* return the result of hwDisableClock ( )
   - TRUE  (1) means crypto engine de-init success
   - FALSE (0) means crypto engine de-init fail    */
unsigned char masp_secure_algo_deinit(void)
{
    return masp_hal_secure_algo_deinit();
}
Esempio n. 2
0
static char* hacc_secure_request(HACC_USER user, unsigned char *buf, unsigned int buf_size,
                                 BOOL bEncrypt, BOOL bDoLock, unsigned char *sec_seed, unsigned int seed_size)
{
    unsigned int ret = SEC_OK;

    /* get hacc lock */
    if(TRUE == bDoLock)
    {
        /* If the semaphore is successfully acquired, this function returns 0.*/
        ret = osal_hacc_lock();

        if(ret)
        {
            ret = ERR_SBOOT_HACC_LOCK_FAIL;
            goto _exit;
        }
    }
    /* turn on clock */
    masp_hal_secure_algo_init();


    if(buf_size != 0)
    {
        /* try to open connection to TEE */
        if(open_sdriver_connection() < 0)
        {
            ret = ERR_HACC_OPEN_SECURE_CONNECTION_FAIL;
            goto _exit;
        }

        /* send request to TEE */
        if( (ret = tee_secure_request((unsigned int)user, buf, buf_size, (unsigned int)bEncrypt, sec_seed, seed_size)) != SEC_OK)
        {
            ret = ERR_HACC_REQUEST_SECURE_SERVICE_FAIL;
            goto _exit;
        }

        if(close_sdriver_connection() < 0)
        {
            ret = ERR_HACC_CLOSE_SECURE_CONNECTION_FAIL;
            goto _exit;
        }
    }
    else
    {
        printk("[HACC] hacc_secure_request - buffer size is 0, no encryption or decyrption is performed\n");
    }


_exit:
    /* turn off clock */
    masp_hal_secure_algo_deinit();
    /* release hacc lock */
    if(TRUE == bDoLock)
    {
        osal_hacc_unlock();
    }

    if(ret)
    {
        printk("[HACC] hacc_secure_request fail (0x%x) (don't ASSERT)\n", ret);

        //ASSERT(0);
    }

    return buf;
}