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