free cleanup almost the finale
[openssl.git] / crypto / modes / ocb128.c
index a3224108c3585789ee984add0f4a4d5b3033fe61..efa403b0f1502f96aa85ba902d9181994877f721 100644 (file)
@@ -151,10 +151,10 @@ static void ocb_block_xor(const unsigned char *in1,
  * Lookup L_index in our lookup table. If we haven't already got it we need to
  * calculate it
  */
-static OCB_BLOCK *ocb_lookup_l(OCB128_CONTEXT *ctx, size_t index)
+static OCB_BLOCK *ocb_lookup_l(OCB128_CONTEXT *ctx, size_t idx)
 {
-    if (index <= ctx->l_index) {
-        return ctx->l + index;
+    if (idx <= ctx->l_index) {
+        return ctx->l + idx;
     }
 
     /* We don't have it - so calculate it */
@@ -166,9 +166,9 @@ static OCB_BLOCK *ocb_lookup_l(OCB128_CONTEXT *ctx, size_t index)
         if (!ctx->l)
             return NULL;
     }
-    ocb_double(ctx->l + (index - 1), ctx->l + index);
+    ocb_double(ctx->l + (idx - 1), ctx->l + idx);
 
-    return ctx->l + index;
+    return ctx->l + idx;
 }
 
 /*
@@ -210,7 +210,7 @@ OCB128_CONTEXT *CRYPTO_ocb128_new(void *keyenc, void *keydec,
     OCB128_CONTEXT *octx;
     int ret;
 
-    if ((octx = (OCB128_CONTEXT *)OPENSSL_malloc(sizeof(OCB128_CONTEXT)))) {
+    if ((octx = OPENSSL_malloc(sizeof(OCB128_CONTEXT)))) {
         ret = CRYPTO_ocb128_init(octx, keyenc, keydec, encrypt, decrypt);
         if (ret)
             return octx;
@@ -588,10 +588,7 @@ int CRYPTO_ocb128_tag(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len)
 void CRYPTO_ocb128_cleanup(OCB128_CONTEXT *ctx)
 {
     if (ctx) {
-        if (ctx->l) {
-            OPENSSL_cleanse(ctx->l, ctx->max_l_index * 16);
-            OPENSSL_free(ctx->l);
-        }
+        OPENSSL_clear_free(ctx->l, ctx->max_l_index * 16);
         OPENSSL_cleanse(ctx, sizeof(*ctx));
     }
 }