X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=gost_ec_sign.c;h=114091c1c96bbbe24c16d02acbea99a4d1044b3d;hb=e55323c4c29e6b2645e7e7357453c34fb9a42440;hp=2deb09324b50d15a50caaba367362d5f83a496b4;hpb=bca47af46027b1b84c23af1c84aef1bf901778f8;p=openssl-gost%2Fengine.git diff --git a/gost_ec_sign.c b/gost_ec_sign.c index 2deb093..114091c 100644 --- a/gost_ec_sign.c +++ b/gost_ec_sign.c @@ -16,7 +16,7 @@ extern void dump_signature(const char *message, const unsigned char *buffer, size_t len); -void dump_dsa_sig(const char *message, DSA_SIG *sig); +void dump_dsa_sig(const char *message, ECDSA_SIG *sig); #else # define dump_signature(a,b,c) @@ -74,7 +74,8 @@ int fill_GOST_EC_params(EC_KEY *eckey, int nid) R3410_ec_params *params = gost_nid2params(nid); EC_GROUP *grp = NULL; EC_POINT *P = NULL; - BIGNUM *p = NULL, *q = NULL, *a = NULL, *b = NULL, *x = NULL, *y = NULL, *cofactor = NULL; + BIGNUM *p = NULL, *q = NULL, *a = NULL, *b = NULL, *x = NULL, *y = + NULL, *cofactor = NULL; BN_CTX *ctx; int ok = 0; @@ -95,7 +96,7 @@ int fill_GOST_EC_params(EC_KEY *eckey, int nid) x = BN_CTX_get(ctx); y = BN_CTX_get(ctx); q = BN_CTX_get(ctx); - cofactor = BN_CTX_get(ctx); + cofactor = BN_CTX_get(ctx); if (!p || !a || !b || !x || !y || !q || !cofactor) { GOSTerr(GOST_F_FILL_GOST_EC_PARAMS, ERR_R_MALLOC_FAILURE); goto end; @@ -104,7 +105,7 @@ int fill_GOST_EC_params(EC_KEY *eckey, int nid) if (!BN_hex2bn(&p, params->p) || !BN_hex2bn(&a, params->a) || !BN_hex2bn(&b, params->b) - || !BN_hex2bn(&cofactor, params->cofactor) ) { + || !BN_hex2bn(&cofactor, params->cofactor)) { GOSTerr(GOST_F_FILL_GOST_EC_PARAMS, ERR_R_INTERNAL_ERROR); goto end; } @@ -150,12 +151,12 @@ int fill_GOST_EC_params(EC_KEY *eckey, int nid) } /* - * Computes gost_ec signature as DSA_SIG structure + * Computes gost_ec signature as ECDSA_SIG structure * */ -DSA_SIG *gost_ec_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) +ECDSA_SIG *gost_ec_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) { - DSA_SIG *newsig = NULL, *ret = NULL; + ECDSA_SIG *newsig = NULL, *ret = NULL; BIGNUM *md = NULL; BIGNUM *order = NULL; const EC_GROUP *group; @@ -178,7 +179,7 @@ DSA_SIG *gost_ec_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) BN_CTX_start(ctx); OPENSSL_assert(dlen == 32 || dlen == 64); md = hashsum2bn(dgst, dlen); - newsig = DSA_SIG_new(); + newsig = ECDSA_SIG_new(); if (!newsig || !md) { GOSTerr(GOST_F_GOST_EC_SIGN, ERR_R_MALLOC_FAILURE); goto err; @@ -284,7 +285,7 @@ DSA_SIG *gost_ec_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) GOSTerr(GOST_F_GOST_EC_SIGN, ERR_R_MALLOC_FAILURE); goto err; } - DSA_SIG_set0(newsig, new_r, new_s); + ECDSA_SIG_set0(newsig, new_r, new_s); ret = newsig; err: @@ -295,7 +296,7 @@ DSA_SIG *gost_ec_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) if (md) BN_free(md); if (!ret && newsig) { - DSA_SIG_free(newsig); + ECDSA_SIG_free(newsig); } return ret; } @@ -305,13 +306,12 @@ DSA_SIG *gost_ec_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) * */ int gost_ec_verify(const unsigned char *dgst, int dgst_len, - DSA_SIG *sig, EC_KEY *ec) + ECDSA_SIG *sig, EC_KEY *ec) { BN_CTX *ctx; const EC_GROUP *group = (ec) ? EC_KEY_get0_group(ec) : NULL; BIGNUM *order; - BIGNUM *md = NULL, *e = NULL, *R = NULL, *v = NULL, - *z1 = NULL, *z2 = NULL; + BIGNUM *md = NULL, *e = NULL, *R = NULL, *v = NULL, *z1 = NULL, *z2 = NULL; const BIGNUM *sig_s = NULL, *sig_r = NULL; BIGNUM *X = NULL, *tmp = NULL; EC_POINT *C = NULL; @@ -345,7 +345,7 @@ int gost_ec_verify(const unsigned char *dgst, int dgst_len, goto err; } - DSA_SIG_get0(sig, &sig_r, &sig_s); + ECDSA_SIG_get0(sig, &sig_r, &sig_s); if (BN_is_zero(sig_s) || BN_is_zero(sig_r) || (BN_cmp(sig_s, order) >= 1) || (BN_cmp(sig_r, order) >= 1)) {