MT2523 API Reference  LinkIt SDK v4
hal_sha.h
1 /* Copyright Statement:
2  *
3  * (C) 2005-2016 MediaTek Inc. All rights reserved.
4  *
5  * This software/firmware and related documentation ("MediaTek Software") are
6  * protected under relevant copyright laws. The information contained herein
7  * is confidential and proprietary to MediaTek Inc. ("MediaTek") and/or its licensors.
8  * Without the prior written permission of MediaTek and/or its licensors,
9  * any reproduction, modification, use or disclosure of MediaTek Software,
10  * and information contained herein, in whole or in part, shall be strictly prohibited.
11  * You may only use, reproduce, modify, or distribute (as applicable) MediaTek Software
12  * if you have agreed to and been bound by the applicable license agreement with
13  * MediaTek ("License Agreement") and been granted explicit permission to do so within
14  * the License Agreement ("Permitted User"). If you are not a Permitted User,
15  * please cease any access or use of MediaTek Software immediately.
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES
18  * ARE PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
19  * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
21  * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
22  * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
23  * SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
24  * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
25  * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
26  * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
27  * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
28  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
29  * CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
30  * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE MEDIATEK SOFTWARE AT ISSUE,
31  * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
32  * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
33  */
34 
35 #ifndef __HAL_SHA_H__
36 #define __HAL_SHA_H__
37 #include "hal_platform.h"
38 
39 #ifdef HAL_SHA_MODULE_ENABLED
40 
41 #ifdef HAL_SHA_USE_PHYSICAL_MEMORY_ADDRESS
42 
85 #else
86 
128 #endif
129 
130 
131 #include "hal_define.h"
132 
133 #ifdef __cplusplus
134 extern "C" {
135 #endif
136 
141 #define HAL_SHA1_BLOCK_SIZE (64)
142 #define HAL_SHA1_DIGEST_SIZE (20)
143 #define HAL_SHA224_BLOCK_SIZE (64)
144 #define HAL_SHA224_DIGEST_SIZE (28)
145 #define HAL_SHA256_BLOCK_SIZE (64)
146 #define HAL_SHA256_DIGEST_SIZE (32)
147 #define HAL_SHA384_BLOCK_SIZE (128)
148 #define HAL_SHA384_DIGEST_SIZE (48)
149 #define HAL_SHA512_BLOCK_SIZE (128)
150 #define HAL_SHA512_DIGEST_SIZE (64)
162 typedef enum {
163  HAL_SHA_STATUS_ERROR = -1,
164  HAL_SHA_STATUS_OK = 0
165 } hal_sha_status_t;
166 
177 typedef struct {
178  uint32_t hash_value[16];
179  uint32_t message_length;
180  uint8_t buffer[HAL_SHA512_BLOCK_SIZE];
181  uint8_t *block;
182  uint32_t block_length;
183 } hal_sha_context_t;
184 
186 #define hal_sha1_context_t hal_sha_context_t
187 
188 #define hal_sha224_context_t hal_sha_context_t
189 
190 #define hal_sha256_context_t hal_sha_context_t
191 
192 #define hal_sha384_context_t hal_sha_context_t
193 
194 #define hal_sha512_context_t hal_sha_context_t
195 
212 hal_sha_status_t hal_sha1_init(hal_sha1_context_t *context);
213 
224 hal_sha_status_t hal_sha1_append(hal_sha1_context_t *context, uint8_t *message, uint32_t length);
225 
235 hal_sha_status_t hal_sha1_end(hal_sha1_context_t *context, uint8_t digest_message[HAL_SHA1_DIGEST_SIZE]);
236 
237 
247 hal_sha_status_t hal_sha224_init(hal_sha224_context_t *context);
248 
249 
260 hal_sha_status_t hal_sha224_append(hal_sha224_context_t *context, uint8_t *message, uint32_t length);
261 
262 
272 hal_sha_status_t hal_sha224_end(hal_sha224_context_t *context, uint8_t digest_message[HAL_SHA224_DIGEST_SIZE]);
273 
274 
284 hal_sha_status_t hal_sha256_init(hal_sha256_context_t *context);
285 
296 hal_sha_status_t hal_sha256_append(hal_sha256_context_t *context, uint8_t *message, uint32_t length);
297 
307 hal_sha_status_t hal_sha256_end(hal_sha256_context_t *context, uint8_t digest_message[HAL_SHA256_DIGEST_SIZE]);
308 
309 
319 hal_sha_status_t hal_sha384_init(hal_sha384_context_t *context);
320 
331 hal_sha_status_t hal_sha384_append(hal_sha384_context_t *context, uint8_t *message, uint32_t length);
332 
342 hal_sha_status_t hal_sha384_end(hal_sha384_context_t *context, uint8_t digest_message[HAL_SHA384_DIGEST_SIZE]);
343 
344 
354 hal_sha_status_t hal_sha512_init(hal_sha512_context_t *context);
355 
366 hal_sha_status_t hal_sha512_append(hal_sha512_context_t *context, uint8_t *message, uint32_t length);
367 
377 hal_sha_status_t hal_sha512_end(hal_sha512_context_t *context, uint8_t digest_message[HAL_SHA512_DIGEST_SIZE]);
378 
379 
380 
381 #ifdef __cplusplus
382 }
383 #endif
384 
389 #endif /*HAL_SHA_MODULE_ENABLED*/
390 #endif /* __HAL_SHA_H__ */
391