michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef _ALGHMAC_H_ michael@0: #define _ALGHMAC_H_ michael@0: michael@0: typedef struct HMACContextStr HMACContext; michael@0: michael@0: SEC_BEGIN_PROTOS michael@0: michael@0: /* destroy HMAC context */ michael@0: extern void michael@0: HMAC_Destroy(HMACContext *cx, PRBool freeit); michael@0: michael@0: /* create HMAC context michael@0: * hash_obj hash object from SECRawHashObjects[] michael@0: * secret the secret with which the HMAC is performed. michael@0: * secret_len the length of the secret. michael@0: * isFIPS true if conforming to FIPS 198. michael@0: * michael@0: * NULL is returned if an error occurs. michael@0: */ michael@0: extern HMACContext * michael@0: HMAC_Create(const SECHashObject *hash_obj, const unsigned char *secret, michael@0: unsigned int secret_len, PRBool isFIPS); michael@0: michael@0: /* like HMAC_Create, except caller allocates HMACContext. */ michael@0: SECStatus michael@0: HMAC_Init(HMACContext *cx, const SECHashObject *hash_obj, michael@0: const unsigned char *secret, unsigned int secret_len, PRBool isFIPS); michael@0: michael@0: /* reset HMAC for a fresh round */ michael@0: extern void michael@0: HMAC_Begin(HMACContext *cx); michael@0: michael@0: /* update HMAC michael@0: * cx HMAC Context michael@0: * data the data to perform HMAC on michael@0: * data_len the length of the data to process michael@0: */ michael@0: extern void michael@0: HMAC_Update(HMACContext *cx, const unsigned char *data, unsigned int data_len); michael@0: michael@0: /* Finish HMAC -- place the results within result michael@0: * cx HMAC context michael@0: * result buffer for resulting hmac'd data michael@0: * result_len where the resultant hmac length is stored michael@0: * max_result_len maximum possible length that can be stored in result michael@0: */ michael@0: extern SECStatus michael@0: HMAC_Finish(HMACContext *cx, unsigned char *result, unsigned int *result_len, michael@0: unsigned int max_result_len); michael@0: michael@0: /* clone a copy of the HMAC state. this is usefult when you would michael@0: * need to keep a running hmac but also need to extract portions michael@0: * partway through the process. michael@0: */ michael@0: extern HMACContext * michael@0: HMAC_Clone(HMACContext *cx); michael@0: michael@0: SEC_END_PROTOS michael@0: michael@0: #endif