summaryrefslogtreecommitdiffstats
path: root/src/crypto/ecdsa/ecdsa.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto/ecdsa/ecdsa.c')
-rw-r--r--src/crypto/ecdsa/ecdsa.c56
1 files changed, 17 insertions, 39 deletions
diff --git a/src/crypto/ecdsa/ecdsa.c b/src/crypto/ecdsa/ecdsa.c
index d389799..b71799e 100644
--- a/src/crypto/ecdsa/ecdsa.c
+++ b/src/crypto/ecdsa/ecdsa.c
@@ -57,7 +57,6 @@
#include <openssl/bn.h>
#include <openssl/err.h>
#include <openssl/mem.h>
-#include <openssl/thread.h>
#include "../ec/internal.h"
@@ -98,12 +97,8 @@ int ECDSA_verify(int type, const uint8_t *digest, size_t digest_len,
ret = ECDSA_do_verify(digest, digest_len, s, eckey);
err:
- if (der != NULL) {
- OPENSSL_free(der);
- }
- if (s != NULL) {
- ECDSA_SIG_free(s);
- }
+ OPENSSL_free(der);
+ ECDSA_SIG_free(s);
return ret;
}
@@ -232,9 +227,7 @@ int ECDSA_do_verify(const uint8_t *digest, size_t digest_len,
err:
BN_CTX_end(ctx);
BN_CTX_free(ctx);
- if (point) {
- EC_POINT_free(point);
- }
+ EC_POINT_free(point);
return ret;
}
@@ -334,12 +327,8 @@ static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
goto err;
}
/* clear old values if necessary */
- if (*rp != NULL) {
- BN_clear_free(*rp);
- }
- if (*kinvp != NULL) {
- BN_clear_free(*kinvp);
- }
+ BN_clear_free(*rp);
+ BN_clear_free(*kinvp);
/* save the pre-computed values */
*rp = r;
@@ -348,21 +337,15 @@ static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
err:
if (!ret) {
- if (k != NULL) {
- BN_clear_free(k);
- }
- if (r != NULL) {
- BN_clear_free(r);
- }
+ BN_clear_free(k);
+ BN_clear_free(r);
}
- if (ctx_in == NULL)
+ if (ctx_in == NULL) {
BN_CTX_free(ctx);
- if (order != NULL)
- BN_free(order);
- if (tmp_point != NULL)
- EC_POINT_free(tmp_point);
- if (X)
- BN_clear_free(X);
+ }
+ BN_free(order);
+ EC_POINT_free(tmp_point);
+ BN_clear_free(X);
return ret;
}
@@ -461,16 +444,11 @@ err:
ECDSA_SIG_free(ret);
ret = NULL;
}
- if (ctx)
- BN_CTX_free(ctx);
- if (m)
- BN_clear_free(m);
- if (tmp)
- BN_clear_free(tmp);
- if (order)
- BN_free(order);
- if (kinv)
- BN_clear_free(kinv);
+ BN_CTX_free(ctx);
+ BN_clear_free(m);
+ BN_clear_free(tmp);
+ BN_free(order);
+ BN_clear_free(kinv);
return ret;
}