diff options
Diffstat (limited to 'crypto/asn1')
-rw-r--r-- | crypto/asn1/d2i_pu.c | 2 | ||||
-rw-r--r-- | crypto/asn1/i2d_pu.c | 2 | ||||
-rw-r--r-- | crypto/asn1/t_pkey.c | 27 | ||||
-rw-r--r-- | crypto/asn1/x_pubkey.c | 2 |
4 files changed, 21 insertions, 12 deletions
diff --git a/crypto/asn1/d2i_pu.c b/crypto/asn1/d2i_pu.c index 81b5d0f..f66d72f 100644 --- a/crypto/asn1/d2i_pu.c +++ b/crypto/asn1/d2i_pu.c @@ -113,7 +113,7 @@ EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, unsigned char **pp, #endif #ifndef OPENSSL_NO_ECDSA case EVP_PKEY_ECDSA: - if ((ret->pkey.ecdsa = d2i_ECDSAPublicKey(&(ret->pkey.ecdsa), + if ((ret->pkey.ecdsa = ECDSAPublicKey_set_octet_string(&(ret->pkey.ecdsa), (const unsigned char **)pp, length)) == NULL) { ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_ASN1_LIB); diff --git a/crypto/asn1/i2d_pu.c b/crypto/asn1/i2d_pu.c index 2607734..2fcc555 100644 --- a/crypto/asn1/i2d_pu.c +++ b/crypto/asn1/i2d_pu.c @@ -85,7 +85,7 @@ int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp) #endif #ifndef OPENSSL_NO_ECDSA case EVP_PKEY_ECDSA: - return(i2d_ECDSAPublicKey(a->pkey.ecdsa, pp)); + return(ECDSAPublicKey_get_octet_string(a->pkey.ecdsa, pp)); #endif default: ASN1err(ASN1_F_I2D_PUBLICKEY,ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE); diff --git a/crypto/asn1/t_pkey.c b/crypto/asn1/t_pkey.c index f169e26..1b29fdc 100644 --- a/crypto/asn1/t_pkey.c +++ b/crypto/asn1/t_pkey.c @@ -237,7 +237,8 @@ int ECDSA_print(BIO *bp, const ECDSA *x, int off) unsigned char *buffer=NULL; int i, buf_len=0, ret=0, reason=ERR_R_BIO_LIB; BIGNUM *tmp_1=NULL, *tmp_2=NULL, *tmp_3=NULL, - *tmp_4=NULL, *tmp_5=NULL; + *tmp_4=NULL, *tmp_5=NULL, *tmp_6=NULL, + *tmp_7=NULL; BN_CTX *ctx=NULL; EC_POINT *point=NULL; @@ -249,7 +250,8 @@ int ECDSA_print(BIO *bp, const ECDSA *x, int off) goto err; } if ((tmp_1 = BN_new()) == NULL || (tmp_2 = BN_new()) == NULL || - (tmp_3 = BN_new()) == NULL || (ctx = BN_CTX_new()) == NULL) + (tmp_3 = BN_new()) == NULL || (ctx = BN_CTX_new()) == NULL || + (tmp_6 = BN_new()) == NULL || (tmp_7 = BN_new()) == NULL) { reason = ERR_R_MALLOC_FAILURE; goto err; @@ -264,7 +266,12 @@ int ECDSA_print(BIO *bp, const ECDSA *x, int off) reason = ERR_R_EC_LIB; goto err; } - if ((buf_len = EC_POINT_point2oct(x->group, point, POINT_CONVERSION_COMPRESSED, NULL, 0, ctx)) == 0) + if (!EC_GROUP_get_order(x->group, tmp_6, NULL) || !EC_GROUP_get_cofactor(x->group, tmp_7, NULL)) + { + reason = ERR_R_EC_LIB; + goto err; + } + if ((buf_len = EC_POINT_point2oct(x->group, point, ECDSA_get_conversion_form(x), NULL, 0, ctx)) == 0) { reason = ECDSA_R_UNEXPECTED_PARAMETER_LENGTH; goto err; @@ -274,14 +281,14 @@ int ECDSA_print(BIO *bp, const ECDSA *x, int off) reason = ERR_R_MALLOC_FAILURE; goto err; } - if (!EC_POINT_point2oct(x->group, point, POINT_CONVERSION_COMPRESSED, + if (!EC_POINT_point2oct(x->group, point, ECDSA_get_conversion_form(x), buffer, buf_len, ctx)) goto err; if ((tmp_4 = BN_bin2bn(buffer, buf_len, NULL)) == NULL) { reason = ERR_R_BN_LIB; goto err; } - if ((i = EC_POINT_point2oct(x->group, x->pub_key, POINT_CONVERSION_COMPRESSED, NULL, 0, ctx)) == 0) + if ((i = EC_POINT_point2oct(x->group, x->pub_key, ECDSA_get_conversion_form(x), NULL, 0, ctx)) == 0) { reason = ECDSA_R_UNEXPECTED_PARAMETER_LENGTH; goto err; @@ -292,7 +299,7 @@ int ECDSA_print(BIO *bp, const ECDSA *x, int off) buf_len = i; goto err; } - if (!EC_POINT_point2oct(x->group, x->pub_key, POINT_CONVERSION_COMPRESSED, + if (!EC_POINT_point2oct(x->group, x->pub_key, ECDSA_get_conversion_form(x), buffer, buf_len, ctx)) { reason = ERR_R_EC_LIB; @@ -330,6 +337,8 @@ int ECDSA_print(BIO *bp, const ECDSA *x, int off) if ((tmp_2 != NULL) && !print(bp, "A: ", tmp_2, buffer, off)) goto err; if ((tmp_3 != NULL) && !print(bp, "B: ", tmp_3, buffer, off)) goto err; if ((tmp_4 != NULL) && !print(bp, "Gen: ", tmp_4, buffer, off)) goto err; + if ((tmp_6 != NULL) && !print(bp, "Order: ", tmp_6, buffer, off)) goto err; + if ((tmp_7 != NULL) && !print(bp, "Cofactor: ", tmp_7, buffer, off)) goto err; ret=1; err: if (!ret) @@ -339,6 +348,8 @@ err: if (tmp_3) BN_free(tmp_3); if (tmp_4) BN_free(tmp_4); if (tmp_5) BN_free(tmp_5); + if (tmp_6) BN_free(tmp_6); + if (tmp_7) BN_free(tmp_7); if (ctx) BN_CTX_free(ctx); if (buffer != NULL) OPENSSL_free(buffer); return(ret); @@ -541,13 +552,13 @@ int ECDSAParameters_print(BIO *bp, const ECDSA *x) if ((point = EC_GROUP_get0_generator(x->group)) == NULL) goto err; if (!EC_GROUP_get_order(x->group, tmp_5, ctx)) goto err; if (!EC_GROUP_get_cofactor(x->group, tmp_6, ctx)) goto err; - buf_len = EC_POINT_point2oct(x->group, point, POINT_CONVERSION_COMPRESSED, NULL, 0, ctx); + buf_len = EC_POINT_point2oct(x->group, point, ECDSA_get_conversion_form(x), NULL, 0, ctx); if (!buf_len || (buffer = OPENSSL_malloc(buf_len)) == NULL) { reason = ERR_R_MALLOC_FAILURE; goto err; } - if (!EC_POINT_point2oct(x->group, point, POINT_CONVERSION_COMPRESSED, buffer, buf_len, ctx)) + if (!EC_POINT_point2oct(x->group, point, ECDSA_get_conversion_form(x), buffer, buf_len, ctx)) { reason = ERR_R_EC_LIB; goto err; diff --git a/crypto/asn1/x_pubkey.c b/crypto/asn1/x_pubkey.c index f6f2a0d..9fea31a 100644 --- a/crypto/asn1/x_pubkey.c +++ b/crypto/asn1/x_pubkey.c @@ -136,7 +136,6 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey) ECDSA *ecdsa; ecdsa = pkey->pkey.ecdsa; - ecdsa->write_params=0; ASN1_TYPE_free(a->parameter); if ((i = i2d_ECDSAParameters(ecdsa, NULL)) == 0) { @@ -272,7 +271,6 @@ EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key) X509err(X509_F_X509_PUBKEY_GET, ERR_R_MALLOC_FAILURE); goto err; } - ret->pkey.ecdsa->write_params = 0; cp = p = a->parameter->value.sequence->data; j = a->parameter->value.sequence->length; if (!d2i_ECDSAParameters(&ret->pkey.ecdsa, &cp, (long)j)) |