projects
/
oweals
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use enum type for do_EC_KEY_print
[oweals/openssl.git]
/
crypto
/
ec
/
ecdsa_ossl.c
diff --git
a/crypto/ec/ecdsa_ossl.c
b/crypto/ec/ecdsa_ossl.c
index 40742bdf0625ec916c287596455cf0a1b230be25..3e755fbafac0506dbd098910eab6d4d7bc7e9ade 100644
(file)
--- a/
crypto/ec/ecdsa_ossl.c
+++ b/
crypto/ec/ecdsa_ossl.c
@@
-1,4
+1,3
@@
-/* crypto/ec/ecdsa_ossl.c */
/*
* Written by Nils Larsch for the OpenSSL project
*/
/*
* Written by Nils Larsch for the OpenSSL project
*/
@@
-85,7
+84,8
@@
static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in,
const unsigned char *dgst, int dlen)
{
BN_CTX *ctx = NULL;
const unsigned char *dgst, int dlen)
{
BN_CTX *ctx = NULL;
- BIGNUM *k = NULL, *r = NULL, *order = NULL, *X = NULL;
+ BIGNUM *k = NULL, *r = NULL, *X = NULL;
+ const BIGNUM *order;
EC_POINT *tmp_point = NULL;
const EC_GROUP *group;
int ret = 0;
EC_POINT *tmp_point = NULL;
const EC_GROUP *group;
int ret = 0;
@@
-105,9
+105,8
@@
static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in,
k = BN_new(); /* this value is later returned in *kinvp */
r = BN_new(); /* this value is later returned in *rp */
k = BN_new(); /* this value is later returned in *kinvp */
r = BN_new(); /* this value is later returned in *rp */
- order = BN_new();
X = BN_new();
X = BN_new();
- if (k == NULL || r == NULL ||
order == NULL ||
X == NULL) {
+ if (k == NULL || r == NULL || X == NULL) {
ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_MALLOC_FAILURE);
goto err;
}
ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_MALLOC_FAILURE);
goto err;
}
@@
-115,7
+114,8
@@
static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in,
ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB);
goto err;
}
ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB);
goto err;
}
- if (!EC_GROUP_get_order(group, order, ctx)) {
+ order = EC_GROUP_get0_order(group);
+ if (order == NULL) {
ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB);
goto err;
}
ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB);
goto err;
}
@@
-223,7
+223,6
@@
static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in,
}
if (ctx != ctx_in)
BN_CTX_free(ctx);
}
if (ctx != ctx_in)
BN_CTX_free(ctx);
- BN_free(order);
EC_POINT_free(tmp_point);
BN_clear_free(X);
return (ret);
EC_POINT_free(tmp_point);
BN_clear_free(X);
return (ret);
@@
-240,8
+239,8
@@
ECDSA_SIG *ossl_ecdsa_sign_sig(const unsigned char *dgst, int dgst_len,
EC_KEY *eckey)
{
int ok = 0, i;
EC_KEY *eckey)
{
int ok = 0, i;
- BIGNUM *kinv = NULL, *s, *m = NULL, *tmp = NULL
, *order = NULL
;
- const BIGNUM *ckinv;
+ BIGNUM *kinv = NULL, *s, *m = NULL, *tmp = NULL;
+ const BIGNUM *
order, *
ckinv;
BN_CTX *ctx = NULL;
const EC_GROUP *group;
ECDSA_SIG *ret;
BN_CTX *ctx = NULL;
const EC_GROUP *group;
ECDSA_SIG *ret;
@@
-262,13
+261,14
@@
ECDSA_SIG *ossl_ecdsa_sign_sig(const unsigned char *dgst, int dgst_len,
}
s = ret->s;
}
s = ret->s;
- if ((ctx = BN_CTX_new()) == NULL ||
(order = BN_new()) == NULL ||
+ if ((ctx = BN_CTX_new()) == NULL ||
(tmp = BN_new()) == NULL || (m = BN_new()) == NULL) {
ECerr(EC_F_OSSL_ECDSA_SIGN_SIG, ERR_R_MALLOC_FAILURE);
goto err;
}
(tmp = BN_new()) == NULL || (m = BN_new()) == NULL) {
ECerr(EC_F_OSSL_ECDSA_SIGN_SIG, ERR_R_MALLOC_FAILURE);
goto err;
}
- if (!EC_GROUP_get_order(group, order, ctx)) {
+ order = EC_GROUP_get0_order(group);
+ if (order == NULL) {
ECerr(EC_F_OSSL_ECDSA_SIGN_SIG, ERR_R_EC_LIB);
goto err;
}
ECerr(EC_F_OSSL_ECDSA_SIGN_SIG, ERR_R_EC_LIB);
goto err;
}
@@
-338,7
+338,6
@@
ECDSA_SIG *ossl_ecdsa_sign_sig(const unsigned char *dgst, int dgst_len,
BN_CTX_free(ctx);
BN_clear_free(m);
BN_clear_free(tmp);
BN_CTX_free(ctx);
BN_clear_free(m);
BN_clear_free(tmp);
- BN_free(order);
BN_clear_free(kinv);
return ret;
}
BN_clear_free(kinv);
return ret;
}
@@
-365,7
+364,7
@@
int ossl_ecdsa_verify(int type, const unsigned char *dgst, int dgst_len,
goto err;
/* Ensure signature uses DER and doesn't have trailing garbage */
derlen = i2d_ECDSA_SIG(s, &der);
goto err;
/* Ensure signature uses DER and doesn't have trailing garbage */
derlen = i2d_ECDSA_SIG(s, &der);
- if (derlen != sig_len || memcmp(sigbuf, der, derlen))
+ if (derlen != sig_len || memcmp(sigbuf, der, derlen)
!= 0
)
goto err;
ret = ECDSA_do_verify(dgst, dgst_len, s, eckey);
err:
goto err;
ret = ECDSA_do_verify(dgst, dgst_len, s, eckey);
err:
@@
-379,7
+378,8
@@
int ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len,
{
int ret = -1, i;
BN_CTX *ctx;
{
int ret = -1, i;
BN_CTX *ctx;
- BIGNUM *order, *u1, *u2, *m, *X;
+ const BIGNUM *order;
+ BIGNUM *u1, *u2, *m, *X;
EC_POINT *point = NULL;
const EC_GROUP *group;
const EC_POINT *pub_key;
EC_POINT *point = NULL;
const EC_GROUP *group;
const EC_POINT *pub_key;
@@
-397,17
+397,17
@@
int ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len,
return -1;
}
BN_CTX_start(ctx);
return -1;
}
BN_CTX_start(ctx);
- order = BN_CTX_get(ctx);
u1 = BN_CTX_get(ctx);
u2 = BN_CTX_get(ctx);
m = BN_CTX_get(ctx);
X = BN_CTX_get(ctx);
u1 = BN_CTX_get(ctx);
u2 = BN_CTX_get(ctx);
m = BN_CTX_get(ctx);
X = BN_CTX_get(ctx);
- if (
!X
) {
+ if (
X == NULL
) {
ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_BN_LIB);
goto err;
}
ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_BN_LIB);
goto err;
}
- if (!EC_GROUP_get_order(group, order, ctx)) {
+ order = EC_GROUP_get0_order(group);
+ if (order == NULL) {
ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_EC_LIB);
goto err;
}
ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_EC_LIB);
goto err;
}