blob: 7534814d55274980e50339e2c1acd4fc0adcae9b [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) 2016
*
* 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).
*
*****************************************************************************/
/*************************************************************
*
* This Software is the property of VIA Telecom, Inc. and may only be used pursuant to a license from VIA Telecom, Inc.
*
* Any unauthorized use inconsistent with the terms of such license is strictly prohibited.
*
* Copyright (c) 2006-2010 VIA Telecom, Inc. All rights reserved.
*
*************************************************************/
/*****************************************************************************
FILE NAME: slcdhkep.h
DESCRIPTION:
This file contains all the constants and apies
that are common for processing dhkep request/response messages.
*****************************************************************************/
#ifndef _SLC_DH_KEP_H
#define _SLC_DH_KEP_H
#include "pswdhapi.h"
#include "do_dsaapi.h"
#include "do_slapi.h"
#include "slc_nvram.h"
#define DHKEP_SIGNATURE_BYTES 20 /* the lenght of signature in bytes */
#define T_KEPKeyResponse 30000
#define T_KEPSigCompAT 3500
#define AT_RAND_SIZE 4 /* this value has big influence to Key Computation time */
typedef enum {
DHKEP_INCONFIG,
DHKEP_INUSE,
DHKEP_MAX_INSTANCE
} DHKepInstanceT;
/* Timer ID*/
typedef enum
{
DHKEP_KEYCAL_TIMER_ID, /* for key calculation */
DHKEP_KEYCOMP_SIG_TIMER_ID, /* for T_KeyCompATTimer */
DHKEP_TIMER_NUM
}DHKEPTimerId;
/*States of DHKEP Module*/
typedef enum
{
DHKEP_INACTIVE_ST, /* Inactive state */
DHKEP_IDLE_ST,
DHKEP_WAIT_ATKEY_RSP_ST, /* Waiting for ATPubKey cal done */
DHKEP_WAIT_SKEY_RSP_ST, /* Waiting for SKey cal is done */
DHKEP_WAIT_KEY_CAL_DONE_ST,
DHKEP_WAIT_START_ST,
DHKEP_WAIT_START_KEY_CAL_ST
}DHKepStateE;
typedef struct
{
kal_uint8 Bytes;
kal_uint8 Number[128];
} SlcDHKepConstantT;
typedef struct
{
kal_uint32 TimerId;
} DHKepTimerExpiredMsgT;
/* this is the state variables of DHKep protocol InConfig entity */
typedef struct
{
kal_uint64 TimeStampLong; /* TimeStamp form AN (ANKeyComplete Msg) */
kal_uint16 Nonce; /* Nonce from AN (ANKeyComplete Msg) */
kal_uint8 KeySignatureAN[SHA1_HASH_SIZE];/* Key signature form AN (ANKeyComplete Msg) */
SlcDHKepSKeyT ATPubKeyInCfg; /* AT Public Key */
SlcDHKepSKeyT ANPubKeyInCfg; /* AN Public Key */
kal_uint32 T_KEPKeyCompAN; /* ExpireTime of AN send ANKeyComplete*/
kal_uint16 KeyLengthInBytes; /* Length of SKey in bytes for InConfig instance */
kal_uint8 ATRand[AT_RAND_SIZE]; /* A Random Number between 1 and p-2, AT Private Key */
kal_uint8 DHKepTransId; /* DHKep TransactionID */
DHKepStateE DHKepState; /* the current state of DHKEP Module */
kal_bool bANSendKeyReq; /* Is AN send KeyRequestMsg */
kal_bool bANSendKeyComplete; /* Is AN send KeyRequestMsg */
kal_bool bCalcATPubKeyDone; /* Is AT calculate AT public key done */
kal_bool bCalcSKeyDone; /* Is AT calculate SKey done */
}SlcDHKepStateInfoT;
#ifdef __cplusplus
extern "C" {
#endif
/*------------------------------------------------------------------------
* Defined Configuration attributes..
*------------------------------------------------------------------------*/
typedef enum
{
/*Mssage ID for DH Key Exchange Protocol*/
DHKEP_KEY_REQ_MSG,
DHKEP_KEY_RSP_MSG,
DHKEP_AN_KEY_COMPLETE_MSG,
DHKEP_AT_KEY_COMPLETE_MSG,
SEC_CONFIG_REQUEST_MESSAGE = 0x50,
SEC_CONFIG_RESPONSE_MESSAGE
}SecMsgTypeE;
/****************************************************************************
DHKep Functions...
****************************************************************************/
void KepInit(void);
void DHKepHandleDsaFMsg(DsaFwdMsgT *MsgDataP);
void DHKepHandleTmExpireMsg(DHKepTimerExpiredMsgT* pMsg);
void DHKepRecvKeyCalRspMsg(DHKepCalRspMsgT* pData);
void DHKepHandleEvtScpReCfgInd(void);
void DHKepGenerateSecurityPacket(kal_uint8 *SecurityPacket, kal_uint8 *SecurityPacketLen);
#ifdef __cplusplus
}
#endif
#endif