security/nss/lib/freebl/ctr.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/freebl/ctr.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,51 @@
     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 CTR_H
     1.9 +#define CTR_H 1
    1.10 +
    1.11 +#include "blapii.h"
    1.12 +
    1.13 +/* This structure is defined in this header because both ctr.c and gcm.c
    1.14 + * need it. */
    1.15 +struct CTRContextStr {
    1.16 +   freeblCipherFunc cipher;
    1.17 +   void *context;
    1.18 +   unsigned char counter[MAX_BLOCK_SIZE];
    1.19 +   unsigned char buffer[MAX_BLOCK_SIZE];
    1.20 +   unsigned long counterBits;
    1.21 +   unsigned int bufPtr;
    1.22 +};
    1.23 +
    1.24 +typedef struct CTRContextStr CTRContext;
    1.25 +
    1.26 +SECStatus CTR_InitContext(CTRContext *ctr, void *context,
    1.27 +			freeblCipherFunc cipher, const unsigned char *param,
    1.28 +			unsigned int blocksize);
    1.29 +
    1.30 +/*
    1.31 + * The context argument is the inner cipher context to use with cipher. The
    1.32 + * CTRContext does not own context. context needs to remain valid for as long
    1.33 + * as the CTRContext is valid.
    1.34 + *
    1.35 + * The cipher argument is a block cipher in the ECB encrypt mode.
    1.36 + */
    1.37 +CTRContext * CTR_CreateContext(void *context, freeblCipherFunc cipher,
    1.38 +			const unsigned char *param, unsigned int blocksize);
    1.39 +
    1.40 +void CTR_DestroyContext(CTRContext *ctr, PRBool freeit);
    1.41 +
    1.42 +SECStatus CTR_Update(CTRContext *ctr, unsigned char *outbuf,
    1.43 +			unsigned int *outlen, unsigned int maxout,
    1.44 +			const unsigned char *inbuf, unsigned int inlen,
    1.45 +			unsigned int blocksize);
    1.46 +
    1.47 +#ifdef USE_HW_AES
    1.48 +SECStatus CTR_Update_HW_AES(CTRContext *ctr, unsigned char *outbuf,
    1.49 +			unsigned int *outlen, unsigned int maxout,
    1.50 +			const unsigned char *inbuf, unsigned int inlen,
    1.51 +			unsigned int blocksize);
    1.52 +#endif
    1.53 +
    1.54 +#endif

mercurial