blob: e90ef454f471ba699771eb2143538c3f754bf09e [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001/*****************************************************************************
2* Copyright Statement:
3* --------------------
4* This software is protected by Copyright and the information contained
5* herein is confidential. The software may not be copied and the information
6* contained herein may not be used or disclosed except with the written
7* permission of MediaTek Inc. (C) 2016
8*
9* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
10* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS (""MEDIATEK SOFTWARE"")
11* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
12* AN ""AS-IS"" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
13* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
14* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
15* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
16* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
17* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
18* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
19* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
20* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
21*
22* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
23* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
24* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
25* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
26* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
27*
28* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
29* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
30* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
31* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
32* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
33*
34*****************************************************************************/
35/*************************************************************
36*
37* This Software is the property of VIA Telecom, Inc. and may only be used pursuant to a license from VIA Telecom, Inc.
38*
39* Any unauthorized use inconsistent with the terms of such license is strictly prohibited.
40*
41* Copyright (c) 1999-2010 VIA Telecom, Inc. All rights reserved.
42*
43*************************************************************/
44/*************************************************************************
45 *
46 * File Name: pswdhdata.h
47 * Project: Diffie Hellman
48 * Original Author: Dan Doucette
49 * Creation Date: Oct. 5 1999
50 *
51 * Description: Defines data types used in the calculation of the
52 * Diffie Hellman exponent
53 *
54 * Restrictions:
55 *
56 * Dependencies:
57 *
58 *************************************************************************
59 *
60 * This Software is the property of ISOTEL Corporation. Unauthorized
61 * use is prohibited.
62 *
63 * ISOTEL Corporation
64 * 340, 525-28 Street S.E.
65 * Calgary, Alberta, Canada T2A 6W9
66 * Tel: (403)275-0041 Fax: (403)274-3598
67 * Web: http://www.isotel.com
68 *
69 *
70 *************************************************************************
71 *
72 * RCS Log Information
73 *
74 * $Revision: 1.2 $
75 *
76 * $Log: pswdhdata.h $
77 *
78 * 07 06 2017 sue.zhong
79 * [MOLY00259241] [6293][C2K]Replace with KAL data type
80 * Correct copyright file header
81 * Revision 1.2 2004/03/25 12:07:47 fpeng
82 * Updated from 6.0 CP 2.5.0
83 * Revision 1.1 2003/05/12 15:39:21 fpeng
84 * Initial revision
85 * Revision 1.2 2002/06/06 14:25:29 dstecker
86 * Updated copyright notice
87 * Revision 1.1 2001/07/23 11:35:29 mclee
88 * Initial revision
89 * Revision 1.1 2001/01/24 11:24:29 mclee
90 * Initial revision
91 * Revision 1.1 2001/01/24 00:08:49Z mclee
92 * Initial revision
93 * Revision 1.0 1999/12/02 14:27:20 danfeng hong
94 * Initial revision
95 *
96 *
97 ************************************************************************/
98
99#ifndef _DH_DATA_H
100#define _DH_DATA_H
101
102#include "pswdhtune.h"
103
104/*
105 * Definition of the type of block used for the storage of the
106 * giant integers
107 */
108typedef kal_uint16 DHBlockType;
109typedef kal_uint32 DHCarryBlockType;
110typedef kal_int32 DHBorrowBlockType;
111
112/*
113 * Define the maximum possible value for the DHBlockType
114 */
115#define DH_MAX_BLOCK_VALUE 0xffff
116
117#define DH_MAX_CARRY_BLOCK_VALUE 0xffffffff
118
119/*
120 * Number of bits in each block
121 */
122#define DH_BIT_SIZE (sizeof(DHBlockType)*8)
123
124/*
125 * Number of half bytes in each block
126 */
127#define DH_HALF_kal_uint8_SIZE (sizeof(DHBlockType)*2)
128
129/*
130 * Number of bytes in each block
131 */
132#define DH_kal_uint8_SIZE (sizeof(DHBlockType))
133
134/*
135 * Number of blocks required to make a giant integer using the above
136 * block size. Eg. 32 blocks @ 16 bits per block = 512 bit integer
137 */
138#define DH_MAX_BLOCKS (DH_KEY_BIT_SIZE+DH_BIT_SIZE-1)/DH_BIT_SIZE
139
140/*
141 * extra blocks to hold extra 32 bits of giant Integers during calculations.
142 */
143 /*
144#define DH_EXTRA_BLOCKS ((32+DH_BIT_SIZE-1)/DH_BIT_SIZE)
145 */
146#define DH_EXTRA_BLOCKS 6
147
148/*
149 * Number of bytes required to make a giant integer using the above
150 * block size.
151 */
152#define DH_MAX_kal_uint8S (DH_KEY_BIT_SIZE+7)/8
153
154/*
155 * generic giant integer types (right-adjusted: LS bit is at 0 bit of 0 byte,
156 * MS bit is in size-1th block)
157 * Each has extra blocks(32 bits) to accommodate larger accumulation and shift values
158 */
159typedef struct {
160 kal_int16 size;
161 DHBlockType number[DH_MAX_BLOCKS+DH_EXTRA_BLOCKS];
162} DHGiantInt;
163
164/*
165 * generic encryption value types (left-adjusted: MS bit is at 7th bit of 0 byte)
166 * value -- hold a byte stream of the encryption value;
167 * bits -- points out how many bits are actual used in the byte stream
168 */
169typedef struct{
170 kal_int16 bits;
171 kal_uint8 value[DH_MAX_kal_uint8S];
172}DHEncryptVal;
173
174#endif
175
176