1 /** @file sha1.h 2 * 3 * @brief This file contains the sha1 functions 4 * 5 * Copyright (C) 2014-2017, Marvell International Ltd. 6 * 7 * This software file (the "File") is distributed by Marvell International 8 * Ltd. under the terms of the GNU General Public License Version 2, June 1991 9 * (the "License"). You may use, redistribute and/or modify this File in 10 * accordance with the terms and conditions of the License, a copy of which 11 * is available by writing to the Free Software Foundation, Inc., 12 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the 13 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 14 * 15 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 17 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about 18 * this warranty disclaimer. 19 */ 20 21 /****************************************************** 22 Change log: 23 03/07/2014: Initial version 24 ******************************************************/ 25 #ifndef _SHA1_H_ 26 #define _SHA1_H_ 27 28 #include "wltypes.h" 29 30 enum { 31 shaSuccess = 0, 32 shaNull, /* Null pointer parameter */ 33 shaInputTooLong, /* input data too long */ 34 shaStateError /* called Input after Result */ 35 }; 36 37 #define A_SHA_DIGEST_LEN 20 38 39 /* 40 * This structure will hold context information for the SHA-1 41 * hashing operation 42 */ 43 typedef struct { 44 UINT32 Intermediate_Hash[A_SHA_DIGEST_LEN / 4]; /* Message Digest */ 45 46 UINT32 Length_Low; /* Message length in bits */ 47 UINT32 Length_High; /* Message length in bits */ 48 49 UINT32 Scratch[16]; /* This is used to reduce the memory 50 ** requirements of the transform 51 **function 52 */ 53 UINT8 Message_Block[64]; /* 512-bit message blocks */ 54 /* Index into message block array */ 55 SINT16 Message_Block_Index; 56 UINT8 Computed; /* Is the digest computed? */ 57 UINT8 Corrupted; /* Is the message digest corrupted? */ 58 } Mrvl_SHA1_CTX; 59 60 /* 61 * Function Prototypes 62 */ 63 64 extern int Mrvl_SHA1Init(Mrvl_SHA1_CTX *); 65 extern int Mrvl_SHA1Update(Mrvl_SHA1_CTX *, const UINT8 *, unsigned int); 66 extern int Mrvl_SHA1Final(void *priv, Mrvl_SHA1_CTX *, 67 UINT8 Message_Digest[A_SHA_DIGEST_LEN]); 68 69 extern void Mrvl_PRF(void *priv, unsigned char *key, 70 int key_len, 71 unsigned char *prefix, 72 int prefix_len, 73 unsigned char *data, 74 int data_len, unsigned char *output, int len); 75 76 extern void Mrvl_hmac_sha1(void *priv, unsigned char **ppText, 77 int *pTextLen, 78 int textNum, 79 unsigned char *key, 80 int key_len, unsigned char *output, int outputLen); 81 82 #endif 83