blob: 82bb0362db7773d6ddcd7a0664b526e92e16b3f5 [file] [log] [blame]
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2018
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*******************************************************************************
* Filename:
* ---------
* mcf_custom.c
*
* Project:
* --------
* UMOLYA
*
* Description:
* ------------
* This file implements MCF customization.
*
* Author:
* -------
* -------
*
*==============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*==============================================================================
*******************************************************************************/
#include "kal_public_api.h"
#include "mcf_custom.h"
#include "cust_chl_interface.h"
#include "mcf_struct.h"
#if defined(__HIF_CCCI_SUPPORT__)
#include "ccci_rpc_if.h"
#endif
/*------------------------------------------------------------------------------
* Global variables.
*----------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
* Public fucntions.
*----------------------------------------------------------------------------*/
/*****************************************************************************
* FUNCTION
* mcf_get_custom_file_path_name
* DESCRIPTION
* This function is used to get MCF customized file path and name.
* PARAMETERS
* path_type [OUT] path type of file path
* relative_file_path_name [OUT] relative file path and name
*
* RETURNS
* KAL_TURE : Success
* KAL_FALSE : Fail
*****************************************************************************/
kal_bool mcf_get_custom_file_path_name(kal_uint8 *path_type, kal_char *relative_file_path_name)
{
#ifdef __MTK_TARGET__
#if defined(__HIF_CCCI_SUPPORT__)
/* CCCI RPC usage should be here */
#endif
#endif
return KAL_FALSE;
}
/*****************************************************************************
* FUNCTION
* mcf_get_custom_aes_password
* DESCRIPTION
* This function is used to get MCF customized AES password.
* PARAMETERS
* password [OUT] customized AES password
* NOTE
* For AES128, the key length should be less than 16, for AES256, the key length should be less than 32.
*
*****************************************************************************/
void mcf_get_custom_aes_password(kal_char *password)
{
#define __MCF_AES_KEY_SCRAMBLE__
/* Password must be the same as MCF bin */
#if !defined(__MCF_AES_KEY_SCRAMBLE__)
/* Fill-in plaintext to save password*/
kal_char plaintext_password[] = "MTKTEST";
strncpy(password, plaintext_password, MCF_MAX_PASSWORD_LEN);
#else
/* Fill-in the reverse password to save it*/
/* for example : original passwork is "MTKTEST", fill-in "TSETKTM" */
kal_char scrambled_password[] = "TSETKTM";
// The scramble algorithm is string reverse, customer can design a way in the following code
{
kal_uint8 i = 0, j = (sizeof(scrambled_password) - 2);
for (i = 0 ; i < (sizeof(scrambled_password) - 1)/2 ; i++, j--)
{
kal_char temp_c = scrambled_password[i];
scrambled_password[i] = scrambled_password[j];
scrambled_password[j] = temp_c;
}
}
strncpy(password, scrambled_password, MCF_MAX_PASSWORD_LEN);
#endif
}
/*****************************************************************************
* FUNCTION
* mcf_get_custom_digest_public_key
* DESCRIPTION
* This function is used to get MCF digest public key.
* PARAMETERS
* digest_key_seq [IN] key sequence from OTA file
* key [OUT] digest public key of this digest_key_seq
*
*****************************************************************************/
kal_bool mcf_get_custom_digest_public_key(kal_uint32 digest_key_seq, t_cust_chl_asym_key *key)
{
// customer defines the mapping between "digest_key_seq from OTA file" and "public key in custom_sec_key.c"
if (digest_key_seq == 0)
{
CustCHL_Get_Asym_Key(CUST_MCF_PUB_KEY1, key);
return KAL_TRUE;
}
else if (digest_key_seq == 1)
{
CustCHL_Get_Asym_Key(CUST_MCF_PUB_KEY2, key);
return KAL_TRUE;
}
/*
else if (digest_key_seq == 2)
{
CustCHL_Get_Asym_Key(CUST_MCF_PUB_KEY3, key);
}
*/
return KAL_FALSE; // key not found
}
/*****************************************************************************
* FUNCTION
* mcf_get_custom_operation_mask
* DESCRIPTION
* This function is used to get MCF customized operation mask.
* If OTA file without customized operation mask, MCF won't update OTA file.
* PARAMETERS
* operation_mask [OUT] customized operation mask
*
*****************************************************************************/
kal_uint32 mcf_get_custom_operation_mask()
{
// customer defines the operation mask which file must have
kal_uint32 operation_mask = 0;
/* //If OTA file must with checksum check
operation_mask |= MCF_FILE_OP_CHECKSUM;
*/
/* //If OTA file must with AES-128 encryption
operation_mask |= MCF_FILE_OP_AES_128;
*/
/* //If OTA file must with AES-256 encryption
operation_mask |= MCF_FILE_OP_AES_256;
*/
/* //If OTA file must with SHA-256 and RSA-2048 digital signature
operation_mask |= MCF_FILE_OP_SHA256_RSA2048;
*/
return operation_mask;
}