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