Commit 9ff9bccc authored by Dr. Stephen Henson's avatar Dr. Stephen Henson
Browse files

Add default operations to EC_METHOD



Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
parent 77470e98
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ const EC_METHOD *EC_GF2m_simple_method(void)
        ec_GF2m_simple_group_set_curve,
        ec_GF2m_simple_group_get_curve,
        ec_GF2m_simple_group_get_degree,
        0, /* group_order_bits */
        ec_group_simple_order_bits,
        ec_GF2m_simple_group_check_discriminant,
        ec_GF2m_simple_point_init,
        ec_GF2m_simple_point_finish,
@@ -118,7 +118,16 @@ const EC_METHOD *EC_GF2m_simple_method(void)
        ec_GF2m_simple_field_div,
        0 /* field_encode */ ,
        0 /* field_decode */ ,
        0                       /* field_set_to_one */
        0,                      /* field_set_to_one */
        ec_key_simple_priv2oct,
        ec_key_simple_oct2priv,
        0, /* set private */
        ec_key_simple_generate_key,
        ec_key_simple_check_key,
        ec_key_simple_generate_public_key,
        0, /* keycopy */
        0, /* keyfinish */
        ecdh_simple_compute_key
    };

    return &ret;
+1 −5
Original line number Diff line number Diff line
@@ -234,11 +234,7 @@ int EC_KEY_generate_key(EC_KEY *eckey)

int ossl_ec_key_gen(EC_KEY *eckey)
{
    if (eckey->group->meth->keygen == NULL) {
        ECerr(EC_F_OSSL_EC_KEY_GEN, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
        return 0;
    }

    OPENSSL_assert(eckey->group->meth->keygen != NULL);
    return eckey->group->meth->keygen(eckey);
}

+1 −4
Original line number Diff line number Diff line
@@ -373,10 +373,7 @@ const BIGNUM *EC_GROUP_get0_order(const EC_GROUP *group)

int EC_GROUP_order_bits(const EC_GROUP *group)
{
    if (group->meth->group_order_bits == NULL) {
        ECerr(EC_F_EC_GROUP_ORDER_BITS, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
        return 0;
    }
    OPENSSL_assert(group->meth->group_order_bits != NULL);
    return group->meth->group_order_bits(group);
}

+4 −5
Original line number Diff line number Diff line
@@ -82,9 +82,8 @@ int ossl_ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
                          void *(*KDF) (const void *in, size_t inlen,
                                        void *out, size_t *outlen))
{
    if (ecdh->group->meth->ecdh_compute_key == 0) {
        ECerr(EC_F_OSSL_ECDH_COMPUTE_KEY,
              ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
    if (ecdh->group->meth->ecdh_compute_key == NULL) {
        ECerr(EC_F_OSSL_ECDH_COMPUTE_KEY, EC_R_CURVE_DOES_NOT_SUPPORT_ECDH);
        return -1;
    }

@@ -113,8 +112,8 @@ int ecdh_simple_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
    unsigned char *buf = NULL;

    if (outlen > INT_MAX) {
        ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, ERR_R_MALLOC_FAILURE); /* sort of,
                                                                 * anyway */
        /* sort of, anyway */
        ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, ERR_R_MALLOC_FAILURE);
        return -1;
    }

+11 −2
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ const EC_METHOD *EC_GFp_mont_method(void)
        ec_GFp_mont_group_set_curve,
        ec_GFp_simple_group_get_curve,
        ec_GFp_simple_group_get_degree,
        0, /* group_order_bits */
        ec_group_simple_order_bits,
        ec_GFp_simple_group_check_discriminant,
        ec_GFp_simple_point_init,
        ec_GFp_simple_point_finish,
@@ -104,7 +104,16 @@ const EC_METHOD *EC_GFp_mont_method(void)
        0 /* field_div */ ,
        ec_GFp_mont_field_encode,
        ec_GFp_mont_field_decode,
        ec_GFp_mont_field_set_to_one
        ec_GFp_mont_field_set_to_one,
        ec_key_simple_priv2oct,
        ec_key_simple_oct2priv,
        0, /* set private */
        ec_key_simple_generate_key,
        ec_key_simple_check_key,
        ec_key_simple_generate_public_key,
        0, /* keycopy */
        0, /* keyfinish */
        ecdh_simple_compute_key
    };

    return &ret;
Loading