Add additional DigestInfo checks.
[openssl.git] / crypto / bn / bn_sqr.c
index 8831daa390a7be5cdbb0bc7815cfb6ebe0efb6b1..65bbf165d0e2f3bc3de3d662c1c02800dbb33c70 100644 (file)
@@ -77,6 +77,7 @@ int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
        if (al <= 0)
                {
                r->top=0;
+               r->neg = 0;
                return 1;
                }
 
@@ -86,7 +87,7 @@ int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
        if (!rr || !tmp) goto err;
 
        max = 2 * al; /* Non-zero (from above) */
-       if (bn_wexpand(rr,max+1) == NULL) goto err;
+       if (bn_wexpand(rr,max) == NULL) goto err;
 
        if (al == 4)
                {
@@ -148,8 +149,8 @@ int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
        if (rr != r) BN_copy(r,rr);
        ret = 1;
  err:
-       if(rr) bn_check_top(rr);
-       if(tmp) bn_check_top(tmp);
+       bn_check_top(rr);
+       bn_check_top(tmp);
        BN_CTX_end(ctx);
        return(ret);
        }