/* ** Destroy a AES KeyWrap context. ** "cx" the context ** "freeit" if PR_TRUE then free the object as well as its sub-objects */ extern void AESKeyWrap_DestroyContext(AESKeyWrapContext *cx, PRBool freeit) { if (cx) { AES_DestroyContext(&cx->aescx, PR_FALSE); /* memset(cx, 0, sizeof *cx); */ if (freeit) PORT_Free(cx); } }
/* AES_CreateContext * * create a new context for Rijndael operations */ AESContext * AES_CreateContext(const unsigned char *key, const unsigned char *iv, int mode, int encrypt, unsigned int keysize, unsigned int blocksize) { AESContext *cx = AES_AllocateContext(); if (cx) { SECStatus rv = AES_InitContext(cx, key, keysize, iv, mode, encrypt, blocksize); if (rv != SECSuccess) { AES_DestroyContext(cx, PR_TRUE); cx = NULL; } } return cx; }