free NULL cleanup.
[openssl.git] / crypto / ec / ecp_nistp224.c
index de7a25b3f0f373d32524eedba473ce03a4ec9118..2f1213f1f778ff6b1a3decd291472a438b55d6ac 100644 (file)
@@ -316,7 +316,7 @@ static void bin28_to_felem(felem out, const u8 in[28])
     out[0] = *((const uint64_t *)(in)) & 0x00ffffffffffffff;
     out[1] = (*((const uint64_t *)(in + 7))) & 0x00ffffffffffffff;
     out[2] = (*((const uint64_t *)(in + 14))) & 0x00ffffffffffffff;
-    out[3] = (*((const uint64_t *)(in + 21))) & 0x00ffffffffffffff;
+    out[3] = (*((const uint64_t *)(in+20))) >> 8;
 }
 
 static void felem_to_bin28(u8 out[28], const felem in)
@@ -613,11 +613,11 @@ static void felem_reduce(felem out, const widefelem in)
     /* output[3] <= 2^56 + 2^16 */
     out[2] = output[2] & 0x00ffffffffffffff;
 
-        /*-
-         * out[0] < 2^56, out[1] < 2^56, out[2] < 2^56,
-         * out[3] <= 2^56 + 2^16 (due to final carry),
-         * so out < 2*p
-         */
+    /*-
+     * out[0] < 2^56, out[1] < 2^56, out[2] < 2^56,
+     * out[3] <= 2^56 + 2^16 (due to final carry),
+     * so out < 2*p
+     */
     out[3] = output[3];
 }
 
@@ -1043,10 +1043,10 @@ static void point_add(felem x3, felem y3, felem z3,
     felem_scalar(ftmp5, 2);
     /* ftmp5[i] < 2 * 2^57 = 2^58 */
 
-        /*-
-         * x_out = (z1^3*y2 - z2^3*y1)^2 - (z1^2*x2 - z2^2*x1)^3 -
-         *  2*z2^2*x1*(z1^2*x2 - z2^2*x1)^2
-         */
+    /*-
+     * x_out = (z1^3*y2 - z2^3*y1)^2 - (z1^2*x2 - z2^2*x1)^3 -
+     *  2*z2^2*x1*(z1^2*x2 - z2^2*x1)^2
+     */
     felem_diff_128_64(tmp2, ftmp5);
     /* tmp2[i] < 2^117 + 2^64 + 8 < 2^118 */
     felem_reduce(x_out, tmp2);
@@ -1061,10 +1061,10 @@ static void point_add(felem x3, felem y3, felem z3,
     felem_mul(tmp2, ftmp3, ftmp2);
     /* tmp2[i] < 4 * 2^57 * 2^59 = 2^118 */
 
-        /*-
-         * y_out = (z1^3*y2 - z2^3*y1)*(z2^2*x1*(z1^2*x2 - z2^2*x1)^2 - x_out) -
-         *  z2^3*y1*(z1^2*x2 - z2^2*x1)^3
-         */
+    /*-
+     * y_out = (z1^3*y2 - z2^3*y1)*(z2^2*x1*(z1^2*x2 - z2^2*x1)^2 - x_out) -
+     *  z2^3*y1*(z1^2*x2 - z2^2*x1)^3
+     */
     widefelem_diff(tmp2, tmp);
     /* tmp2[i] < 2^118 + 2^120 < 2^121 */
     felem_reduce(y_out, tmp2);
@@ -1602,8 +1602,7 @@ int ec_GFp_nistp224_points_mul(const EC_GROUP *group, EC_POINT *r,
 
  err:
     BN_CTX_end(ctx);
-    if (generator != NULL)
-        EC_POINT_free(generator);
+    EC_POINT_free(generator);
     if (new_ctx != NULL)
         BN_CTX_free(new_ctx);
     if (secrets != NULL)
@@ -1739,8 +1738,7 @@ int ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
     pre = NULL;
  err:
     BN_CTX_end(ctx);
-    if (generator != NULL)
-        EC_POINT_free(generator);
+    EC_POINT_free(generator);
     if (new_ctx != NULL)
         BN_CTX_free(new_ctx);
     if (pre)