From: Bodo Möller Date: Wed, 20 Feb 2002 13:08:17 +0000 (+0000) Subject: simplifications X-Git-Tag: OpenSSL_0_9_6d~20^2~149 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3613e6fc57d59d05a1b9e992879845000783bb36;p=oweals%2Fopenssl.git simplifications Submitted by: Nils Larsch --- diff --git a/crypto/ecdsa/ecs_asn1.c b/crypto/ecdsa/ecs_asn1.c index 542a987bc2..886cd01db2 100644 --- a/crypto/ecdsa/ecs_asn1.c +++ b/crypto/ecdsa/ecs_asn1.c @@ -61,29 +61,10 @@ static point_conversion_form_t POINT_CONVERSION_FORM = POINT_CONVERSION_COMPRESSED; -/* Override the default new methods */ -static int sig_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) -{ - if(operation == ASN1_OP_NEW_PRE) { - ECDSA_SIG *sig; - sig = OPENSSL_malloc(sizeof(ECDSA_SIG)); - if (sig == NULL) - { - ECDSAerr(ECDSA_F_SIG_CB, ERR_R_MALLOC_FAILURE); - return 0; - } - sig->r = NULL; - sig->s = NULL; - *pval = (ASN1_VALUE *)sig; - return 2; - } - return 1; -} - -ASN1_SEQUENCE_cb(ECDSA_SIG, sig_cb) = { +ASN1_SEQUENCE(ECDSA_SIG) = { ASN1_SIMPLE(ECDSA_SIG, r, CBIGNUM), ASN1_SIMPLE(ECDSA_SIG, s, CBIGNUM) -} ASN1_SEQUENCE_END_cb(ECDSA_SIG, ECDSA_SIG) +} ASN1_SEQUENCE_END(ECDSA_SIG) IMPLEMENT_ASN1_FUNCTIONS_const(ECDSA_SIG) @@ -439,9 +420,7 @@ ECDSA *ECDSA_x9_62parameters2ecdsa(const X9_62_EC_PARAMETERS *params, EC if ((point = EC_POINT_new(ret->group)) == NULL) goto err; } else OPENSSL_ECDSA_ABORT(ECDSA_R_WRONG_FIELD_IDENTIFIER) - /* FIXME!!! It seems like the comparison of data with 0 isn't the - intended thing. */ - if (params->curve->seed != NULL && params->curve->seed->data != 0) + if (params->curve->seed != NULL) { if (ret->seed != NULL) OPENSSL_free(ret->seed); diff --git a/crypto/ecdsa/ecs_ossl.c b/crypto/ecdsa/ecs_ossl.c index 5a36707cfb..a79b0c2fe2 100644 --- a/crypto/ecdsa/ecs_ossl.c +++ b/crypto/ecdsa/ecs_ossl.c @@ -285,16 +285,20 @@ static ECDSA_SIG *ecdsa_do_sign(const unsigned char *dgst, int dgst_len, ECDSA * reason = ECDSA_R_SIGNATURE_MALLOC_FAILED; goto err; } - ret->r = r; - ret->s = s; + if (BN_copy(ret->r, r) == NULL || BN_copy(ret->s, s) == NULL) + { + ECDSA_SIG_free(ret); + ret = NULL; + reason = ERR_R_BN_LIB; + } err: if (!ret) { ECDSAerr(ECDSA_F_ECDSA_DO_SIGN,reason); - BN_free(r); - BN_free(s); } + if (r != NULL) BN_clear_free(r); + if (s != NULL) BN_clear_free(s); if (ctx != NULL) BN_CTX_free(ctx); if (m != NULL) BN_clear_free(m); if (tmp != NULL) BN_clear_free(tmp);