Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #ifndef _ALGHMAC_H_ |
michael@0 | 6 | #define _ALGHMAC_H_ |
michael@0 | 7 | |
michael@0 | 8 | typedef struct HMACContextStr HMACContext; |
michael@0 | 9 | |
michael@0 | 10 | SEC_BEGIN_PROTOS |
michael@0 | 11 | |
michael@0 | 12 | /* destroy HMAC context */ |
michael@0 | 13 | extern void |
michael@0 | 14 | HMAC_Destroy(HMACContext *cx, PRBool freeit); |
michael@0 | 15 | |
michael@0 | 16 | /* create HMAC context |
michael@0 | 17 | * hash_obj hash object from SECRawHashObjects[] |
michael@0 | 18 | * secret the secret with which the HMAC is performed. |
michael@0 | 19 | * secret_len the length of the secret. |
michael@0 | 20 | * isFIPS true if conforming to FIPS 198. |
michael@0 | 21 | * |
michael@0 | 22 | * NULL is returned if an error occurs. |
michael@0 | 23 | */ |
michael@0 | 24 | extern HMACContext * |
michael@0 | 25 | HMAC_Create(const SECHashObject *hash_obj, const unsigned char *secret, |
michael@0 | 26 | unsigned int secret_len, PRBool isFIPS); |
michael@0 | 27 | |
michael@0 | 28 | /* like HMAC_Create, except caller allocates HMACContext. */ |
michael@0 | 29 | SECStatus |
michael@0 | 30 | HMAC_Init(HMACContext *cx, const SECHashObject *hash_obj, |
michael@0 | 31 | const unsigned char *secret, unsigned int secret_len, PRBool isFIPS); |
michael@0 | 32 | |
michael@0 | 33 | /* reset HMAC for a fresh round */ |
michael@0 | 34 | extern void |
michael@0 | 35 | HMAC_Begin(HMACContext *cx); |
michael@0 | 36 | |
michael@0 | 37 | /* update HMAC |
michael@0 | 38 | * cx HMAC Context |
michael@0 | 39 | * data the data to perform HMAC on |
michael@0 | 40 | * data_len the length of the data to process |
michael@0 | 41 | */ |
michael@0 | 42 | extern void |
michael@0 | 43 | HMAC_Update(HMACContext *cx, const unsigned char *data, unsigned int data_len); |
michael@0 | 44 | |
michael@0 | 45 | /* Finish HMAC -- place the results within result |
michael@0 | 46 | * cx HMAC context |
michael@0 | 47 | * result buffer for resulting hmac'd data |
michael@0 | 48 | * result_len where the resultant hmac length is stored |
michael@0 | 49 | * max_result_len maximum possible length that can be stored in result |
michael@0 | 50 | */ |
michael@0 | 51 | extern SECStatus |
michael@0 | 52 | HMAC_Finish(HMACContext *cx, unsigned char *result, unsigned int *result_len, |
michael@0 | 53 | unsigned int max_result_len); |
michael@0 | 54 | |
michael@0 | 55 | /* clone a copy of the HMAC state. this is usefult when you would |
michael@0 | 56 | * need to keep a running hmac but also need to extract portions |
michael@0 | 57 | * partway through the process. |
michael@0 | 58 | */ |
michael@0 | 59 | extern HMACContext * |
michael@0 | 60 | HMAC_Clone(HMACContext *cx); |
michael@0 | 61 | |
michael@0 | 62 | SEC_END_PROTOS |
michael@0 | 63 | |
michael@0 | 64 | #endif |