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 CTR_H michael@0: #define CTR_H 1 michael@0: michael@0: #include "blapii.h" michael@0: michael@0: /* This structure is defined in this header because both ctr.c and gcm.c michael@0: * need it. */ michael@0: struct CTRContextStr { michael@0: freeblCipherFunc cipher; michael@0: void *context; michael@0: unsigned char counter[MAX_BLOCK_SIZE]; michael@0: unsigned char buffer[MAX_BLOCK_SIZE]; michael@0: unsigned long counterBits; michael@0: unsigned int bufPtr; michael@0: }; michael@0: michael@0: typedef struct CTRContextStr CTRContext; michael@0: michael@0: SECStatus CTR_InitContext(CTRContext *ctr, void *context, michael@0: freeblCipherFunc cipher, const unsigned char *param, michael@0: unsigned int blocksize); michael@0: michael@0: /* michael@0: * The context argument is the inner cipher context to use with cipher. The michael@0: * CTRContext does not own context. context needs to remain valid for as long michael@0: * as the CTRContext is valid. michael@0: * michael@0: * The cipher argument is a block cipher in the ECB encrypt mode. michael@0: */ michael@0: CTRContext * CTR_CreateContext(void *context, freeblCipherFunc cipher, michael@0: const unsigned char *param, unsigned int blocksize); michael@0: michael@0: void CTR_DestroyContext(CTRContext *ctr, PRBool freeit); michael@0: michael@0: SECStatus CTR_Update(CTRContext *ctr, unsigned char *outbuf, michael@0: unsigned int *outlen, unsigned int maxout, michael@0: const unsigned char *inbuf, unsigned int inlen, michael@0: unsigned int blocksize); michael@0: michael@0: #ifdef USE_HW_AES michael@0: SECStatus CTR_Update_HW_AES(CTRContext *ctr, unsigned char *outbuf, michael@0: unsigned int *outlen, unsigned int maxout, michael@0: const unsigned char *inbuf, unsigned int inlen, michael@0: unsigned int blocksize); michael@0: #endif michael@0: michael@0: #endif