security/nss/lib/freebl/alghmac.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/freebl/alghmac.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,64 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef _ALGHMAC_H_
     1.9 +#define _ALGHMAC_H_
    1.10 +
    1.11 +typedef struct HMACContextStr HMACContext;
    1.12 +
    1.13 +SEC_BEGIN_PROTOS
    1.14 +
    1.15 +/* destroy HMAC context */
    1.16 +extern void
    1.17 +HMAC_Destroy(HMACContext *cx, PRBool freeit);
    1.18 +
    1.19 +/* create HMAC context
    1.20 + *  hash_obj    hash object from SECRawHashObjects[]
    1.21 + *  secret	the secret with which the HMAC is performed.
    1.22 + *  secret_len	the length of the secret.
    1.23 + *  isFIPS	true if conforming to FIPS 198.
    1.24 + *
    1.25 + * NULL is returned if an error occurs.
    1.26 + */
    1.27 +extern HMACContext *
    1.28 +HMAC_Create(const SECHashObject *hash_obj, const unsigned char *secret, 
    1.29 +	    unsigned int secret_len, PRBool isFIPS);
    1.30 +
    1.31 +/* like HMAC_Create, except caller allocates HMACContext. */
    1.32 +SECStatus
    1.33 +HMAC_Init(HMACContext *cx, const SECHashObject *hash_obj, 
    1.34 +	  const unsigned char *secret, unsigned int secret_len, PRBool isFIPS);
    1.35 +
    1.36 +/* reset HMAC for a fresh round */
    1.37 +extern void
    1.38 +HMAC_Begin(HMACContext *cx);
    1.39 +
    1.40 +/* update HMAC 
    1.41 + *  cx		HMAC Context
    1.42 + *  data	the data to perform HMAC on
    1.43 + *  data_len	the length of the data to process
    1.44 + */
    1.45 +extern void 
    1.46 +HMAC_Update(HMACContext *cx, const unsigned char *data, unsigned int data_len);
    1.47 +
    1.48 +/* Finish HMAC -- place the results within result
    1.49 + *  cx		HMAC context
    1.50 + *  result	buffer for resulting hmac'd data
    1.51 + *  result_len	where the resultant hmac length is stored
    1.52 + *  max_result_len  maximum possible length that can be stored in result
    1.53 + */
    1.54 +extern SECStatus
    1.55 +HMAC_Finish(HMACContext *cx, unsigned char *result, unsigned int *result_len,
    1.56 +	    unsigned int max_result_len);
    1.57 +
    1.58 +/* clone a copy of the HMAC state.  this is usefult when you would
    1.59 + * need to keep a running hmac but also need to extract portions 
    1.60 + * partway through the process.
    1.61 + */
    1.62 +extern HMACContext *
    1.63 +HMAC_Clone(HMACContext *cx);
    1.64 +
    1.65 +SEC_END_PROTOS
    1.66 +
    1.67 +#endif

mercurial